summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-10 13:44:40 +0100
committerder richter <der.richter@gmx.de>2024-03-10 14:53:07 +0100
commit0ec385bc763567cbab4532b3579cd24b07958802 (patch)
tree3b1f1abe8801d8c9c3a998478d41c5ccbe638eb7
parenta56d8ff18470e4612cbb23e35e7849b8e522ba7e (diff)
downloadmpv-0ec385bc763567cbab4532b3579cd24b07958802.tar.bz2
mpv-0ec385bc763567cbab4532b3579cd24b07958802.tar.xz
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
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst9
-rw-r--r--options/options.c5
-rw-r--r--options/options.h2
-rw-r--r--video/out/cocoa_cb_common.swift3
-rw-r--r--video/out/mac/common.swift6
-rw-r--r--video/out/mac_common.swift4
7 files changed, 21 insertions, 9 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 14557de1b5..5852aeb709 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -63,6 +63,7 @@ Interface changes
- add `--border-background` option
- add `video-target-params` property
- add `hdr10plus` sub-parameter to `format` video filter
+ - remove `--focus-on-open` and add replacement `--focus-on`
--- mpv 0.37.0 ---
- `--save-position-on-quit` and its associated commands now store state files
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 6a09cf3884..100fc0482b 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3227,10 +3227,13 @@ Window
:desktop: On top of the Desktop behind windows and Desktop icons.
:level: A level as integer.
-``--focus-on-open``, ``--no-focus-on-open``
+``--focus-on=<never|open|all>``,
(macOS only)
- Focus the video window on creation and makes it the front most window. This
- is on by default.
+ Focus the video window and make it the front most window on specific events (default: open).
+
+ :never: Never focus the window on open or new file load events.
+ :open: Focus the window on creation, eg when a vo is initialised.
+ :all: Focus the window on open and new file load event.
``--window-corners=<default|donotround|round|roundsmall>``
(Windows only)
diff --git a/options/options.c b/options/options.c
index 796a6c668b..3db965a3f7 100644
--- a/options/options.c
+++ b/options/options.c
@@ -131,7 +131,8 @@ static const m_option_t mp_vo_opt_list[] = {
{"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)},
{"window-minimized", OPT_BOOL(window_minimized)},
{"window-maximized", OPT_BOOL(window_maximized)},
- {"focus-on-open", OPT_BOOL(focus_on_open)},
+ {"focus-on-open", OPT_REMOVED("Replaced by --focus-on")},
+ {"focus-on", OPT_CHOICE(focus_on, {"never", 0}, {"open", 1}, {"all", 2})},
{"force-render", OPT_BOOL(force_render)},
{"force-window-position", OPT_BOOL(force_window_position)},
{"x11-name", OPT_STRING(winname)},
@@ -254,7 +255,7 @@ const struct m_sub_options vo_sub_opts = {
.ontop_level = -1,
.timing_offset = 0.050,
.swapchain_depth = 3,
- .focus_on_open = true,
+ .focus_on = 1,
},
};
diff --git a/options/options.h b/options/options.h
index 1b7c3e3583..4d3d988789 100644
--- a/options/options.h
+++ b/options/options.h
@@ -20,7 +20,7 @@ typedef struct mp_vo_opts {
bool all_workspaces;
bool window_minimized;
bool window_maximized;
- bool focus_on_open;
+ int focus_on;
int screen_id;
char *screen_name;
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index 094dab1a55..2b260a2999 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -68,6 +68,9 @@ class CocoaCB: Common {
DispatchQueue.main.async {
self.updateWindowSize(vo)
self.layer?.update(force: true)
+ if self.mpv?.opts.focus_on ?? 1 == 2 {
+ NSApp.activate(ignoringOtherApps: true)
+ }
}
}
}
diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift
index 7b6fa48b5d..5790d3b844 100644
--- a/video/out/mac/common.swift
+++ b/video/out/mac/common.swift
@@ -122,11 +122,11 @@ class Common: NSObject {
window.orderFront(nil)
}
- NSApp.activate(ignoringOtherApps: mpv.opts.focus_on_open)
+ NSApp.activate(ignoringOtherApps: mpv.opts.focus_on >= 1)
// workaround for macOS 10.15 to refocus the previous App
- if (!mpv.opts.focus_on_open) {
- previousActiveApp?.activate(options: .activateAllWindows)
+ if mpv.opts.focus_on == 0 {
+ previousActiveApp?.activate()
}
}
diff --git a/video/out/mac_common.swift b/video/out/mac_common.swift
index 71659de8e5..f7b07596d3 100644
--- a/video/out/mac_common.swift
+++ b/video/out/mac_common.swift
@@ -62,6 +62,10 @@ class MacCommon: Common {
window?.updateSize(wr.size)
}
+ if mpv?.opts.focus_on ?? 1 == 2 {
+ NSApp.activate(ignoringOtherApps: true)
+ }
+
windowDidResize()
updateICCProfile()
}