[mutter] cursor-sprite: Register all cursor sprites with the cursor tracker
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-sprite: Register all cursor sprites with the cursor tracker
- Date: Wed, 22 Dec 2021 17:07:49 +0000 (UTC)
commit 25ed64b61decc3e20bca6cd06f14287f19a8e626
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Nov 15 14:24:53 2021 +0100
cursor-sprite: Register all cursor sprites with the cursor tracker
This will later be used to invalidate GPU state when closing device
nodes.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
src/backends/meta-cursor-sprite-xcursor.c | 7 ++-
src/backends/meta-cursor-sprite-xcursor.h | 4 +-
src/backends/meta-cursor-tracker-private.h | 8 +++
src/backends/meta-cursor-tracker.c | 31 ++++++++++++
src/backends/meta-cursor.c | 65 +++++++++++++++++++++++++
src/backends/x11/cm/meta-cursor-sprite-xfixes.c | 6 ++-
src/backends/x11/cm/meta-cursor-sprite-xfixes.h | 5 +-
src/backends/x11/meta-cursor-tracker-x11.c | 6 ++-
src/core/display.c | 2 +-
src/wayland/meta-cursor-sprite-wayland.c | 7 ++-
src/wayland/meta-cursor-sprite-wayland.h | 3 +-
src/wayland/meta-wayland-cursor-surface.c | 6 ++-
src/wayland/meta-wayland-tablet-tool.c | 5 +-
13 files changed, 141 insertions(+), 14 deletions(-)
---
diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c
index c188cd16e5..742e1a0bf9 100644
--- a/src/backends/meta-cursor-sprite-xcursor.c
+++ b/src/backends/meta-cursor-sprite-xcursor.c
@@ -343,11 +343,14 @@ meta_cursor_sprite_xcursor_invalidate (MetaCursorSprite *sprite)
}
MetaCursorSpriteXcursor *
-meta_cursor_sprite_xcursor_new (MetaCursor cursor)
+meta_cursor_sprite_xcursor_new (MetaCursor cursor,
+ MetaCursorTracker *cursor_tracker)
{
MetaCursorSpriteXcursor *sprite_xcursor;
- sprite_xcursor = g_object_new (META_TYPE_CURSOR_SPRITE_XCURSOR, NULL);
+ sprite_xcursor = g_object_new (META_TYPE_CURSOR_SPRITE_XCURSOR,
+ "cursor-tracker", cursor_tracker,
+ NULL);
sprite_xcursor->cursor = cursor;
return sprite_xcursor;
diff --git a/src/backends/meta-cursor-sprite-xcursor.h b/src/backends/meta-cursor-sprite-xcursor.h
index dbc927484d..dcb74817c0 100644
--- a/src/backends/meta-cursor-sprite-xcursor.h
+++ b/src/backends/meta-cursor-sprite-xcursor.h
@@ -23,12 +23,14 @@
#include <X11/Xcursor/Xcursor.h>
#include "backends/meta-cursor.h"
+#include "meta/types.h"
#define META_TYPE_CURSOR_SPRITE_XCURSOR meta_cursor_sprite_xcursor_get_type ()
G_DECLARE_FINAL_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,
META, CURSOR_SPRITE_XCURSOR, MetaCursorSprite)
-MetaCursorSpriteXcursor * meta_cursor_sprite_xcursor_new (MetaCursor cursor);
+MetaCursorSpriteXcursor * meta_cursor_sprite_xcursor_new (MetaCursor cursor,
+ MetaCursorTracker *cursor_tracker);
void meta_cursor_sprite_xcursor_set_theme_scale (MetaCursorSpriteXcursor *sprite_xcursor,
int scale);
diff --git a/src/backends/meta-cursor-tracker-private.h b/src/backends/meta-cursor-tracker-private.h
index 2d8d380428..ab4b065718 100644
--- a/src/backends/meta-cursor-tracker-private.h
+++ b/src/backends/meta-cursor-tracker-private.h
@@ -53,4 +53,12 @@ void meta_cursor_tracker_notify_cursor_changed (MetaCursorTracker *tracker);
void meta_cursor_tracker_destroy (MetaCursorTracker *tracker);
+void meta_cursor_tracker_register_cursor_sprite (MetaCursorTracker *tracker,
+ MetaCursorSprite *sprite);
+
+void meta_cursor_tracker_unregister_cursor_sprite (MetaCursorTracker *tracker,
+ MetaCursorSprite *sprite);
+
+GList * meta_cursor_tracker_peek_cursor_sprites (MetaCursorTracker *tracker);
+
#endif
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 116215195e..82238f99d8 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -74,6 +74,8 @@ typedef struct _MetaCursorTrackerPrivate
MetaCursorSprite *window_cursor;
MetaCursorSprite *root_cursor;
+
+ GList *cursor_sprites;
} MetaCursorTrackerPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorTracker, meta_cursor_tracker,
@@ -532,3 +534,32 @@ meta_cursor_tracker_get_backend (MetaCursorTracker *tracker)
return priv->backend;
}
+
+void
+meta_cursor_tracker_register_cursor_sprite (MetaCursorTracker *tracker,
+ MetaCursorSprite *sprite)
+{
+ MetaCursorTrackerPrivate *priv =
+ meta_cursor_tracker_get_instance_private (tracker);
+
+ priv->cursor_sprites = g_list_prepend (priv->cursor_sprites, sprite);
+}
+
+void
+meta_cursor_tracker_unregister_cursor_sprite (MetaCursorTracker *tracker,
+ MetaCursorSprite *sprite)
+{
+ MetaCursorTrackerPrivate *priv =
+ meta_cursor_tracker_get_instance_private (tracker);
+
+ priv->cursor_sprites = g_list_remove (priv->cursor_sprites, sprite);
+}
+
+GList *
+meta_cursor_tracker_peek_cursor_sprites (MetaCursorTracker *tracker)
+{
+ MetaCursorTrackerPrivate *priv =
+ meta_cursor_tracker_get_instance_private (tracker);
+
+ return priv->cursor_sprites;
+}
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
index ae35539dff..aaca5ca2a4 100644
--- a/src/backends/meta-cursor.c
+++ b/src/backends/meta-cursor.c
@@ -24,9 +24,21 @@
#include "backends/meta-cursor.h"
#include "backends/meta-backend-private.h"
+#include "backends/meta-cursor-tracker-private.h"
#include "cogl/cogl.h"
#include "meta/common.h"
+enum
+{
+ PROP_0,
+
+ PROP_CURSOR_TRACKER,
+
+ N_PROPS
+};
+
+static GParamSpec *obj_props[N_PROPS];
+
enum
{
TEXTURE_CHANGED,
@@ -47,6 +59,8 @@ typedef struct _MetaCursorSpritePrivate
MetaCursorPrepareFunc prepare_func;
gpointer prepare_func_data;
+
+ MetaCursorTracker *cursor_tracker;
} MetaCursorSpritePrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCursorSprite,
@@ -239,6 +253,22 @@ meta_cursor_sprite_init (MetaCursorSprite *sprite)
priv->texture_transform = META_MONITOR_TRANSFORM_NORMAL;
}
+static void
+meta_cursor_sprite_constructed (GObject *object)
+{
+ MetaCursorSprite *sprite = META_CURSOR_SPRITE (object);
+ MetaCursorSpritePrivate *priv =
+ meta_cursor_sprite_get_instance_private (sprite);
+
+ g_assert (priv->cursor_tracker);
+
+ meta_cursor_tracker_register_cursor_sprite (priv->cursor_tracker, sprite);
+
+ g_clear_pointer (&priv->texture, cogl_object_unref);
+
+ G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->constructed (object);
+}
+
static void
meta_cursor_sprite_finalize (GObject *object)
{
@@ -248,15 +278,50 @@ meta_cursor_sprite_finalize (GObject *object)
g_clear_pointer (&priv->texture, cogl_object_unref);
+ meta_cursor_tracker_unregister_cursor_sprite (priv->cursor_tracker, sprite);
+
G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->finalize (object);
}
+static void
+meta_cursor_tracker_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MetaCursorSprite *sprite = META_CURSOR_SPRITE (object);
+ MetaCursorSpritePrivate *priv =
+ meta_cursor_sprite_get_instance_private (sprite);
+
+ switch (prop_id)
+ {
+ case PROP_CURSOR_TRACKER:
+ priv->cursor_tracker = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static void
meta_cursor_sprite_class_init (MetaCursorSpriteClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->constructed = meta_cursor_sprite_constructed;
object_class->finalize = meta_cursor_sprite_finalize;
+ object_class->set_property = meta_cursor_tracker_set_property;
+
+ obj_props[PROP_CURSOR_TRACKER] =
+ g_param_spec_object ("cursor-tracker",
+ "cursor tracker",
+ "MetaCursorTracker",
+ META_TYPE_CURSOR_TRACKER,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_properties (object_class, N_PROPS, obj_props);
signals[TEXTURE_CHANGED] = g_signal_new ("texture-changed",
G_TYPE_FROM_CLASS (object_class),
diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
index ae6e2b6acb..2847cd295d 100644
--- a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
+++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
@@ -103,12 +103,14 @@ meta_cursor_sprite_xfixes_set_property (GObject *object,
}
MetaCursorSpriteXfixes *
-meta_cursor_sprite_xfixes_new (MetaDisplay *display,
- GError **error)
+meta_cursor_sprite_xfixes_new (MetaDisplay *display,
+ MetaCursorTracker *cursor_tracker,
+ GError **error)
{
return g_initable_new (META_TYPE_CURSOR_SPRITE_XFIXES,
NULL, error,
"display", display,
+ "cursor-tracker", cursor_tracker,
NULL);
}
diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.h b/src/backends/x11/cm/meta-cursor-sprite-xfixes.h
index c7073fc2c0..469d958a26 100644
--- a/src/backends/x11/cm/meta-cursor-sprite-xfixes.h
+++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.h
@@ -30,7 +30,8 @@ G_DECLARE_FINAL_TYPE (MetaCursorSpriteXfixes,
META, CURSOR_SPRITE_XFIXES,
MetaCursorSprite)
-MetaCursorSpriteXfixes * meta_cursor_sprite_xfixes_new (MetaDisplay *display,
- GError **error);
+MetaCursorSpriteXfixes * meta_cursor_sprite_xfixes_new (MetaDisplay *display,
+ MetaCursorTracker *cursor_tracker,
+ GError **error);
#endif /* META_CURSOR_SPRITE_XFIXES_H */
diff --git a/src/backends/x11/meta-cursor-tracker-x11.c b/src/backends/x11/meta-cursor-tracker-x11.c
index 7355f828ea..e01046d800 100644
--- a/src/backends/x11/meta-cursor-tracker-x11.c
+++ b/src/backends/x11/meta-cursor-tracker-x11.c
@@ -77,12 +77,16 @@ static gboolean
ensure_xfixes_cursor (MetaCursorTrackerX11 *tracker_x11)
{
MetaDisplay *display = meta_get_display ();
+ MetaCursorTracker *cursor_tracker;
g_autoptr (GError) error = NULL;
if (tracker_x11->xfixes_cursor)
return FALSE;
- tracker_x11->xfixes_cursor = meta_cursor_sprite_xfixes_new (display, &error);
+ cursor_tracker = META_CURSOR_TRACKER (tracker_x11);
+ tracker_x11->xfixes_cursor = meta_cursor_sprite_xfixes_new (display,
+ cursor_tracker,
+ &error);
if (!tracker_x11->xfixes_cursor)
g_warning ("Failed to create XFIXES cursor: %s", error->message);
diff --git a/src/core/display.c b/src/core/display.c
index 60b8add77e..bb3918cf3a 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1742,7 +1742,7 @@ meta_display_reload_cursor (MetaDisplay *display)
MetaBackend *backend = meta_get_backend ();
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
- sprite_xcursor = meta_cursor_sprite_xcursor_new (cursor);
+ sprite_xcursor = meta_cursor_sprite_xcursor_new (cursor, cursor_tracker);
if (meta_is_wayland_compositor ())
manage_root_cursor_sprite_scale (display, sprite_xcursor);
diff --git a/src/wayland/meta-cursor-sprite-wayland.c b/src/wayland/meta-cursor-sprite-wayland.c
index 40a8d10b06..fc265114be 100644
--- a/src/wayland/meta-cursor-sprite-wayland.c
+++ b/src/wayland/meta-cursor-sprite-wayland.c
@@ -64,11 +64,14 @@ meta_cursor_sprite_wayland_invalidate (MetaCursorSprite *sprite)
}
MetaCursorSpriteWayland *
-meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface)
+meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface,
+ MetaCursorTracker *cursor_tracker)
{
MetaCursorSpriteWayland *sprite_wayland;
- sprite_wayland = g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND, NULL);
+ sprite_wayland = g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND,
+ "cursor-tracker", cursor_tracker,
+ NULL);
sprite_wayland->surface = surface;
return sprite_wayland;
diff --git a/src/wayland/meta-cursor-sprite-wayland.h b/src/wayland/meta-cursor-sprite-wayland.h
index 107698f3f9..6beb0b69a3 100644
--- a/src/wayland/meta-cursor-sprite-wayland.h
+++ b/src/wayland/meta-cursor-sprite-wayland.h
@@ -28,7 +28,8 @@
G_DECLARE_FINAL_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland,
META, CURSOR_SPRITE_WAYLAND, MetaCursorSprite)
-MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface);
+MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface,
+ MetaCursorTracker *cursor_tracker);
MetaWaylandBuffer * meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland);
diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c
index a0b8757021..87d55535cb 100644
--- a/src/wayland/meta-wayland-cursor-surface.c
+++ b/src/wayland/meta-wayland-cursor-surface.c
@@ -250,6 +250,9 @@ meta_wayland_cursor_surface_constructed (GObject *object)
META_WAYLAND_SURFACE_ROLE (cursor_surface);
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
+ MetaWaylandCompositor *compositor = surface->compositor;
+ MetaBackend *backend = meta_context_get_backend (compositor->context);
+ MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
MetaWaylandBuffer *buffer;
buffer = meta_wayland_surface_get_buffer (surface);
@@ -262,7 +265,8 @@ meta_wayland_cursor_surface_constructed (GObject *object)
meta_wayland_surface_ref_buffer_use_count (surface);
}
- priv->cursor_sprite = meta_cursor_sprite_wayland_new (surface);
+ priv->cursor_sprite = meta_cursor_sprite_wayland_new (surface,
+ cursor_tracker);
meta_cursor_sprite_set_prepare_func (META_CURSOR_SPRITE (priv->cursor_sprite),
(MetaCursorPrepareFunc) cursor_sprite_prepare_at,
cursor_surface);
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 4e24f8cbee..eeacd9bf9a 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -385,6 +385,8 @@ meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *device_tool)
{
+ MetaBackend *backend = meta_get_backend ();
+ MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
MetaWaylandTabletTool *tool;
tool = g_new0 (MetaWaylandTabletTool, 1);
@@ -397,7 +399,8 @@ meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
tool->focus_surface_destroy_listener.notify = tablet_tool_handle_focus_surface_destroy;
tool->cursor_surface_destroy_listener.notify = tablet_tool_handle_cursor_surface_destroy;
- tool->default_sprite = meta_cursor_sprite_xcursor_new (META_CURSOR_CROSSHAIR);
+ tool->default_sprite = meta_cursor_sprite_xcursor_new (META_CURSOR_CROSSHAIR,
+ cursor_tracker);
meta_cursor_sprite_set_prepare_func (META_CURSOR_SPRITE (tool->default_sprite),
(MetaCursorPrepareFunc) tool_cursor_prepare_at,
tool);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]