[gnome-flashback] desktop-background: use desktop window only when needed
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] desktop-background: use desktop window only when needed
- Date: Wed, 27 Apr 2016 14:23:51 +0000 (UTC)
commit 9d1d6846626984aa8a5583cb88f403af7f9410d0
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Apr 26 23:03:44 2016 +0300
desktop-background: use desktop window only when needed
.../libdesktop-background/gf-background-window.c | 18 +-------
.../libdesktop-background/gf-desktop-background.c | 40 ++++++++++----------
2 files changed, 23 insertions(+), 35 deletions(-)
---
diff --git a/gnome-flashback/libdesktop-background/gf-background-window.c
b/gnome-flashback/libdesktop-background/gf-background-window.c
index 24e2422..aff19dc 100644
--- a/gnome-flashback/libdesktop-background/gf-background-window.c
+++ b/gnome-flashback/libdesktop-background/gf-background-window.c
@@ -316,17 +316,12 @@ set_no_input_and_no_focus (GdkWindow *window)
}
static void
-gf_background_window_screen_changed (GdkScreen *screen,
- gpointer user_data)
+set_size_request (GdkScreen *screen,
+ GtkWidget *widget)
{
- GfBackgroundWindow *window;
- GtkWidget *widget;
gint width;
gint height;
- window = GF_BACKGROUND_WINDOW (user_data);
- widget = GTK_WIDGET (window);
-
width = gdk_screen_get_width (screen);
height = gdk_screen_get_height (screen);
@@ -421,14 +416,7 @@ gf_background_window_init (GfBackgroundWindow *window)
gtk_window = GTK_WINDOW (window);
gtk_widget = GTK_WIDGET (window);
- g_signal_connect_object (screen, "monitors-changed",
- G_CALLBACK (gf_background_window_screen_changed),
- window, G_CONNECT_AFTER);
- g_signal_connect_object (screen, "size-changed",
- G_CALLBACK (gf_background_window_screen_changed),
- window, G_CONNECT_AFTER);
-
- gf_background_window_screen_changed (screen, window);
+ set_size_request (screen, gtk_widget);
gtk_window_set_keep_below (gtk_window, TRUE);
gtk_widget_add_events (gtk_widget, GDK_STRUCTURE_MASK);
gtk_widget_realize (gtk_widget);
diff --git a/gnome-flashback/libdesktop-background/gf-desktop-background.c
b/gnome-flashback/libdesktop-background/gf-desktop-background.c
index 068a262..a75d7ca 100644
--- a/gnome-flashback/libdesktop-background/gf-desktop-background.c
+++ b/gnome-flashback/libdesktop-background/gf-desktop-background.c
@@ -167,6 +167,9 @@ on_fade_finished (GnomeBGCrossfade *fade,
if (background->surface != NULL)
gnome_bg_set_surface_as_root (screen, background->surface);
+
+ gtk_widget_destroy (background->background);
+ background->background = NULL;
}
static gboolean
@@ -215,6 +218,9 @@ background_set_up (GfDesktopBackground *background)
cairo_pattern_destroy (pattern);
gnome_bg_set_surface_as_root (screen, background->surface);
+
+ gtk_widget_destroy (background->background);
+ background->background = NULL;
}
}
@@ -225,11 +231,15 @@ background_changed_cb (gpointer user_data)
background = GF_DESKTOP_BACKGROUND (user_data);
+ g_assert (background->background == NULL);
+ background->background = gf_background_window_new ();
+
+ init_fade (background);
background_unrealize (background);
background_set_up (background);
- gtk_widget_show (background->background);
- gtk_widget_queue_draw (background->background);
+ if (background->background)
+ gtk_widget_show (background->background);
background->change_idle_id = 0;
return G_SOURCE_REMOVE;
@@ -245,26 +255,16 @@ queue_background_change (GfDesktopBackground *background)
}
static void
-desktop_background_changed (GnomeBG *bg,
- gpointer user_data)
+changed_cb (GnomeBG *bg,
+ GfDesktopBackground *background)
{
- GfDesktopBackground *background;
-
- background = GF_DESKTOP_BACKGROUND (user_data);
-
- init_fade (background);
queue_background_change (background);
}
static void
-desktop_background_transitioned (GnomeBG *bg,
- gpointer user_data)
+transitioned_cb (GnomeBG *bg,
+ GfDesktopBackground *background)
{
- GfDesktopBackground *background;
-
- background = GF_DESKTOP_BACKGROUND (user_data);
-
- init_fade (background);
queue_background_change (background);
}
@@ -315,7 +315,8 @@ gf_desktop_background_finalize (GObject *object)
free_surface (background);
free_fade (background);
- gtk_widget_destroy (background->background);
+ if (background->background != NULL)
+ gtk_widget_destroy (background->background);
G_OBJECT_CLASS (gf_desktop_background_parent_class)->finalize (object);
}
@@ -340,13 +341,12 @@ gf_desktop_background_init (GfDesktopBackground *background)
background->bg = gnome_bg_new ();
background->gnome_settings = g_settings_new (DESKTOP_BG);
background->background_settings = g_settings_new (GNOME_FLASHBACK_BG);
- background->background = gf_background_window_new ();
g_signal_connect (background->bg, "changed",
- G_CALLBACK (desktop_background_changed), background);
+ G_CALLBACK (changed_cb), background);
g_signal_connect (background->bg, "transitioned",
- G_CALLBACK (desktop_background_transitioned), background);
+ G_CALLBACK (transitioned_cb), background);
background->change_event_id =
g_signal_connect (background->gnome_settings, "change-event",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]