backend: Add simple HW cursor inhibit API

The existing is meant to allow more complex inhibitation, but sometimes
it's useful to inhibit globally, e.g. for debugging purposes. Add API to
achieve this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
This commit is contained in:
Jonas Ådahl 2024-12-10 22:37:16 +01:00 committed by Sebastian Wick
parent da0fa12f1f
commit b97516edb9
2 changed files with 40 additions and 0 deletions

View File

@ -216,6 +216,10 @@ void meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend,
void meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend,
MetaHwCursorInhibitor *inhibitor);
void meta_backend_inhibit_hw_cursor (MetaBackend *backend);
void meta_backend_uninhibit_hw_cursor (MetaBackend *backend);
gboolean meta_backend_is_hw_cursors_inhibited (MetaBackend *backend);
void meta_backend_update_from_event (MetaBackend *backend,

View File

@ -168,6 +168,7 @@ struct _MetaBackendPrivate
GList *gpus;
GList *hw_cursor_inhibitors;
int global_hw_cursor_inhibitors;
gboolean in_init;
@ -1817,12 +1818,47 @@ meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend,
inhibitor);
}
void
meta_backend_inhibit_hw_cursor (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
priv->global_hw_cursor_inhibitors++;
meta_topic (META_DEBUG_BACKEND,
"Global hw cursor inhibitors: %d",
priv->global_hw_cursor_inhibitors);
if (priv->global_hw_cursor_inhibitors == 1)
clutter_stage_schedule_update (CLUTTER_STAGE (priv->stage));
}
void
meta_backend_uninhibit_hw_cursor (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
g_return_if_fail (priv->global_hw_cursor_inhibitors > 0);
priv->global_hw_cursor_inhibitors--;
meta_topic (META_DEBUG_BACKEND,
"Global hw cursor inhibitors: %d",
priv->global_hw_cursor_inhibitors);
if (priv->global_hw_cursor_inhibitors == 0)
clutter_stage_schedule_update (CLUTTER_STAGE (priv->stage));
}
gboolean
meta_backend_is_hw_cursors_inhibited (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
GList *l;
if (priv->global_hw_cursor_inhibitors > 0)
return TRUE;
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
{
MetaHwCursorInhibitor *inhibitor = l->data;