input: Update mouse x/y coordinates on wl_pointer_enter

Otherwise if you don't receive motion event before e.g. button pressed,
the coordinates will be incorrect. This happens when e.g. you get
alt-tabbed so that the mouse cursor ends up on top of the terminal
window, but the mouse never actually moved.
This commit is contained in:
Jonas Ådahl 2021-11-19 15:04:51 +01:00
parent 5c2557b421
commit c0ce131f1a

14
input.c
View file

@ -1405,11 +1405,18 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
struct wl_window *win = wl_surface_get_user_data(surface);
struct terminal *term = win->term;
int x = wl_fixed_to_int(surface_x) * term->scale;
int y = wl_fixed_to_int(surface_y) * term->scale;
seat->pointer.serial = serial;
seat->pointer.hidden = false;
seat->mouse.x = x;
seat->mouse.y = y;
LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p",
(void *)wl_pointer, serial, (void *)surface, (void *)term);
LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p, "
"x=%d, y=%d",
(void *)wl_pointer, serial, (void *)surface, (void *)term,
x, y);
xassert(tll_length(seat->mouse.buttons) == 0);
@ -1418,9 +1425,6 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
seat->mouse_focus = term;
int x = wl_fixed_to_int(surface_x) * term->scale;
int y = wl_fixed_to_int(surface_y) * term->scale;
switch ((term->active_surface = term_surface_kind(term, surface))) {
case TERM_SURF_GRID: {
/*