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:
@ -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),
|
||||
|
Reference in New Issue
Block a user