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>
This commit is contained in:
Olivier Fourdan 2023-12-14 18:10:05 +01:00 committed by Marge Bot
parent afaad1b847
commit 654c354da9
2 changed files with 33 additions and 10 deletions

View File

@ -587,14 +587,26 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
maybe_fake_grab_devices(xwl_seat); 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 static void
pointer_handle_leave(void *data, struct wl_pointer *pointer, pointer_handle_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface) uint32_t serial, struct wl_surface *surface)
{ {
struct xwl_seat *xwl_seat = data; 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 /* The pointer has left a known xwindow, save it for a possible match
* in sprite_check_lost_focus() * in sprite_check_lost_focus()
@ -602,10 +614,10 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
if (xwl_seat->focus_window) { if (xwl_seat->focus_window) {
xwl_seat->last_xwindow = xwl_seat->focus_window->window; xwl_seat->last_xwindow = xwl_seat->focus_window->window;
xwl_seat->focus_window = NULL; 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 static void
@ -1177,15 +1189,11 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
maybe_fake_grab_devices(xwl_seat); maybe_fake_grab_devices(xwl_seat);
} }
static void void
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, xwl_seat_leave_kbd(struct xwl_seat *xwl_seat)
uint32_t serial, struct wl_surface *surface)
{ {
struct xwl_seat *xwl_seat = data;
uint32_t *k; uint32_t *k;
xwl_seat->xwl_screen->serial = serial;
wl_array_for_each(k, &xwl_seat->keys) wl_array_for_each(k, &xwl_seat->keys)
QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8); QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8);
@ -1194,6 +1202,18 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
maybe_fake_ungrab_devices(xwl_seat); maybe_fake_ungrab_devices(xwl_seat);
} }
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 static void
keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t mods_depressed, uint32_t serial, uint32_t mods_depressed,

View File

@ -190,6 +190,9 @@ struct xwl_tablet_pad {
struct xorg_list pad_group_list; 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_destroy(struct xwl_seat *xwl_seat);
void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window); void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window);