[Xfce4-commits] <xfce4-panel:xfce-4.8> Don't disappear when wm restarts with compositing (bug #7194).

Nick Schermer noreply at xfce.org
Sat Jan 29 21:26:26 CET 2011


Updating branch refs/heads/xfce-4.8
         to 16ca0888abb9e92ed8a38d1e53128da01c712c4f (commit)
       from f76161d04c3d5e70abb3daf0b4295ed6f219da00 (commit)

commit 16ca0888abb9e92ed8a38d1e53128da01c712c4f
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Jan 29 18:18:37 2011 +0100

    Don't disappear when wm restarts with compositing (bug #7194).
    
    Because of a quick widget hide/show to make sure the
    window was redrawn, the window became invisible when quickly
    restarting the wm. Remove this unneeded trick.
    
    Also cleanup the colormap handling, we now only set the rgba
    colormap in the init function, since it depends on the screen
    and won't change during runtime, this makes things a lot easier.

 libxfce4panel/xfce-panel-macros-46.h |    3 -
 panel/panel-base-window.c            |   87 +++++++++++++--------------------
 panel/panel-window.c                 |   24 ---------
 wrapper/wrapper-plug.c               |    4 --
 4 files changed, 34 insertions(+), 84 deletions(-)

diff --git a/libxfce4panel/xfce-panel-macros-46.h b/libxfce4panel/xfce-panel-macros-46.h
index dd28bb9..b18a04e 100644
--- a/libxfce4panel/xfce-panel-macros-46.h
+++ b/libxfce4panel/xfce-panel-macros-46.h
@@ -583,10 +583,7 @@ G_BEGIN_DECLS
     gtk_widget_set_app_paintable (plug, TRUE); \
     \
     screen = gtk_widget_get_screen (plug); \
-    \
     colormap = gdk_screen_get_rgba_colormap (screen); \
-    if (colormap == NULL) \
-      colormap = gdk_screen_get_rgb_colormap (screen); \
     if (colormap != NULL) \
       gtk_widget_set_colormap (plug, colormap); \
     \
diff --git a/panel/panel-base-window.c b/panel/panel-base-window.c
index 8bdb298..751e0c9 100644
--- a/panel/panel-base-window.c
+++ b/panel/panel-base-window.c
@@ -192,6 +192,9 @@ panel_base_window_class_init (PanelBaseWindowClass *klass)
 static void
 panel_base_window_init (PanelBaseWindow *window)
 {
+  GdkColormap *colormap;
+  GdkScreen   *screen;
+
   window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, PANEL_TYPE_BASE_WINDOW, PanelBaseWindowPrivate);
 
   window->is_composited = FALSE;
@@ -210,7 +213,19 @@ panel_base_window_init (PanelBaseWindow *window)
    * the type-hint already takes care of that */
   gtk_window_stick (GTK_WINDOW (window));
 
-  panel_base_window_composited_changed (GTK_WIDGET (window));
+  /* set the rgba colormap if supported by the screen */
+  screen = gtk_window_get_screen (GTK_WINDOW (window));
+  colormap = gdk_screen_get_rgba_colormap (screen);
+  if (colormap != NULL)
+    {
+      gtk_widget_set_colormap (GTK_WIDGET (window), colormap);
+      window->is_composited = gtk_widget_is_composited (GTK_WIDGET (window));
+    }
+
+   panel_debug (PANEL_DEBUG_BASE_WINDOW,
+               "%p: rgba colormap=%s, compositing=%s", window,
+               PANEL_DEBUG_BOOL (colormap != NULL),
+               PANEL_DEBUG_BOOL (window->is_composited));
 }
 
 
@@ -641,50 +656,17 @@ static void
 panel_base_window_composited_changed (GtkWidget *widget)
 {
   PanelBaseWindow *window = PANEL_BASE_WINDOW (widget);
-  GdkColormap     *colormap = NULL;
   gboolean         was_composited = window->is_composited;
-  gboolean         was_visible;
-  GdkScreen       *screen;
-  gboolean         colormap_changed;
-  gboolean         colormap_rgba = FALSE;
-
-  panel_return_if_fail (PANEL_IS_BASE_WINDOW (widget));
-
-  /* get the widget screen */
-  screen = gtk_window_get_screen (GTK_WINDOW (widget));
-  panel_return_if_fail (GDK_IS_SCREEN (screen));
-
-  /* get the rgba colormap */
-  colormap = gdk_screen_get_rgba_colormap (screen);
-  if (G_UNLIKELY (colormap == NULL))
-    {
-      window->is_composited = FALSE;
-      colormap = gdk_screen_get_rgb_colormap (screen);
-    }
-  else
-    {
-      colormap_rgba = TRUE;
-      window->is_composited = gtk_widget_is_composited (widget);
-      gtk_window_set_opacity (GTK_WINDOW (widget), window->priv->leave_opacity);
-    }
+  GdkWindow       *gdkwindow;
 
-  panel_return_if_fail (GDK_IS_COLORMAP (colormap));
-  colormap_changed = gtk_widget_get_colormap (widget) != colormap;
+  /* set new compositing state */
+  window->is_composited = gtk_widget_is_composited (widget);
+  if (window->is_composited)
+    gtk_window_set_opacity (GTK_WINDOW (widget), window->priv->leave_opacity);
 
   panel_debug (PANEL_DEBUG_BASE_WINDOW,
-               "%p: composited=%s, rgba=%s, visible=%s", window,
-               PANEL_DEBUG_BOOL (gtk_widget_is_composited (widget)),
-               PANEL_DEBUG_BOOL (colormap_rgba),
-               PANEL_DEBUG_BOOL (GTK_WIDGET_VISIBLE (widget)));
-
-  was_visible = GTK_WIDGET_VISIBLE (widget);
-  if (was_visible)
-    {
-      gtk_widget_hide (widget);
-
-      if (colormap_changed)
-        gtk_widget_unrealize (widget);
-    }
+               "%p: compositing=%s", window,
+               PANEL_DEBUG_BOOL (window->is_composited));
 
   /* clear cairo image cache */
   if (window->priv->bg_image_cache != NULL)
@@ -693,20 +675,19 @@ panel_base_window_composited_changed (GtkWidget *widget)
       window->priv->bg_image_cache = NULL;
     }
 
-  if (colormap_changed)
-    gtk_widget_set_colormap (widget, colormap);
-
-  if (was_visible)
-    {
-      /* restore the window */
-      if (colormap_changed)
-        gtk_widget_realize (widget);
-      gtk_widget_show (widget);
-    }
-
-  /* emit the property if it changed */
   if (window->is_composited != was_composited)
     g_object_notify (G_OBJECT (widget), "composited");
+
+  /* make sure the entire window is redrawn */
+  gdkwindow = gtk_widget_get_window (widget);
+  if (gdkwindow != NULL)
+    gdk_window_invalidate_rect (gdkwindow, NULL, TRUE);
+
+  /* HACK: invalid the geometry, so the wm notices it */
+  gtk_window_move (GTK_WINDOW (window),
+                   widget->allocation.x,
+                   widget->allocation.y);
+  gtk_widget_queue_resize (widget);
 }
 
 
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 046e2ec..1d5424d 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -117,7 +117,6 @@ static void         panel_window_style_set                  (GtkWidget        *w
 static void         panel_window_realize                    (GtkWidget        *widget);
 static StrutsEgde   panel_window_screen_struts_edge         (PanelWindow      *window);
 static void         panel_window_screen_struts_set          (PanelWindow      *window);
-static void         panel_window_screen_force_update        (PanelWindow      *window);
 static void         panel_window_screen_update_borders      (PanelWindow      *window);
 static SnapPosition panel_window_snap_position              (PanelWindow      *window);
 static void         panel_window_display_layout_debug       (GtkWidget        *widget);
@@ -457,10 +456,6 @@ panel_window_init (PanelWindow *window)
 
   /* set the screen */
   panel_window_screen_changed (GTK_WIDGET (window), NULL);
-
-  /* watch changes in the compositing */
-  g_signal_connect (G_OBJECT (window), "notify::composited",
-      G_CALLBACK (panel_window_screen_force_update), NULL);
 }
 
 
@@ -1577,25 +1572,6 @@ panel_window_screen_struts_set (PanelWindow *window)
 
 
 static void
-panel_window_screen_force_update (PanelWindow *window)
-{
-  panel_return_if_fail (PANEL_IS_WINDOW (window));
-
-  if (GTK_WIDGET_VISIBLE (window))
-    {
-      /* make sure the struts are set again, when enabled */
-      if (window->struts_edge != STRUTS_EDGE_NONE
-          && window->autohide_state == AUTOHIDE_DISABLED)
-        window->struts[0] = -1;
-
-      /* update the panel position */
-      panel_window_screen_layout_changed (window->screen, window);
-    }
-}
-
-
-
-static void
 panel_window_screen_update_borders (PanelWindow *window)
 {
   PanelBorders borders = PANEL_BORDER_NONE;
diff --git a/wrapper/wrapper-plug.c b/wrapper/wrapper-plug.c
index 691c197..99f00c2 100644
--- a/wrapper/wrapper-plug.c
+++ b/wrapper/wrapper-plug.c
@@ -103,11 +103,7 @@ wrapper_plug_init (WrapperPlug *plug)
 
   /* set the colormap */
   screen = gtk_window_get_screen (GTK_WINDOW (plug));
-
-
   colormap = gdk_screen_get_rgba_colormap (screen);
-  if (colormap == NULL)
-    colormap = gdk_screen_get_rgb_colormap (screen);
   if (colormap != NULL)
     gtk_widget_set_colormap (GTK_WIDGET (plug), colormap);
 }



More information about the Xfce4-commits mailing list