From: Dana Jansens Date: Tue, 8 Apr 2003 07:31:26 +0000 (+0000) Subject: move config option loading for the kernel into config.c/h X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=71badb0790c8595a0ab6dedfbf8027c698369210;p=chaz%2Fopenbox move config option loading for the kernel into config.c/h add options for the number of desktops and the names of the desktops --- diff --git a/build/Makefile.kernel b/build/Makefile.kernel index c539dbf9..7adfdfec 100644 --- a/build/Makefile.kernel +++ b/build/Makefile.kernel @@ -8,7 +8,7 @@ LIBS += $(GLIB_LIBS) $(GMODULE_LIBS) $(XFT_LIBS) $(X_LIBS) $(XINERAMA_LIBS) LDFLAGS += -export-dynamic target = openbox3 -sources = action.c client.c dispatch.c engine.c event.c group.c \ +sources = action.c client.c config.c dispatch.c engine.c event.c group.c \ extensions.c focus.c frame.c grab.c menu.c openbox.c \ parse.c plugin.c prop.c screen.c stacking.c timer.c xerror.c \ parse.lex.c parse.tab.c diff --git a/engines/openbox/obengine.c b/engines/openbox/obengine.c index 843a6988..75396c8a 100644 --- a/engines/openbox/obengine.c +++ b/engines/openbox/obengine.c @@ -4,7 +4,7 @@ #include "kernel/openbox.h" #include "kernel/extensions.h" #include "kernel/dispatch.h" -#include "kernel/engine.h" +#include "kernel/config.h" #ifdef HAVE_SYS_STAT_H # include @@ -703,7 +703,7 @@ static void layout_title(ObFrame *self) /* figure out whats being shown, and the width of the label */ self->label_width = self->width - (ob_s_bevel + 1) * 2; - for (lc = engine_layout; *lc != '\0'; ++lc) { + for (lc = config_engine_layout; *lc != '\0'; ++lc) { switch (*lc) { case 'N': if (!(self->frame.client->decorations & Decor_Icon)) break; @@ -761,7 +761,7 @@ static void layout_title(ObFrame *self) if (!c) XUnmapWindow(ob_display, self->close); x = ob_s_bevel + 1; - for (lc = engine_layout; *lc != '\0'; ++lc) { + for (lc = config_engine_layout; *lc != '\0'; ++lc) { switch (*lc) { case 'N': if (!n) break; diff --git a/engines/openbox/obtheme.c b/engines/openbox/obtheme.c index f7e7941d..533559f9 100644 --- a/engines/openbox/obtheme.c +++ b/engines/openbox/obtheme.c @@ -1,6 +1,6 @@ #include "obengine.h" #include "kernel/openbox.h" -#include "kernel/engine.h" +#include "kernel/config.h" #include #include @@ -119,7 +119,7 @@ static gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value) if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { - button_dir = g_strdup_printf("%s_buttons", engine_theme); + button_dir = g_strdup_printf("%s_buttons", config_engine_theme); s = g_build_filename(g_get_home_dir(), ".openbox", "themes", "openbox", button_dir, retvalue.addr, NULL); @@ -136,8 +136,8 @@ static gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value) char *themename; g_free(s); - themename = g_path_get_basename(engine_theme); - s = g_strdup_printf("%s/%s_buttons/%s", engine_theme, + themename = g_path_get_basename(config_engine_theme); + s = g_strdup_printf("%s/%s_buttons/%s", config_engine_theme, themename, retvalue.addr); g_free(themename); if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == @@ -275,10 +275,10 @@ gboolean obtheme_load() Justify winjust; char *winjuststr; - if (engine_theme) { - db = loaddb(engine_theme); + if (config_engine_theme) { + db = loaddb(config_engine_theme); if (db == NULL) { - g_warning("Failed to load the theme '%s'", engine_theme); + g_warning("Failed to load the theme '%s'", config_engine_theme); g_message("Falling back to the default: '%s'", DEFAULT_THEME); } } @@ -289,15 +289,15 @@ gboolean obtheme_load() return FALSE; } /* set it to what was loaded */ - g_free(engine_theme); - engine_theme = g_strdup(DEFAULT_THEME); + g_free(config_engine_theme); + config_engine_theme = g_strdup(DEFAULT_THEME); } /* load the font, not from the theme file tho, its in the config */ - ob_s_winfont = font_open(engine_font); - ob_s_winfont_height = font_height(ob_s_winfont, engine_shadow, - engine_shadow_offset); + ob_s_winfont = font_open(config_engine_font); + ob_s_winfont_height = font_height(ob_s_winfont, config_engine_shadow, + config_engine_shadow_offset); winjust = Justify_Left; if (read_string(db, "window.justify", &winjuststr)) { @@ -494,32 +494,37 @@ gboolean obtheme_load() ob_a_focused_label->texture[0].type = Text; ob_a_focused_label->texture[0].data.text.justify = winjust; ob_a_focused_label->texture[0].data.text.font = ob_s_winfont; - ob_a_focused_label->texture[0].data.text.shadow = engine_shadow; - ob_a_focused_label->texture[0].data.text.offset = engine_shadow_offset; - ob_a_focused_label->texture[0].data.text.tint = engine_shadow_tint; + ob_a_focused_label->texture[0].data.text.shadow = config_engine_shadow; + ob_a_focused_label->texture[0].data.text.offset = + config_engine_shadow_offset; + ob_a_focused_label->texture[0].data.text.tint = config_engine_shadow_tint; ob_a_focused_label->texture[0].data.text.color = ob_s_title_focused_color; ob_app_hilite_label->texture[0].type = Text; ob_app_hilite_label->texture[0].data.text.justify = winjust; ob_app_hilite_label->texture[0].data.text.font = ob_s_winfont; - ob_app_hilite_label->texture[0].data.text.shadow = engine_shadow; - ob_app_hilite_label->texture[0].data.text.offset = engine_shadow_offset; - ob_app_hilite_label->texture[0].data.text.tint = engine_shadow_tint; + ob_app_hilite_label->texture[0].data.text.shadow = config_engine_shadow; + ob_app_hilite_label->texture[0].data.text.offset = + config_engine_shadow_offset; + ob_app_hilite_label->texture[0].data.text.tint = config_engine_shadow_tint; ob_app_hilite_label->texture[0].data.text.color = ob_s_title_focused_color; ob_a_unfocused_label->texture[0].type = Text; ob_a_unfocused_label->texture[0].data.text.justify = winjust; ob_a_unfocused_label->texture[0].data.text.font = ob_s_winfont; - ob_a_unfocused_label->texture[0].data.text.shadow = engine_shadow; - ob_a_unfocused_label->texture[0].data.text.offset = engine_shadow_offset; - ob_a_unfocused_label->texture[0].data.text.tint = engine_shadow_tint; + ob_a_unfocused_label->texture[0].data.text.shadow = config_engine_shadow; + ob_a_unfocused_label->texture[0].data.text.offset = + config_engine_shadow_offset; + ob_a_unfocused_label->texture[0].data.text.tint =config_engine_shadow_tint; ob_a_unfocused_label->texture[0].data.text.color = ob_s_title_unfocused_color; ob_app_unhilite_label->texture[0].type = Text; ob_app_unhilite_label->texture[0].data.text.justify = winjust; ob_app_unhilite_label->texture[0].data.text.font = ob_s_winfont; - ob_app_unhilite_label->texture[0].data.text.shadow = engine_shadow; - ob_app_unhilite_label->texture[0].data.text.offset = engine_shadow_offset; - ob_app_unhilite_label->texture[0].data.text.tint = engine_shadow_tint; + ob_app_unhilite_label->texture[0].data.text.shadow = config_engine_shadow; + ob_app_unhilite_label->texture[0].data.text.offset = + config_engine_shadow_offset; + ob_app_unhilite_label->texture[0].data.text.tint = + config_engine_shadow_tint; ob_app_unhilite_label->texture[0].data.text.color = ob_s_title_unfocused_color; diff --git a/openbox/client.c b/openbox/client.c index 7fca4796..af24d921 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -10,6 +10,7 @@ #include "stacking.h" #include "dispatch.h" #include "group.h" +#include "config.h" #include #include @@ -138,7 +139,7 @@ void client_manage_all() client_startup_stack_order = NULL; client_startup_stack_size = 0; - if (focus_new) + if (config_focus_new) focus_fallback(Fallback_NoFocus); } @@ -237,7 +238,7 @@ void client_manage(Window window) dispatch_client(Event_Client_Mapped, self, 0, 0); - if (ob_state != State_Starting && focus_new) + if (ob_state != State_Starting && config_focus_new) client_focus(self); /* update the list hints */ @@ -1811,13 +1812,13 @@ void client_set_desktop(Client *self, guint target, gboolean donthide) focus_order[old] = g_list_remove(focus_order[old], self); if (target == DESKTOP_ALL) { for (i = 0; i < screen_num_desktops; ++i) { - if (focus_new) + if (config_focus_new) focus_order[i] = g_list_prepend(focus_order[i], self); else focus_order[i] = g_list_append(focus_order[i], self); } } else { - if (focus_new) + if (config_focus_new) focus_order[target] = g_list_prepend(focus_order[target], self); else focus_order[target] = g_list_append(focus_order[target], self); diff --git a/openbox/config.c b/openbox/config.c new file mode 100644 index 00000000..12255906 --- /dev/null +++ b/openbox/config.c @@ -0,0 +1,177 @@ +#include "config.h" +#include "parse.h" + +gboolean config_focus_new; +gboolean config_focus_follow; +gboolean config_focus_last; +gboolean config_focus_last_on_desktop; + +char *config_engine_name; +char *config_engine_theme; +char *config_engine_layout; +char *config_engine_font; +gboolean config_engine_shadow; +int config_engine_shadow_offset; +int config_engine_shadow_tint; + +int config_desktops_num; +GSList *config_desktops_names; + +static void parse_focus(char *name, ParseToken *value) +{ + if (!g_ascii_strcasecmp(name, "focusnew")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + config_focus_new = value->data.bool; + } + } else if (!g_ascii_strcasecmp(name, "followmouse")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + config_focus_follow = value->data.bool; + } + } else if (!g_ascii_strcasecmp(name, "focuslast")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + config_focus_last = value->data.bool; + } + } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + config_focus_last_on_desktop = value->data.bool; + } + } else + yyerror("invalid option"); + parse_free_token(value); +} + +static void parse_engine(char *name, ParseToken *value) +{ + if (!g_ascii_strcasecmp(name, "engine")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(config_engine_name); + config_engine_name = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "theme")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(config_engine_theme); + config_engine_theme = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "titlebarlayout")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(config_engine_layout); + config_engine_layout = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "font.title")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(config_engine_font); + config_engine_font = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + config_engine_shadow = value->data.bool; + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow.offset")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + config_engine_shadow_offset = value->data.integer; + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow.tint")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + config_engine_shadow_tint = value->data.integer; + if (config_engine_shadow_tint < -100) + config_engine_shadow_tint = -100; + else if (config_engine_shadow_tint > 100) + config_engine_shadow_tint = 100; + } + } else + yyerror("invalid option"); + parse_free_token(value); +} + +static void parse_desktops(char *name, ParseToken *value) +{ + GList *it; + + if (!g_ascii_strcasecmp(name, "number")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + config_desktops_num = value->data.integer; + } + } else if (!g_ascii_strcasecmp(name, "names")) { + if (value->type == TOKEN_LIST) { + for (it = value->data.list; it; it = it->next) + if (((ParseToken*)it->data)->type != TOKEN_STRING) break; + if (it == NULL) { + /* build a string list */ + g_free(config_desktops_names); + for (it = value->data.list; it; it = it->next) + config_desktops_names = + g_slist_append(config_desktops_names, + g_strdup + (((ParseToken*)it->data)->data.string)); + } else { + yyerror("invalid string in names list"); + } + } else { + yyerror("syntax error (expected list of strings)"); + } + } else + yyerror("invalid option"); + parse_free_token(value); +} + +void config_startup() +{ + config_focus_new = TRUE; + config_focus_follow = FALSE; + config_focus_last = TRUE; + config_focus_last_on_desktop = TRUE; + + parse_reg_section("focus", NULL, parse_focus); + + config_engine_name = g_strdup(DEFAULT_ENGINE); + config_engine_theme = NULL; + config_engine_layout = g_strdup("NLIMC"); + config_engine_font = g_strdup("Sans-7"); + config_engine_shadow = FALSE; + config_engine_shadow_offset = 1; + config_engine_shadow_tint = 25; + + parse_reg_section("engine", NULL, parse_engine); + + config_desktops_num = 4; + config_desktops_names = NULL; + + parse_reg_section("desktops", NULL, parse_desktops); +} + +void config_shutdown() +{ + GSList *it; + + g_free(config_engine_name); + g_free(config_engine_layout); + g_free(config_engine_font); + + for (it = config_desktops_names; it; it = it->next) + g_free(it->data); + g_slist_free(config_desktops_names); +} diff --git a/openbox/config.h b/openbox/config.h new file mode 100644 index 00000000..0dceb920 --- /dev/null +++ b/openbox/config.h @@ -0,0 +1,39 @@ +#ifndef __config_h +#define __config_h + +#include + +/*! Should new windows be focused */ +extern gboolean config_focus_new; +/*! Focus windows when the mouse enters them */ +extern gboolean config_focus_follow; +/*! Focus the last focused window as a fallback */ +extern gboolean config_focus_last; +/*! Focus the last focused window as a fallback when switching desktops */ +extern gboolean config_focus_last_on_desktop; + +/*! The engine to load */ +extern char *config_engine_name; +/*! The theme to load */ +extern char *config_engine_theme; +/*! The titlebar layout */ +extern char *config_engine_layout; +/*! The titlebar font */ +extern char *config_engine_font; +/*! The titlebar font's shadow */ +extern gboolean config_engine_shadow; +/*! The titlebar font's shadow offset */ +extern int config_engine_shadow_offset; +/*! The titlebar font's shadow transparency */ +extern int config_engine_shadow_tint; + +/*! The number of desktops */ +extern int config_desktops_num; +/*! Names for the desktops */ +extern GSList *config_desktops_names; + + +void config_startup(); +void config_shutdown(); + +#endif diff --git a/openbox/engine.c b/openbox/engine.c index 66d30580..53e10deb 100644 --- a/openbox/engine.c +++ b/openbox/engine.c @@ -1,5 +1,5 @@ #include "engine.h" -#include "parse.h" +#include "config.h" #include #include @@ -7,14 +7,6 @@ # include #endif -char *engine_name; -char *engine_theme; -char *engine_layout; -char *engine_font; -gboolean engine_shadow; -int engine_shadow_offset; -int engine_shadow_tint; - EngineFrameNew *engine_frame_new; EngineFrameGrabClient *engine_frame_grab_client; EngineFrameReleaseClient *engine_frame_release_client; @@ -86,80 +78,16 @@ static gboolean load(char *name) return TRUE; } -static void parse_assign(char *name, ParseToken *value) -{ - if (!g_ascii_strcasecmp(name, "engine")) { - if (value->type != TOKEN_STRING) - yyerror("invalid value"); - else { - g_free(engine_name); - engine_name = g_strdup(value->data.string); - } - } else if (!g_ascii_strcasecmp(name, "theme")) { - if (value->type != TOKEN_STRING) - yyerror("invalid value"); - else { - g_free(engine_theme); - engine_theme = g_strdup(value->data.string); - } - } else if (!g_ascii_strcasecmp(name, "titlebarlayout")) { - if (value->type != TOKEN_STRING) - yyerror("invalid value"); - else { - g_free(engine_layout); - engine_layout = g_strdup(value->data.string); - } - } else if (!g_ascii_strcasecmp(name, "font.title")) { - if (value->type != TOKEN_STRING) - yyerror("invalid value"); - else { - g_free(engine_font); - engine_font = g_strdup(value->data.string); - } - } else if (!g_ascii_strcasecmp(name, "font.title.shadow")) { - if (value->type != TOKEN_BOOL) - yyerror("invalid value"); - else { - engine_shadow = value->data.bool; - } - } else if (!g_ascii_strcasecmp(name, "font.title.shadow.offset")) { - if (value->type != TOKEN_INTEGER) - yyerror("invalid value"); - else { - engine_shadow_offset = value->data.integer; - } - } else if (!g_ascii_strcasecmp(name, "font.title.shadow.tint")) { - if (value->type != TOKEN_INTEGER) - yyerror("invalid value"); - else { - engine_shadow_tint = value->data.integer; - if (engine_shadow_tint < -100) engine_shadow_tint = -100; - else if (engine_shadow_tint > 100) engine_shadow_tint = 100; - } - } else - yyerror("invalid option"); - parse_free_token(value); -} - void engine_startup() { module = NULL; - engine_name = g_strdup(DEFAULT_ENGINE); - engine_theme = NULL; - engine_layout = g_strdup("NLIMC"); - engine_font = g_strdup("Sans-7"); - engine_shadow = FALSE; - engine_shadow_offset = 1; - engine_shadow_tint = 25; - - parse_reg_section("engine", NULL, parse_assign); } void engine_load() { - if (load(engine_name)) + if (load(config_engine_name)) return; - g_warning("Failed to load the engine '%s'", engine_name); + g_warning("Failed to load the engine '%s'", config_engine_name); g_message("Falling back to the default: '%s'", DEFAULT_ENGINE); if (module != NULL) { g_module_close(module); @@ -173,7 +101,6 @@ void engine_load() void engine_shutdown() { - g_free(engine_name); if (module != NULL) { eshutdown(); g_module_close(module); diff --git a/openbox/engine.h b/openbox/engine.h index 0180e3e5..e2c314a6 100644 --- a/openbox/engine.h +++ b/openbox/engine.h @@ -3,21 +3,6 @@ #include "../engines/engineinterface.h" -/* The engine to load */ -extern char *engine_name; -/* The theme to load */ -extern char *engine_theme; -/* The titlebar layout */ -extern char *engine_layout; -/* The titlebar font */ -extern char *engine_font; -/* The titlebar font's shadow */ -extern gboolean engine_shadow; -/* The titlebar font's shadow offset */ -extern int engine_shadow_offset; -/* The titlebar font's shadow transparency */ -extern int engine_shadow_tint; - void engine_startup(); void engine_load(); void engine_shutdown(); diff --git a/openbox/event.c b/openbox/event.c index 04174af0..edd6f4ce 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -2,6 +2,7 @@ #include "client.h" #include "xerror.h" #include "prop.h" +#include "config.h" #include "screen.h" #include "frame.h" #include "engine.h" @@ -388,7 +389,7 @@ static void event_handle_client(Client *client, XEvent *e) client); focus_order[desktop] = g_list_prepend(focus_order[desktop], client); - } else if (focus_follow) { + } else if (config_focus_follow) { #ifdef DEBUG_FOCUS g_message("EnterNotify on %lx, focusing window", client->window); diff --git a/openbox/focus.c b/openbox/focus.c index 8afbdcb6..7542fae6 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -1,6 +1,7 @@ #include "event.h" #include "openbox.h" #include "client.h" +#include "config.h" #include "frame.h" #include "screen.h" #include "group.h" @@ -18,44 +19,9 @@ GList **focus_order = NULL; /* these lists are created when screen_startup sets the number of desktops */ Window focus_backup = None; -gboolean focus_new = TRUE; -gboolean focus_follow = FALSE; -static gboolean focus_last = TRUE; -static gboolean focus_last_on_desktop = TRUE; static gboolean noreorder = 0; -static void parse_assign(char *name, ParseToken *value) -{ - if (!g_ascii_strcasecmp(name, "focusnew")) { - if (value->type != TOKEN_BOOL) - yyerror("invalid value"); - else { - focus_new = value->data.bool; - } - } else if (!g_ascii_strcasecmp(name, "followmouse")) { - if (value->type != TOKEN_BOOL) - yyerror("invalid value"); - else { - focus_follow = value->data.bool; - } - } else if (!g_ascii_strcasecmp(name, "focuslast")) { - if (value->type != TOKEN_BOOL) - yyerror("invalid value"); - else { - focus_last = value->data.bool; - } - } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) { - if (value->type != TOKEN_BOOL) - yyerror("invalid value"); - else { - focus_last_on_desktop = value->data.bool; - } - } else - yyerror("invalid option"); - parse_free_token(value); -} - void focus_startup() { /* create the window which gets focus when no clients get it. Have to @@ -64,10 +30,6 @@ void focus_startup() XSetWindowAttributes attrib; focus_client = NULL; - focus_new = TRUE; - focus_follow = FALSE; - focus_last = TRUE; - focus_last_on_desktop = TRUE; attrib.override_redirect = TRUE; focus_backup = XCreateWindow(ob_display, ob_root, @@ -78,8 +40,6 @@ void focus_startup() /* start with nothing focused */ focus_set_client(NULL); - - parse_reg_section("focus", NULL, parse_assign); } void focus_shutdown() @@ -176,8 +136,9 @@ void focus_fallback(FallbackType type) */ focus_set_client(NULL); - if (!(type == Fallback_Desktop ? focus_last_on_desktop : focus_last)) { - if (focus_follow) focus_under_pointer(); + if (!(type == Fallback_Desktop ? + config_focus_last_on_desktop : config_focus_last)) { + if (config_focus_follow) focus_under_pointer(); return; } diff --git a/openbox/focus.h b/openbox/focus.h index 3ad60682..d7f0183e 100644 --- a/openbox/focus.h +++ b/openbox/focus.h @@ -15,11 +15,6 @@ extern struct Client *focus_client; /*! The recent focus order on each desktop */ extern GList **focus_order; -/*! Should new windows be focused */ -extern gboolean focus_new; -/*! Focus windows when the mouse enters them */ -extern gboolean focus_follow; - void focus_startup(); void focus_shutdown(); diff --git a/openbox/openbox.c b/openbox/openbox.c index 74f8164c..c4784aff 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -13,6 +13,7 @@ #include "plugin.h" #include "timer.h" #include "group.h" +#include "config.h" #include "gettext.h" #include "../render/render.h" #include "../render/font.h" @@ -159,11 +160,12 @@ int main(int argc, char **argv) event_startup(); grab_startup(); engine_startup(); - focus_startup(); plugin_startup(); /* load the plugins specified in the pluginrc */ plugin_loadall(); + /* set up the kernel config shit */ + config_startup(); /* parse/load user options */ parse_rc(); /* we're done with parsing now, kill it */ @@ -172,6 +174,7 @@ int main(int argc, char **argv) /* load the engine specified in the rc */ engine_load(); + focus_startup(); screen_startup(); group_startup(); client_startup(); @@ -199,6 +202,7 @@ int main(int argc, char **argv) event_shutdown(); render_shutdown(); timer_shutdown(); + config_shutdown(); } dispatch_shutdown(); diff --git a/openbox/prop.c b/openbox/prop.c index 9a448500..97f5fb94 100644 --- a/openbox/prop.c +++ b/openbox/prop.c @@ -265,6 +265,20 @@ gboolean prop_get_strings(Window win, Atom prop, Atom type, return FALSE; } +void prop_set_strings(Window win, Atom prop, Atom type, GPtrArray *data) +{ + GString *str; + guint i; + + str = g_string_sized_new(0); + for (i = 0; i < data->len; ++i) { + str = g_string_append(str, data->pdata[i]); + str = g_string_append_c(str, '\0'); + } + XChangeProperty(ob_display, win, prop, type, 8, + PropModeReplace, (guchar*)str->str, str->len); +} + void prop_erase(Window win, Atom prop) { XDeleteProperty(ob_display, win, prop); diff --git a/openbox/screen.c b/openbox/screen.c index 4b551b7e..49d3d22d 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -1,5 +1,6 @@ #include "openbox.h" #include "prop.h" +#include "config.h" #include "screen.h" #include "client.h" #include "frame.h" @@ -148,13 +149,23 @@ gboolean screen_annex() void screen_startup() { + GSList *it; + screen_desktop_names = g_ptr_array_new(); /* get the initial size */ screen_resize(); + /* set the names */ + for (it = config_desktops_names; it; it = it->next) + g_ptr_array_add(screen_desktop_names, it->data); /* dont strdup */ + PROP_SETSA(ob_root, net_desktop_names, utf8, screen_desktop_names); + g_ptr_array_set_size(screen_desktop_names, 0); /* rm the ptrs so they dont + get frees when we + update the desktop + names */ screen_num_desktops = 0; - screen_set_num_desktops(4); + screen_set_num_desktops(config_desktops_num); screen_desktop = 0; screen_set_desktop(0);