[mutter/gnome-3-24] wayland/pointer: Use glib signals tracking focus surface
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-24] wayland/pointer: Use glib signals tracking focus surface
- Date: Thu, 1 Jun 2017 06:40:25 +0000 (UTC)
commit bbed0d80453a680711358bdfb55235bfac3057e4
Author: Jonas Ådahl <jadahl gmail com>
Date: Wed May 31 17:24:07 2017 +0800
wayland/pointer: Use glib signals tracking focus surface
Use the "destroy" MetaWaylandSurface signal instead of the wl_resource
destroy signal for tracking the lifetime of the surface with pointer
focus.
As unsetting the focus may have side effects due to handlers of the
"focus-surface-changed" signal, connect the signal after the default
handler to make sure other clean up facilities have the chance deal with
the surface destruction before we try to unset the focus.
https://bugzilla.gnome.org/show_bug.cgi?id=783113
src/wayland/meta-wayland-pointer.c | 28 +++++++++++++++-------------
src/wayland/meta-wayland-pointer.h | 2 +-
2 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 4578f3e..7c05912 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -247,14 +247,6 @@ sync_focus_surface (MetaWaylandPointer *pointer)
}
static void
-pointer_handle_focus_surface_destroy (struct wl_listener *listener, void *data)
-{
- MetaWaylandPointer *pointer = wl_container_of (listener, pointer, focus_surface_listener);
-
- meta_wayland_pointer_set_focus (pointer, NULL);
-}
-
-static void
meta_wayland_pointer_send_frame (MetaWaylandPointer *pointer,
struct wl_resource *resource)
{
@@ -488,8 +480,6 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) meta_wayland_pointer_client_free);
- pointer->focus_surface_listener.notify = pointer_handle_focus_surface_destroy;
-
pointer->cursor_surface = NULL;
manager = clutter_device_manager_get_default ();
@@ -815,6 +805,13 @@ meta_wayland_pointer_broadcast_leave (MetaWaylandPointer *pointer,
meta_wayland_pointer_broadcast_frame (pointer);
}
+static void
+focus_surface_destroyed (MetaWaylandSurface *surface,
+ MetaWaylandPointer *pointer)
+{
+ meta_wayland_pointer_set_focus (pointer, NULL);
+}
+
void
meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface)
@@ -838,7 +835,9 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
pointer->focus_client = NULL;
}
- wl_list_remove (&pointer->focus_surface_listener.link);
+ g_signal_handler_disconnect (pointer->focus_surface,
+ pointer->focus_surface_destroyed_handler_id);
+ pointer->focus_surface_destroyed_handler_id = 0;
pointer->focus_surface = NULL;
}
@@ -848,8 +847,11 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
ClutterPoint pos;
pointer->focus_surface = surface;
- wl_resource_add_destroy_listener (pointer->focus_surface->resource,
- &pointer->focus_surface_listener);
+
+ pointer->focus_surface_destroyed_handler_id =
+ g_signal_connect_after (pointer->focus_surface, "destroy",
+ G_CALLBACK (focus_surface_destroyed),
+ pointer);
clutter_input_device_get_coords (pointer->device, NULL, &pos);
diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h
index 547cd56..9f55590 100644
--- a/src/wayland/meta-wayland-pointer.h
+++ b/src/wayland/meta-wayland-pointer.h
@@ -71,7 +71,7 @@ struct _MetaWaylandPointer
GHashTable *pointer_clients;
MetaWaylandSurface *focus_surface;
- struct wl_listener focus_surface_listener;
+ gulong focus_surface_destroyed_handler_id;
guint32 focus_serial;
guint32 click_serial;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]