change how rc parsing will work. a=b will be parsed in any [section] and given to...
authorDana Jansens <danakj@orodu.net>
Sat, 5 Apr 2003 20:27:03 +0000 (20:27 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 5 Apr 2003 20:27:03 +0000 (20:27 +0000)
26 files changed:
build/Makefile.kernel
engines/openbox/obengine.c
engines/openbox/obengine.h
engines/openbox/obtheme.c
openbox/action.c
openbox/action.h
openbox/client.c
openbox/client.h
openbox/config.c [deleted file]
openbox/config.h [deleted file]
openbox/engine.c
openbox/engine.h
openbox/event.c
openbox/focus.c
openbox/focus.h
openbox/openbox.c
openbox/parse.c
openbox/parse.h
openbox/parse.l
openbox/parse.y
openbox/screen.c
plugins/keyboard/keyboard.c
plugins/mouse/mouse.c
plugins/placement/history.c
plugins/placement/placement.c
plugins/resistance.c

index 4860260..71492d8 100644 (file)
@@ -8,7 +8,7 @@ LIBS += $(GLIB_LIBS) $(GMODULE_LIBS) $(XFT_LIBS)
 LDFLAGS = -export-dynamic
 
 target = openbox3
-sources = action.c client.c config.c dispatch.c engine.c event.c \
+sources = action.c client.c dispatch.c engine.c event.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 4dda711..bad7b51 100644 (file)
@@ -1,10 +1,10 @@
 #include "obtheme.h"
 #include "obrender.h"
 #include "obengine.h"
-#include "../../kernel/openbox.h"
-#include "../../kernel/extensions.h"
-#include "../../kernel/dispatch.h"
-#include "../../kernel/config.h"
+#include "kernel/openbox.h"
+#include "kernel/extensions.h"
+#include "kernel/dispatch.h"
+#include "kernel/engine.h"
 
 #ifdef HAVE_SYS_STAT_H
 #  include <sys/stat.h>
@@ -34,9 +34,6 @@ color_rgb *ob_s_titlebut_focused_color;
 color_rgb *ob_s_titlebut_unfocused_color;
 /* style settings - fonts */
 int ob_s_winfont_height;
-int ob_s_winfont_shadow;
-int ob_s_winfont_shadow_offset;
-int ob_s_winfont_shadow_tint;
 ObFont *ob_s_winfont;
 /* style settings - masks */
 pixmap_mask *ob_s_max_set_mask;
@@ -694,16 +691,12 @@ static void layout_title(ObFrame *self)
     char *lc;
     int x;
     gboolean n, d, i, l, m, c, s;
-    ConfigValue layout;
 
     n = d = i = l = m = c = s = FALSE;
 
-    if (!config_get("titlebar.layout", Config_String, &layout))
-        g_assert_not_reached();
-
     /* figure out whats being shown, and the width of the label */
     self->label_width = self->width - (ob_s_bevel + 1) * 2;
-    for (lc = layout.string; *lc != '\0'; ++lc) {
+    for (lc = engine_layout; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
            if (!(self->frame.client->decorations & Decor_Icon)) break;
@@ -761,7 +754,7 @@ static void layout_title(ObFrame *self)
     if (!c) XUnmapWindow(ob_display, self->close);
 
     x = ob_s_bevel + 1;
-    for (lc = layout.string; *lc != '\0'; ++lc) {
+    for (lc = engine_layout; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
            if (!n) break;
index b4e4698..2a879b7 100644 (file)
@@ -28,9 +28,6 @@ extern color_rgb *ob_s_titlebut_focused_color;
 extern color_rgb *ob_s_titlebut_unfocused_color;
 
 extern int ob_s_winfont_height;
-extern int ob_s_winfont_shadow;
-extern int ob_s_winfont_shadow_offset;
-extern int ob_s_winfont_shadow_tint;
 extern ObFont *ob_s_winfont;
 
 extern pixmap_mask *ob_s_max_set_mask;
index 3f45c20..59c1b45 100644 (file)
@@ -1,6 +1,6 @@
 #include "obengine.h"
-#include "../../kernel/config.h"
-#include "../../kernel/openbox.h"
+#include "kernel/openbox.h"
+#include "kernel/engine.h"
 
 #include <glib.h>
 #include <X11/Xlib.h>
@@ -115,14 +115,11 @@ static gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value)
     int hx, hy; /* ignored */
     unsigned int w, h;
     unsigned char *b;
-    ConfigValue theme;
   
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
-        if (!config_get("theme", Config_String, &theme))
-            g_assert_not_reached(); /* where's the default!? its not set? */
 
-       button_dir = g_strdup_printf("%s_buttons", theme.string);
+       button_dir = g_strdup_printf("%s_buttons", engine_theme);
 
         s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
                              "openbox", button_dir, retvalue.addr, NULL);
@@ -139,8 +136,8 @@ static gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value)
                 char *themename;
 
                 g_free(s);
-                themename = g_path_get_basename(theme.string);
-                s = g_strdup_printf("%s_buttons/%s", theme.string,
+                themename = g_path_get_basename(engine_theme);
+                s = g_strdup_printf("%s_buttons/%s", engine_theme,
                                     themename);
                 g_free(themename);
                 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) ==
@@ -277,12 +274,11 @@ gboolean obtheme_load()
     XrmDatabase db = NULL;
     Justify winjust;
     char *winjuststr;
-    ConfigValue theme, shadow, offset, font, tint;
 
-    if (config_get("theme", Config_String, &theme)) {
-       db = loaddb(theme.string);
+    if (engine_theme) {
+       db = loaddb(engine_theme);
         if (db == NULL) {
-           g_warning("Failed to load the theme '%s'", theme.string);
+           g_warning("Failed to load the theme '%s'", engine_theme);
            g_message("Falling back to the default: '%s'", DEFAULT_THEME);
        }
     }
@@ -292,31 +288,16 @@ gboolean obtheme_load()
            g_warning("Failed to load the theme '%s'.", DEFAULT_THEME);
            return FALSE;
        }
-        /* change to reflect what was actually loaded */
-        theme.string = DEFAULT_THEME;
-        config_set("theme", Config_String, theme);
+        /* set it to what was loaded */
+        g_free(engine_theme);
+        engine_theme = g_strdup(DEFAULT_THEME);
     }
 
     /* load the font, not from the theme file tho, its in the config */
 
-    if (!config_get("font.shadow", Config_Bool, &shadow))
-        g_assert_not_reached();
-    ob_s_winfont_shadow = shadow.bool;
-    if (!config_get("font.shadow.offset", Config_Integer, &offset))
-        g_assert_not_reached();
-    ob_s_winfont_shadow_offset = offset.integer;
-    if (!config_get("font.shadow.tint", Config_Integer, &tint))
-        g_assert_not_reached();
-    /* XXX put these checks into the config system somehow!!! */
-    if (tint.integer < -100) tint.integer = -100;
-    if (tint.integer > 100) tint.integer = 100;
-    config_set("font.shadow.tint", Config_Integer, tint);
-    ob_s_winfont_shadow_tint = tint.integer;
-    if (!config_get("font", Config_String, &font))
-        g_assert_not_reached();
-    ob_s_winfont = font_open(font.string);
-    ob_s_winfont_height = font_height(ob_s_winfont, ob_s_winfont_shadow,
-                                      ob_s_winfont_shadow_offset);
+    ob_s_winfont = font_open(engine_font);
+    ob_s_winfont_height = font_height(ob_s_winfont, engine_shadow,
+                                      engine_shadow_offset);
 
     winjust = Justify_Left;
     if (read_string(db, "window.justify", &winjuststr)) {
@@ -492,19 +473,17 @@ 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 = ob_s_winfont_shadow;
-    ob_a_focused_label->texture[0].data.text.offset =
-        ob_s_winfont_shadow_offset;
-    ob_a_focused_label->texture[0].data.text.tint = ob_s_winfont_shadow_tint;
+    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.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 = ob_s_winfont_shadow;
-    ob_a_unfocused_label->texture[0].data.text.offset =
-        ob_s_winfont_shadow_offset;
-    ob_a_unfocused_label->texture[0].data.text.tint = ob_s_winfont_shadow_tint;
+    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.color =
         ob_s_title_unfocused_color;
 
index 7e0321b..0e41e2e 100644 (file)
@@ -157,9 +157,16 @@ Action *action_from_string(char *name)
         a = action_new(action_restart);
     } else if (!g_ascii_strcasecmp(name, "exit")) {
         a = action_new(action_exit);
-    }
-    else if (!g_ascii_strcasecmp(name, "showmenu")) {
+    } else if (!g_ascii_strcasecmp(name, "showmenu")) {
         a = action_new(action_showmenu);
+    } else if (!g_ascii_strcasecmp(name, "nextwindowlinear")) {
+        a = action_new(action_cycle_windows);
+        a->data.cycle.linear = TRUE;
+        a->data.cycle.forward = TRUE;
+    } else if (!g_ascii_strcasecmp(name, "previouswindowlinear")) {
+        a = action_new(action_cycle_windows);
+        a->data.cycle.linear = TRUE;
+        a->data.cycle.forward = FALSE;
     }
     
     return a;
@@ -655,3 +662,27 @@ void action_showmenu(union ActionData *data)
 {
     g_message(__FUNCTION__);
 }
+
+void action_cycle_windows(union ActionData *data)
+{
+    if (data->cycle.linear) {
+        if (!data->cycle.final) {
+            GList *it, *start;
+
+            start = it = g_list_find(client_list, data->cycle.c);
+            do {
+                if (data->cycle.forward) {
+                    it = it->next;
+                    if (it == NULL) it = client_list;
+                } else {
+                    it = it->prev;
+                    if (it == NULL) it = g_list_last(client_list);
+                }
+                if (client_focus(it->data))
+                    break;
+            } while (it != start);
+        }
+    } else {
+    }
+}
+
index 9c204e3..0fe42f6 100644 (file)
@@ -65,7 +65,14 @@ struct Resize {
 
 struct ShowMenu {
     Client *c;
-    char * menuName;
+    char *menuName;
+};
+
+struct CycleWindows {
+    Client *c;
+    gboolean linear;
+    gboolean forward;
+    gboolean final;
 };
 
 union ActionData {
@@ -80,6 +87,7 @@ union ActionData {
     struct Move move;
     struct Resize resize;
     struct ShowMenu showMenu;
+    struct CycleWindows cycle;
 };
 
 typedef struct {
@@ -194,4 +202,6 @@ void action_restart(union ActionData *data);
 void action_exit(union ActionData *data);
 /* ShowMenu */
 void action_showmenu(union ActionData *data);
+/* CycleWindows */
+void action_cycle_windows(union ActionData *data);
 #endif
index 1df411e..36ca352 100644 (file)
@@ -2,7 +2,6 @@
 #include "screen.h"
 #include "prop.h"
 #include "extensions.h"
-#include "config.h"
 #include "frame.h"
 #include "engine.h"
 #include "event.h"
@@ -21,7 +20,7 @@
 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
                                ButtonMotionMask)
 
-GSList     *client_list      = NULL;
+GList      *client_list      = NULL;
 GHashTable *client_map       = NULL;
 
 static Window *client_startup_stack_order = NULL;
@@ -65,8 +64,8 @@ void client_shutdown()
 void client_set_list()
 {
     Window *windows, *win_it;
-    GSList *it;
-    guint size = g_slist_length(client_list);
+    GList *it;
+    guint size = g_list_length(client_list);
 
     /* create an array of the window ids */
     if (size > 0) {
@@ -87,7 +86,6 @@ void client_set_list()
 
 void client_manage_all()
 {
-    ConfigValue focus_new;
     unsigned int i, j, nchild;
     Window w, *children;
     XWMHints *wmhints;
@@ -138,9 +136,7 @@ void client_manage_all()
     client_startup_stack_order = NULL;
     client_startup_stack_size = 0;
 
-    if (!config_get("focusNew", Config_Bool, &focus_new))
-        g_assert_not_reached();
-    if (focus_new.bool)
+    if (focus_new)
         focus_fallback(FALSE);
 }
 
@@ -152,7 +148,6 @@ void client_manage(Window window)
     XSetWindowAttributes attrib_set;
 /*    XWMHints *wmhint; */
     guint i;
-    ConfigValue focus_new;
 
     grab_server(TRUE);
 
@@ -215,7 +210,7 @@ void client_manage(Window window)
 
     grab_server(FALSE);
      
-    client_list = g_slist_append(client_list, client);
+    client_list = g_list_append(client_list, client);
     stacking_list = g_list_append(stacking_list, client);
     g_assert(!g_hash_table_lookup(client_map, &client->window));
     g_hash_table_insert(client_map, &client->window, client);
@@ -239,9 +234,7 @@ void client_manage(Window window)
 
     dispatch_client(Event_Client_Mapped, client, 0, 0);
 
-    if (!config_get("focusNew", Config_Bool, &focus_new))
-        g_assert_not_reached();
-    if (ob_state != State_Starting && focus_new.bool)
+    if (ob_state != State_Starting && focus_new)
         client_focus(client);
 
     /* update the list hints */
@@ -275,7 +268,7 @@ void client_unmanage(Client *client)
 
     engine_frame_hide(client->frame);
 
-    client_list = g_slist_remove(client_list, client);
+    client_list = g_list_remove(client_list, client);
     stacking_list = g_list_remove(stacking_list, client);
     g_hash_table_remove(client_map, &client->window);
 
@@ -1708,7 +1701,6 @@ void client_kill(Client *self)
 void client_set_desktop(Client *self, guint target, gboolean donthide)
 {
     guint old, i;
-    ConfigValue focus_new;
 
     if (target == self->desktop) return;
   
@@ -1730,8 +1722,6 @@ void client_set_desktop(Client *self, guint target, gboolean donthide)
     screen_update_struts();
 
     /* update the focus lists */
-    if (!config_get("focusNew", Config_Bool, &focus_new))
-        g_assert_not_reached();
     if (old == DESKTOP_ALL) {
         for (i = 0; i < screen_num_desktops; ++i)
             focus_order[i] = g_list_remove(focus_order[i], self);
@@ -1739,13 +1729,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.bool)
+            if (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.bool)
+        if (focus_new)
             focus_order[target] = g_list_prepend(focus_order[target], self);
         else
             focus_order[target] = g_list_append(focus_order[target], self);
index 2838535..94bcf38 100644 (file)
@@ -285,7 +285,7 @@ typedef struct Client {
     Pixmap pixmap_icon_mask;
 } Client;
 
-extern GSList *client_list;
+extern GList *client_list;
 extern GHashTable *client_map;
 
 void client_startup();
diff --git a/openbox/config.c b/openbox/config.c
deleted file mode 100644 (file)
index a6056ee..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-#include "config.h"
-
-#ifdef HAVE_STDIO_H
-#  include <stdio.h>
-#endif
-
-static void config_free_entry(ConfigEntry *entry);
-static void config_set_entry(char *name, ConfigValueType type,
-                             ConfigValue value);
-static void config_def_free(ConfigDefEntry *entry);
-
-static GData *config = NULL;
-static GData *config_def = NULL;
-
-/* provided by cparse.l */
-void cparse_go(char *filename, FILE *);
-
-
-void config_startup()
-{
-    ConfigValue val;
-
-    /* set up options exported by the kernel */
-    config_def_set(config_def_new("engine", Config_String,
-                                  "Engine",
-                                  "The name of the theming engine to be used "
-                                  "to decorate windows."));
-
-    config_def_set(config_def_new("theme", Config_String,
-                                  "Theme",
-                                  "The name of the theme to load with the "
-                                  "chosen engine."));
-
-    config_def_set(config_def_new("font", Config_String,
-                                  "Titlebar Font",
-                                  "The fontstring specifying the font to "
-                                  "be used in window titlebars."));
-    val.string = "Sans-7";
-    config_set("font", Config_String, val);
-
-    config_def_set(config_def_new("font.shadow", Config_Bool,
-                                  "Titlebar Font Shadow",
-                                  "Whether or not the text in the window "
-                                  "titlebars gets a drop shadow."));
-    val.bool = FALSE;
-    config_set("font.shadow", Config_Bool, val);
-
-    config_def_set(config_def_new("font.shadow.offset", Config_Integer,
-                                  "Titlebar Font Shadow Offset",
-                                  "The offset of the drop shadow for text "
-                                  "in the window titlebars."));
-    val.integer = 1;
-    config_set("font.shadow.offset", Config_Integer, val);
-
-    config_def_set(config_def_new("font.shadow.tint", Config_Integer,
-                                  "Titlebar Font Shadow Tint",
-                                  "The percentage of tint/opacity to give the "
-                                  "the shadow(from -100(white) to "
-                                  "100(black))."));
-    val.integer = 25;
-    config_set("font.shadow.tint", Config_Integer, val);
-
-    config_def_set(config_def_new("titlebar.layout", Config_String,
-                                  "Titlebar Layout",
-                                  "The ordering of the elements in the "
-                                  "window titlebars."));
-    val.string = "NDSLIMC";
-    config_set("titlebar.layout", Config_String, val);
-
-    config_def_set(config_def_new("focusNew", Config_Bool,
-                                  "Focus New Windows",
-                                  "Focus windows when they first appear."));
-    val.bool = TRUE;
-    config_set("focusNew", Config_Bool, val);
-
-    config_def_set(config_def_new("focusFollowsMouse", Config_Bool,
-                                  "Focus Follows Mouse",
-                                  "Focus windows when the mouse pointer "
-                                  "enters them."));
-    val.bool = TRUE;
-    config_set("focusFollowsMouse", Config_Bool, val);
-}
-
-void config_shutdown()
-{
-    g_datalist_clear(&config);
-    g_datalist_clear(&config_def);
-}
-
-gboolean config_set(char *name, ConfigValueType type, ConfigValue value)
-{
-    ConfigDefEntry *def;
-    gboolean ret = FALSE;
-
-    name = g_ascii_strdown(name, -1);
-
-    def = g_datalist_get_data(&config_def, name);
-
-    if (def == NULL) {
-        g_warning("Invalid config option '%s'", name);
-    } else {
-        if (def->hasList) {
-            gboolean found = FALSE;
-            GSList *it;
-
-            it = def->values;
-            g_assert(it != NULL);
-            do {
-                if (g_ascii_strcasecmp(it->data, value.string) == 0) {
-                    found = TRUE;
-                    break;
-                }
-            } while ((it = it->next));
-
-            if (!found)
-                g_warning("Invalid value '%s' for config option '%s'",
-                          value.string, name);
-            else
-                ret = TRUE;
-        } else if (type != def->type) {
-            g_warning("Incorrect type of value for config option '%s'", name);
-        } else
-            ret = TRUE;
-
-    }
-
-    if (ret)
-        config_set_entry(name, type, value);
-    else
-        g_free(name);
-
-    return ret;
-}
-
-gboolean config_get(char *name, ConfigValueType type, ConfigValue *value)
-{
-    ConfigEntry *entry;
-    gboolean ret = FALSE;
-
-    name = g_ascii_strdown(name, -1);
-    entry = g_datalist_get_data(&config, name);
-    if (entry != NULL && entry->type == type) {
-        *value = entry->value;
-        ret = TRUE;
-    }
-    g_free(name);
-    return ret;
-}
-
-static void config_set_entry(char *name, ConfigValueType type,
-                             ConfigValue value)
-{
-    ConfigEntry *entry = NULL;
-
-    entry = g_new(ConfigEntry, 1);
-    entry->name = name;
-    entry->type = type;
-    if (type == Config_String)
-        entry->value.string = g_strdup(value.string);
-    else
-        entry->value = value;
-
-    g_datalist_set_data_full(&config, name, entry,
-                             (GDestroyNotify)config_free_entry);
-}
-
-static void config_free_entry(ConfigEntry *entry)
-{
-    g_free(entry->name);
-    entry->name = NULL;
-    if(entry->type == Config_String) {
-        g_free(entry->value.string);
-        entry->value.string = NULL;
-    }
-    g_free(entry);
-}
-
-ConfigDefEntry *config_def_new(char *name, ConfigValueType type,
-                                char *descriptive_name, char *long_description)
-{
-    ConfigDefEntry *entry;
-
-    entry = g_new(ConfigDefEntry, 1);
-    entry->name = g_ascii_strdown(name, -1);
-    entry->descriptive_name = g_strdup(descriptive_name);
-    entry->long_description = g_strdup(long_description);
-    entry->hasList = FALSE;
-    entry->type = type;
-    entry->values = NULL;
-    return entry;
-}
-
-static void config_def_free(ConfigDefEntry *entry)
-{
-    GSList *it;
-
-    g_free(entry->name);
-    g_free(entry->descriptive_name);
-    g_free(entry->long_description);
-    if (entry->hasList) {
-        for (it = entry->values; it != NULL; it = it->next)
-            g_free(it->data);
-        g_slist_free(entry->values);
-    }
-    g_free(entry);
-}
-
-gboolean config_def_add_value(ConfigDefEntry *entry, char *value)
-{
-    if (entry->type != Config_String) {
-        g_warning("Tried adding value to non-string config definition");
-        return FALSE;
-    }
-
-    entry->hasList = TRUE;
-    entry->values = g_slist_append(entry->values, g_ascii_strdown(value, -1));
-    return TRUE;
-}
-
-gboolean config_def_set(ConfigDefEntry *entry)
-{
-    gboolean ret = FALSE;
-    ConfigDefEntry *def;
-
-    if ((def = g_datalist_get_data(&config_def, entry->name))) {
-        g_assert(def != entry); /* adding it twice!? */
-        g_warning("Definition already set for config option '%s'. ",
-                  entry->name);
-        config_def_free(entry);
-    } else {
-        g_datalist_set_data_full(&config_def, entry->name, entry,
-                                 (GDestroyNotify)config_def_free);
-        ret = TRUE;
-    }
-
-    return ret;
-}
diff --git a/openbox/config.h b/openbox/config.h
deleted file mode 100644 (file)
index 3d82090..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __config_h
-#define __config_h
-
-#include <glib.h>
-
-typedef enum {
-    Config_String,
-    Config_Integer,
-    Config_Bool
-} ConfigValueType;
-
-typedef union {
-    char *string;
-    int integer;
-    gboolean bool;
-} ConfigValue;
-
-typedef struct {
-    char *name;
-    ConfigValueType type;
-    ConfigValue value;
-} ConfigEntry;
-
-typedef struct {
-    char *name;
-    char *descriptive_name; /* user friendly name */
-    char *long_description; /* text description of option */
-    ConfigValueType type;
-    /* if it is a string type optionally provide a list of valid strings */
-    gboolean hasList;
-    GSList *values;
-} ConfigDefEntry;
-
-void config_startup();
-void config_shutdown();
-
-/* Set a config variable's value. The variable must have already been defined
-   with a call to config_def_set */
-gboolean config_set(char *name, ConfigValueType type, ConfigValue value);
-
-/* Get a config variable's value. Returns FALSE if the value has not been
-   set. */
-gboolean config_get(char *name, ConfigValueType type, ConfigValue *value);
-
-/* Create a new config definition to add to the config system */
-ConfigDefEntry *config_def_new(char *name, ConfigValueType type,
-                               char *descriptive_name, char *long_description);
-
-/* Add a value to a String type config definition */
-gboolean config_def_add_value(ConfigDefEntry *entry, char *value);
-
-/* Sets up the definition in the config system, Don't free or touch the entry
-   after setting it with this. It is invalidated even if the function returns
-   FALSE. */
-gboolean config_def_set(ConfigDefEntry *entry);
-
-#endif
index c654d26..0ede97f 100644 (file)
@@ -1,5 +1,4 @@
 #include "engine.h"
-#include "config.h"
 
 #include <glib.h>
 #include <gmodule.h>
@@ -7,9 +6,17 @@
 #  include <stdlib.h>
 #endif
 
-static GModule *module;
-static EngineStartup *estartup;
-static EngineShutdown *eshutdown;
+char *engine_name = NULL;
+char *engine_theme = NULL;
+char *engine_layout = "NDSLIMC";
+char *engine_font = "Sans-7";
+gboolean engine_shadow = FALSE;
+int engine_shadow_offset = 1;
+int engine_shadow_tint = 25;
+
+static GModule *module = NULL;
+static EngineStartup *estartup = NULL;
+static EngineShutdown *eshutdown = NULL;
 
 #define LOADSYM(name, var) \
     if (!g_module_symbol(module, #name, (gpointer*)&var)) { \
@@ -61,16 +68,15 @@ static gboolean load(char *name)
 
 void engine_startup()
 {
-    ConfigValue engine;
-
     module = NULL;
+}
 
-    if (config_get("engine", Config_String, &engine)) {
-       if (load(engine.string))
-           return;
-       g_warning("Failed to load the engine '%s'", engine.string);
-       g_message("Falling back to the default: '%s'", DEFAULT_ENGINE);
-    }
+void engine_load()
+{
+    if (load(engine_name))
+        return;
+    g_warning("Failed to load the engine '%s'", engine_name);
+    g_message("Falling back to the default: '%s'", DEFAULT_ENGINE);
     if (!load(DEFAULT_ENGINE)) {
        g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE);
        exit(1);
@@ -79,6 +85,7 @@ void engine_startup()
 
 void engine_shutdown()
 {
+    g_free(engine_name);
     if (module != NULL) {
        eshutdown();
        g_module_close(module);
index 0ab578c..76bb149 100644 (file)
@@ -3,7 +3,23 @@
 
 #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();
 
 EngineFrameNew *engine_frame_new;
index 2d14451..79befa6 100644 (file)
@@ -1,6 +1,5 @@
 #include "openbox.h"
 #include "client.h"
-#include "config.h"
 #include "xerror.h"
 #include "prop.h"
 #include "screen.h"
@@ -356,7 +355,6 @@ static void event_handle_client(Client *client, XEvent *e)
     XEvent ce;
     Atom msgtype;
     int i=0;
-    ConfigValue focus_follow;
      
     switch (e->type) {
     case FocusIn:
@@ -378,12 +376,8 @@ static void event_handle_client(Client *client, XEvent *e)
                                                      client);
                 focus_order[desktop] = g_list_prepend(focus_order[desktop],
                                                       client);
-            } else {
-                if (!config_get("focusFollowsMouse",Config_Bool,&focus_follow))
-                    g_assert_not_reached();
-                if (focus_follow.bool)
-                    client_focus(client);
-            }
+            } else if (focus_follow)
+                client_focus(client);
         }
         break;
     case ConfigureRequest:
index 1c5d2c7..b676c12 100644 (file)
@@ -1,5 +1,4 @@
 #include "event.h"
-#include "config.h"
 #include "openbox.h"
 #include "client.h"
 #include "frame.h"
@@ -16,6 +15,8 @@ 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 = TRUE;
 
 void focus_startup()
 {
@@ -25,6 +26,8 @@ void focus_startup()
     XSetWindowAttributes attrib;
 
     focus_client = NULL;
+    focus_new = TRUE;
+    focus_follow = TRUE;
 
     attrib.override_redirect = TRUE;
     focus_backup = XCreateWindow(ob_display, ob_root,
@@ -113,7 +116,6 @@ static gboolean focus_under_pointer()
 
 void focus_fallback(gboolean switching_desks)
 {
-    ConfigValue focus_follow;
     GList *it;
     gboolean under = FALSE;
     Client *old = NULL;
@@ -130,9 +132,7 @@ void focus_fallback(gboolean switching_desks)
         /* don't skip any windows when switching desktops */
         old = NULL;
     } else {
-        if (!config_get("focusFollowsMouse", Config_Bool, &focus_follow))
-            g_assert_not_reached();
-        if (focus_follow.bool)
+        if (focus_follow)
             under = focus_under_pointer();
     }
 
index af95015..8a511cf 100644 (file)
@@ -15,6 +15,11 @@ 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;
+/*! Should focus follow the mouse pointer */
+extern gboolean focus_follow;
+
 void focus_startup();
 void focus_shutdown();
 
index e2a4de3..9075609 100644 (file)
@@ -7,7 +7,6 @@
 #include "screen.h"
 #include "focus.h"
 #include "extensions.h"
-#include "config.h"
 #include "parse.h"
 #include "grab.h"
 #include "engine.h"
@@ -149,11 +148,11 @@ int main(int argc, char **argv)
 
     if (screen_annex()) { /* it will be ours! */
        timer_startup();
-        config_startup();
        render_startup();
        font_startup();
        event_startup();
         grab_startup();
+        engine_startup();
         plugin_startup();
 
         /* startup the parsing so plugins can register sections of the rc */
@@ -167,7 +166,9 @@ int main(int argc, char **argv)
         /* we're done with parsing now, kill it */
         parse_shutdown();
 
-       engine_startup();
+        /* load the engine specified in the rc */
+       engine_load();
+
        screen_startup();
        focus_startup();
        client_startup();
@@ -193,7 +194,6 @@ int main(int argc, char **argv)
         grab_shutdown();
        event_shutdown();
        render_shutdown();
-        config_shutdown();
        timer_shutdown();
     }
 
index 80a918c..a72cfd8 100644 (file)
@@ -1,20 +1,18 @@
 #include "parse.h"
-#include "config.h"
 
-static GHashTable *reg = NULL;
-static ParseFunc func = NULL;
+static GHashTable     *reg = NULL;
 
-/* parse tokens from the [openbox] section of the rc file */
-static void parse_rc_token(ParseToken *token);
+struct Functions {
+    ParseFunc       func;
+    AssignParseFunc afunc;
+} *funcs;
 
-void destkey(gpointer key) { g_free(key); }
+void destshit(gpointer key) { g_free(key); }
 
 void parse_startup()
 {
-    reg = g_hash_table_new_full(g_str_hash, g_str_equal, destkey, NULL);
-    func = NULL;
-
-    parse_reg_section("openbox", parse_rc_token);
+    reg = g_hash_table_new_full(g_str_hash, g_str_equal, destshit, destshit);
+    funcs = NULL;
 }
 
 void parse_shutdown()
@@ -22,13 +20,17 @@ void parse_shutdown()
     g_hash_table_destroy(reg);
 }
 
-void parse_reg_section(char *section, ParseFunc func)
+void parse_reg_section(char *section, ParseFunc func, AssignParseFunc afunc)
 {
     if (g_hash_table_lookup(reg, section) != NULL)
         g_warning("duplicate request for section '%s' in the rc file",
                   section);
-    else
-        g_hash_table_insert(reg, g_ascii_strdown(section, -1), (void*)func);
+    else {
+        struct Functions *f = g_new(struct Functions, 1);
+        f->func = func;
+        f->afunc = afunc;
+        g_hash_table_insert(reg, g_ascii_strdown(section, -1), f);
+    }
 }
 
 void parse_free_token(ParseToken *token)
@@ -54,7 +56,6 @@ void parse_free_token(ParseToken *token)
     case TOKEN_BOOL:
     case TOKEN_LBRACE:
     case TOKEN_RBRACE:
-    case TOKEN_EQUALS:
     case TOKEN_COMMA:
     case TOKEN_NEWLINE:
         break;
@@ -63,82 +64,25 @@ void parse_free_token(ParseToken *token)
 
 void parse_set_section(char *section)
 {
-    func = (ParseFunc)g_hash_table_lookup(reg, section);
+    funcs = g_hash_table_lookup(reg, section);
 }
 
 void parse_token(ParseToken *token)
 {
-    if (func != NULL)
-        func(token);
+    if (funcs) {
+        if (funcs->func != NULL)
+            funcs->func(token);
+        else if (token->type != TOKEN_NEWLINE)
+            yyerror("syntax error");
+    }
 }
 
-static void parse_rc_token(ParseToken *token)
+void parse_assign(char *name, ParseToken *value)
 {
-    static int got_eq = FALSE;
-    static ParseTokenType got_val = 0;
-    static char *id = NULL, *s = NULL;
-    static int i;
-    static gboolean b;
-
-    if (id == NULL) {
-        if (token->type == TOKEN_IDENTIFIER) {
-            id = token->data.identifier;
-            return;
-        } else {
-            yyerror("syntax error");
-        }
-    } else if (!got_eq) {
-        if (token->type == TOKEN_EQUALS) {
-            got_eq = TRUE;
-            return;
-        } else {
-            yyerror("syntax error");
-        }
-    } else if (!got_val) {
-        if (token->type == TOKEN_STRING) {
-            s = token->data.string;
-            got_val = token->type;
-            return;
-        } else if (token->type == TOKEN_BOOL) {
-            b = token->data.bool;
-            got_val = token->type;
-            return;
-        } else if (token->type == TOKEN_INTEGER) {
-            i = token->data.integer;
-            got_val = token->type;
-            return;
-        } else
+    if (funcs) {
+        if (funcs->afunc != NULL)
+            funcs->afunc(name, value);
+        else
             yyerror("syntax error");
-    } else if (token->type != TOKEN_NEWLINE) {
-        yyerror("syntax error");
-    } else {
-        ConfigValue v;
-
-        switch (got_val) {
-        case TOKEN_STRING:
-            v.string = s;
-            if (!config_set(id, Config_String, v))
-                yyerror("invalid value type");
-            break;
-        case TOKEN_BOOL:
-            v.bool = b;
-            if (!config_set(id, Config_Bool, v))
-                yyerror("invalid value type");
-            break;
-        case TOKEN_INTEGER:
-            v.integer = i;
-            if (!config_set(id, Config_Integer, v))
-                yyerror("invalid value type");
-            break;
-        default:
-            g_assert_not_reached(); /* unhandled type got parsed */
-        }
     }
-
-    g_free(id);
-    g_free(s);
-    id = s = NULL;
-    got_eq = FALSE;
-    got_val = 0;
-    parse_free_token(token);
 }
index bd6c03f..d77b692 100644 (file)
@@ -13,7 +13,6 @@ typedef enum {
     TOKEN_LIST,
     TOKEN_LBRACE     = '{',
     TOKEN_RBRACE     = '}',
-    TOKEN_EQUALS     = '=',
     TOKEN_COMMA      = ',',
     TOKEN_NEWLINE    = '\n'
 } ParseTokenType;
@@ -24,6 +23,7 @@ typedef struct {
 } ParseToken;
 
 typedef void (*ParseFunc)(ParseToken *token);
+typedef void (*AssignParseFunc)(char *name, ParseToken *value);
 
 void parse_startup();
 void parse_shutdown();
@@ -33,7 +33,7 @@ void parse_shutdown();
 */
 void parse_rc();
 
-void parse_reg_section(char *section, ParseFunc func);
+void parse_reg_section(char *section, ParseFunc func, AssignParseFunc afunc);
 
 
 /* Free a parsed token's allocated memory */
index 427a55c..4dcdc2c 100644 (file)
@@ -35,7 +35,7 @@ bool ([tT][rR][uU][eE]|[fF][aA][lL][sS][eE]|[yY][eE][sS]|[nN][oO]|[oO][nN]|[oO][
              }
 {identifier} { yylval.identifier = g_strdup(yytext); return IDENTIFIER; }
 [{}()\[\]=,] { yylval.character = *yytext; return *yytext; }
-\n           { yylval.character = *yytext; ++yylineno; return *yytext; }
+\n           { yylval.character = *yytext; return *yytext; }
 .            { return INVALID; }
 
 %%
index f8b0a04..125f180 100644 (file)
@@ -31,6 +31,7 @@ static ParseToken t;
 
 /* in parse.c */
 void parse_token(ParseToken *token);
+void parse_assign(char *name, ParseToken *token);
 void parse_set_section(char *section);
 %}
 
@@ -54,31 +55,32 @@ void parse_set_section(char *section);
 %%
 
 sections:
-  | sections '[' IDENTIFIER ']' { parse_set_section($3); } '\n' lines
+  | sections '[' IDENTIFIER ']' { parse_set_section($3); } '\n'
+    { ++yylineno; } lines
   ;
 
 lines:
-  | lines tokens '\n' { t.type = $3; t.data.character = $3; parse_token(&t); }
+  | lines tokens { t.type='\n'; t.data.character='\n'; parse_token(&t); } '\n'
+    { ++yylineno; }
+  | lines IDENTIFIER '=' listtoken { parse_assign($2, &t); } '\n'
+    { ++yylineno; }
   ;
 
 tokens:
-    tokens token
-  | token
+    tokens token { parse_token(&t); }
+  | token        { parse_token(&t); }
   ;
 
 token:
-    REAL       { t.type = TOKEN_REAL; t.data.real = $1; parse_token(&t); }
-  | INTEGER    { t.type = TOKEN_INTEGER; t.data.integer = $1;
-                 parse_token(&t); }
-  | STRING     { t.type = TOKEN_STRING; t.data.string = $1; parse_token(&t); }
-  | IDENTIFIER { t.type = TOKEN_IDENTIFIER; t.data.identifier = $1;
-                 parse_token(&t);}
-  | BOOL       { t.type = TOKEN_BOOL; t.data.bool = $1; parse_token(&t); }
-  | list       { t.type = TOKEN_LIST; t.data.list = $1; parse_token(&t); }
-  | '{'        { t.type = $1; t.data.character = $1; parse_token(&t); }
-  | '}'        { t.type = $1; t.data.character = $1; parse_token(&t); }
-  | '='        { t.type = $1; t.data.character = $1; parse_token(&t); }
-  | ','        { t.type = $1; t.data.character = $1; parse_token(&t); }
+    REAL       { t.type = TOKEN_REAL; t.data.real = $1; }
+  | INTEGER    { t.type = TOKEN_INTEGER; t.data.integer = $1; }
+  | STRING     { t.type = TOKEN_STRING; t.data.string = $1; }
+  | IDENTIFIER { t.type = TOKEN_IDENTIFIER; t.data.identifier = $1; }
+  | BOOL       { t.type = TOKEN_BOOL; t.data.bool = $1; }
+  | list       { t.type = TOKEN_LIST; t.data.list = $1; }
+  | '{'        { t.type = $1; t.data.character = $1; }
+  | '}'        { t.type = $1; t.data.character = $1; }
+  | ','        { t.type = $1; t.data.character = $1; }
   ;
 
 list:
@@ -107,7 +109,6 @@ listtoken:
   | list       { t.type = TOKEN_LIST; t.data.list = $1; }
   | '{'        { t.type = $1; t.data.character = $1; }
   | '}'        { t.type = $1; t.data.character = $1; }
-  | '='        { t.type = $1; t.data.character = $1; }
   | ','        { t.type = $1; t.data.character = $1; }
   ;
 
index 5cf2bc5..3145a63 100644 (file)
@@ -208,7 +208,7 @@ void screen_set_num_desktops(guint num)
 {
     guint i, old;
     gulong *viewport;
-    GSList *it;
+    GList *it;
 
     g_assert(num > 0);
 
@@ -424,7 +424,7 @@ void screen_install_colormap(Client *client, gboolean install)
 
 void screen_update_struts()
 {
-    GSList *it;
+    GList *it;
     guint i;
      
     g_free(strut);
@@ -496,7 +496,7 @@ static void screen_update_area()
 */
        if (!RECT_EQUAL(old_area, area[i])) {
            /* the area has changed, adjust all the maximized windows */
-           GSList *it;
+           GList *it;
            for (it = client_list; it; it = it->next) {
                Client *c = it->data;
                if (i < screen_num_desktops) {
index b0529e0..2233a04 100644 (file)
@@ -13,7 +13,7 @@
 
 void plugin_setup_config()
 {
-    parse_reg_section("keyboard", keyparse);
+    parse_reg_section("keyboard", keyparse, NULL);
 }
 
 KeyBindingTree *firstnode = NULL;
index 90c9242..27c536d 100644 (file)
@@ -6,7 +6,6 @@
 #include "kernel/frame.h"
 #include "kernel/grab.h"
 #include "kernel/engine.h"
-#include "kernel/config.h"
 #include "kernel/parse.h"
 #include "kernel/frame.h"
 #include "translate.h"
 #include "mouseparse.h"
 #include <glib.h>
 
+static int threshold;
+static int dclicktime;
+
+static void parse_assign(char *name, ParseToken *value)
+{
+    if (!g_ascii_strcasecmp(name, "dragthreshold")) {
+        if (value->type != TOKEN_INTEGER)
+            yyerror("invalid value");
+        else {
+            if (value->data.integer >= 0)
+                threshold = value->data.integer;
+        }
+    } else if (!g_ascii_strcasecmp(name, "doubleclicktime")) {
+        if (value->type != TOKEN_INTEGER)
+            yyerror("invalid value");
+        else {
+            if (value->data.integer >= 0)
+                dclicktime = value->data.integer;
+        }
+    } else
+        yyerror("invalid option");
+    parse_free_token(value);
+}
+
 void plugin_setup_config()
 {
-    config_def_set(config_def_new("mouse.dragThreshold", Config_Integer,
-                                  "Drag Threshold",
-                                  "The drag threshold in pixels before a Drag "
-                                  "event starts."));
-    config_def_set(config_def_new("mouse.doubleClickTime", Config_Integer,
-                                  "Double Click Interval",
-                                  "The amount of time (in milliseconds) in "
-                                  "which two clicks must occur to cause a "
-                                  "DoubleClick event."));
-
-    parse_reg_section("mouse", mouseparse);
+    threshold = 3;
+    dclicktime = 200;
+    parse_reg_section("mouse", mouseparse, parse_assign);
 }
 
 /* Array of GSList*s of PointerBinding*s. */
@@ -66,7 +81,7 @@ static void grab_for_client(Client *client, gboolean grab)
 
 static void grab_all_clients(gboolean grab)
 {
-    GSList *it;
+    GList *it;
 
     for (it = client_list; it != NULL; it = it->next)
        grab_for_client(it->data, grab);
@@ -192,17 +207,10 @@ static void event(ObEvent *e, void *foo)
     static guint button = 0, lbutton = 0;
     static gboolean drag = FALSE, drag_used = FALSE;
     static Corner corner = Corner_TopLeft;
-    ConfigValue doubleclicktime;
-    ConfigValue dragthreshold;
     gboolean click = FALSE;
     gboolean dclick = FALSE;
     Context context;
     
-    if (!config_get("mouse.dragThreshold", Config_Integer, &dragthreshold))
-        dragthreshold.integer = 3; /* default */
-    if (!config_get("mouse.doubleClickTime", Config_Integer, &doubleclicktime))
-        doubleclicktime.integer = 200; /* default */
-
     switch (e->type) {
     case Event_Client_Mapped:
         grab_for_client(e->data.c.client, TRUE);
@@ -273,8 +281,7 @@ static void event(ObEvent *e, void *foo)
                     click = TRUE;
                     /* double clicks happen if there were 2 in a row! */
                     if (lbutton == button &&
-                        e->data.x.e->xbutton.time - doubleclicktime.integer <=
-                        ltime) {
+                        e->data.x.e->xbutton.time - dclicktime <= ltime) {
                         dclick = TRUE;
                         lbutton = 0;
                     } else
@@ -304,8 +311,7 @@ static void event(ObEvent *e, void *foo)
             dx = e->data.x.e->xmotion.x_root - px;
             dy = e->data.x.e->xmotion.y_root - py;
             if (!drag &&
-                (ABS(dx) >= dragthreshold.integer ||
-                 ABS(dy) >= dragthreshold.integer))
+                (ABS(dx) >= threshold || ABS(dy) >= threshold))
                 drag = TRUE;
             if (drag) {
                 context = engine_get_context(e->data.x.client,
index fbfbf25..dfdcea2 100644 (file)
@@ -1,7 +1,7 @@
-#include "../../kernel/openbox.h"
-#include "../../kernel/dispatch.h"
-#include "../../kernel/frame.h"
-#include "../../kernel/client.h"
+#include "kernel/openbox.h"
+#include "kernel/dispatch.h"
+#include "kernel/frame.h"
+#include "kernel/client.h"
 #include <glib.h>
 #include <string.h>
 #ifdef HAVE_STDLIB_H
index 76b4552..23ffbb5 100644 (file)
@@ -1,24 +1,31 @@
-#include "../../kernel/dispatch.h"
-#include "../../kernel/client.h"
-#include "../../kernel/frame.h"
-#include "../../kernel/screen.h"
-#include "../../kernel/openbox.h"
-#include "../../kernel/config.h"
+#include "kernel/dispatch.h"
+#include "kernel/client.h"
+#include "kernel/frame.h"
+#include "kernel/screen.h"
+#include "kernel/openbox.h"
+#include "kernel/parse.h"
 #include "history.h"
 #include <glib.h>
 
-gboolean history = TRUE;
+static gboolean history;
+
+static void parse_assign(char *name, ParseToken *value)
+{
+    if  (!g_ascii_strcasecmp(name, "remember")) {
+        if (value->type != TOKEN_BOOL)
+            yyerror("invalid value");
+        else
+            history = value->data.bool;
+    } else
+        yyerror("invalid option");
+    parse_free_token(value);
+}
 
 void plugin_setup_config()
 {
-    ConfigValue val;
-
-    config_def_set(config_def_new("placement.remember", Config_Bool,
-                                  "Remember Window Positions",
-                                  "Place windows where they last were "
-                                  "positioned."));
-    val.bool = TRUE;
-    config_set("placement.remember", Config_Bool, val);
+    history = TRUE;
+
+    parse_reg_section("placement", NULL, parse_assign);
 }
 
 static void place_random(Client *c)
@@ -48,17 +55,12 @@ static void place_random(Client *c)
 
 static void event(ObEvent *e, void *foo)
 {
-    ConfigValue remember;
-
     g_assert(e->type == Event_Client_New);
 
     /* requested a position */
     if (e->data.c.client->positioned) return;
 
-    if (!config_get("placement.remember", Config_Bool, &remember))
-        g_assert_not_reached();
-
-    if (!remember.bool || !place_history(e->data.c.client))
+    if (!history || !place_history(e->data.c.client))
         place_random(e->data.c.client);
 }
 
index 6805631..29d5137 100644 (file)
@@ -1,29 +1,39 @@
-#include "../kernel/dispatch.h"
-#include "../kernel/client.h"
-#include "../kernel/frame.h"
-#include "../kernel/stacking.h"
-#include "../kernel/screen.h"
-#include "../kernel/config.h"
+#include "kernel/dispatch.h"
+#include "kernel/client.h"
+#include "kernel/frame.h"
+#include "kernel/parse.h"
+#include "kernel/stacking.h"
+#include "kernel/screen.h"
 #include <glib.h>
 
-#define DEFAULT_RESISTANCE 10
+static int resistance;
+static gboolean resist_windows;
+
+static void parse_assign(char *name, ParseToken *value)
+{
+    if (!g_ascii_strcasecmp(name, "strength")) {
+        if (value->type != TOKEN_INTEGER)
+            yyerror("invalid value");
+        else {
+            if (value->data.integer >= 0)
+                resistance = value->data.integer;
+        }
+    } else if  (!g_ascii_strcasecmp(name, "windows")) {
+        if (value->type != TOKEN_BOOL)
+            yyerror("invalid value");
+        else
+            resist_windows = value->data.bool;
+    } else
+        yyerror("invalid option");
+    parse_free_token(value);
+}
 
 void plugin_setup_config()
 {
-    ConfigValue val;
+    resistance = 10;
+    resist_windows = TRUE;
 
-    config_def_set(config_def_new("resistance", Config_Integer,
-                                  "Edge Resistance",
-                                  "The amount of resistance to provide when "
-                                  "moving windows past edges."
-                                  "positioned."));
-    config_def_set(config_def_new("resistance.windows", Config_Bool,
-                                  "Edge Resistance On Windows",
-                                  "Whether to provide edge resistance when "
-                                  "moving windows past the edge of another "
-                                  "window."));
-    val.bool = TRUE;
-    config_set("resistance.windows", Config_Bool, val);
+    parse_reg_section("resistance", NULL, parse_assign);
 }
 
 static void resist_move(Client *c, int *x, int *y)
@@ -35,15 +45,6 @@ static void resist_move(Client *c, int *x, int *y)
     int cl, ct, cr, cb; /* current edges */
     int w, h; /* current size */
     Client *snapx = NULL, *snapy = NULL;
-    ConfigValue resist, window_resist;
-
-    if (!config_get("resistance", Config_Integer, &resist) ||
-        resist.integer < 0) {
-        resist.integer = DEFAULT_RESISTANCE;
-        config_set("resistance", Config_Integer, resist);
-    }
-    if (!config_get("resistance.windows", Config_Bool, &window_resist))
-        g_assert_not_reached();
 
     w = c->frame->area.width;
     h = c->frame->area.height;
@@ -59,7 +60,7 @@ static void resist_move(Client *c, int *x, int *y)
     cb = ct + c->frame->area.height - 1;
     
     /* snap to other clients */
-    if (window_resist.bool)
+    if (resist_windows)
         for (it = stacking_list; it != NULL; it = it->next) {
             Client *target;
             int tl, tt, tr, tb; /* 1 past the target's edges on each side */
@@ -79,30 +80,30 @@ static void resist_move(Client *c, int *x, int *y)
             */
             if (snapx == NULL) {
                 if (ct < tb && cb > tt) {
-                    if (cl >= tr && l < tr && l >= tr - resist.integer)
+                    if (cl >= tr && l < tr && l >= tr - resistance)
                         *x = tr, snapx = target;
-                    else if (cr <= tl && r > tl && r <= tl + resist.integer)
+                    else if (cr <= tl && r > tl && r <= tl + resistance)
                         *x = tl - w + 1, snapx = target;
                     if (snapx != NULL) {
                         /* try to corner snap to the window */
-                        if (ct > tt && t <= tt && t > tt - resist.integer)
+                        if (ct > tt && t <= tt && t > tt - resistance)
                             *y = tt + 1, snapy = target;
-                        else if (cb < tb && b >= tb && b < tb + resist.integer)
+                        else if (cb < tb && b >= tb && b < tb + resistance)
                             *y = tb - h, snapy = target;
                     }
                 }
             }
             if (snapy == NULL) {
                 if (cl < tr && cr > tl) {
-                    if (ct >= tb && t < tb && t >= tb - resist.integer)
+                    if (ct >= tb && t < tb && t >= tb - resistance)
                         *y = tb, snapy = target;
-                    else if (cb <= tt && b > tt && b <= tt + resist.integer)
+                    else if (cb <= tt && b > tt && b <= tt + resistance)
                         *y = tt - h + 1, snapy = target;
                     if (snapy != NULL) {
                         /* try to corner snap to the window */
-                        if (cl > tl && l <= tl && l > tl - resist.integer)
+                        if (cl > tl && l <= tl && l > tl - resistance)
                             *x = tl + 1, snapx = target;
-                        else if (cr < tr && r >= tr && r < tr + resist.integer)
+                        else if (cr < tr && r >= tr && r < tr + resistance)
                             *x = tr - w, snapx = target;
                     }
                 }
@@ -119,13 +120,13 @@ static void resist_move(Client *c, int *x, int *y)
     ab = at + area->height - 1;
 
     /* snap to screen edges */
-    if (cl >= al && l < al && l >= al - resist.integer)
+    if (cl >= al && l < al && l >= al - resistance)
         *x = al;
-    else if (cr <= ar && r > ar && r <= ar + resist.integer)
+    else if (cr <= ar && r > ar && r <= ar + resistance)
             *x = ar - w + 1;
-    if (ct >= at && t < at && t >= at - resist.integer)
+    if (ct >= at && t < at && t >= at - resistance)
         *y = at;
-    else if (cb <= ab && b > ab && b < ab + resist.integer)
+    else if (cb <= ab && b > ab && b < ab + resistance)
         *y = ab - h + 1;
 }
 
@@ -139,15 +140,6 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
     Rect *area;
     int al, at, ar, ab; /* screen boundaries */
     Client *snapx = NULL, *snapy = NULL;
-    ConfigValue resist, window_resist;
-
-    if (!config_get("resistance", Config_Integer, &resist) ||
-        resist.integer < 0) {
-        resist.integer = DEFAULT_RESISTANCE;
-        config_set("resistance", Config_Integer, resist);
-    }
-    if (!config_get("resistance.windows", Config_Bool, &window_resist))
-        g_assert_not_reached();
 
     l = c->frame->area.x;
     r = l + c->frame->area.width - 1;
@@ -162,7 +154,7 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
     ab = at + area->height - 1;
 
     /* snap to other windows */
-    if (window_resist.bool) {
+    if (resist_windows) {
         for (it = stacking_list; it != NULL; it = it->next) {
             target = it->data;
 
@@ -182,14 +174,14 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
                     case Corner_BottomLeft:
                         dlt = l;
                         drb = r + *w - c->frame->area.width;
-                        if (r < tl && drb >= tl && drb < tl + resist.integer)
+                        if (r < tl && drb >= tl && drb < tl + resistance)
                             *w = tl - l, snapx = target;
                         break;
                     case Corner_TopRight:
                     case Corner_BottomRight:
                         dlt = l - *w + c->frame->area.width;
                         drb = r;
-                        if (l > tr && dlt <= tr && dlt > tr - resist.integer)
+                        if (l > tr && dlt <= tr && dlt > tr - resistance)
                             *w = r - tr, snapx = target;
                         break;
                     }
@@ -204,14 +196,14 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
                     case Corner_TopRight:
                         dlt = t;
                         drb = b + *h - c->frame->area.height;
-                        if (b < tt && drb >= tt && drb < tt + resist.integer)
+                        if (b < tt && drb >= tt && drb < tt + resistance)
                             *h = tt - t, snapy = target;
                         break;
                     case Corner_BottomLeft:
                     case Corner_BottomRight:
                         dlt = t - *h + c->frame->area.height;
                         drb = b;
-                        if (t > tb && dlt <= tb && dlt > tb - resist.integer)
+                        if (t > tb && dlt <= tb && dlt > tb - resistance)
                             *h = b - tb, snapy = target;
                         break;
                     }
@@ -231,14 +223,14 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
     case Corner_BottomLeft:
         dlt = l;
         drb = r + *w - c->frame->area.width;
-        if (r <= ar && drb > ar && drb <= ar + resist.integer)
+        if (r <= ar && drb > ar && drb <= ar + resistance)
             *w = ar - l + 1;
         break;
     case Corner_TopRight:
     case Corner_BottomRight:
         dlt = l - *w + c->frame->area.width;
         drb = r;
-        if (l >= al && dlt < al && dlt >= al - resist.integer)
+        if (l >= al && dlt < al && dlt >= al - resistance)
             *w = r - al + 1;
         break;
     }
@@ -249,14 +241,14 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
     case Corner_TopRight:
         dlt = t;
         drb = b + *h - c->frame->area.height;
-        if (b <= ab && drb > ab && drb <= ab + resist.integer)
+        if (b <= ab && drb > ab && drb <= ab + resistance)
             *h = ab - t + 1;
         break;
     case Corner_BottomLeft:
     case Corner_BottomRight:
         dlt = t - *h + c->frame->area.height;
         drb = b;
-        if (t >= at && dlt < at && dlt >= at - resist.integer)
+        if (t >= at && dlt < at && dlt >= at - resistance)
             *h = b - at + 1;
         break;
     }