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
Unified · Split
| @@ -63,6 +63,7 @@ Interface changes · 62 unmodified lines | ||
| 63 | 63 | - add `--border-background` option |
| 64 | 64 | - add `video-target-params` property |
| 65 | 65 | - add `hdr10plus` sub-parameter to `format` video filter |
| 66 | + - remove `--focus-on-open` and add replacement `--focus-on` | |
| 66 | 67 | --- mpv 0.37.0 --- |
| 67 | 68 | - `--save-position-on-quit` and its associated commands now store state files |
| 68 | 69 | in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows. |
| @@ -3227,10 +3227,13 @@ Window · 3226 unmodified lines | ||
| 3227 | 3227 | :desktop: On top of the Desktop behind windows and Desktop icons. |
| 3228 | 3228 | :level: A level as integer. |
| 3229 | 3229 | |
| 3230 | −``--focus-on-open``, ``--no-focus-on-open`` | |
| 3230 | +``--focus-on=<never|open|all>``, | |
| 3231 | 3231 | (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. | |
| 3234 | 3237 | |
| 3235 | 3238 | ``--window-corners=<default|donotround|round|roundsmall>`` |
| 3236 | 3239 | (Windows only) |
| @@ -131,7 +131,8 @@ static const m_option_t mp_vo_opt_list[] = { · 130 unmodified lines | ||
| 131 | 131 | {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)}, |
| 132 | 132 | {"window-minimized", OPT_BOOL(window_minimized)}, |
| 133 | 133 | {"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})}, | |
| 135 | 136 | {"force-render", OPT_BOOL(force_render)}, |
| 136 | 137 | {"force-window-position", OPT_BOOL(force_window_position)}, |
| 137 | 138 | {"x11-name", OPT_STRING(winname)}, |
| @@ -254,7 +255,7 @@ const struct m_sub_options vo_sub_opts = { · 116 unmodified lines | ||
| 254 | 255 | .ontop_level = -1, |
| 255 | 256 | .timing_offset = 0.050, |
| 256 | 257 | .swapchain_depth = 3, |
| 257 | − .focus_on_open = true, | |
| 258 | + .focus_on = 1, | |
| 258 | 259 | }, |
| 259 | 260 | }; |
| 260 | 261 | |
| @@ -20,7 +20,7 @@ typedef struct mp_vo_opts { · 19 unmodified lines | ||
| 20 | 20 | bool all_workspaces; |
| 21 | 21 | bool window_minimized; |
| 22 | 22 | bool window_maximized; |
| 23 | − bool focus_on_open; | |
| 23 | + int focus_on; | |
| 24 | 24 | |
| 25 | 25 | int screen_id; |
| 26 | 26 | char *screen_name; |
| @@ -68,6 +68,9 @@ class CocoaCB: Common { · 67 unmodified lines | ||
| 68 | 68 | DispatchQueue.main.async { |
| 69 | 69 | self.updateWindowSize(vo) |
| 70 | 70 | self.layer?.update(force: true) |
| 71 | + if self.mpv?.opts.focus_on ?? 1 == 2 { | |
| 72 | + NSApp.activate(ignoringOtherApps: true) | |
| 73 | + } | |
| 71 | 74 | } |
| 72 | 75 | } |
| 73 | 76 | } |
| @@ -122,11 +122,11 @@ class Common: NSObject { · 121 unmodified lines | ||
| 122 | 122 | window.orderFront(nil) |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | − NSApp.activate(ignoringOtherApps: mpv.opts.focus_on_open) | |
| 125 | + NSApp.activate(ignoringOtherApps: mpv.opts.focus_on >= 1) | |
| 126 | 126 | |
| 127 | 127 | // 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() | |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| @@ -62,6 +62,10 @@ class MacCommon: Common { · 61 unmodified lines | ||
| 62 | 62 | window?.updateSize(wr.size) |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + if mpv?.opts.focus_on ?? 1 == 2 { | |
| 66 | + NSApp.activate(ignoringOtherApps: true) | |
| 67 | + } | |
| 68 | + | |
| 65 | 69 | windowDidResize() |
| 66 | 70 | updateICCProfile() |
| 67 | 71 | } |