[mutter/wip/carlosg/keyboard-activation] wayland: Check keyboard serials for activation
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/keyboard-activation] wayland: Check keyboard serials for activation
- Date: Thu, 9 Dec 2021 12:19:40 +0000 (UTC)
commit 881edea2d356439752344fba9ba0fc12b5397ef8
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Dec 9 12:47:04 2021 +0100
wayland: Check keyboard serials for activation
We are using internal API that has the benefit of checking that the
focus surface still matches, but has the drawback that it does not
check the MetaWaylandKeyboard state.
In order to fix this, look for keyboard focus and serial matches
specifically when triggering activation.
src/wayland/meta-wayland-activation.c | 31 +++++++++++++++++++++++++------
src/wayland/meta-wayland-keyboard.c | 12 ++++++++++++
src/wayland/meta-wayland-keyboard.h | 3 +++
3 files changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/src/wayland/meta-wayland-activation.c b/src/wayland/meta-wayland-activation.c
index 1983566c1c..d30fbd3d65 100644
--- a/src/wayland/meta-wayland-activation.c
+++ b/src/wayland/meta-wayland-activation.c
@@ -259,6 +259,30 @@ activation_get_activation_token (struct wl_client *client,
id);
}
+static gboolean
+token_can_activate (MetaXdgActivationToken *token)
+{
+ MetaWaylandSeat *seat;
+
+ if (!token->seat)
+ return FALSE;
+ if (!token->surface)
+ return FALSE;
+
+ seat = token->seat;
+
+ if (seat->keyboard &&
+ meta_wayland_keyboard_can_grab_surface (seat->keyboard,
+ token->surface,
+ token->serial))
+ return TRUE;
+
+ return meta_wayland_seat_get_grab_info (seat,
+ token->surface,
+ token->serial,
+ FALSE, NULL, NULL);
+}
+
static void
activation_activate (struct wl_client *client,
struct wl_resource *resource,
@@ -278,12 +302,7 @@ activation_activate (struct wl_client *client,
if (!token)
return;
- if (token->seat &&
- token->surface &&
- meta_wayland_seat_get_grab_info (token->seat,
- token->surface,
- token->serial,
- FALSE, NULL, NULL))
+ if (token_can_activate (token))
{
uint32_t timestamp;
int32_t workspace_idx;
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 836939c9d3..114802e6b7 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -816,6 +816,18 @@ meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
}
}
+gboolean
+meta_wayland_keyboard_can_grab_surface (MetaWaylandKeyboard *keyboard,
+ MetaWaylandSurface *surface,
+ uint32_t serial)
+{
+ if (keyboard->focus_surface != surface)
+ return FALSE;
+
+ return (keyboard->focus_serial == serial ||
+ meta_wayland_keyboard_can_popup (keyboard, serial));
+}
+
gboolean
meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
uint32_t serial)
diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h
index ac57d76774..6cce803ff1 100644
--- a/src/wayland/meta-wayland-keyboard.h
+++ b/src/wayland/meta-wayland-keyboard.h
@@ -130,6 +130,9 @@ void meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
struct wl_resource *seat_resource,
uint32_t id);
+gboolean meta_wayland_keyboard_can_grab_surface (MetaWaylandKeyboard *keyboard,
+ MetaWaylandSurface *surface,
+ uint32_t serial);
gboolean meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
uint32_t serial);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]