]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
restore the desktop and focused window on restarts if possible
[chaz/openbox] / openbox / screen.c
index 118798e8e8b02f00a8a3b61c30b37a0b6e84948a..03cee447e7456c40093da8f37ac4faf6fe6ebe5d 100644 (file)
@@ -1,5 +1,6 @@
 #include "openbox.h"
 #include "prop.h"
+#include "startup.h"
 #include "config.h"
 #include "screen.h"
 #include "client.h"
@@ -173,8 +174,10 @@ void screen_startup()
 
     screen_num_desktops = 0;
     screen_set_num_desktops(config_desktops_num);
-    screen_desktop = 0;
-    screen_set_desktop(0);
+    if (startup_desktop >= screen_num_desktops)
+        startup_desktop = 0;
+    screen_desktop = startup_desktop;
+    screen_set_desktop(startup_desktop);
 
     /* don't start in showing-desktop mode */
     screen_showing_desktop = FALSE;
@@ -302,7 +305,6 @@ void screen_set_desktop(guint num)
 
     /* focus the last focused window on the desktop, and ignore enter events
        from the switch so it doesnt mess with the focus */
-    XSync(ob_display, FALSE);
     while (XCheckTypedEvent(ob_display, EnterNotify, &e));
     focus_fallback(Fallback_Desktop);
 
@@ -424,6 +426,16 @@ void screen_show_desktop(gboolean show)
        }
     }
 
+    if (show) {
+        /* focus desktop */
+        for (it = focus_order[screen_desktop]; it; it = it->next)
+            if (((Client*)it->data)->type == Type_Desktop &&
+                client_focus(it->data))
+                break;
+    } else {
+        focus_fallback(Fallback_NoFocus);
+    }
+
     show = !!show; /* make it boolean */
     PROP_SET32(ob_root, net_showing_desktop, cardinal, show);
 
This page took 0.020373 seconds and 4 git commands to generate.