[Xfce4-commits] <xfce4-panel:devel> Don't flicker panel on startup.

Nick Schermer nick at xfce.org
Tue Aug 11 20:32:20 CEST 2009


Updating branch refs/heads/devel
         to af6d3e02b1614ce8b14a27a51e966fd1c7489663 (commit)
       from 1ed8230901516e5a120d3873c33e7a9c780ae72e (commit)

commit af6d3e02b1614ce8b14a27a51e966fd1c7489663
Author: Nick Schermer <nick at xfce.org>
Date:   Mon May 18 21:36:37 2009 +0200

    Don't flicker panel on startup.

 panel/panel-application.c |   14 +++++++-------
 panel/panel-application.h |    2 +-
 panel/panel-window.c      |   35 +++++++++++++++++++++--------------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/panel/panel-application.c b/panel/panel-application.c
index daa234c..15f6260 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -195,10 +195,7 @@ panel_application_init (PanelApplication *application)
 
   /* create empty window */
   if (G_UNLIKELY (application->windows == NULL))
-    {
-      window = panel_application_new_window (application, NULL, TRUE);
-      gtk_widget_show (GTK_WIDGET (window));
-    }
+    window = panel_application_new_window (application, NULL, TRUE);
 }
 
 
@@ -338,7 +335,7 @@ panel_application_load (PanelApplication *application)
         }
 
       /* show the window */
-      gtk_widget_show (GTK_WIDGET (window));
+      //gtk_widget_show (GTK_WIDGET (window));
     }
 }
 
@@ -1109,7 +1106,7 @@ panel_application_add_new_item (PanelApplication  *application,
 PanelWindow *
 panel_application_new_window (PanelApplication *application,
                               GdkScreen        *screen,
-                              gboolean          reset_properties)
+                              gboolean          new_window)
 {
   GtkWidget *window;
   GtkWidget *itembar;
@@ -1136,12 +1133,15 @@ panel_application_new_window (PanelApplication *application,
   application->windows = g_slist_append (application->windows, window);
 
   /* flush the window properties */
-  if (reset_properties)
+  if (new_window)
     {
       /* remove the xfconf properties */
       property = g_strdup_printf ("/panels/panel-%d", g_slist_index (application->windows, window));
       xfconf_channel_reset_property (application->xfconf, property, TRUE);
       g_free (property);
+
+      /* set default position */
+      g_object_set (G_OBJECT (window), "position", "p=0;x=100;y=100", NULL);
     }
 
   /* add the itembar */
diff --git a/panel/panel-application.h b/panel/panel-application.h
index 59cbef6..ae64642 100644
--- a/panel/panel-application.h
+++ b/panel/panel-application.h
@@ -57,7 +57,7 @@ void              panel_application_add_new_item      (PanelApplication  *applic
 
 PanelWindow      *panel_application_new_window        (PanelApplication  *application,
                                                        GdkScreen         *screen,
-                                                       gboolean           reset_properties);
+                                                       gboolean           new_window);
 
 guint             panel_application_get_n_windows     (PanelApplication  *application);
 
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 579e89b..09aaedf 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -367,8 +367,8 @@ panel_window_init (PanelWindow *window)
   window->autohide_timeout_id = 0;
   window->autohide_block = 0;
 
-  window->base_x = 100;
-  window->base_y = 100;
+  window->base_x = -1;
+  window->base_y = -1;
 
   window->grab_time = 0;
   window->grab_x = 0;
@@ -466,12 +466,14 @@ panel_window_set_property (GObject      *object,
 
         /* send the new orientation to the panel plugins */
         itembar = gtk_bin_get_child (GTK_BIN (window));
-        gtk_container_foreach (GTK_CONTAINER (itembar),
-            panel_window_set_plugin_orientation, window);
+        if (G_LIKELY (itembar != NULL))
+          gtk_container_foreach (GTK_CONTAINER (itembar),
+              panel_window_set_plugin_orientation, window);
 
         /* send the new screen position */
-        gtk_container_foreach (GTK_CONTAINER (itembar),
-            panel_window_set_plugin_screen_position, window);
+        if (G_LIKELY (itembar != NULL))
+          gtk_container_foreach (GTK_CONTAINER (itembar),
+              panel_window_set_plugin_screen_position, window);
         break;
 
       case PROP_SIZE:
@@ -484,8 +486,9 @@ panel_window_set_property (GObject      *object,
 
         /* send the new size to the panel plugins */
         itembar = gtk_bin_get_child (GTK_BIN (window));
-        gtk_container_foreach (GTK_CONTAINER (itembar),
-            panel_window_set_plugin_size, window);
+        if (G_LIKELY (itembar != NULL))
+          gtk_container_foreach (GTK_CONTAINER (itembar),
+              panel_window_set_plugin_size, window);
         break;
 
       case PROP_LENGTH:
@@ -544,8 +547,9 @@ panel_window_set_property (GObject      *object,
 
             /* send the new screen position to the panel plugins */
             itembar = gtk_bin_get_child (GTK_BIN (window));
-            gtk_container_foreach (GTK_CONTAINER (itembar),
-                panel_window_set_plugin_screen_position, window);
+            if (G_LIKELY (itembar != NULL))
+              gtk_container_foreach (GTK_CONTAINER (itembar),
+                  panel_window_set_plugin_screen_position, window);
           }
         else
           {
@@ -1475,6 +1479,10 @@ panel_window_screen_layout_changed (GdkScreen   *screen,
   panel_return_if_fail (GDK_IS_SCREEN (screen));
   panel_return_if_fail (window->screen == screen);
 
+  /* leave when the screen position if not set */
+  if (window->base_x == -1 && window->base_y == -1)
+    return;
+
   /* update the struts edge of this window and check if we need to force
    * a struts update (ie. remove struts that are currently set) */
   struts_edge = panel_window_screen_struts_edge (window);
@@ -1553,10 +1561,6 @@ panel_window_screen_layout_changed (GdkScreen   *screen,
                 gtk_widget_hide (GTK_WIDGET (window));
               return;
             }
-          else if (!GTK_WIDGET_VISIBLE (window))
-            {
-              gtk_widget_show (GTK_WIDGET (window));
-            }
         }
 
       /* don't do the check if we're not setting struts anyways */
@@ -1612,6 +1616,9 @@ done:
   /* update the struts if needed, ie. we need to reset the struts */
   if (force_struts_update)
     panel_window_screen_struts_set (window);
+
+  if (!GTK_WIDGET_VISIBLE (window))
+    gtk_widget_show (GTK_WIDGET (window));
 }
 
 



More information about the Xfce4-commits mailing list