From d2ab714567671ab6c006bbdac59952e51f279425 Mon Sep 17 00:00:00 2001 From: Sorokin Alexei Date: Sat, 18 Jun 2016 16:22:40 +0300 Subject: fix clear background --- savers/gs-theme-engine.c | 23 +++++++++-------- src/gs-window-x11.c | 67 ++++++++++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/savers/gs-theme-engine.c b/savers/gs-theme-engine.c index 4d6d441..c864df6 100644 --- a/savers/gs-theme-engine.c +++ b/savers/gs-theme-engine.c @@ -111,12 +111,14 @@ static void gs_theme_engine_clear (GtkWidget *widget) { #if GTK_CHECK_VERSION (3, 0, 0) - GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 }; + GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 }; + GtkStateFlags state; #else GdkColor color = { 0, 0x0000, 0x0000, 0x0000 }; - GdkColormap *colormap; -#endif + GdkColormap *colormap; + GtkStyle *style; GtkStateType state; +#endif g_return_if_fail (GS_IS_THEME_ENGINE (widget)); @@ -125,20 +127,19 @@ gs_theme_engine_clear (GtkWidget *widget) return; } - state = (GtkStateType) 0; - while (state < (GtkStateType) G_N_ELEMENTS (gtk_widget_get_style (widget)->bg)) - { #if GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_override_background_color (widget, state, &color); + state = gtk_widget_get_state_flags (widget); + gtk_widget_override_background_color (widget, state, &color); + gdk_window_set_background_rgba (gtk_widget_get_window (widget), &color); #else + style = gtk_widget_get_style (widget); + state = (GtkStateType) 0; + while (state < (GtkStateType) G_N_ELEMENTS (style->bg)) + { gtk_widget_modify_bg (widget, state, &color); -#endif state++; } -#if GTK_CHECK_VERSION (3, 0, 0) - gdk_window_set_background_rgba (gtk_widget_get_window (widget), &color); -#else colormap = gdk_drawable_get_colormap (gtk_widget_get_window (widget)); gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE); gdk_window_set_background (gtk_widget_get_window (widget), &color); diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c index b374715..8199786 100644 --- a/src/gs-window-x11.c +++ b/src/gs-window-x11.c @@ -212,34 +212,6 @@ gs_window_override_user_time (GSWindow *window) gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)), ev_time); } -#if !GTK_CHECK_VERSION (3, 0, 0) -static void -force_no_pixmap_background (GtkWidget *widget) -{ - static gboolean first_time = TRUE; - - if (first_time) - { - gtk_rc_parse_string ("\n" - " style \"gs-theme-engine-style\"\n" - " {\n" - " bg_pixmap[NORMAL] = \"\"\n" - " bg_pixmap[INSENSITIVE] = \"\"\n" - " bg_pixmap[ACTIVE] = \"\"\n" - " bg_pixmap[PRELIGHT] = \"\"\n" - " bg[NORMAL] = { 0.0, 0.0, 0.0 }\n" - " bg[INSENSITIVE] = { 0.0, 0.0, 0.0 }\n" - " bg[ACTIVE] = { 0.0, 0.0, 0.0 }\n" - " bg[PRELIGHT] = { 0.0, 0.0, 0.0 }\n" - " }\n" - " widget \"gs-window-drawing-area*\" style : highest \"gs-theme-engine-style\"\n" - "\n"); - first_time = FALSE; - } - - gtk_widget_set_name (widget, "gs-window-drawing-area"); -} - static void clear_children (Window window) { @@ -298,7 +270,6 @@ widget_clear_all_children (GtkWidget *widget) gdk_error_trap_pop (); #endif } -#endif #if GTK_CHECK_VERSION (3, 0, 0) static void @@ -311,6 +282,33 @@ gs_window_reset_background_surface (GSWindow *window) cairo_pattern_destroy (pattern); gtk_widget_queue_draw (GTK_WIDGET (window)); } +#else +static void +force_no_pixmap_background (GtkWidget *widget) +{ + static gboolean first_time = TRUE; + + if (first_time) + { + gtk_rc_parse_string ("\n" + " style \"gs-theme-engine-style\"\n" + " {\n" + " bg_pixmap[NORMAL] = \"\"\n" + " bg_pixmap[INSENSITIVE] = \"\"\n" + " bg_pixmap[ACTIVE] = \"\"\n" + " bg_pixmap[PRELIGHT] = \"\"\n" + " bg[NORMAL] = { 0.0, 0.0, 0.0 }\n" + " bg[INSENSITIVE] = { 0.0, 0.0, 0.0 }\n" + " bg[ACTIVE] = { 0.0, 0.0, 0.0 }\n" + " bg[PRELIGHT] = { 0.0, 0.0, 0.0 }\n" + " }\n" + " widget \"gs-window-drawing-area*\" style : highest \"gs-theme-engine-style\"\n" + "\n"); + first_time = FALSE; + } + + gtk_widget_set_name (widget, "gs-window-drawing-area"); +} #endif void @@ -420,7 +418,8 @@ static void clear_widget (GtkWidget *widget) { #if GTK_CHECK_VERSION (3, 0, 0) - GdkRGBA rgba = { 0.0, 0.0, 0.0, 1.0 }; + GdkRGBA rgba = { 0.0, 0.0, 0.0, 1.0 }; + GtkStateFlags state; #else GdkColormap *colormap; GdkColor color = { 0, 0x0000, 0x0000, 0x0000 }; @@ -436,10 +435,12 @@ clear_widget (GtkWidget *widget) gs_debug ("Clearing widget"); - gtk_widget_override_background_color (widget, GTK_STATE_FLAG_NORMAL, &rgba); + state = gtk_widget_get_state_flags (widget); + gtk_widget_override_background_color (widget, state, &rgba); + gdk_window_set_background_rgba (gtk_widget_get_window (widget), &rgba); gtk_widget_queue_draw (GTK_WIDGET (widget)); #else - if (! gtk_widget_get_visible (widget)) + if (!gtk_widget_get_visible (widget)) { return; } @@ -476,12 +477,12 @@ clear_widget (GtkWidget *widget) g_object_unref (style); gdk_window_clear (gtk_widget_get_window (widget)); +#endif /* If a screensaver theme adds child windows we need to clear them too */ widget_clear_all_children (widget); gdk_flush (); -#endif } void -- cgit v1.2.1