From 9b9ce74afaafb29045fe3ab975eaaa9290eb3b7d Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Mon, 7 Sep 2020 18:22:25 +0200 Subject: 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(). --- DOCS/man/input.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'DOCS/man') diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 739f5f1022..18027ce17a 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -2439,6 +2439,9 @@ Property list since setting the option, and the window size was not restricted in other ways. The property is unavailable if no video is active. +``focused`` + Whether the window has focus. Currently works only on X11 and Wayland. + ``display-names`` Names of the displays that the mpv window covers. On X11, these are the xrandr names (LVDS1, HDMI1, DP1, VGA1, etc.). On Windows, these -- cgit v1.2.3