wayland: fix cursor behavior on an edge case

This small regression was introduced by #7216. Previously, the wayland
backend used a trick which kept track of the previous fullscreen state
and used that logic for showing the cursor. Since vo_opts now keeps
track of the current fullscreen state, most of this stopped being
neccessary.

However, there was one edge case where the cursor didn't
behave the same: passing a fullscreen flag for the inital window. The
cursor would initially be visible here which is not desirable. This can
be remedied pretty easily by just setting the cursor visiblity to false
if the pointer entry event occurs on fullscreen. The only thing we need
to do is to make sure that the autohide delay isn't completely disabled
(i.e. the cursor is always visible). Hence the need for the previous
commit.
This commit is contained in:
dudemanguy 2019-12-02 09:28:52 -06:00 committed by Dudemanguy
parent 65a317436d
commit 7f300a00e9
2 changed files with 2 additions and 7 deletions

View File

@ -136,6 +136,8 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
wl->pointer = pointer;
wl->pointer_id = serial;
if (wl->vo_opts->fullscreen && wl->vo_opts->cursor_autohide_delay != -1)
wl->cursor_visible = false;
set_cursor_visibility(wl, wl->cursor_visible);
mp_input_put_key(wl->vo->input_ctx, MP_KEY_MOUSE_ENTER);
}
@ -151,12 +153,7 @@ static void pointer_handle_motion(void *data, struct wl_pointer *pointer,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
{
struct vo_wayland_state *wl = data;
if (!wl->prev_fullscreen && wl->vo_opts->fullscreen) {
wl->prev_fullscreen = wl->vo_opts->fullscreen;
return;
}
wl->prev_fullscreen = wl->vo_opts->fullscreen;
wl->mouse_x = wl_fixed_to_int(sx) * wl->scaling;
wl->mouse_y = wl_fixed_to_int(sy) * wl->scaling;
wl->mouse_unscaled_x = sx;
@ -1078,7 +1075,6 @@ int vo_wayland_init(struct vo *vo)
.wakeup_pipe = {-1, -1},
.dnd_fd = -1,
.cursor_visible = true,
.prev_fullscreen = vo->opts->fullscreen,
.vo_opts_cache = m_config_cache_alloc(wl, vo->global, &vo_sub_opts),
};
wl->vo_opts = wl->vo_opts_cache->opts;

View File

@ -138,7 +138,6 @@ struct vo_wayland_state {
struct wl_surface *cursor_surface;
int allocated_cursor_scale;
bool cursor_visible;
bool prev_fullscreen;
};
int vo_wayland_init(struct vo *vo);