]> Dogcows Code - chaz/openbox/commitdiff
move config option loading for the kernel into config.c/h
authorDana Jansens <danakj@orodu.net>
Tue, 8 Apr 2003 07:31:26 +0000 (07:31 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 8 Apr 2003 07:31:26 +0000 (07:31 +0000)
add options for the number of desktops and the names of the desktops

14 files changed:
build/Makefile.kernel
engines/openbox/obengine.c
engines/openbox/obtheme.c
openbox/client.c
openbox/config.c [new file with mode: 0644]
openbox/config.h [new file with mode: 0644]
openbox/engine.c
openbox/engine.h
openbox/event.c
openbox/focus.c
openbox/focus.h
openbox/openbox.c
openbox/prop.c
openbox/screen.c

index c539dbf92f36ad9fbbee725aedfb0fd782882df0..7adfdfec4c8fa0b9d2f903267d214e7b7dffe60b 100644 (file)
@@ -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
index 843a69887185aca30eba88a7dc877374c52e7384..75396c8a6ca5b4c4a569ba38b34d82fe597d4763 100644 (file)
@@ -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 <sys/stat.h>
@@ -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;
index f7e7941d854ae1e4b7a21aeb9846894e110d74d4..533559f9af4edb5900e13c2fe13d12109bc21a28 100644 (file)
@@ -1,6 +1,6 @@
 #include "obengine.h"
 #include "kernel/openbox.h"
-#include "kernel/engine.h"
+#include "kernel/config.h"
 
 #include <glib.h>
 #include <X11/Xlib.h>
@@ -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;
 
index 7fca4796bbdb838c6060ed79774b60701c84f327..af24d921dad7b9dcb01e4e8e6f262f41f992e5c4 100644 (file)
@@ -10,6 +10,7 @@
 #include "stacking.h"
 #include "dispatch.h"
 #include "group.h"
+#include "config.h"
 
 #include <glib.h>
 #include <X11/Xutil.h>
@@ -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 (file)
index 0000000..1225590
--- /dev/null
@@ -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 (file)
index 0000000..0dceb92
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __config_h
+#define __config_h
+
+#include <glib.h>
+
+/*! 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
index 66d305805a155c48f137a4e6c1c5321899edfb8d..53e10debebf80701741ae03f7cba282a43e2063e 100644 (file)
@@ -1,5 +1,5 @@
 #include "engine.h"
-#include "parse.h"
+#include "config.h"
 
 #include <glib.h>
 #include <gmodule.h>
@@ -7,14 +7,6 @@
 #  include <stdlib.h>
 #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);
index 0180e3e56182f54fe720a0acd3ba6a713a2a1588..e2c314a67752faffc4472565949f2574d14abc81 100644 (file)
@@ -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();
index 04174af087297e4067e7e6aa15489f5f1a2d203e..edd6f4cee6db81d63a47e83063931fa9a5e149d1 100644 (file)
@@ -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);
index 8afbdcb6f6fc942569679db9e6701d5b03c6f4f4..7542fae66577bccd1184ad510f3fc285d0ce688b 100644 (file)
@@ -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;
     }
 
index 3ad606820ebe04f9102e75e3da9b6332f555bf2c..d7f0183e901e6db88fb9ee96518ad5ecbe1f8064 100644 (file)
@@ -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();
 
index 74f8164c840a0f39ef811dcba6d2a9feee84ee8e..c4784aff5ef96dab4a887c173998e51fbf5cffa3 100644 (file)
@@ -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();
index 9a4485006506e48bfdf69ef5adf630aa500a6ecc..97f5fb94b7832059dbc28547be71da3176af4ffc 100644 (file)
@@ -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);
index 4b551b7e808c3a6d9efec3e12fdc1b11129dfa52..49d3d22d46316c5b7a7d0f266010c84cf1cbd03b 100644 (file)
@@ -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);
 
This page took 0.048815 seconds and 4 git commands to generate.