[mutter] cursor-renderer: Add a cursor painted signal
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-renderer: Add a cursor painted signal
- Date: Wed, 31 Aug 2016 18:15:00 +0000 (UTC)
commit 2c1d3e5b7020beeb83419d9c799d7bb6734f9f07
Author: Rui Matos <tiagomatos gmail com>
Date: Sun Jan 10 17:28:54 2016 +0100
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
src/backends/meta-cursor-renderer.c | 45 +++++++++++++++++++++
src/backends/meta-cursor-renderer.h | 3 +
src/backends/native/meta-cursor-renderer-native.c | 5 ++
3 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index da3f99a..d27922d 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
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
index b6024dd..73f6dfc 100644
--- a/src/backends/meta-cursor-renderer.h
+++ b/src/backends/meta-cursor-renderer.h
@@ -78,4 +78,7 @@ void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *rende
MetaCursorSprite *cursor_sprite,
XcursorImage *xc_image);
+void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
+ MetaCursorSprite *cursor_sprite);
+
#endif /* META_CURSOR_RENDERER_H */
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index 9219441..2105d61 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -216,6 +216,7 @@ update_hw_cursor (MetaCursorRendererNative *native,
MetaCRTC *crtcs;
unsigned int i, n_crtcs;
MetaRectangle rect;
+ gboolean painted = FALSE;
monitors = meta_monitor_manager_get ();
meta_monitor_manager_get_resources (monitors, NULL, NULL, &crtcs, &n_crtcs, NULL, NULL);
@@ -247,8 +248,12 @@ update_hw_cursor (MetaCursorRendererNative *native,
drmModeMoveCursor (priv->drm_fd, crtcs[i].crtc_id,
rect.x - crtc_rect->x,
rect.y - crtc_rect->y);
+ painted = TRUE;
}
}
+
+ if (painted)
+ meta_cursor_renderer_emit_painted (renderer, cursor_sprite);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]