[mutter] wayland: Make it possible to trigger popups through pointer/keyboard/touch
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Make it possible to trigger popups through pointer/keyboard/touch
- Date: Sat, 17 Oct 2015 16:55:42 +0000 (UTC)
commit a5d2555196758d530a563bcabec5457b1bfed375
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Oct 9 16:42:06 2015 +0200
wayland: Make it possible to trigger popups through pointer/keyboard/touch
Right now we just check the pointer serial, so the popup will be
immediately dismissed if the client passes a serial corresponding to
another input device.
Abstract this a bit further and add a meta_wayland_seat_can_popup() call
that will check the serial all input devices. This makes it possible to
trigger menus through touch or keyboard devices.
https://bugzilla.gnome.org/show_bug.cgi?id=756296
src/wayland/meta-wayland-keyboard.c | 7 +++++++
src/wayland/meta-wayland-keyboard.h | 3 +++
src/wayland/meta-wayland-seat.c | 9 +++++++++
src/wayland/meta-wayland-seat.h | 2 ++
src/wayland/meta-wayland-surface.c | 4 ++--
src/wayland/meta-wayland-touch.c | 20 ++++++++++++++++++++
src/wayland/meta-wayland-touch.h | 3 +++
7 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 7cc4853..9620705 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -673,3 +673,10 @@ meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
wl_list_insert (&keyboard->resource_list, wl_resource_get_link (cr));
}
}
+
+gboolean
+meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
+ uint32_t serial)
+{
+ return keyboard->key_serial == serial;
+}
diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h
index aaf431f..7127c0d 100644
--- a/src/wayland/meta-wayland-keyboard.h
+++ b/src/wayland/meta-wayland-keyboard.h
@@ -101,4 +101,7 @@ void meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
struct wl_resource *seat_resource,
uint32_t id);
+gboolean meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
+ uint32_t serial);
+
#endif /* META_WAYLAND_KEYBOARD_H */
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index e92ee35..9ac2cd1 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -405,3 +405,12 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
return sequence || can_grab_surface;
}
+
+gboolean
+meta_wayland_seat_can_popup (MetaWaylandSeat *seat,
+ uint32_t serial)
+{
+ return (meta_wayland_pointer_can_popup (&seat->pointer, serial) ||
+ meta_wayland_keyboard_can_popup (&seat->keyboard, serial) ||
+ meta_wayland_touch_can_popup (&seat->touch, serial));
+}
diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h
index c0768ec..42d2304 100644
--- a/src/wayland/meta-wayland-seat.h
+++ b/src/wayland/meta-wayland-seat.h
@@ -64,5 +64,7 @@ gboolean meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
uint32_t serial,
gfloat *x,
gfloat *y);
+gboolean meta_wayland_seat_can_popup (MetaWaylandSeat *seat,
+ uint32_t serial);
#endif /* META_WAYLAND_SEAT_H */
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index ba21d77..9d15401 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1518,7 +1518,7 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
surface->xdg_popup = popup_resource;
surface->xdg_shell_resource = resource;
- if (!meta_wayland_pointer_can_popup (&seat->pointer, serial))
+ if (!meta_wayland_seat_can_popup (seat, serial))
{
xdg_popup_send_popup_done (popup_resource);
return;
@@ -1739,7 +1739,7 @@ wl_shell_surface_set_popup (struct wl_client *client,
wl_shell_surface_set_state (surface, SURFACE_STATE_TOPLEVEL);
- if (!meta_wayland_pointer_can_popup (&seat->pointer, serial))
+ if (!meta_wayland_seat_can_popup (seat, serial))
{
wl_shell_surface_send_popup_done (resource);
return;
diff --git a/src/wayland/meta-wayland-touch.c b/src/wayland/meta-wayland-touch.c
index 7400d66..2892510 100644
--- a/src/wayland/meta-wayland-touch.c
+++ b/src/wayland/meta-wayland-touch.c
@@ -575,6 +575,26 @@ meta_wayland_touch_create_new_resource (MetaWaylandTouch *touch,
wl_list_insert (&touch->resource_list, wl_resource_get_link (cr));
}
+gboolean
+meta_wayland_touch_can_popup (MetaWaylandTouch *touch,
+ uint32_t serial)
+{
+ MetaWaylandTouchInfo *touch_info;
+ GHashTableIter iter;
+
+ if (!touch->touches)
+ return FALSE;
+
+ g_hash_table_iter_init (&iter, touch->touches);
+
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer*) &touch_info))
+ {
+ if (touch_info->slot_serial == serial)
+ return TRUE;
+ }
+ return FALSE;
+}
+
ClutterEventSequence *
meta_wayland_touch_find_grab_sequence (MetaWaylandTouch *touch,
MetaWaylandSurface *surface,
diff --git a/src/wayland/meta-wayland-touch.h b/src/wayland/meta-wayland-touch.h
index beaf6ca..e5abc12 100644
--- a/src/wayland/meta-wayland-touch.h
+++ b/src/wayland/meta-wayland-touch.h
@@ -70,4 +70,7 @@ gboolean meta_wayland_touch_get_press_coords (MetaWaylandTouch *touch,
gfloat *x,
gfloat *y);
+gboolean meta_wayland_touch_can_popup (MetaWaylandTouch *touch,
+ uint32_t serial);
+
#endif /* META_WAYLAND_TOUCH_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]