diff options
author | Dudemanguy <random342@airmail.cc> | 2022-05-12 16:26:49 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-07-04 19:16:43 +0000 |
commit | dbc0fcea1bcd3b5ea0319f74a6310f2691c1d371 (patch) | |
tree | c4048328397dd550bdb9ddb9e90218b010a8476f /video/out/wayland_common.c | |
parent | 3ba446d0b065f867ca262a2e05e4e8d24c7c0783 (diff) | |
download | mpv-dbc0fcea1bcd3b5ea0319f74a6310f2691c1d371.tar.bz2 mpv-dbc0fcea1bcd3b5ea0319f74a6310f2691c1d371.tar.xz |
player: add --input-cursor-passthrough option
Add an option for allowing pointer events to pass through the mpv
window. This could be useful in cases where a user wants to display
transparent images/video with mpv and interact with applications beneath
the window. This commit implements this functionality for x11 and
wayland. Note that whether or not this actually works likely depends on
your window manager and/or compositor. E.g. sway ignores pointer events
but the entire window becomes draggable when you float it (nothing under
the mpv window receives events). Weston behaves as expected however so
that is a compositor bug. Excuse the couple of completely unrelated
style fixes (both were originally done by me).
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r-- | video/out/wayland_common.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index ed9c7a911a..28cd6eb55b 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1548,7 +1548,8 @@ static void greatest_common_divisor(struct vo_wayland_state *wl, int a, int b) { } } -static void guess_focus(struct vo_wayland_state *wl) { +static void guess_focus(struct vo_wayland_state *wl) +{ // We can't actually know if the window is focused or not in wayland, // so just guess it with some common sense. Obviously won't work if // the user has no keyboard. @@ -1717,6 +1718,17 @@ static void set_geometry(struct vo_wayland_state *wl, bool resize) } } +static void set_input_region(struct vo_wayland_state *wl, bool passthrough) +{ + if (passthrough) { + struct wl_region *region = wl_compositor_create_region(wl->compositor); + wl_surface_set_input_region(wl->surface, region); + wl_region_destroy(region); + } else { + wl_surface_set_input_region(wl->surface, NULL); + } +} + static int set_screensaver_inhibitor(struct vo_wayland_state *wl, int state) { if (!wl->idle_inhibit_manager) @@ -1967,6 +1979,8 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) } if (opt == &opts->content_type) set_content_type(wl); + if (opt == &opts->cursor_passthrough) + set_input_region(wl, opts->cursor_passthrough); if (opt == &opts->fullscreen) toggle_fullscreen(wl); if (opt == &opts->hidpi_window_scale) @@ -2255,6 +2269,9 @@ bool vo_wayland_reconfig(struct vo *vo) wl->geometry = wl->window_size; } + if (wl->vo_opts->cursor_passthrough) + set_input_region(wl, true); + if (wl->vo_opts->fullscreen) toggle_fullscreen(wl); |