xwayland: Update lost focus on deactivation

Use the "activated" state from xdg-shell to call the pointer and
keyboard leave events when running rootful.

The regular pointer and keyboard leave notifications are now ignored
when running rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1604
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
This commit is contained in:
Olivier Fourdan 2023-12-14 18:26:33 +01:00 committed by Marge Bot
parent 122ad8a0de
commit 792758faa5
3 changed files with 21 additions and 2 deletions

View File

@ -617,6 +617,7 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
focus_lost = TRUE; focus_lost = TRUE;
} }
if (xwl_screen->rootless)
xwl_seat_leave_ptr(xwl_seat, focus_lost); xwl_seat_leave_ptr(xwl_seat, focus_lost);
} }
@ -1211,6 +1212,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
xwl_screen->serial = serial; xwl_screen->serial = serial;
if (xwl_screen->rootless)
xwl_seat_leave_kbd(xwl_seat); xwl_seat_leave_kbd(xwl_seat);
} }

View File

@ -54,6 +54,7 @@ struct xwl_screen {
int expecting_event; int expecting_event;
enum RootClipMode root_clip_mode; enum RootClipMode root_clip_mode;
Bool active;
int rootless; int rootless;
xwl_glamor_mode_flags glamor; xwl_glamor_mode_flags glamor;
int present; int present;

View File

@ -795,6 +795,8 @@ xdg_toplevel_handle_configure(void *data,
{ {
struct xwl_window *xwl_window = data; struct xwl_window *xwl_window = data;
struct xwl_screen *xwl_screen = xwl_window->xwl_screen; struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
uint32_t *p;
Bool old_active = xwl_screen->active;
/* Maintain our current size if no dimensions are requested */ /* Maintain our current size if no dimensions are requested */
if (width == 0 && height == 0) if (width == 0 && height == 0)
@ -804,6 +806,20 @@ xdg_toplevel_handle_configure(void *data,
/* This will be committed by the xdg_surface.configure handler */ /* This will be committed by the xdg_surface.configure handler */
xwl_window_maybe_resize(xwl_window, width, height); xwl_window_maybe_resize(xwl_window, width, height);
} }
xwl_screen->active = FALSE;
wl_array_for_each (p, states) {
uint32_t state = *p;
if (state == XDG_TOPLEVEL_STATE_ACTIVATED) {
xwl_screen->active = TRUE;
break;
}
}
if (old_active != xwl_screen->active) {
if (!xwl_screen->active)
xwl_screen_lost_focus(xwl_screen);
}
} }
static void static void