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>
This commit is contained in:
parent
c498ae337f
commit
25ed64b61d
@ -343,11 +343,14 @@ meta_cursor_sprite_xcursor_invalidate (MetaCursorSprite *sprite)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorSpriteXcursor *
|
MetaCursorSpriteXcursor *
|
||||||
meta_cursor_sprite_xcursor_new (MetaCursor cursor)
|
meta_cursor_sprite_xcursor_new (MetaCursor cursor,
|
||||||
|
MetaCursorTracker *cursor_tracker)
|
||||||
{
|
{
|
||||||
MetaCursorSpriteXcursor *sprite_xcursor;
|
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;
|
sprite_xcursor->cursor = cursor;
|
||||||
|
|
||||||
return sprite_xcursor;
|
return sprite_xcursor;
|
||||||
|
@ -23,12 +23,14 @@
|
|||||||
#include <X11/Xcursor/Xcursor.h>
|
#include <X11/Xcursor/Xcursor.h>
|
||||||
|
|
||||||
#include "backends/meta-cursor.h"
|
#include "backends/meta-cursor.h"
|
||||||
|
#include "meta/types.h"
|
||||||
|
|
||||||
#define META_TYPE_CURSOR_SPRITE_XCURSOR meta_cursor_sprite_xcursor_get_type ()
|
#define META_TYPE_CURSOR_SPRITE_XCURSOR meta_cursor_sprite_xcursor_get_type ()
|
||||||
G_DECLARE_FINAL_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,
|
G_DECLARE_FINAL_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,
|
||||||
META, CURSOR_SPRITE_XCURSOR, MetaCursorSprite)
|
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,
|
void meta_cursor_sprite_xcursor_set_theme_scale (MetaCursorSpriteXcursor *sprite_xcursor,
|
||||||
int scale);
|
int scale);
|
||||||
|
@ -53,4 +53,12 @@ void meta_cursor_tracker_notify_cursor_changed (MetaCursorTracker *tracker);
|
|||||||
|
|
||||||
void meta_cursor_tracker_destroy (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
|
#endif
|
||||||
|
@ -74,6 +74,8 @@ typedef struct _MetaCursorTrackerPrivate
|
|||||||
MetaCursorSprite *window_cursor;
|
MetaCursorSprite *window_cursor;
|
||||||
|
|
||||||
MetaCursorSprite *root_cursor;
|
MetaCursorSprite *root_cursor;
|
||||||
|
|
||||||
|
GList *cursor_sprites;
|
||||||
} MetaCursorTrackerPrivate;
|
} MetaCursorTrackerPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorTracker, meta_cursor_tracker,
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorTracker, meta_cursor_tracker,
|
||||||
@ -532,3 +534,32 @@ meta_cursor_tracker_get_backend (MetaCursorTracker *tracker)
|
|||||||
|
|
||||||
return priv->backend;
|
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;
|
||||||
|
}
|
||||||
|
@ -24,9 +24,21 @@
|
|||||||
#include "backends/meta-cursor.h"
|
#include "backends/meta-cursor.h"
|
||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
|
#include "backends/meta-cursor-tracker-private.h"
|
||||||
#include "cogl/cogl.h"
|
#include "cogl/cogl.h"
|
||||||
#include "meta/common.h"
|
#include "meta/common.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
|
||||||
|
PROP_CURSOR_TRACKER,
|
||||||
|
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *obj_props[N_PROPS];
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TEXTURE_CHANGED,
|
TEXTURE_CHANGED,
|
||||||
@ -47,6 +59,8 @@ typedef struct _MetaCursorSpritePrivate
|
|||||||
|
|
||||||
MetaCursorPrepareFunc prepare_func;
|
MetaCursorPrepareFunc prepare_func;
|
||||||
gpointer prepare_func_data;
|
gpointer prepare_func_data;
|
||||||
|
|
||||||
|
MetaCursorTracker *cursor_tracker;
|
||||||
} MetaCursorSpritePrivate;
|
} MetaCursorSpritePrivate;
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCursorSprite,
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCursorSprite,
|
||||||
@ -239,6 +253,22 @@ meta_cursor_sprite_init (MetaCursorSprite *sprite)
|
|||||||
priv->texture_transform = META_MONITOR_TRANSFORM_NORMAL;
|
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
|
static void
|
||||||
meta_cursor_sprite_finalize (GObject *object)
|
meta_cursor_sprite_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -248,15 +278,50 @@ meta_cursor_sprite_finalize (GObject *object)
|
|||||||
|
|
||||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
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);
|
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
|
static void
|
||||||
meta_cursor_sprite_class_init (MetaCursorSpriteClass *klass)
|
meta_cursor_sprite_class_init (MetaCursorSpriteClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructed = meta_cursor_sprite_constructed;
|
||||||
object_class->finalize = meta_cursor_sprite_finalize;
|
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",
|
signals[TEXTURE_CHANGED] = g_signal_new ("texture-changed",
|
||||||
G_TYPE_FROM_CLASS (object_class),
|
G_TYPE_FROM_CLASS (object_class),
|
||||||
|
@ -103,12 +103,14 @@ meta_cursor_sprite_xfixes_set_property (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorSpriteXfixes *
|
MetaCursorSpriteXfixes *
|
||||||
meta_cursor_sprite_xfixes_new (MetaDisplay *display,
|
meta_cursor_sprite_xfixes_new (MetaDisplay *display,
|
||||||
GError **error)
|
MetaCursorTracker *cursor_tracker,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
return g_initable_new (META_TYPE_CURSOR_SPRITE_XFIXES,
|
return g_initable_new (META_TYPE_CURSOR_SPRITE_XFIXES,
|
||||||
NULL, error,
|
NULL, error,
|
||||||
"display", display,
|
"display", display,
|
||||||
|
"cursor-tracker", cursor_tracker,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ G_DECLARE_FINAL_TYPE (MetaCursorSpriteXfixes,
|
|||||||
META, CURSOR_SPRITE_XFIXES,
|
META, CURSOR_SPRITE_XFIXES,
|
||||||
MetaCursorSprite)
|
MetaCursorSprite)
|
||||||
|
|
||||||
MetaCursorSpriteXfixes * meta_cursor_sprite_xfixes_new (MetaDisplay *display,
|
MetaCursorSpriteXfixes * meta_cursor_sprite_xfixes_new (MetaDisplay *display,
|
||||||
GError **error);
|
MetaCursorTracker *cursor_tracker,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
#endif /* META_CURSOR_SPRITE_XFIXES_H */
|
#endif /* META_CURSOR_SPRITE_XFIXES_H */
|
||||||
|
@ -77,12 +77,16 @@ static gboolean
|
|||||||
ensure_xfixes_cursor (MetaCursorTrackerX11 *tracker_x11)
|
ensure_xfixes_cursor (MetaCursorTrackerX11 *tracker_x11)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
|
MetaCursorTracker *cursor_tracker;
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
if (tracker_x11->xfixes_cursor)
|
if (tracker_x11->xfixes_cursor)
|
||||||
return FALSE;
|
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)
|
if (!tracker_x11->xfixes_cursor)
|
||||||
g_warning ("Failed to create XFIXES cursor: %s", error->message);
|
g_warning ("Failed to create XFIXES cursor: %s", error->message);
|
||||||
|
|
||||||
|
@ -1742,7 +1742,7 @@ meta_display_reload_cursor (MetaDisplay *display)
|
|||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (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 ())
|
if (meta_is_wayland_compositor ())
|
||||||
manage_root_cursor_sprite_scale (display, sprite_xcursor);
|
manage_root_cursor_sprite_scale (display, sprite_xcursor);
|
||||||
|
@ -64,11 +64,14 @@ meta_cursor_sprite_wayland_invalidate (MetaCursorSprite *sprite)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorSpriteWayland *
|
MetaCursorSpriteWayland *
|
||||||
meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface)
|
meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface,
|
||||||
|
MetaCursorTracker *cursor_tracker)
|
||||||
{
|
{
|
||||||
MetaCursorSpriteWayland *sprite_wayland;
|
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;
|
sprite_wayland->surface = surface;
|
||||||
|
|
||||||
return sprite_wayland;
|
return sprite_wayland;
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
G_DECLARE_FINAL_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland,
|
G_DECLARE_FINAL_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland,
|
||||||
META, CURSOR_SPRITE_WAYLAND, MetaCursorSprite)
|
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);
|
MetaWaylandBuffer * meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland);
|
||||||
|
|
||||||
|
@ -250,6 +250,9 @@ meta_wayland_cursor_surface_constructed (GObject *object)
|
|||||||
META_WAYLAND_SURFACE_ROLE (cursor_surface);
|
META_WAYLAND_SURFACE_ROLE (cursor_surface);
|
||||||
MetaWaylandSurface *surface =
|
MetaWaylandSurface *surface =
|
||||||
meta_wayland_surface_role_get_surface (surface_role);
|
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;
|
MetaWaylandBuffer *buffer;
|
||||||
|
|
||||||
buffer = meta_wayland_surface_get_buffer (surface);
|
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);
|
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),
|
meta_cursor_sprite_set_prepare_func (META_CURSOR_SPRITE (priv->cursor_sprite),
|
||||||
(MetaCursorPrepareFunc) cursor_sprite_prepare_at,
|
(MetaCursorPrepareFunc) cursor_sprite_prepare_at,
|
||||||
cursor_surface);
|
cursor_surface);
|
||||||
|
@ -385,6 +385,8 @@ meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
|
|||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterInputDeviceTool *device_tool)
|
ClutterInputDeviceTool *device_tool)
|
||||||
{
|
{
|
||||||
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
MetaWaylandTabletTool *tool;
|
MetaWaylandTabletTool *tool;
|
||||||
|
|
||||||
tool = g_new0 (MetaWaylandTabletTool, 1);
|
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->focus_surface_destroy_listener.notify = tablet_tool_handle_focus_surface_destroy;
|
||||||
tool->cursor_surface_destroy_listener.notify = tablet_tool_handle_cursor_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),
|
meta_cursor_sprite_set_prepare_func (META_CURSOR_SPRITE (tool->default_sprite),
|
||||||
(MetaCursorPrepareFunc) tool_cursor_prepare_at,
|
(MetaCursorPrepareFunc) tool_cursor_prepare_at,
|
||||||
tool);
|
tool);
|
||||||
|
Loading…
Reference in New Issue
Block a user