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
63 - add `--border-background` option63 - add `--border-background` option
64 - add `video-target-params` property64 - add `video-target-params` property
65 - add `hdr10plus` sub-parameter to `format` video filter65 - add `hdr10plus` sub-parameter to `format` video filter
66 - remove `--focus-on-open` and add replacement `--focus-on`
66 --- mpv 0.37.0 ---67 --- mpv 0.37.0 ---
67 - `--save-position-on-quit` and its associated commands now store state files68 - `--save-position-on-quit` and its associated commands now store state files
68 in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.69 in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
DOCS/man/options.rst+6−3
@@ -3227,10 +3227,13 @@ Window · 3226 unmodified lines
3227 :desktop: On top of the Desktop behind windows and Desktop icons.3227 :desktop: On top of the Desktop behind windows and Desktop icons.
3228 :level: A level as integer.3228 :level: A level as integer.
3229 3229
3230``--focus-on-open``, ``--no-focus-on-open``3230``--focus-on=<never|open|all>``,
3231 (macOS only)3231 (macOS only)
3232 Focus the video window on creation and makes it the front most window. This3232 Focus the video window and make it the front most window on specific events (default: open).
3233 is on by default.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``--window-corners=<default|donotround|round|roundsmall>``3238``--window-corners=<default|donotround|round|roundsmall>``
3236 (Windows only)3239 (Windows only)
options/options.c+3−2
@@ -131,7 +131,8 @@ static const m_option_t mp_vo_opt_list[] = { · 130 unmodified lines
131 {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)},131 {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)},
132 {"window-minimized", OPT_BOOL(window_minimized)},132 {"window-minimized", OPT_BOOL(window_minimized)},
133 {"window-maximized", OPT_BOOL(window_maximized)},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 {"force-render", OPT_BOOL(force_render)},136 {"force-render", OPT_BOOL(force_render)},
136 {"force-window-position", OPT_BOOL(force_window_position)},137 {"force-window-position", OPT_BOOL(force_window_position)},
137 {"x11-name", OPT_STRING(winname)},138 {"x11-name", OPT_STRING(winname)},
@@ -254,7 +255,7 @@ const struct m_sub_options vo_sub_opts = { · 116 unmodified lines
254 .ontop_level = -1,255 .ontop_level = -1,
255 .timing_offset = 0.050,256 .timing_offset = 0.050,
256 .swapchain_depth = 3,257 .swapchain_depth = 3,
257 .focus_on_open = true,258 .focus_on = 1,
258 },259 },
259};260};
260 261
options/options.h+1−1
@@ -20,7 +20,7 @@ typedef struct mp_vo_opts { · 19 unmodified lines
20 bool all_workspaces;20 bool all_workspaces;
21 bool window_minimized;21 bool window_minimized;
22 bool window_maximized;22 bool window_maximized;
23 bool focus_on_open;23 int focus_on;
24 24
25 int screen_id;25 int screen_id;
26 char *screen_name;26 char *screen_name;
video/out/cocoa_cb_common.swift+3−0
@@ -68,6 +68,9 @@ class CocoaCB: Common { · 67 unmodified lines
68 DispatchQueue.main.async {68 DispatchQueue.main.async {
69 self.updateWindowSize(vo)69 self.updateWindowSize(vo)
70 self.layer?.update(force: true)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 }
video/out/mac/common.swift+3−3
@@ -122,11 +122,11 @@ class Common: NSObject { · 121 unmodified lines
122 window.orderFront(nil)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 // workaround for macOS 10.15 to refocus the previous App127 // workaround for macOS 10.15 to refocus the previous App
128 if (!mpv.opts.focus_on_open) {128 if mpv.opts.focus_on == 0 {
129 previousActiveApp?.activate(options: .activateAllWindows)129 previousActiveApp?.activate()
130 }130 }
131 }131 }
132 132
video/out/mac_common.swift+4−0
@@ -62,6 +62,10 @@ class MacCommon: Common { · 61 unmodified lines
62 window?.updateSize(wr.size)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 windowDidResize()69 windowDidResize()
66 updateICCProfile()70 updateICCProfile()
67 }71 }

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