[mutter] wayland: Check the serial when creating popups
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Check the serial when creating popups
- Date: Tue, 17 Feb 2015 14:17:12 +0000 (UTC)
commit f5c65d9ea142c458bd931c8da89c5fd19baca935
Author: Jonas Ådahl <jadahl gmail com>
Date: Tue Feb 10 21:11:17 2015 +0800
wayland: Check the serial when creating popups
Send popup_done immediately if the serial is incorrect so the client can
destroy its resources.
https://bugzilla.gnome.org/show_bug.cgi?id=744452
src/wayland/meta-wayland-pointer.c | 6 ++++++
src/wayland/meta-wayland-pointer.h | 3 +++
src/wayland/meta-wayland-surface.c | 22 ++++++++++++++++++++--
3 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index d2227ab..fcb7795 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -844,3 +844,9 @@ meta_wayland_pointer_can_grab_surface (MetaWaylandPointer *pointer,
pointer->grab_serial == serial &&
pointer->focus_surface == surface);
}
+
+gboolean
+meta_wayland_pointer_can_popup (MetaWaylandPointer *pointer, uint32_t serial)
+{
+ return pointer->grab_serial == serial;
+}
diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h
index 6bd01a8..de5d815 100644
--- a/src/wayland/meta-wayland-pointer.h
+++ b/src/wayland/meta-wayland-pointer.h
@@ -114,4 +114,7 @@ gboolean meta_wayland_pointer_can_grab_surface (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface,
uint32_t serial);
+gboolean meta_wayland_pointer_can_popup (MetaWaylandPointer *pointer,
+ uint32_t serial);
+
#endif /* META_WAYLAND_POINTER_H */
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 5904eac..7089cc4 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1046,6 +1046,7 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
int32_t x,
int32_t y)
{
+ struct wl_resource *popup_resource;
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
@@ -1077,9 +1078,20 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
return;
}
- surface->xdg_popup = wl_resource_create (client, &xdg_popup_interface, wl_resource_get_version (resource),
id);
- wl_resource_set_implementation (surface->xdg_popup, &meta_wayland_xdg_popup_interface, surface,
xdg_popup_destructor);
+ popup_resource = wl_resource_create (client, &xdg_popup_interface,
+ wl_resource_get_version (resource), id);
+ wl_resource_set_implementation (popup_resource,
+ &meta_wayland_xdg_popup_interface,
+ surface,
+ xdg_popup_destructor);
+ if (!meta_wayland_pointer_can_popup (&seat->pointer, serial))
+ {
+ xdg_popup_send_popup_done (popup_resource);
+ return;
+ }
+
+ surface->xdg_popup = popup_resource;
surface->xdg_shell_resource = resource;
window = meta_window_wayland_new (display, surface);
@@ -1275,6 +1287,12 @@ 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))
+ {
+ wl_shell_surface_send_popup_done (resource);
+ return;
+ }
+
meta_window_set_transient_for (surface->window, parent_surf->window);
meta_window_move_frame (surface->window, FALSE,
parent_surf->window->rect.x + x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]