diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2023-12-14 18:10:05 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-03-18 23:34:29 +0000 |
commit | 654c354da971d11bafd310d9821578bc64bd7936 (patch) | |
tree | cf46d6cca00335a2bf571207d866ee8c04be5cef | |
parent | afaad1b84708f2efa0198ac498c3bd4214d52954 (diff) |
xwayland: Move the leave kbd/ptr code
Move part of the code that deals with pointer or keyboard leave
notifications to their own function.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
-rw-r--r-- | hw/xwayland/xwayland-input.c | 40 | ||||
-rw-r--r-- | hw/xwayland/xwayland-input.h | 3 |
2 files changed, 33 insertions, 10 deletions
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index 078e7c2d3..00949ba6b 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -587,14 +587,26 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, maybe_fake_grab_devices(xwl_seat); } +void +xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost) +{ + DeviceIntPtr dev = get_pointer_device(xwl_seat); + + if (focus_lost) + CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT)); + + maybe_fake_ungrab_devices(xwl_seat); +} + static void pointer_handle_leave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface) { struct xwl_seat *xwl_seat = data; - DeviceIntPtr dev = get_pointer_device(xwl_seat); + struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; + Bool focus_lost = FALSE; - xwl_seat->xwl_screen->serial = serial; + xwl_screen->serial = serial; /* The pointer has left a known xwindow, save it for a possible match * in sprite_check_lost_focus() @@ -602,10 +614,10 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer, if (xwl_seat->focus_window) { xwl_seat->last_xwindow = xwl_seat->focus_window->window; xwl_seat->focus_window = NULL; - CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT)); + focus_lost = TRUE; } - maybe_fake_ungrab_devices(xwl_seat); + xwl_seat_leave_ptr(xwl_seat, focus_lost); } static void @@ -1177,15 +1189,11 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, maybe_fake_grab_devices(xwl_seat); } -static void -keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, - uint32_t serial, struct wl_surface *surface) +void +xwl_seat_leave_kbd(struct xwl_seat *xwl_seat) { - struct xwl_seat *xwl_seat = data; uint32_t *k; - xwl_seat->xwl_screen->serial = serial; - wl_array_for_each(k, &xwl_seat->keys) QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8); @@ -1195,6 +1203,18 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, } static void +keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, + uint32_t serial, struct wl_surface *surface) +{ + struct xwl_seat *xwl_seat = data; + struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; + + xwl_screen->serial = serial; + + xwl_seat_leave_kbd(xwl_seat); +} + +static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, diff --git a/hw/xwayland/xwayland-input.h b/hw/xwayland/xwayland-input.h index ee94d73ae..2e686f945 100644 --- a/hw/xwayland/xwayland-input.h +++ b/hw/xwayland/xwayland-input.h @@ -190,6 +190,9 @@ struct xwl_tablet_pad { struct xorg_list pad_group_list; }; +void xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost); +void xwl_seat_leave_kbd(struct xwl_seat *xwl_seat); + void xwl_seat_destroy(struct xwl_seat *xwl_seat); void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window); |