From e622927efb135a0fd69d5d2227ae6f532f4ff0c7 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Sun, 14 Jan 2007 19:05:34 +0000
Subject: stay on same workspace after restart

---
 ChangeLog     |  2 ++
 src/Screen.cc | 17 +++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 03a68db..60563ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
  (Format: Year/Month/Day)
 Changes for 1.0rc3:
 *07/01/14:
+   * Stay on the same workspace after a restart (Mark)
+     Screen.cc
    * Properly 'properly fix' shaded and stuck windows on restart -- i.e. allow
      windows to deiconify themselves the rest of the time (Mark)
      Window.cc
diff --git a/src/Screen.cc b/src/Screen.cc
index a82307d..252df9c 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -460,8 +460,21 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
     setupConfigmenu(*m_configmenu.get());
     m_configmenu->setInternalMenu();
 
-    // start with workspace 0
-    changeWorkspaceID(0);
+    // check which desktop we should start on
+    unsigned int first_desktop = 0;
+    if (m_restart) {
+        Atom net_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False);
+        // other arguments are already defined above
+        if (XGetWindowProperty(disp, m_root_window.window(), net_desktop, 0l,
+                1l, False, XA_CARDINAL, &xa_ret_type, &ret_format, &ret_nitems,
+                &ret_bytes_after, &ret_prop) == Success) {
+            if (ret_prop && (unsigned int) *ret_prop < (unsigned) nr_ws)
+                first_desktop = (unsigned int) *ret_prop;
+            XFree(ret_prop);
+        }
+    }
+
+    changeWorkspaceID(first_desktop);
     updateNetizenWorkspaceCount();
 
     // we need to load win frame theme before we create any fluxbox window
-- 
cgit v0.11.2