[Xfce4-commits] <thunar:nick/1.8> Patiently wait for screen to realize on startup.

Nick Schermer noreply at xfce.org
Sat Sep 21 13:12:03 CEST 2013


Updating branch refs/heads/nick/1.8
         to 65530142f3d933613321c560f0ec0cb1732d2d65 (commit)
       from 93a7a18fb43536d04e818e91730e3d428e39265d (commit)

commit 65530142f3d933613321c560f0ec0cb1732d2d65
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Sep 21 13:10:16 2013 +0200

    Patiently wait for screen to realize on startup.
    
    No background was drawn during login because thunar
    was too hard trying to update the yet-to-be-initialized
    screens. Esp on multi screen desktops this was a problem.

 thunar/thunar-desktop-window.c |   45 +++++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/thunar/thunar-desktop-window.c b/thunar/thunar-desktop-window.c
index c3b8f50..384613e 100644
--- a/thunar/thunar-desktop-window.c
+++ b/thunar/thunar-desktop-window.c
@@ -62,6 +62,8 @@ struct _ThunarDesktopWindow
   GtkWindow __parent__;
 
   ThunarDesktopBackground *background;
+
+  guint                    screen_changed_idle_id;
 };
 
 
@@ -115,14 +117,11 @@ thunar_desktop_window_size_request (GtkWidget      *widget,
 
 
 
-static void
-thunar_desktop_window_screen_changed (GdkScreen           *screen,
-                                      ThunarDesktopWindow *window)
+static gboolean
+thunar_desktop_window_screen_changed_idle (gpointer data)
 {
-  GdkWindow *gdk_window;
-
-  _thunar_return_if_fail (GDK_IS_SCREEN (screen));
-  _thunar_return_if_fail (THUNAR_DESKTOP_WINDOW (window));
+  ThunarDesktopWindow *window = THUNAR_DESKTOP_WINDOW (data);
+  GdkWindow           *gdk_window;
 
   /* release background */
   if (window->background != NULL)
@@ -134,6 +133,34 @@ thunar_desktop_window_screen_changed (GdkScreen           *screen,
   /* allocate bg and set it on the window */
   gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
   window->background = thunar_desktop_background_new (gdk_window);
+
+  return FALSE;
+}
+
+
+
+static void
+thunar_desktop_window_screen_changed_idle_destoyed (gpointer data)
+{
+  THUNAR_DESKTOP_WINDOW (data)->screen_changed_idle_id = 0;
+}
+
+
+
+static void
+thunar_desktop_window_screen_changed (GdkScreen           *screen,
+                                      ThunarDesktopWindow *window)
+{
+  _thunar_return_if_fail (GDK_IS_SCREEN (screen));
+  _thunar_return_if_fail (THUNAR_DESKTOP_WINDOW (window));
+
+  if (window->screen_changed_idle_id == 0)
+    {
+      /* avoid multiple calls of screen changed during session startup */
+      window->screen_changed_idle_id =
+          g_idle_add_full (G_PRIORITY_LOW, thunar_desktop_window_screen_changed_idle,
+                           window, thunar_desktop_window_screen_changed_idle_destoyed);
+    }
 }
 
 
@@ -180,6 +207,10 @@ thunar_desktop_window_unrealize (GtkWidget *widget)
   GdkScreen           *screen;
   GdkWindow           *root;
 
+  /* no more new backgrounds */
+  if (window->screen_changed_idle_id != 0)
+    g_source_remove (window->screen_changed_idle_id);
+
   /* drop background */
   if (window->background != NULL)
     {


More information about the Xfce4-commits mailing list