History

options: remove --focus-on-open and add --focus-on

replaces the old focus-on-open option with a more generic focus-on options that can be extended. adjust the only platform that uses that option. Fixes #8337

der richter committed 2 years ago

Commit 0ec385b1 parent a56d8ff7 files · +21 −9Browse files

Unified · Split

7 files
  1. DOCS/interface-changes.rst +1 −0
  2. DOCS/man/options.rst +6 −3
  3. options/options.c +3 −2
  4. options/options.h +1 −1
  5. video/out/cocoa_cb_common.swift +3 −0
  6. video/out/mac/common.swift +3 −3
  7. video/out/mac_common.swift +4 −0
DOCS/interface-changes.rst+1−0
@@ -63,6 +63,7 @@ Interface changes · 62 unmodified lines
6363 - add `--border-background` option
6464 - add `video-target-params` property
6565 - add `hdr10plus` sub-parameter to `format` video filter
66+ - remove `--focus-on-open` and add replacement `--focus-on`
6667 --- mpv 0.37.0 ---
6768 - `--save-position-on-quit` and its associated commands now store state files
6869 in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
DOCS/man/options.rst+6−3
@@ -3227,10 +3227,13 @@ Window · 3226 unmodified lines
32273227 :desktop: On top of the Desktop behind windows and Desktop icons.
32283228 :level: A level as integer.
32293229
3230−``--focus-on-open``, ``--no-focus-on-open``
3230+``--focus-on=<never|open|all>``,
32313231 (macOS only)
3232− Focus the video window on creation and makes it the front most window. This
3233− is on by default.
3232+ Focus the video window and make it the front most window on specific events (default: open).
3233+
3234+ :never: Never focus the window on open or new file load events.
3235+ :open: Focus the window on creation, eg when a vo is initialised.
3236+ :all: Focus the window on open and new file load event.
32343237
32353238 ``--window-corners=<default|donotround|round|roundsmall>``
32363239 (Windows only)
options/options.c+3−2
@@ -131,7 +131,8 @@ static const m_option_t mp_vo_opt_list[] = { · 130 unmodified lines
131131 {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)},
132132 {"window-minimized", OPT_BOOL(window_minimized)},
133133 {"window-maximized", OPT_BOOL(window_maximized)},
134− {"focus-on-open", OPT_BOOL(focus_on_open)},
134+ {"focus-on-open", OPT_REMOVED("Replaced by --focus-on")},
135+ {"focus-on", OPT_CHOICE(focus_on, {"never", 0}, {"open", 1}, {"all", 2})},
135136 {"force-render", OPT_BOOL(force_render)},
136137 {"force-window-position", OPT_BOOL(force_window_position)},
137138 {"x11-name", OPT_STRING(winname)},
@@ -254,7 +255,7 @@ const struct m_sub_options vo_sub_opts = { · 116 unmodified lines
254255 .ontop_level = -1,
255256 .timing_offset = 0.050,
256257 .swapchain_depth = 3,
257− .focus_on_open = true,
258+ .focus_on = 1,
258259 },
259260 };
260261
options/options.h+1−1
@@ -20,7 +20,7 @@ typedef struct mp_vo_opts { · 19 unmodified lines
2020 bool all_workspaces;
2121 bool window_minimized;
2222 bool window_maximized;
23− bool focus_on_open;
23+ int focus_on;
2424
2525 int screen_id;
2626 char *screen_name;
video/out/cocoa_cb_common.swift+3−0
@@ -68,6 +68,9 @@ class CocoaCB: Common { · 67 unmodified lines
6868 DispatchQueue.main.async {
6969 self.updateWindowSize(vo)
7070 self.layer?.update(force: true)
71+ if self.mpv?.opts.focus_on ?? 1 == 2 {
72+ NSApp.activate(ignoringOtherApps: true)
73+ }
7174 }
7275 }
7376 }
video/out/mac/common.swift+3−3
@@ -122,11 +122,11 @@ class Common: NSObject { · 121 unmodified lines
122122 window.orderFront(nil)
123123 }
124124
125− NSApp.activate(ignoringOtherApps: mpv.opts.focus_on_open)
125+ NSApp.activate(ignoringOtherApps: mpv.opts.focus_on >= 1)
126126
127127 // workaround for macOS 10.15 to refocus the previous App
128− if (!mpv.opts.focus_on_open) {
129− previousActiveApp?.activate(options: .activateAllWindows)
128+ if mpv.opts.focus_on == 0 {
129+ previousActiveApp?.activate()
130130 }
131131 }
132132
video/out/mac_common.swift+4−0
@@ -62,6 +62,10 @@ class MacCommon: Common { · 61 unmodified lines
6262 window?.updateSize(wr.size)
6363 }
6464
65+ if mpv?.opts.focus_on ?? 1 == 2 {
66+ NSApp.activate(ignoringOtherApps: true)
67+ }
68+
6569 windowDidResize()
6670 updateICCProfile()
6771 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t