[Xfce4-commits] <xfwm4:master> Upon restart, restore the previous selected workspace.

Olivier Fourdan noreply at xfce.org
Fri Oct 21 08:48:04 CEST 2011


Updating branch refs/heads/master
         to d154ab127af75a4e1e7b37351dd7e48491a4f69e (commit)
       from 7da8c081dc4dd01a15e38475996613ca2f140393 (commit)

commit d154ab127af75a4e1e7b37351dd7e48491a4f69e
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Fri Oct 21 08:47:04 2011 +0200

    Upon restart, restore the previous selected workspace.

 src/hints.c      |   31 +++++++++++++++++++++++++------
 src/hints.h      |    5 +++++
 src/main.c       |    2 +-
 src/workspaces.c |    6 +-----
 4 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/src/hints.c b/src/hints.c
index 41fd99c..45c243c 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -558,15 +558,22 @@ setNetFullscreenMonitors (DisplayInfo *display_info, Window w, gint top, gint bo
                      XA_CARDINAL, 32, PropModeReplace, (unsigned char *) data, 4);
 }
 
+int
+getNetCurrentDesktop (DisplayInfo *display_info, Window root)
+{
+    long ws;
+
+    TRACE ("entering getNetCurrentDesktop");
+    getHint (display_info, root, NET_CURRENT_DESKTOP, &ws);
+    return (int) ws;
+}
+
 void
-initNetDesktopInfo (DisplayInfo *display_info, Window root, int workspace, int width, int height)
+setNetCurrentDesktop (DisplayInfo *display_info, Window root, int workspace)
 {
     unsigned long data[2];
-    TRACE ("entering initNetDesktopInfo");
-    data[0] = width;
-    data[1] = height;
-    XChangeProperty (display_info->dpy, root, display_info->atoms[NET_DESKTOP_GEOMETRY],
-                     XA_CARDINAL, 32, PropModeReplace, (unsigned char *) data, 2);
+    TRACE ("entering setNetCurrentDesktop");
+
     data[0] = 0;
     data[1] = 0;
     XChangeProperty (display_info->dpy, root, display_info->atoms[NET_DESKTOP_VIEWPORT],
@@ -577,6 +584,18 @@ initNetDesktopInfo (DisplayInfo *display_info, Window root, int workspace, int w
 }
 
 void
+initNetDesktopInfo (DisplayInfo *display_info, Window root, int workspace, int width, int height)
+{
+    unsigned long data[2];
+    TRACE ("entering initNetDesktopInfo");
+    data[0] = width;
+    data[1] = height;
+    XChangeProperty (display_info->dpy, root, display_info->atoms[NET_DESKTOP_GEOMETRY],
+                     XA_CARDINAL, 32, PropModeReplace, (unsigned char *) data, 2);
+    setNetCurrentDesktop (display_info, root, workspace);
+}
+
+void
 setUTF8StringHint (DisplayInfo *display_info, Window w, int atom_id, const gchar *val)
 {
     g_return_if_fail ((atom_id >= 0) && (atom_id < ATOM_COUNT));
diff --git a/src/hints.h b/src/hints.h
index 70a5c80..c106247 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -195,6 +195,11 @@ void                     setNetFullscreenMonitors               (DisplayInfo *,
                                                                  gint,
                                                                  gint,
                                                                  gint);
+int                      getNetCurrentDesktop                   (DisplayInfo *,
+                                                                 Window root);
+void                     setNetCurrentDesktop                   (DisplayInfo *,
+                                                                 Window,
+                                                                 int);
 void                     initNetDesktopInfo                     (DisplayInfo *,
                                                                  Window,
                                                                  int,
diff --git a/src/main.c b/src/main.c
index 1eb755b..15eae37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -482,7 +482,7 @@ initialize (gint compositor_mode, gboolean replace_wm)
 
         sn_init_display (screen_info);
         myDisplayAddScreen (main_display_info, screen_info);
-        screen_info->current_ws = 0;
+        screen_info->current_ws = getNetCurrentDesktop (main_display_info, screen_info->xroot);
         setUTF8StringHint (main_display_info, screen_info->xfwm4_win, NET_WM_NAME, "Xfwm4");
         setNetSupportedHint (main_display_info, screen_info->xroot, screen_info->xfwm4_win);
         initNetDesktopInfo (main_display_info, screen_info->xroot, screen_info->current_ws,
diff --git a/src/workspaces.c b/src/workspaces.c
index ef3fc15..8625249 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -246,7 +246,6 @@ workspaceSwitch (ScreenInfo *screen_info, gint new_ws, Client * c2, gboolean upd
     Window dr, window;
     gint rx, ry, wx, wy;
     unsigned int mask;
-    unsigned long data[1];
 
     g_return_if_fail (screen_info != NULL);
 
@@ -368,10 +367,7 @@ workspaceSwitch (ScreenInfo *screen_info, gint new_ws, Client * c2, gboolean upd
         }
     }
 
-    data[0] = new_ws;
-    XChangeProperty (myScreenGetXDisplay (screen_info), screen_info->xroot,
-                     display_info->atoms[NET_CURRENT_DESKTOP], XA_CARDINAL, 32,
-                     PropModeReplace, (unsigned char *) data, 1);
+    setNetCurrentDesktop (display_info, screen_info->xroot, new_ws);
     if (!(screen_info->params->click_to_focus))
     {
         if (!(c2) && (XQueryPointer (myScreenGetXDisplay (screen_info), screen_info->xroot, &dr, &window, &rx, &ry, &wx, &wy, &mask)))


More information about the Xfce4-commits mailing list