mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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:
parent
5c2557b421
commit
c0ce131f1a
1 changed files with 9 additions and 5 deletions
14
input.c
14
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 wl_window *win = wl_surface_get_user_data(surface);
|
||||||
struct terminal *term = win->term;
|
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.serial = serial;
|
||||||
seat->pointer.hidden = false;
|
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",
|
LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p, "
|
||||||
(void *)wl_pointer, serial, (void *)surface, (void *)term);
|
"x=%d, y=%d",
|
||||||
|
(void *)wl_pointer, serial, (void *)surface, (void *)term,
|
||||||
|
x, y);
|
||||||
|
|
||||||
xassert(tll_length(seat->mouse.buttons) == 0);
|
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;
|
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))) {
|
switch ((term->active_surface = term_surface_kind(term, surface))) {
|
||||||
case TERM_SURF_GRID: {
|
case TERM_SURF_GRID: {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue