summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-08-02 16:45:06 -0500
committerDudemanguy <random342@airmail.cc>2020-08-02 17:06:51 -0500
commitfb55ee99e34498528a3c7e0abe19710ea47d8448 (patch)
tree94af3bbd2740b951ddc574b3739b81969cc39806 /video/out
parent359261c50c83f1046e3ccc143c44606123fc33c4 (diff)
downloadmpv-fb55ee99e34498528a3c7e0abe19710ea47d8448.tar.bz2
mpv-fb55ee99e34498528a3c7e0abe19710ea47d8448.tar.xz
wayland: don't set mouse pos on state change
Sway 1.5 started sending more pointer motion events to mpv which broke the autohiding behavior. The cursor would appear again if you fullscreened. Sway had a good reason to do this because certain applications had inconsistencies between hardware cursor and software cursor without rebasing on state changes[1]. So mpv needs to take this special case into consideration. Initially, simply checking mouse coordinates for changes was considered, but this doesn't work. All coordinates are surface-local in wayland so something can appear to move in the local coordinate space but not globally. You're not allowed to know global mouse coordinates in wayland, and we don't care about local coordinate changes in mpv so this approach isn't viable. Instead, let's just keep track of a local state change. If the toplevel surface changes in some way (fullscreen, maximized, etc.), then just set a bool that lets us ignore the mp_input_set_mouse_pos function. This keeps the cursor from appearing simply because the state was changed (i.e. fullscreening). For compositors that don't send pointer motion events on a state change, this does technically mean that the initial mp_input_set_mouse_pos is never set. In practice, this isn't a noticeable difference though because moving a mouse generates a ton of motion events so you'll immediately see it on the second motion event. [1] https://github.com/swaywm/sway/issues/5594
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c6
-rw-r--r--video/out/wayland_common.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 07d5317ba6..1665919465 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -155,7 +155,10 @@ static void pointer_handle_motion(void *data, struct wl_pointer *pointer,
wl->mouse_unscaled_x = sx;
wl->mouse_unscaled_y = sy;
- mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y);
+ if (!wl->state_changed) {
+ mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y);
+ }
+ wl->state_changed = false;
}
static void window_move(struct vo_wayland_state *wl, uint32_t serial)
@@ -1030,6 +1033,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
mp_rect_w(wl->geometry)*wl->scaling, mp_rect_h(wl->geometry)*wl->scaling);
wl->pending_vo_events |= VO_EVENT_RESIZE;
+ wl->state_changed = true;
}
static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index 31e75c4331..895db3393d 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -75,6 +75,7 @@ struct vo_wayland_state {
int reduced_height;
bool configured;
bool frame_wait;
+ bool state_changed;
int wakeup_pipe[2];
int pending_vo_events;
int mouse_x;