[Xfce4-commits] <xfce4-panel:master> Set and restore a unique role name for windows (bug #7094).

Nick Schermer noreply at xfce.org
Sun Jan 23 12:58:01 CET 2011


Updating branch refs/heads/master
         to 4a3230b22f6cec2549b3ee2ee696b5d8a65ba155 (commit)
       from 39c02586f4ceefc99c83afdafd15aae0802c847f (commit)

commit 4a3230b22f6cec2549b3ee2ee696b5d8a65ba155
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Jan 23 12:55:59 2011 +0100

    Set and restore a unique role name for windows (bug #7094).
    
    This way each panel window can be identified by window managers
    and other tools.

 panel/panel-application.c |   15 ++++++++++++++-
 panel/panel-window.c      |    3 ++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/panel/panel-application.c b/panel/panel-application.c
index 9431f89..d3101c4 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -260,7 +260,6 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
   const PanelProperty  properties[] =
   {
     { "position-locked", G_TYPE_BOOLEAN },
-    { "autohide", G_TYPE_BOOLEAN },
     { "span-monitors", G_TYPE_BOOLEAN },
     { "horizontal", G_TYPE_BOOLEAN },
     { "size", G_TYPE_UINT },
@@ -275,6 +274,8 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
     { "output-name", G_TYPE_STRING },
     { "position", G_TYPE_STRING },
     { "disable-struts", G_TYPE_BOOLEAN },
+    { "role", G_TYPE_STRING }, /* GtkWindow property (see bug #7094) */
+    { "autohide", G_TYPE_BOOLEAN },
     { NULL }
   };
 
@@ -1264,6 +1265,8 @@ panel_application_new_window (PanelApplication *application,
   GtkWidget *itembar;
   gchar     *property;
   gint       idx;
+  GTimeVal   tv;
+  gchar     *wmrole;
 
   panel_return_val_if_fail (PANEL_IS_APPLICATION (application), NULL);
   panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), NULL);
@@ -1325,6 +1328,16 @@ panel_application_new_window (PanelApplication *application,
   if (new_window)
     g_object_notify (G_OBJECT (window), "position");
 
+  /* create a somewhat unique role for the panel window (bug #7094) */
+  if (gtk_window_get_role (GTK_WINDOW (window)) == NULL)
+    {
+      g_get_current_time (&tv);
+      idx = g_slist_index (application->windows, window);
+      wmrole = g_strdup_printf (PACKAGE_NAME "-%ld%d", tv.tv_sec, idx);
+      gtk_window_set_role (GTK_WINDOW (window), wmrole);
+      g_free (wmrole);
+    }
+
   return PANEL_WINDOW (window);
 }
 
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 12c53d8..352c7e5 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -2109,7 +2109,8 @@ panel_window_set_autohide (PanelWindow *window,
   guint        i;
   const gchar *properties[] = { "enter-opacity", "leave-opacity",
                                 "background-alpha", "borders",
-                                "background-style", "background-color" };
+                                "background-style", "background-color",
+                                "role" };
 
   panel_return_if_fail (PANEL_IS_WINDOW (window));
 



More information about the Xfce4-commits mailing list