[mutter] cursor: Correct switching between fallback and backend cursors



commit 3a0de6a4f1c5e7231bcce73dd8f4fd6b1fee4d37
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat May 17 11:22:05 2014 -0400

    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 +-
 src/backends/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 eb6d557..21f1a46 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 ec5d4e8..b2afe3b 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 873be30..883ddef 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]