X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=openbox%2Fconfig.c;h=6df57241edd60855ef817e093e31cea953cf46d0;hb=014969a9599bef99bce1e31c95326ca7f605c2ed;hp=9109675b2529dd560918a30a7a0c7ce8cb05bd06;hpb=310d268bf0b3fbc065e754b9dc25862a60efcaae;p=chaz%2Fopenbox
diff --git a/openbox/config.c b/openbox/config.c
index 9109675b..6df57241 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -22,6 +22,7 @@
#include "mouse.h"
#include "prop.h"
#include "translate.h"
+#include "client.h"
#include "parser/parse.h"
#include "openbox.h"
@@ -80,6 +81,113 @@ gint config_resist_edge;
gboolean config_resist_layers_below;
+GSList *config_per_app_settings;
+
+/*
+
+
+ false
+
+
+ above
+
+ 700
+ 0
+
+ 1
+
+
+*/
+
+/* Manages settings for individual applications.
+ Some notes: head is the screen number in a multi monitor
+ (Xinerama) setup (starting from 0) or mouse, meaning the
+ head the pointer is on. Default: mouse.
+ If decor is false and shade is true, the decor will be
+ set to true (otherwise we will have an invisible window).
+ Layer can be three values, above (Always on top), below
+ (Always on bottom) and everything else (normal behaviour).
+ Positions can be an integer value or center, which will
+ center the window in the specified axis. Position is relative
+ from head, so center
1
+ will center the window on the second head.
+*/
+static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
+ xmlNodePtr node, gpointer d)
+{
+ xmlNodePtr app = parse_find_node("application", node->children);
+ gchar *name;
+
+ while (app) {
+ gboolean x_pos_given = FALSE;
+ if (parse_attr_string("name", app, &name)) {
+ xmlNodePtr n, c;
+ ObAppSettings *settings = g_new0(ObAppSettings, 1);
+ settings->name = name;
+
+ settings->decor = TRUE;
+ if ((n = parse_find_node("decor", app->children)))
+ settings->decor = parse_bool(doc, n);
+
+ if ((n = parse_find_node("shade", app->children)))
+ settings->shade = parse_bool(doc, n);
+
+ settings->position.x = settings->position.y = 0;
+ settings->pos_given = FALSE;
+ if ((n = parse_find_node("position", app->children))) {
+ if ((c = parse_find_node("x", n->children))) {
+ if (!strcmp(parse_string(doc, c), "center")) {
+ settings->center_x = TRUE;
+ x_pos_given = TRUE;
+ } else {
+ settings->position.x = parse_int(doc, c);
+ x_pos_given = TRUE;
+ }
+ }
+
+ if (x_pos_given && (c = parse_find_node("y", n->children))) {
+ if (!strcmp(parse_string(doc, c), "center")) {
+ settings->center_y = TRUE;
+ settings->pos_given;
+ } else {
+ settings->position.y = parse_int(doc, c);
+ settings->pos_given;
+ }
+ }
+ }
+
+ if ((n = parse_find_node("focus", app->children)))
+ settings->focus = parse_bool(doc, n);
+
+ if ((n = parse_find_node("desktop", app->children)))
+ settings->desktop = parse_int(doc, n);
+ else
+ settings->desktop = -1;
+
+ if ((n = parse_find_node("head", app->children))) {
+ if (!strcmp(parse_string(doc, n), "mouse"))
+ settings->head = -1;
+ else
+ settings->head = parse_int(doc, n);
+ }
+
+ if ((n = parse_find_node("layer", app->children))) {
+ if (!strcmp(parse_string(doc, n), "above"))
+ settings->layer = 1;
+ else if (!strcmp(parse_string(doc, n), "below"))
+ settings->layer = -1;
+ else
+ settings->layer = 0;
+ }
+
+ config_per_app_settings = g_slist_append(config_per_app_settings,
+ (gpointer) settings);
+ }
+
+ app = parse_find_node("application", app->next);
+ }
+}
+
/*
@@ -625,6 +733,10 @@ void config_startup(ObParseInst *i)
config_menu_files = NULL;
parse_register(i, "menu", parse_menu, NULL);
+
+ config_per_app_settings = NULL;
+
+ parse_register(i, "applications", parse_per_app_settings, NULL);
}
void config_shutdown()
@@ -642,4 +754,8 @@ void config_shutdown()
for (it = config_menu_files; it; it = g_slist_next(it))
g_free(it->data);
g_slist_free(config_menu_files);
+
+ for (it = config_per_app_settings; it; it = g_slist_next(it))
+ g_free(it->data);
+ g_slist_free(config_per_app_settings);
}