summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-05-24 15:35:26 +0000
committerDana Jansens <danakj@orodu.net>2003-05-24 15:35:26 +0000
commitd2857b11944146e2e6973b7f7280cb57e1ee260b (patch)
tree51bf06d58f90953842b0e6babc9493f04934d7d9 /plugins
parentf7df74b9cc9369fe401d5622c097e258a124f742 (diff)
ECKS EM ELL
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am3
-rw-r--r--plugins/keyboard/Makefile.am5
-rw-r--r--plugins/keyboard/keyboard.c62
-rw-r--r--plugins/mouse/Makefile.am7
-rw-r--r--plugins/mouse/mouse.c101
-rw-r--r--plugins/placement/Makefile.am3
-rw-r--r--plugins/placement/history.c309
-rw-r--r--plugins/placement/history.h2
-rw-r--r--plugins/placement/placement.c16
-rw-r--r--plugins/resistance.c25
10 files changed, 348 insertions, 185 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 4796307a..b23259d6 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,7 +2,8 @@ plugindir=$(libdir)/openbox/plugins
SUBDIRS = keyboard mouse placement menu
-CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) \
+ $(XML_CFLAGS) @CPPFLAGS@ \
-DPLUGINDIR=\"$(plugindir)\"
INCLUDES=-I..
diff --git a/plugins/keyboard/Makefile.am b/plugins/keyboard/Makefile.am
index ffcd104b..4b1e850a 100644
--- a/plugins/keyboard/Makefile.am
+++ b/plugins/keyboard/Makefile.am
@@ -1,6 +1,7 @@
plugindir=$(libdir)/openbox/plugins
-CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) \
+ $(XML_CFLAGS) @CPPFLAGS@ \
-DG_LOG_DOMAIN=\"Plugin-Keyboard\"
INCLUDES=-I../..
@@ -8,7 +9,7 @@ INCLUDES=-I../..
plugin_LTLIBRARIES=keyboard.la
keyboard_la_LDFLAGS=-module -avoid-version
-keyboard_la_SOURCES=keyboard.c keyparse.c translate.c tree.c
+keyboard_la_SOURCES=keyboard.c translate.c tree.c
noinst_HEADERS=keyboard.h keyparse.h translate.h tree.h
diff --git a/plugins/keyboard/keyboard.c b/plugins/keyboard/keyboard.c
index 5991606a..d1d93241 100644
--- a/plugins/keyboard/keyboard.c
+++ b/plugins/keyboard/keyboard.c
@@ -4,17 +4,74 @@
#include "kernel/event.h"
#include "kernel/grab.h"
#include "kernel/action.h"
+#include "kernel/prop.h"
#include "kernel/parse.h"
#include "kernel/timer.h"
#include "tree.h"
#include "keyboard.h"
-#include "keyparse.h"
#include "translate.h"
#include <glib.h>
+/*
+
+<keybind key="C-x">
+ <action name="ChangeDesktop">
+ <desktop>3</desktop>
+ </action>
+</keybind>
+
+*/
+
+static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
+{
+ char *key;
+ Action *action;
+ xmlNodePtr n, nact;
+ GList *it;
+
+ n = parse_find_node("keybind", node);
+ while (n) {
+ if (parse_attr_string("key", n, &key)) {
+ keylist = g_list_append(keylist, key);
+
+ parse_key(doc, n->xmlChildrenNode, keylist);
+
+ it = g_list_last(keylist);
+ g_free(it->data);
+ keylist = g_list_delete_link(keylist, it);
+ }
+ n = parse_find_node("keybind", n->next);
+ }
+ if (keylist) {
+ nact = parse_find_node("action", node);
+ while (nact) {
+ if ((action = parse_action(doc, nact))) {
+ /* validate that its okay for a key binding */
+ if (action->func == action_moveresize &&
+ action->data.moveresize.corner !=
+ prop_atoms.net_wm_moveresize_move_keyboard &&
+ action->data.moveresize.corner !=
+ prop_atoms.net_wm_moveresize_size_keyboard) {
+ action_free(action);
+ action = NULL;
+ }
+
+ if (action)
+ kbind(keylist, action);
+ }
+ nact = parse_find_node("action", nact->next);
+ }
+ }
+}
+
+static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
+{
+ parse_key(doc, node, NULL);
+}
+
void plugin_setup_config()
{
- parse_reg_section("keyboard", keyparse, NULL);
+ parse_register("keyboard", parse_xml, NULL);
}
KeyBindingTree *firstnode = NULL;
@@ -160,6 +217,7 @@ static void event(ObEvent *e, void *foo)
act->data.cycle.cancel = FALSE;
}
+ act->data.any.c = focus_client;
act->func(&act->data);
if (act->func == action_cycle_windows &&
diff --git a/plugins/mouse/Makefile.am b/plugins/mouse/Makefile.am
index e4c897d5..3d4d6b9e 100644
--- a/plugins/mouse/Makefile.am
+++ b/plugins/mouse/Makefile.am
@@ -1,6 +1,7 @@
plugindir=$(libdir)/openbox/plugins
-CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) \
+ $(XML_CFLAGS) @CPPFLAGS@ \
-DG_LOG_DOMAIN=\"Plugin-Mouse\"
INCLUDES=-I../..
@@ -8,9 +9,9 @@ INCLUDES=-I../..
plugin_LTLIBRARIES=mouse.la
mouse_la_LDFLAGS=-module -avoid-version
-mouse_la_SOURCES=mouse.c mouseparse.c translate.c
+mouse_la_SOURCES=mouse.c translate.c
-noinst_HEADERS=mouse.h mouseparse.h translate.h
+noinst_HEADERS=mouse.h translate.h
MAINTAINERCLEANFILES=Makefile.in
diff --git a/plugins/mouse/mouse.c b/plugins/mouse/mouse.c
index e39720cb..0bfe602c 100644
--- a/plugins/mouse/mouse.c
+++ b/plugins/mouse/mouse.c
@@ -9,38 +9,97 @@
#include "kernel/frame.h"
#include "translate.h"
#include "mouse.h"
-#include "mouseparse.h"
#include <glib.h>
static int threshold;
static int dclicktime;
-static void parse_assign(char *name, ParseToken *value)
+/*
+
+<context name="Titlebar">
+ <mousebind button="Left" action="Press">
+ <action name="Raise"></action>
+ </mousebind>
+</context>
+
+*/
+
+static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
{
- 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;
+ xmlNodePtr n, nbut, nact;
+ char *buttonstr;
+ char *contextstr;
+ MouseAction mact;
+ Action *action;
+
+ if ((n = parse_find_node("dragThreshold", node)))
+ threshold = parse_int(doc, n);
+ if ((n = parse_find_node("doubleClickTime", node)))
+ dclicktime = parse_int(doc, n);
+
+ n = parse_find_node("context", node);
+ while (n) {
+ if (!parse_attr_string("name", n, &contextstr))
+ goto next_n;
+ nbut = parse_find_node("mousebind", n->xmlChildrenNode);
+ while (nbut) {
+ if (!parse_attr_string("button", nbut, &buttonstr))
+ goto next_nbut;
+ if (parse_attr_contains("press", nbut, "action"))
+ mact = MouseAction_Press;
+ else if (parse_attr_contains("release", nbut, "action"))
+ mact = MouseAction_Release;
+ else if (parse_attr_contains("click", nbut, "action"))
+ mact = MouseAction_Click;
+ else if (parse_attr_contains("doubleclick", nbut,"action"))
+ mact = MouseAction_DClick;
+ else if (parse_attr_contains("drag", nbut, "action"))
+ mact = MouseAction_Motion;
+ else
+ goto next_nbut;
+ nact = parse_find_node("action", nbut->xmlChildrenNode);
+ while (nact) {
+ if ((action = parse_action(doc, nact))) {
+ /* validate that its okay for a mouse binding*/
+ if (mact == MouseAction_Motion) {
+ if (action->func != action_moveresize ||
+ action->data.moveresize.corner ==
+ prop_atoms.net_wm_moveresize_move_keyboard ||
+ action->data.moveresize.corner ==
+ prop_atoms.net_wm_moveresize_size_keyboard) {
+ action_free(action);
+ action = NULL;
+ }
+ } else {
+ if (action->func == action_moveresize &&
+ action->data.moveresize.corner !=
+ prop_atoms.net_wm_moveresize_move_keyboard &&
+ action->data.moveresize.corner !=
+ prop_atoms.net_wm_moveresize_size_keyboard) {
+ action_free(action);
+ action = NULL;
+ }
+ }
+ if (action)
+ mbind(buttonstr, contextstr, mact, action);
+ }
+ nact = parse_find_node("action", nact->next);
+ }
+ g_free(buttonstr);
+ next_nbut:
+ nbut = parse_find_node("mousebind", nbut->next);
}
- } else
- yyerror("invalid option");
- parse_free_token(value);
+ g_free(contextstr);
+ next_n:
+ n = parse_find_node("context", n->next);
+ }
}
void plugin_setup_config()
{
threshold = 3;
dclicktime = 200;
- parse_reg_section("mouse", mouseparse, parse_assign);
+ parse_register("mouse", parse_xml, NULL);
}
/* Array of GSList*s of PointerBinding*s. */
@@ -240,11 +299,11 @@ static void event(ObEvent *e, void *foo)
e->data.x.e->xbutton.window);
if (e->data.x.e->xbutton.button == button) {
/* clicks are only valid if its released over the window */
- int junk;
+ int junk1, junk2;
Window wjunk;
guint ujunk, b, w, h;
XGetGeometry(ob_display, e->data.x.e->xbutton.window,
- &wjunk, &junk, &junk, &w, &h, &b, &ujunk);
+ &wjunk, &junk1, &junk2, &w, &h, &b, &ujunk);
if (e->data.x.e->xbutton.x >= (signed)-b &&
e->data.x.e->xbutton.y >= (signed)-b &&
e->data.x.e->xbutton.x < (signed)(w+b) &&
diff --git a/plugins/placement/Makefile.am b/plugins/placement/Makefile.am
index 6b328008..762f5af8 100644
--- a/plugins/placement/Makefile.am
+++ b/plugins/placement/Makefile.am
@@ -1,6 +1,7 @@
plugindir=$(libdir)/openbox/plugins
-CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(LIBSN_CFLAGS) $(GL_CFLAGS) \
+ $(XML_CFLAGS) @CPPFLAGS@ \
-DG_LOG_DOMAIN=\"Plugin-Placement\"
INCLUDES=-I../..
diff --git a/plugins/placement/history.c b/plugins/placement/history.c
index ea3d60df..9d932b9e 100644
--- a/plugins/placement/history.c
+++ b/plugins/placement/history.c
@@ -3,41 +3,47 @@
#include "kernel/frame.h"
#include "kernel/client.h"
#include "kernel/screen.h"
+#include "kernel/parse.h"
+#include "history.h"
#include <glib.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
+#define PLACED (1 << 0)
+
+#define HAVE_POSITION (1 << 1)
+#define HAVE_SIZE (1 << 2)
+#define HAVE_DESKTOP (1 << 3)
+
struct HistoryItem {
char *name;
char *class;
char *role;
- int x;
- int y;
- gboolean placed;
+
+ int flags;
+
+ int x, y;
+ int w, h;
+ guint desk;
};
-static GSList *history = NULL;
+static GSList *history_list = NULL;
static char *history_path = NULL;
-static struct HistoryItem *find_history(Client *c)
+static struct HistoryItem *history_find(const char *name, const char *class,
+ const char *role)
{
GSList *it;
struct HistoryItem *hi = NULL;
/* find the client */
- for (it = history; it != NULL; it = it->next) {
+ for (it = history_list; it != NULL; it = it->next) {
hi = it->data;
- g_assert(hi->name != NULL);
- g_assert(hi->class != NULL);
- g_assert(hi->role != NULL);
- g_assert(c->name != NULL);
- g_assert(c->class != NULL);
- g_assert(c->role != NULL);
- if (!strcmp(hi->name, c->name) &&
- !strcmp(hi->class, c->class) &&
- !strcmp(hi->role, c->role))
+ if (!g_utf8_collate(hi->name, name) &&
+ !g_utf8_collate(hi->class, class) &&
+ !g_utf8_collate(hi->role, role))
return hi;
}
return NULL;
@@ -46,57 +52,65 @@ static struct HistoryItem *find_history(Client *c)
gboolean place_history(Client *c)
{
struct HistoryItem *hi;
- int x, y;
+ int x, y, w, h;
- hi = find_history(c);
+ hi = history_find(c->name, c->class, c->role);
- if (hi != NULL && !hi->placed) {
- hi->placed = TRUE;
+ if (hi && !(hi->flags & PLACED)) {
+ hi->flags |= PLACED;
if (ob_state != State_Starting) {
- x = hi->x;
- y = hi->y;
-
- frame_frame_gravity(c->frame, &x, &y); /* get where the client
- should be */
- client_configure(c, Corner_TopLeft, x, y,
- c->area.width, c->area.height,
- TRUE, TRUE);
+ if (hi->flags & HAVE_POSITION ||
+ hi->flags & HAVE_SIZE) {
+ if (hi->flags & HAVE_POSITION) {
+ x = hi->x;
+ y = hi->y;
+ /* get where the client should be */
+ frame_frame_gravity(c->frame, &x, &y);
+ } else {
+ x = c->area.x;
+ y = c->area.y;
+ }
+ if (hi->flags & HAVE_SIZE) {
+ w = hi->w * c->size_inc.width;
+ h = hi->h * c->size_inc.height;
+ } else {
+ w = c->area.width;
+ h = c->area.height;
+ }
+ client_configure(c, Corner_TopLeft, x, y, w, h,
+ TRUE, TRUE);
+ }
+ if (hi->flags & HAVE_DESKTOP) {
+ client_set_desktop(c, hi->desk, FALSE);
+ }
}
- return TRUE;
+ return hi->flags & HAVE_POSITION;
}
return FALSE;
}
-static void strip_tabs(char *s)
-{
- while (*s != '\0') {
- if (*s == '\t')
- *s = ' ';
- ++s;
- }
-}
-
static void set_history(Client *c)
{
struct HistoryItem *hi;
- hi = find_history(c);
+ hi = history_find(c->name, c->class, c->role);
if (hi == NULL) {
hi = g_new(struct HistoryItem, 1);
- history = g_slist_append(history, hi);
+ history_list = g_slist_append(history_list, hi);
hi->name = g_strdup(c->name);
- strip_tabs(hi->name);
hi->class = g_strdup(c->class);
- strip_tabs(hi->class);
hi->role = g_strdup(c->role);
- strip_tabs(hi->role);
+ hi->flags = HAVE_POSITION;
+ }
+
+ if (hi->flags & HAVE_POSITION) {
+ hi->x = c->frame->area.x;
+ hi->y = c->frame->area.y;
}
- hi->x = c->frame->area.x;
- hi->y = c->frame->area.y;
- hi->placed = FALSE;
+ hi->flags &= ~PLACED;
}
static void event(ObEvent *e, void *foo)
@@ -106,104 +120,140 @@ static void event(ObEvent *e, void *foo)
set_history(e->data.c.client);
}
+/*
+
+<entry name="name" class="class" role="role">
+ <x>0</x>
+ <y>0</y>
+ <width>300</width>
+ <height>200</height>
+ <desktop>1</desktop>
+</entry>
+
+*/
+
static void save_history()
{
- GError *err = NULL;
- GIOChannel *io;
- GString *buf;
+ xmlDocPtr doc;
+ xmlNodePtr root, node;
+ char *s;
GSList *it;
- struct HistoryItem *hi;
- gsize ret;
-
- io = g_io_channel_new_file(history_path, "w", &err);
- if (io != NULL) {
- for (it = history; it != NULL; it = it->next) {
- hi = it->data;
- buf = g_string_sized_new(0);
- buf=g_string_append(buf, hi->name);
- g_string_append_c(buf, '\t');
- buf=g_string_append(buf, hi->class);
- g_string_append_c(buf, '\t');
- buf=g_string_append(buf, hi->role);
- g_string_append_c(buf, '\t');
- g_string_append_printf(buf, "%d", hi->x);
- buf=g_string_append_c(buf, '\t');
- g_string_append_printf(buf, "%d", hi->y);
- buf=g_string_append_c(buf, '\n');
- if (g_io_channel_write_chars(io, buf->str, buf->len, &ret, &err) !=
- G_IO_STATUS_NORMAL)
- break;
- g_string_free(buf, TRUE);
+
+ doc = xmlNewDoc(NULL);
+ root = xmlNewNode(NULL, (const xmlChar*) "openbox_history");
+ xmlDocSetRootElement(doc, root);
+
+ for (it = history_list; it; it = g_slist_next(it)) {
+ struct HistoryItem *hi = it->data;
+ g_message("adding %s", hi->name);
+ node = xmlNewChild(root, NULL, (const xmlChar*) "entry", NULL);
+ xmlNewProp(node, (const xmlChar*) "name", (const xmlChar*) hi->name);
+ xmlNewProp(node, (const xmlChar*) "class", (const xmlChar*) hi->class);
+ xmlNewProp(node, (const xmlChar*) "role", (const xmlChar*) hi->role);
+ if (hi->flags & HAVE_POSITION) {
+ s = g_strdup_printf("%d", hi->x);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "x", (const xmlChar*) s);
+ g_free(s);
+ s = g_strdup_printf("%d", hi->y);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "y", (const xmlChar*) s);
+ g_free(s);
+ }
+ if (hi->flags & HAVE_SIZE) {
+ s = g_strdup_printf("%d", hi->w);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "width", (const xmlChar*) s);
+ g_free(s);
+ s = g_strdup_printf("%d", hi->h);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "height", (const xmlChar*) s);
+ g_free(s);
+ }
+ if (hi->flags & HAVE_DESKTOP) {
+ s = g_strdup_printf("%d", hi->desk < 0 ? hi->desk : hi->desk + 1);
+ xmlNewTextChild(node, NULL,
+ (const xmlChar*) "desktop", (const xmlChar*) s);
+ g_free(s);
}
- g_io_channel_unref(io);
}
+
+ xmlIndentTreeOutput = 1;
+ xmlSaveFormatFile(history_path, doc, 1);
+
+ xmlFree(doc);
}
static void load_history()
{
- GError *err = NULL;
- GIOChannel *io;
- char *buf = NULL;
- char *b, *c;
- struct HistoryItem *hi = NULL;
-
- io = g_io_channel_new_file(history_path, "r", &err);
- if (io != NULL) {
- while (g_io_channel_read_line(io, &buf, NULL, NULL, &err) ==
- G_IO_STATUS_NORMAL) {
- hi = g_new0(struct HistoryItem, 1);
-
- b = buf;
- if ((c = strchr(b, '\t')) == NULL) break;
- *c = '\0';
- hi->name = g_strdup(b);
-
- b = c + 1;
- if ((c = strchr(b, '\t')) == NULL) break;
- *c = '\0';
- hi->class = g_strdup(b);
-
- b = c + 1;
- if ((c = strchr(b, '\t')) == NULL) break;
- *c = '\0';
- hi->role = g_strdup(b);
-
- b = c + 1;
- if ((c = strchr(b, '\t')) == NULL) break;
- *c = '\0';
- hi->x = atoi(b);
-
- b = c + 1;
- if ((c = strchr(b, '\n')) == NULL) break;
- *c = '\0';
- hi->y = atoi(b);
-
- hi->placed = FALSE;
-
- g_free(buf);
- buf = NULL;
+ xmlDocPtr doc;
+ xmlNodePtr node, n;
+ char *name;
+ char *class;
+ char *role;
+ struct HistoryItem *hi;
- history = g_slist_append(history, hi);
- hi = NULL;
- }
- g_io_channel_unref(io);
+ if (!(doc = xmlParseFile(history_path)))
+ return;
+ if (!(node = xmlDocGetRootElement(doc))) {
+ xmlFreeDoc(doc);
+ doc = NULL;
+ return;
+ }
+ if (xmlStrcasecmp(node->name, (const xmlChar*)"openbox_history")) {
+ xmlFreeDoc(doc);
+ doc = NULL;
+ return;
}
-
- g_free(buf);
- if (hi != NULL) {
- g_free(hi->name);
- g_free(hi->class);
- g_free(hi->role);
+ node = parse_find_node("entry", node->xmlChildrenNode);
+ while (node) {
+ name = class = role = NULL;
+ if (parse_attr_string("name", node, &name) &&
+ parse_attr_string("class", node, &class) &&
+ parse_attr_string("role", node, &role)) {
+
+ hi = history_find(name, class, role);
+ if (!hi) {
+ hi = g_new(struct HistoryItem, 1);
+ hi->name = g_strdup(name);
+ hi->class = g_strdup(class);
+ hi->role = g_strdup(role);
+ hi->flags = 0;
+ }
+ if ((n = parse_find_node("x", node->xmlChildrenNode))) {
+ hi->x = parse_int(doc, n);
+ if ((n = parse_find_node("y", node->xmlChildrenNode))) {
+ hi->y = parse_int(doc, n);
+ hi->flags |= HAVE_POSITION;
+ }
+ }
+ if ((n = parse_find_node("width", node->xmlChildrenNode))) {
+ hi->w = parse_int(doc, n);
+ if ((n = parse_find_node("height", node->xmlChildrenNode))) {
+ hi->h = parse_int(doc, n);
+ hi->flags |= HAVE_SIZE;
+ }
+ }
+ if ((n = parse_find_node("desktop", node->xmlChildrenNode))) {
+ hi->desk = parse_int(doc, n);
+ if (hi->desk > 0) --hi->desk;
+ hi->flags |= HAVE_DESKTOP;
+ }
+
+ history_list = g_slist_append(history_list, hi);
+ }
+ g_free(name); g_free(class); g_free(role);
+ node = parse_find_node("entry", node->next);
}
- g_free(hi);
+ xmlFree(doc);
}
void history_startup()
{
char *path;
- history = NULL;
+ history_list = NULL;
path = g_build_filename(g_get_home_dir(), ".openbox", "history", NULL);
history_path = g_strdup_printf("%s.%d", path, ob_screen);
@@ -219,9 +269,14 @@ void history_shutdown()
GSList *it;
save_history(); /* save to the historydb file */
- for (it = history; it != NULL; it = it->next)
- g_free(it->data);
- g_slist_free(history);
+ for (it = history_list; it != NULL; it = it->next) {
+ struct HistoryItem *hi = it->data;
+ g_free(hi->name);
+ g_free(hi->class);
+ g_free(hi->role);
+ g_free(hi);
+ }
+ g_slist_free(history_list);
dispatch_register(0, (EventHandler)event, NULL);
diff --git a/plugins/placement/history.h b/plugins/placement/history.h
index 48a29c3e..38571769 100644
--- a/plugins/placement/history.h
+++ b/plugins/placement/history.h
@@ -1,7 +1,7 @@
#ifndef __plugin_placement_history_h
#define __plugin_placement_history_h
-#include "../../kernel/client.h"
+#include "kernel/client.h"
#include <glib.h>
void history_startup();
diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c
index 23ffbb5d..dd818970 100644
--- a/plugins/placement/placement.c
+++ b/plugins/placement/placement.c
@@ -9,23 +9,19 @@
static gboolean history;
-static void parse_assign(char *name, ParseToken *value)
+static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
{
- 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);
+ xmlNodePtr n;
+
+ if ((n = parse_find_node("remember", node)))
+ history = parse_bool(doc, n);
}
void plugin_setup_config()
{
history = TRUE;
- parse_reg_section("placement", NULL, parse_assign);
+ parse_register("placement", parse_xml, NULL);
}
static void place_random(Client *c)
diff --git a/plugins/resistance.c b/plugins/resistance.c
index bafd362c..ee6f6e1e 100644
--- a/plugins/resistance.c
+++ b/plugins/resistance.c
@@ -9,23 +9,14 @@
static int resistance;
static gboolean resist_windows;
-static void parse_assign(char *name, ParseToken *value)
+static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
{
- 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);
+ xmlNodePtr n;
+
+ if ((n = parse_find_node("strength", node)))
+ resistance = parse_int(doc, n);
+ if ((n = parse_find_node("windows", node)))
+ resist_windows = parse_bool(doc, n);
}
void plugin_setup_config()
@@ -33,7 +24,7 @@ void plugin_setup_config()
resistance = 10;
resist_windows = TRUE;
- parse_reg_section("resistance", NULL, parse_assign);
+ parse_register("resistance", parse_xml, NULL);
}
static void resist_move(Client *c, int *x, int *y)