diff options
author | Guido Cella <guidocella91@gmail.com> | 2020-09-07 18:22:25 +0200 |
---|---|---|
committer | wm4 <1387750+wm4@users.noreply.github.com> | 2020-09-08 20:09:17 +0200 |
commit | 9b9ce74afaafb29045fe3ab975eaaa9290eb3b7d (patch) | |
tree | 3a9e096c411bb00bcc2591ef8ef03e5b5f58dbc7 /video/out/vo.h | |
parent | 5a4fc8684eaad79ab22d44cf27c0a16a34c07123 (diff) | |
download | mpv-9b9ce74afaafb29045fe3ab975eaaa9290eb3b7d.tar.bz2 mpv-9b9ce74afaafb29045fe3ab975eaaa9290eb3b7d.tar.xz |
command: add read-only focused property
Add a property that returns whether the window is focused, currently
only for X11 and Wayland.
My use cause for this is having an equivalent of pause-when-minimize.lua
for tiling window managers: make mpv play only while it's in the current
workspace or is focused (I'm fine with either one but prefer focus).
On X I do this by observing display-names, which is empty when the
rectangles of the display and mpv don't intersect, but on Wayland its
value doesn't change when mpv leaves the current workspace (and the same
check doesn't work since the geometries still intersect).
This could later be made writable as requested in #6252.
Note that on Wayland se shouldn't consider an unactivated window with
keyboard input focused.
The wlroots compositors I tested set activated after changing the
keyboard focus, so if you set wl->focused only in
keyboard_handle_enter() and keyboard_handle_leave() to avoid adding the
"has_keyboard_input" member, focused isn't set to true when first
opening mpv until you focus another window and focus mpv again.
Conversely, if that order can't be assumed for all compositors, we
should toggle wl->focused when necessary in keyboard_handle_enter() and
keyboard_handle_leave() as well as in handle_toplevel_config().
Diffstat (limited to 'video/out/vo.h')
-rw-r--r-- | video/out/vo.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/video/out/vo.h b/video/out/vo.h index 1b7a239798..5deb99a6f1 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -48,10 +48,11 @@ enum { // Special thing for encode mode (vo_driver.initially_blocked). // Part of VO_EVENTS_USER to make vo_is_ready_for_frame() work properly. VO_EVENT_INITIAL_UNBLOCK = 1 << 7, + VO_EVENT_FOCUS = 1 << 8, // Set of events the player core may be interested in. VO_EVENTS_USER = VO_EVENT_RESIZE | VO_EVENT_WIN_STATE | VO_EVENT_DPI | - VO_EVENT_INITIAL_UNBLOCK, + VO_EVENT_INITIAL_UNBLOCK | VO_EVENT_FOCUS, }; enum mp_voctrl { @@ -99,6 +100,8 @@ enum mp_voctrl { VOCTRL_GET_UNFS_WINDOW_SIZE, // int[2] (w/h) VOCTRL_SET_UNFS_WINDOW_SIZE, // int[2] (w/h) + VOCTRL_GET_FOCUSED, // bool* + // char *** (NULL terminated array compatible with CONF_TYPE_STRING_LIST) // names for displays the window is on VOCTRL_GET_DISPLAY_NAMES, |