mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
wayland/pointer: Track lifetime of current surface
Clear the pointer->current when the surface is destroyed. https://bugzilla.gnome.org/show_bug.cgi?id=783113
This commit is contained in:
parent
b19e4592df
commit
b4120a75e0
@ -86,6 +86,10 @@ static guint signals[LAST_SIGNAL];
|
|||||||
G_DEFINE_TYPE (MetaWaylandPointer, meta_wayland_pointer,
|
G_DEFINE_TYPE (MetaWaylandPointer, meta_wayland_pointer,
|
||||||
META_TYPE_WAYLAND_INPUT_DEVICE)
|
META_TYPE_WAYLAND_INPUT_DEVICE)
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_wayland_pointer_set_current (MetaWaylandPointer *pointer,
|
||||||
|
MetaWaylandSurface *surface);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_wayland_pointer_reset_grab (MetaWaylandPointer *pointer);
|
meta_wayland_pointer_reset_grab (MetaWaylandPointer *pointer);
|
||||||
|
|
||||||
@ -510,6 +514,7 @@ meta_wayland_pointer_disable (MetaWaylandPointer *pointer)
|
|||||||
meta_wayland_pointer_cancel_grab (pointer);
|
meta_wayland_pointer_cancel_grab (pointer);
|
||||||
meta_wayland_pointer_reset_grab (pointer);
|
meta_wayland_pointer_reset_grab (pointer);
|
||||||
meta_wayland_pointer_set_focus (pointer, NULL);
|
meta_wayland_pointer_set_focus (pointer, NULL);
|
||||||
|
meta_wayland_pointer_set_current (pointer, NULL);
|
||||||
|
|
||||||
g_clear_pointer (&pointer->pointer_clients, g_hash_table_unref);
|
g_clear_pointer (&pointer->pointer_clients, g_hash_table_unref);
|
||||||
pointer->cursor_surface = NULL;
|
pointer->cursor_surface = NULL;
|
||||||
@ -537,11 +542,40 @@ count_buttons (const ClutterEvent *event)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
current_surface_destroyed (MetaWaylandSurface *surface,
|
||||||
|
MetaWaylandPointer *pointer)
|
||||||
|
{
|
||||||
|
meta_wayland_pointer_set_current (pointer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_wayland_pointer_set_current (MetaWaylandPointer *pointer,
|
||||||
|
MetaWaylandSurface *surface)
|
||||||
|
{
|
||||||
|
if (pointer->current)
|
||||||
|
{
|
||||||
|
g_signal_handler_disconnect (pointer->current,
|
||||||
|
pointer->current_surface_destroyed_handler_id);
|
||||||
|
pointer->current = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (surface)
|
||||||
|
{
|
||||||
|
pointer->current = surface;
|
||||||
|
pointer->current_surface_destroyed_handler_id =
|
||||||
|
g_signal_connect (surface, "destroy",
|
||||||
|
G_CALLBACK (current_surface_destroyed),
|
||||||
|
pointer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
repick_for_event (MetaWaylandPointer *pointer,
|
repick_for_event (MetaWaylandPointer *pointer,
|
||||||
const ClutterEvent *for_event)
|
const ClutterEvent *for_event)
|
||||||
{
|
{
|
||||||
ClutterActor *actor;
|
ClutterActor *actor;
|
||||||
|
MetaWaylandSurface *surface;
|
||||||
|
|
||||||
if (for_event)
|
if (for_event)
|
||||||
actor = clutter_event_get_source (for_event);
|
actor = clutter_event_get_source (for_event);
|
||||||
@ -549,10 +583,18 @@ repick_for_event (MetaWaylandPointer *pointer,
|
|||||||
actor = clutter_input_device_get_pointer_actor (pointer->device);
|
actor = clutter_input_device_get_pointer_actor (pointer->device);
|
||||||
|
|
||||||
if (META_IS_SURFACE_ACTOR_WAYLAND (actor))
|
if (META_IS_SURFACE_ACTOR_WAYLAND (actor))
|
||||||
pointer->current =
|
{
|
||||||
meta_surface_actor_wayland_get_surface (META_SURFACE_ACTOR_WAYLAND (actor));
|
MetaSurfaceActorWayland *actor_wayland =
|
||||||
|
META_SURFACE_ACTOR_WAYLAND (actor);
|
||||||
|
|
||||||
|
surface = meta_surface_actor_wayland_get_surface (actor_wayland);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pointer->current = NULL;
|
{
|
||||||
|
surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_wayland_pointer_set_current (pointer, surface);
|
||||||
|
|
||||||
sync_focus_surface (pointer);
|
sync_focus_surface (pointer);
|
||||||
meta_wayland_pointer_update_cursor_surface (pointer);
|
meta_wayland_pointer_update_cursor_surface (pointer);
|
||||||
|
@ -87,6 +87,7 @@ struct _MetaWaylandPointer
|
|||||||
|
|
||||||
ClutterInputDevice *device;
|
ClutterInputDevice *device;
|
||||||
MetaWaylandSurface *current;
|
MetaWaylandSurface *current;
|
||||||
|
gulong current_surface_destroyed_handler_id;
|
||||||
|
|
||||||
guint32 button_count;
|
guint32 button_count;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user