aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2021-11-19 14:04:51 +0000
committerJonas Ådahl <jadahl@gmail.com>2021-11-29 15:26:40 +0000
commitc0ce131f1a4195585cc89f58ab65cfd7658ca0b7 (patch)
tree5fceecedaf602df6df52cd923379d91220397bde /input.c
parentterminal: Make seat xcursor update focus aware (diff)
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.
Diffstat (limited to 'input.c')
-rw-r--r--input.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/input.c b/input.c
index 5f864a8d..35baf3d4 100644
--- a/input.c
+++ b/input.c
@@ -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: {
/*