mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
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
This commit is contained in:
parent
e9c9ee844c
commit
b19e4592df
@ -246,14 +246,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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user