backends: Move HW cursor inhibitors to MetaBackend

We are aiming for a split of HW and SW cursor rendering management.
Given the HW plane is a limited resource and the amount of cursor
renderers may be >1 (due to tablets, even though we currently use an
always-software cursor renderer there), it would ideally be able to
switch between renderers.

Being MetaCursorRenderer not really a singleton, having cursor
inhibitor accounting here doesn't pan out. Make it MetaBackend API
so all cursor renderers get the same picture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho
2020-07-13 17:45:41 +02:00
committed by Marge Bot
parent e218b00747
commit d6f720497a
7 changed files with 67 additions and 88 deletions

View File

@@ -53,6 +53,7 @@
#include <stdlib.h>
#include "backends/meta-cursor-renderer.h"
#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-idle-monitor-private.h"
#include "backends/meta-input-settings-private.h"
@@ -149,6 +150,7 @@ struct _MetaBackendPrivate
ClutterActor *stage;
GList *gpus;
GList *hw_cursor_inhibitors;
gboolean is_pointer_position_initialized;
@@ -1514,3 +1516,40 @@ meta_backend_get_wacom_database (MetaBackend *backend)
return priv->wacom_db;
}
#endif
void
meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend,
MetaHwCursorInhibitor *inhibitor)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors,
inhibitor);
}
void
meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend,
MetaHwCursorInhibitor *inhibitor)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors,
inhibitor);
}
gboolean
meta_backend_is_hw_cursors_inhibited (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
GList *l;
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
{
MetaHwCursorInhibitor *inhibitor = l->data;
if (meta_hw_cursor_inhibitor_is_cursor_inhibited (inhibitor))
return TRUE;
}
return FALSE;
}