[gnumeric] GUI: Ant-ing fallback for certain themes.



commit 0c300ea37f2ab6f94a9dbb37a37c5ecb0de589b7
Author: Morten Welinder <terra gnome org>
Date:   Wed Jan 29 11:26:10 2014 -0500

    GUI: Ant-ing fallback for certain themes.

 ChangeLog         |    5 +++++
 src/item-cursor.c |   40 +++++++++++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3727b0f..9d90f10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-29  Morten Welinder  <terra gnome org>
+
+       * src/item-cursor.c (cb_item_cursor_animation): Do a run-time
+       check for bad clipping somewhere in gtk+ or theme land.
+
 2014-01-28  Jean Brefort  <jean brefort normalesup org>
 
        * src/sheet-object-component.c (gnm_soc_user_config): release the new
diff --git a/src/item-cursor.c b/src/item-cursor.c
index 7933222..8f3308f 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -30,6 +30,7 @@
 #include "commands.h"
 #include "ranges.h"
 #include "parse-util.h"
+#include "gutils.h"
 #include "gui-util.h"
 #include "sheet-autofill.h"
 #include <gsf/gsf-impl-utils.h>
@@ -149,19 +150,36 @@ static int
 cb_item_cursor_animation (GnmItemCursor *ic)
 {
        GocItem *item = GOC_ITEM (ic);
+       static int use_fallback = -1;
 
-#if GTK_CHECK_VERSION(3,8,0)
-       GdkWindow *w = gtk_widget_get_window (GTK_WIDGET (item->canvas));
-       cairo_t *cr = gdk_cairo_create (w);
-
-       ic->state = !ic->state;
-       goc_item_draw (item, cr);
-       cairo_destroy (cr);
-#else
-       /* Somehow the above doesn't work.  */
        ic->state = !ic->state;
-       goc_item_invalidate (item);
-#endif
+
+       if (use_fallback != 1) {
+               GdkWindow *w = gtk_widget_get_window (GTK_WIDGET (item->canvas));
+               cairo_t *cr = gdk_cairo_create (w);
+
+               if (use_fallback == -1) {
+                       /*
+                        * Under some themes we get a (0,0,0,0) clip and
+                        * our drawing does nothing.  Detect this and
+                        * fall back to full invalidation.
+                        */
+                       double cx0, cy0, cx1, cy1;
+                       cairo_clip_extents (cr, &cx0, &cy0, &cx1, &cy1);
+                       use_fallback = (cx0 == 0 && cy0 == 0 && cx1 == 0 && cy1 == 0);
+                       if (use_fallback == 1 && gnm_debug_flag ("ant"))
+                               g_printerr ("Using ant-ing fallback\n");
+               }
+
+               if (use_fallback == 0)
+                       goc_item_draw (item, cr);
+
+               cairo_destroy (cr);
+       }
+
+       if (use_fallback == 1)
+               goc_item_invalidate (item);
+
        return TRUE;
 }
 


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