Fix a minor issue with lastdesktop right after startup.
[mikachu/openbox.git] / openbox / screen.c
index b88562f..5201f78 100644 (file)
@@ -59,16 +59,16 @@ static void     screen_fallback_focus(void);
 guint    screen_num_desktops;
 guint    screen_num_monitors;
 guint    screen_desktop;
-guint    screen_last_desktop = 1;
-guint    screen_old_desktop;
-gboolean screen_desktop_timeout = TRUE;
-Size     screen_physical_size;
+guint    screen_last_desktop;
 gboolean screen_showing_desktop;
 ObDesktopLayout screen_desktop_layout;
 gchar  **screen_desktop_names;
 Window   screen_support_win;
 Time     screen_desktop_user_time = CurrentTime;
 
+static Size     screen_physical_size;
+static guint    screen_old_desktop;
+static gboolean screen_desktop_timeout = TRUE;
 /*! An array of desktops, holding array of areas per monitor */
 static Rect  *monitor_area = NULL;
 /*! An array of desktops, holding an array of struts */
@@ -300,6 +300,7 @@ gboolean screen_annex(void)
     supported[i++] = prop_atoms.ob_wm_state_undecorated;
     supported[i++] = prop_atoms.openbox_pid;
     supported[i++] = prop_atoms.ob_theme;
+    supported[i++] = prop_atoms.ob_config_file;
     supported[i++] = prop_atoms.ob_control;
     g_assert(i == num_support);
 
@@ -402,7 +403,13 @@ void screen_startup(gboolean reconfig)
     screen_num_desktops = 0;
     if (PROP_GET32(RootWindow(ob_display, ob_screen),
                    net_number_of_desktops, cardinal, &d))
+    {
+        if (d != config_desktops_num) {
+            g_warning(_("Openbox is configured for %d desktops, but the current session has %d.  Overriding the Openbox configuration."),
+                      config_desktops_num, d);
+        }
         screen_set_num_desktops(d);
+    }
     /* restore from session if possible */
     else if (session_num_desktops)
         screen_set_num_desktops(session_num_desktops);
@@ -613,10 +620,15 @@ void screen_set_desktop(guint num, gboolean dofocus)
         /* If screen_desktop_timeout is true, then we've been on this desktop
            long enough and we can save it as the last desktop. */
 
-        /* save the "last desktop" as the "old desktop" */
-        screen_old_desktop = screen_last_desktop;
-        /* save the desktop we're coming from as the "last desktop" */
-        screen_last_desktop = previous;
+        if (screen_last_desktop == previous)
+            /* this is the startup state only */
+            screen_old_desktop = screen_desktop;
+        else {
+            /* save the "last desktop" as the "old desktop" */
+            screen_old_desktop = screen_last_desktop;
+            /* save the desktop we're coming from as the "last desktop" */
+            screen_last_desktop = previous;
+        }
     }
     else {
         /* If screen_desktop_timeout is false, then we just got to this desktop