From 3a0de6a4f1c5e7231bcce73dd8f4fd6b1fee4d37 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 17 May 2014 11:22:05 -0400 Subject: [PATCH] cursor: Correct switching between fallback and backend cursors When switching from the stage cursor to the native cursor, we forgot to repaint the stage to get rid of the old cursor. Fix this by having the abstract cursor renderer class track whether we're using the backend, rather than doing chain-up shenanigans. --- src/backends/meta-cursor-renderer.c | 27 ++++++++++++++----- src/backends/meta-cursor-renderer.h | 2 +- .../native/meta-cursor-renderer-native.c | 7 ++--- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index eb6d5579d..21f1a463e 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -41,6 +41,7 @@ struct _MetaCursorRendererPrivate MetaRectangle current_rect; MetaCursorReference *displayed_cursor; + gboolean handled_by_backend; }; typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate; @@ -57,15 +58,16 @@ queue_redraw (MetaCursorRenderer *renderer) if (!stage) return; - meta_stage_set_cursor (META_STAGE (stage), - priv->displayed_cursor, - &priv->current_rect); + if (priv->handled_by_backend) + meta_stage_set_cursor (META_STAGE (stage), NULL, &priv->current_rect); + else + meta_stage_set_cursor (META_STAGE (stage), priv->displayed_cursor, &priv->current_rect); } -static void +static gboolean meta_cursor_renderer_real_update_cursor (MetaCursorRenderer *renderer) { - queue_redraw (renderer); + return FALSE; } static void @@ -83,6 +85,8 @@ static void update_cursor (MetaCursorRenderer *renderer) { MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer); + gboolean handled_by_backend; + gboolean should_redraw = FALSE; if (priv->displayed_cursor) { @@ -104,7 +108,18 @@ update_cursor (MetaCursorRenderer *renderer) priv->current_rect.height = 0; } - META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer); + handled_by_backend = META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer); + if (handled_by_backend != priv->handled_by_backend) + { + priv->handled_by_backend = handled_by_backend; + should_redraw = TRUE; + } + + if (!handled_by_backend) + should_redraw = TRUE; + + if (should_redraw) + queue_redraw (renderer); } MetaCursorRenderer * diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h index ec5d4e846..b2afe3b02 100644 --- a/src/backends/meta-cursor-renderer.h +++ b/src/backends/meta-cursor-renderer.h @@ -51,7 +51,7 @@ struct _MetaCursorRendererClass { GObjectClass parent_class; - void (* update_cursor) (MetaCursorRenderer *renderer); + gboolean (* update_cursor) (MetaCursorRenderer *renderer); }; GType meta_cursor_renderer_get_type (void) G_GNUC_CONST; diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index 873be3068..883ddef4d 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -140,7 +140,7 @@ should_have_hw_cursor (MetaCursorRenderer *renderer) return FALSE; } -static void +static gboolean meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer) { MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer); @@ -148,10 +148,7 @@ meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer) priv->has_hw_cursor = should_have_hw_cursor (renderer); update_hw_cursor (native, FALSE); - - /* Fall back to the stage-based cursor if we don't have HW cursors. */ - if (!priv->has_hw_cursor) - META_CURSOR_RENDERER_CLASS (meta_cursor_renderer_native_parent_class)->update_cursor (renderer); + return priv->has_hw_cursor; } static void