+ /* if names don't exist and we have session names, set those.
+ do this stuff BEFORE setting the number of desktops, because that
+ will create default names for them
+ */
+ if (!namesexist && session_desktop_names != NULL) {
+ guint i, numnames;
+ GSList *it;
+
+ /* get the desktop names */
+ numnames = g_slist_length(session_desktop_names);
+ names = g_new(gchar*, numnames + 1);
+ names[numnames] = NULL;
+ for (i = 0, it = session_desktop_names; it; ++i, it = g_slist_next(it))
+ names[i] = g_strdup(it->data);
+
+ /* set the root window property */
+ OBT_PROP_SETSS(obt_root(ob_screen),
+ NET_DESKTOP_NAMES, utf8, (const gchar**)names);
+
+ g_strfreev(names);
+ }
+
+ /* set the number of desktops, if it's not already set.
+
+ this will also set the default names from the config file up for
+ desktops that don't have names yet */
+ screen_num_desktops = 0;
+ if (OBT_PROP_GET32(obt_root(ob_screen),
+ NET_NUMBER_OF_DESKTOPS, CARDINAL, &d))
+ {
+ if (d != config_desktops_num) {
+ /* TRANSLATORS: If you need to specify a different order of the
+ arguments, you can use %1$d for the first one and %2$d for the
+ second one. For example,
+ "The current session has %2$d desktops, but Openbox is configured for %1$d ..." */
+ 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);
+ else
+ screen_set_num_desktops(config_desktops_num);
+
+ screen_desktop = screen_num_desktops; /* something invalid */
+ /* start on the current desktop when a wm was already running */
+ if (OBT_PROP_GET32(obt_root(ob_screen),
+ NET_CURRENT_DESKTOP, CARDINAL, &d) &&
+ d < screen_num_desktops)
+ {
+ screen_set_desktop(d, FALSE);
+ } else if (session_desktop >= 0)
+ screen_set_desktop(MIN((guint)session_desktop,
+ screen_num_desktops), FALSE);
+ else
+ screen_set_desktop(MIN(config_screen_firstdesk,
+ screen_num_desktops) - 1, FALSE);
+ screen_last_desktop = screen_desktop;
+
+ /* don't start in showing-desktop mode */
+ screen_showing_desktop = FALSE;
+ OBT_PROP_SET32(obt_root(ob_screen),
+ NET_SHOWING_DESKTOP, CARDINAL, screen_showing_desktop);
+
+ if (session_desktop_layout_present &&
+ screen_validate_layout(&session_desktop_layout))
+ {
+ screen_desktop_layout = session_desktop_layout;