summaryrefslogtreecommitdiff
path: root/src/backends/meta-cursor-renderer.c
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2016-01-10 17:28:54 +0100
committerRui Matos <tiagomatos@gmail.com>2016-08-31 20:10:14 +0200
commit2c1d3e5b7020beeb83419d9c799d7bb6734f9f07 (patch)
tree608d7db36b84babd8a729030c834f5c75f5dccb7 /src/backends/meta-cursor-renderer.c
parent262e184fe7e9f3d41149ffc4d34424371d0c0102 (diff)
downloadmutter-2c1d3e5b7020beeb83419d9c799d7bb6734f9f07.tar.gz
cursor-renderer: Add a cursor painted signal
This signal allows interested parties to be notified of a new cursor frame being painted regardless of whether it's being painted by the backend directly or if it's a software rendered cursor frame handled by clutter. https://bugzilla.gnome.org/show_bug.cgi?id=749913
Diffstat (limited to 'src/backends/meta-cursor-renderer.c')
-rw-r--r--src/backends/meta-cursor-renderer.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index da3f99a0b..d27922dd4 100644
--- a/src/backends/meta-cursor-renderer.c
+++ b/src/backends/meta-cursor-renderer.c
@@ -42,11 +42,25 @@ struct _MetaCursorRendererPrivate
MetaCursorSprite *displayed_cursor;
MetaOverlay *stage_overlay;
gboolean handled_by_backend;
+ guint post_paint_func_id;
};
typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate;
+enum {
+ CURSOR_PAINTED,
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL];
+
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRenderer, meta_cursor_renderer, G_TYPE_OBJECT);
+void
+meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
+ MetaCursorSprite *cursor_sprite)
+{
+ g_signal_emit (renderer, signals[CURSOR_PAINTED], 0, cursor_sprite);
+}
+
static void
queue_redraw (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
@@ -77,6 +91,19 @@ queue_redraw (MetaCursorRenderer *renderer,
}
static gboolean
+meta_cursor_renderer_post_paint (gpointer data)
+{
+ MetaCursorRenderer *renderer = META_CURSOR_RENDERER (data);
+ MetaCursorRendererPrivate *priv =
+ meta_cursor_renderer_get_instance_private (renderer);
+
+ if (priv->displayed_cursor && !priv->handled_by_backend)
+ meta_cursor_renderer_emit_painted (renderer, priv->displayed_cursor);
+
+ return TRUE;
+}
+
+static gboolean
meta_cursor_renderer_real_update_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
@@ -97,6 +124,8 @@ meta_cursor_renderer_finalize (GObject *object)
if (priv->stage_overlay)
meta_stage_remove_cursor_overlay (META_STAGE (stage), priv->stage_overlay);
+ clutter_threads_remove_repaint_func (priv->post_paint_func_id);
+
G_OBJECT_CLASS (meta_cursor_renderer_parent_class)->finalize (object);
}
@@ -107,11 +136,27 @@ meta_cursor_renderer_class_init (MetaCursorRendererClass *klass)
object_class->finalize = meta_cursor_renderer_finalize;
klass->update_cursor = meta_cursor_renderer_real_update_cursor;
+
+ signals[CURSOR_PAINTED] = g_signal_new ("cursor-painted",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
}
static void
meta_cursor_renderer_init (MetaCursorRenderer *renderer)
{
+ MetaCursorRendererPrivate *priv =
+ meta_cursor_renderer_get_instance_private (renderer);
+
+ priv->post_paint_func_id =
+ clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT,
+ meta_cursor_renderer_post_paint,
+ renderer,
+ NULL);
}
MetaRectangle