Blob Blame History Raw
From 76f532a0fa5e389f95380152b656ebf0f0672b5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann?= <ssp@redhat.com>
Date: Mon, 16 Dec 2013 16:10:15 -0500
Subject: [PATCH] load-graph.cpp: Draw the background explicitly

The gdk_window_set_background_pattern() function is a little dubious
to use unless you are writing GTK+ code since the background may be
overridden by gtkwidget.c whenever the style of the widget changes.

So instead of relying on this function, just paint the cached pattern
on every expose.

This fixes

     https://bugzilla.redhat.com/show_bug.cgi?id=1015507

in which the background grid would disappear when the
gnome-system-monitor window was unfocused, then focused.
---
 src/load-graph.cpp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index 8d9b86b..5a4666c 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -228,13 +228,6 @@ load_graph_draw (GtkWidget *widget,
 
     window = gtk_widget_get_window (graph->disp);
 
-    if (graph->background == NULL) {
-        draw_background(graph);
-        cairo_pattern_t * pattern = cairo_pattern_create_for_surface (graph->background);
-        gdk_window_set_background_pattern (window, pattern);
-        cairo_pattern_destroy (pattern);
-    }
-
     /* Number of pixels wide for one graph point */
     sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
     /* General offset */
@@ -248,6 +241,15 @@ load_graph_draw (GtkWidget *widget,
 
     cr = gdk_cairo_create (window);
 
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+
+    cairo_pattern_t * pattern = cairo_pattern_create_for_surface (graph->background);
+    cairo_set_source (cr, pattern);
+    cairo_paint (cr);
+    cairo_pattern_destroy (pattern);
+
     cairo_set_line_width (cr, 1);
     cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
     cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
-- 
1.8.3.1