[evince] libview: Save/restore context when getting colors for a different state



commit 1987f04ea36329b1bd61d053a19d9e341e0454ce
Author: Sebastian Keller <sebastian-keller gmx de>
Date:   Tue Sep 22 23:25:34 2015 +0200

    libview: Save/restore context when getting colors for a different state
    
    Getting colors for a state different from the current state of the
    corresponding widget without saving the context might trigger an
    invalidation and a redraw. Because this was happening from the draw
    function this resulted in a redraw loop and constant high CPU usage.
    
    This could be triggered by selecting text or searching.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755442

 libview/ev-view.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 6f2876d..11c69c7 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -4272,7 +4272,9 @@ get_cursor_color (GtkStyleContext *context,
 
                gdk_color_free (style_color);
        } else {
+               gtk_style_context_save (context);
                gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, color);
+               gtk_style_context_restore (context);
        }
 }
 
@@ -6511,7 +6513,9 @@ draw_rubberband (EvView             *view,
        GdkRGBA          color;
 
        context = gtk_widget_get_style_context (GTK_WIDGET (view));
+       gtk_style_context_save (context);
        gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color);
+       gtk_style_context_restore (context);
         cairo_save (cr);
 
        cairo_set_source_rgba (cr, color.red, color.green, color.blue, alpha);
@@ -6632,12 +6636,15 @@ _ev_view_get_selection_colors (EvView  *view,
 
        state = gtk_widget_has_focus (widget) ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_ACTIVE;
        context = gtk_widget_get_style_context (widget);
+       gtk_style_context_save (context);
 
        if (bg_color)
                gtk_style_context_get_background_color (context, state, bg_color);
 
        if (fg_color)
                gtk_style_context_get_color (context, state, fg_color);
+
+       gtk_style_context_restore (context);
 }
 
 static void


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