compositor: Handle grab state through ClutterStage::is-grabbed handler

This is something the compositor could now track by itself, instead of
being pushed through events. It also makes more sense to do this directly
when the grabbing conditions change, as opposed to the next event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
This commit is contained in:
Carlos Garnacho 2023-08-16 13:46:05 +02:00 committed by Marge Bot
parent 0b9f5ae75b
commit 90a00dae99
3 changed files with 18 additions and 15 deletions

View File

@ -115,6 +115,7 @@ typedef struct _MetaCompositorPrivate
gulong after_paint_handler_id;
gulong window_visibility_updated_id;
gulong monitors_changed_internal_id;
gulong grabbed_notify_handler_id;
int64_t server_time_query_time;
int64_t server_time_offset;
@ -1179,6 +1180,17 @@ on_monitors_changed_internal (MetaMonitorManager *monitor_manager,
meta_compositor_ensure_compositor_views (compositor);
}
static void
on_is_grabbed_changed_cb (ClutterStage *stage,
GParamSpec *pspec,
MetaCompositor *compositor)
{
if (clutter_stage_get_grab_actor (stage) != NULL)
meta_compositor_grab_begin (compositor);
else
meta_compositor_grab_end (compositor);
}
static void
meta_compositor_set_property (GObject *object,
guint prop_id,
@ -1255,6 +1267,11 @@ meta_compositor_constructed (GObject *object)
"after-paint",
G_CALLBACK (on_after_paint),
compositor);
priv->grabbed_notify_handler_id =
g_signal_connect (stage,
"notify::is-grabbed",
G_CALLBACK (on_is_grabbed_changed_cb),
compositor);
priv->window_visibility_updated_id =
g_signal_connect (priv->display,
@ -1288,6 +1305,7 @@ meta_compositor_dispose (GObject *object)
g_clear_signal_handler (&priv->stage_presented_id, stage);
g_clear_signal_handler (&priv->before_paint_handler_id, stage);
g_clear_signal_handler (&priv->after_paint_handler_id, stage);
g_clear_signal_handler (&priv->grabbed_notify_handler_id, stage);
g_clear_signal_handler (&priv->window_visibility_updated_id, priv->display);
g_clear_pointer (&priv->windows, g_list_free);

View File

@ -120,7 +120,6 @@ struct _MetaDisplay
/* Opening the display */
unsigned int display_opening : 1;
unsigned int grabbed_in_clutter : 1;
/* Closing down the display */
int closing;

View File

@ -257,20 +257,6 @@ meta_display_handle_event (MetaDisplay *display,
has_grab = stage_has_grab (display);
if (display->grabbed_in_clutter != has_grab)
{
if (!display->grabbed_in_clutter && has_grab)
{
display->grabbed_in_clutter = TRUE;
meta_compositor_grab_begin (compositor);
}
else if (display->grabbed_in_clutter && !has_grab)
{
display->grabbed_in_clutter = FALSE;
meta_compositor_grab_end (compositor);
}
}
sequence = clutter_event_get_event_sequence (event);
event_type = clutter_event_type (event);
time_ms = clutter_event_get_time (event);