summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-05-23 04:21:25 +0000
committerDana Jansens <danakj@orodu.net>2007-05-23 04:21:25 +0000
commite9fb95168ec918f22a1a25172fc1219f2504b6e0 (patch)
treed5181c50df47a0962e4a829944b22923f61571fb
parent0b7b5e3b936efab8f386f2126510084f0195b4c6 (diff)
restore the desktop names and number from the session. don't clobber them if they are already set when we start up.
-rw-r--r--openbox/screen.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/openbox/screen.c b/openbox/screen.c
index b9cbdd2c..61e46b71 100644
--- a/openbox/screen.c
+++ b/openbox/screen.c
@@ -304,10 +304,9 @@ gboolean screen_annex()
void screen_startup(gboolean reconfig)
{
- guint i, numnames;
- gchar **names;
- GSList *it, *namelist;
+ gchar **names = NULL;
guint32 d;
+ gboolean namesexist = FALSE;
desktop_cycle_popup = pager_popup_new(FALSE);
pager_popup_height(desktop_cycle_popup, POPUP_HEIGHT);
@@ -323,23 +322,45 @@ void screen_startup(gboolean reconfig)
/* get the initial size */
screen_resize();
- /* get the desktop names */
- namelist = session_desktop_names ?
- session_desktop_names : config_desktops_names;
- numnames = g_slist_length(namelist);
- names = g_new(gchar*, numnames + 1);
- names[numnames] = NULL;
- for (i = 0, it = namelist; it; ++i, it = g_slist_next(it))
- names[i] = g_strdup(it->data);
+ /* have names already been set for the desktops? */
+ if (PROP_GETSS(RootWindow(ob_display, ob_screen),
+ net_desktop_names, utf8, &names))
+ {
+ g_strfreev(names);
+ namesexist = TRUE;
+ }
+
+ /* 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 */
- PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,names);
+ /* set the root window property */
+ PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,names);
- g_strfreev(names);
+ g_strfreev(names);
+ }
- /* set the number of desktops */
+ /* 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 (session_num_desktops)
+ if (PROP_GET32(RootWindow(ob_display, ob_screen),
+ net_number_of_desktops, cardinal, &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);