[gnome-system-monitor] load-graph.cpp: Draw the background explicitly (bgo #720560)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] load-graph.cpp: Draw the background explicitly (bgo #720560)
- Date: Fri, 20 Dec 2013 23:54:37 +0000 (UTC)
commit af2fb1c682acb75468aaf7b3ee602291b49b9b5a
Author: Søren Sandmann <ssp redhat com>
Date: Sat Dec 21 01:53:09 2013 +0200
load-graph.cpp: Draw the background explicitly (bgo #720560)
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.
v2: Instead of caching a surface and creating a pattern for that
surface on each expose, keep the pattern in the cache
instead. (Requested by Robert Roth in
https://bugzilla.gnome.org/show_bug.cgi?id=720560).
src/load-graph.cpp | 14 +++++++-------
src/load-graph.h | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index 3a072fe..578766f 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -19,7 +19,7 @@
void LoadGraph::clear_background()
{
if (background) {
- cairo_surface_destroy (background);
+ cairo_pattern_destroy (background);
background = NULL;
}
}
@@ -62,6 +62,7 @@ void draw_background(LoadGraph *graph) {
PangoLayout* layout;
PangoFontDescription* font_desc;
PangoRectangle extents;
+ cairo_surface_t *surface;
GdkRGBA fg;
num_bars = graph->num_bars();
@@ -71,11 +72,11 @@ void draw_background(LoadGraph *graph) {
graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
gtk_widget_get_allocation (graph->disp, &allocation);
- graph->background = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp),
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp),
CAIRO_CONTENT_COLOR_ALPHA,
allocation.width,
allocation.height);
- cr = cairo_create (graph->background);
+ cr = cairo_create (surface);
GtkStyleContext *context = gtk_widget_get_style_context (GsmApplication::get()->stack);
@@ -173,6 +174,8 @@ void draw_background(LoadGraph *graph) {
g_object_unref(layout);
cairo_stroke (cr);
cairo_destroy (cr);
+ graph->background = cairo_pattern_create_for_surface (surface);
+ cairo_surface_destroy (surface);
}
/* Redraws the backing buffer for the load graph and updates the window */
@@ -248,11 +251,8 @@ load_graph_draw (GtkWidget *widget,
if (graph->background == NULL) {
draw_background(graph);
}
-
- cairo_pattern_t * pattern = cairo_pattern_create_for_surface (graph->background);
- cairo_set_source (cr, pattern);
+ cairo_set_source (cr, graph->background);
cairo_paint (cr);
- cairo_pattern_destroy (pattern);
cairo_set_line_width (cr, 1);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
diff --git a/src/load-graph.h b/src/load-graph.h
index 7d09f33..8674daf 100644
--- a/src/load-graph.h
+++ b/src/load-graph.h
@@ -64,7 +64,7 @@ struct LoadGraph
GtkWidget *main_widget;
GtkWidget *disp;
- cairo_surface_t *background;
+ cairo_pattern_t *background;
guint timer_index;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]