Save screen_last_desktop to the root prop _OB_LAST_DESKTOP.
authorMikael Magnusson <mikachu@comhem.se>
Wed, 27 Feb 2008 15:53:43 +0000 (16:53 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Sat, 11 Oct 2014 00:17:20 +0000 (02:17 +0200)
obt/prop.c
obt/prop.h
openbox/screen.c

index 893d199..2099706 100644 (file)
@@ -192,6 +192,7 @@ void obt_prop_startup(void)
     CREATE_(OB_CONFIG_FILE);
     CREATE_(OB_WM_ACTION_UNDECORATE);
     CREATE_(OB_WM_STATE_UNDECORATED);
+    CREATE_(OB_LAST_DESKTOP);
     CREATE_(OB_CONTROL);
     CREATE_(OB_VERSION);
     CREATE_(OB_APP_ROLE);
index 79e3380..62f86bd 100644 (file)
@@ -214,6 +214,7 @@ typedef enum {
     OBT_PROP_OPENBOX_PID, /* this is depreecated in favour of ob_control */
     OBT_PROP_OB_THEME,
     OBT_PROP_OB_CONFIG_FILE,
+    OBT_PROP_OB_LAST_DESKTOP,
     OBT_PROP_OB_CONTROL,
     OBT_PROP_OB_VERSION,
     OBT_PROP_OB_APP_ROLE,
index 84c9154..97a1764 100644 (file)
@@ -300,6 +300,7 @@ gboolean screen_annex(void)
     supported[i++] = OBT_PROP_ATOM(OPENBOX_PID);
     supported[i++] = OBT_PROP_ATOM(OB_THEME);
     supported[i++] = OBT_PROP_ATOM(OB_CONFIG_FILE);
+    supported[i++] = OBT_PROP_ATOM(OB_LAST_DESKTOP);
     supported[i++] = OBT_PROP_ATOM(OB_CONTROL);
     supported[i++] = OBT_PROP_ATOM(OB_VERSION);
     supported[i++] = OBT_PROP_ATOM(OB_APP_ROLE);
@@ -443,7 +444,11 @@ void screen_startup(gboolean reconfig)
     else
         screen_set_desktop(MIN(config_screen_firstdesk,
                                screen_num_desktops) - 1, FALSE);
-    screen_last_desktop = screen_desktop;
+    OBT_PROP_GET32(obt_root(ob_screen), OB_LAST_DESKTOP, CARDINAL, &screen_last_desktop);
+    if (screen_last_desktop < 0 || screen_last_desktop >= screen_num_desktops) {
+        screen_last_desktop = screen_desktop;
+        OBT_PROP_SET32(obt_root(ob_screen), OB_LAST_DESKTOP, CARDINAL, screen_last_desktop);
+    }
 
     /* don't start in showing-desktop mode */
     screen_show_desktop_mode = SCREEN_SHOW_DESKTOP_NO;
@@ -603,6 +608,7 @@ static void screen_fallback_focus(void)
 static gboolean last_desktop_func(gpointer data)
 {
     screen_desktop_timeout = TRUE;
+    OBT_PROP_SET32(obt_root(ob_screen), OB_LAST_DESKTOP, CARDINAL, screen_last_desktop);
     screen_desktop_timer = 0;
     return FALSE; /* don't repeat */
 }