From 4bb14f5ff09c47f37a17b8b128c691878b8b1c4c Mon Sep 17 00:00:00 2001
From: raveit65 <mate@raveit.de>
Date: Fri, 9 Mar 2018 16:14:26 +0100
Subject: 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

inspired by:
https://git.gnome.org/browse/evince/commit/?id=1987f04
https://github.com/linuxmint/xreader/commit/e76a18d
---
 libdocument/ev-document-misc.c | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'libdocument')

diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index 87364525..40d03400 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -161,9 +161,11 @@ ev_document_misc_paint_one_page (cairo_t      *cr,
 	GtkStateFlags state = gtk_widget_get_state_flags (widget);
         GdkRGBA fg, bg, shade_bg;
 
+        gtk_style_context_save (context);
         gtk_style_context_get_background_color (context, state, &bg);
         gtk_style_context_get_color (context, state, &fg);
         gtk_style_context_get_color (context, state, &shade_bg);
+        gtk_style_context_restore (context);
         shade_bg.alpha *= 0.5;
 
 	gdk_cairo_set_source_rgba (cr, highlight ? &fg : &shade_bg);
-- 
cgit v1.2.1