Skip to content

Commit

Permalink
wayland_common: set mouse position on pointer enter
Browse files Browse the repository at this point in the history
At least on some compositors, when the pointer enters a surface,
only a wl_pointer_enter event is generated, but not wl_pointer_motion.
This results in the initial mouse position being lost, which is
especially problematic when input simulation is used.

Fix this by setting the mouse position on pointer enter event.
  • Loading branch information
na-na-hi authored and Dudemanguy committed Apr 1, 2024
1 parent 0a083ea commit a140d27
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
s->pointer_enter_serial = serial;
set_cursor_visibility(s, wl->cursor_visible);
mp_input_put_key(wl->vo->input_ctx, MP_KEY_MOUSE_ENTER);

wl->mouse_x = wl_fixed_to_int(sx) * wl->scaling;
wl->mouse_y = wl_fixed_to_int(sy) * wl->scaling;

if (!wl->toplevel_configured)
mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y);
wl->toplevel_configured = false;
}

static void pointer_handle_leave(void *data, struct wl_pointer *pointer,
Expand Down

0 comments on commit a140d27

Please sign in to comment.