diff -uNr openbox.old/Makefile.am openbox/Makefile.am
--- openbox.old/Makefile.am 2004-05-07 09:16:34.000000000 +0200
+++ openbox/Makefile.am 2004-06-13 22:55:52.789046646 +0200
@@ -191,7 +191,9 @@
openbox/window.c \
openbox/window.h \
openbox/xerror.c \
- openbox/xerror.h
+ openbox/xerror.h \
+ openbox/per_app_settings.c \
+ openbox/per_app_settings.h
## kdetrayproxy ##
diff -uNr openbox.old/data/rc.xsd openbox/data/rc.xsd
--- openbox.old/data/rc.xsd 2004-04-22 14:44:20.000000000 +0200
+++ openbox/data/rc.xsd 2004-06-13 23:16:13.683510654 +0200
@@ -52,6 +52,7 @@
+
@@ -175,6 +176,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Files openbox.old/openbox/.libs/openbox and openbox/openbox/.libs/openbox differ
diff -uNr openbox.old/openbox/client.c openbox/openbox/client.c
--- openbox.old/openbox/client.c 2004-03-31 09:40:06.000000000 +0200
+++ openbox/openbox/client.c 2004-06-13 22:55:53.308960823 +0200
@@ -40,6 +40,7 @@
#include "keyboard.h"
#include "mouse.h"
#include "render/render.h"
+#include "per_app_settings.h"
#include
#include
@@ -212,7 +213,8 @@
XSetWindowAttributes attrib_set;
XWMHints *wmhint;
gboolean activate = FALSE;
-
+ ObAppSetting *settings;
+
grab_server(TRUE);
/* check if it has already been unmapped by the time we started mapping
@@ -292,12 +294,29 @@
client_apply_startup_state(self);
+ /* get and set application level settings */
+ settings = (ObAppSetting *) get_client_settings(self);
+
+ if (settings) {
+ if (settings->shade && !settings->decor)
+ settings->decor = TRUE;
+
+ client_shade(self, settings->shade);
+ client_set_undecorated(self, !settings->decor);
+
+ if (settings->desktop != -1)
+ client_set_desktop(self, settings->desktop, FALSE);
+
+ client_set_layer(self, settings->layer);
+ }
+
stacking_add(CLIENT_AS_WINDOW(self));
client_restore_session_stacking(self);
/* focus the new window? */
if (ob_state() != OB_STATE_STARTING &&
- (config_focus_new || client_search_focus_parent(self)) &&
+ (config_focus_new || client_search_focus_parent(self)) ||
+ (settings && settings->focus) &&
/* note the check against Type_Normal/Dialog, not client_normal(self),
which would also include other types. in this case we want more
strict rules for focus */
@@ -344,6 +363,9 @@
place_client(self, &x, &y);
+ if (settings)
+ place_window_from_settings(settings, self, &x, &y);
+
/* make sure the window is visible */
client_find_onscreen(self, &x, &y,
self->frame->area.width,
diff -uNr openbox.old/openbox/config.c openbox/openbox/config.c
--- openbox.old/openbox/config.c 2004-04-17 14:14:06.000000000 +0200
+++ openbox/openbox/config.c 2004-06-14 16:19:11.785967096 +0200
@@ -73,6 +73,108 @@
gint config_resist_win;
gint config_resist_edge;
+GSList *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 center1
+ 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) {
+ if (parse_attr_string("name", app, &name)) {
+ xmlNodePtr n, c;
+ ObAppSetting *setting = g_new0(ObAppSetting, 1);
+ setting->name = name;
+
+ setting->decor = TRUE;
+ if ((n = parse_find_node("decor", app->children)))
+ setting->decor = parse_bool(doc, n);
+
+ if ((n = parse_find_node("shade", app->children)))
+ setting->shade = parse_bool(doc, n);
+
+ setting->position.x = setting->position.y = -1;
+ if ((n = parse_find_node("position", app->children))) {
+ if ((c = parse_find_node("x", n->children))) {
+ if (!strcmp(parse_string(doc, c), "center")) {
+ setting->center_x = TRUE;
+ }
+ else
+ setting->position.x = parse_int(doc, c);
+ }
+
+ if ((c = parse_find_node("y", n->children))) {
+ if (!strcmp(parse_string(doc, c), "center")) {
+ setting->center_y = TRUE;
+ }
+ else
+ setting->position.y = parse_int(doc, c);
+ }
+ }
+
+ if ((n = parse_find_node("focus", app->children)))
+ setting->focus = parse_bool(doc, n);
+
+ if ((n = parse_find_node("desktop", app->children)))
+ setting->desktop = parse_int(doc, n);
+ else
+ setting->desktop = -1;
+
+ if ((n = parse_find_node("head", app->children))) {
+ if (!strcmp(parse_string(doc, n), "mouse"))
+ setting->head = -1;
+ else
+ setting->head = parse_int(doc, n);
+ }
+
+ if ((n = parse_find_node("layer", app->children))) {
+ if (!strcmp(parse_string(doc, n), "above"))
+ setting->layer = 1;
+ else if (!strcmp(parse_string(doc, n), "below"))
+ setting->layer = -1;
+ else
+ setting->layer = 0;
+ }
+
+ per_app_settings = g_slist_append(per_app_settings,
+ (gpointer) setting);
+ }
+
+ app = parse_find_node("application", app->next);
+ }
+}
+
/*
@@ -599,6 +701,10 @@
config_menu_files = NULL;
parse_register(i, "menu", parse_menu, NULL);
+
+ per_app_settings = NULL;
+
+ parse_register(i, "applications", parse_per_app_settings, NULL);
}
void config_shutdown()
diff -uNr openbox.old/openbox/config.h openbox/openbox/config.h
--- openbox.old/openbox/config.h 2004-03-21 21:06:40.000000000 +0100
+++ openbox/openbox/config.h 2004-06-13 22:55:53.313959997 +0200
@@ -23,6 +23,7 @@
#include "misc.h"
#include "stacking.h"
#include "place.h"
+#include "per_app_settings.h"
#include
diff -uNr openbox.old/openbox/per_app_settings.c openbox/openbox/per_app_settings.c
--- openbox.old/openbox/per_app_settings.c 1970-01-01 01:00:00.000000000 +0100
+++ openbox/openbox/per_app_settings.c 2004-06-14 16:17:35.027939177 +0200
@@ -0,0 +1,57 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- */
+
+#include "per_app_settings.h"
+#include "screen.h"
+
+GSList *per_app_settings;
+
+ObAppSetting *get_client_settings(ObClient *client)
+{
+ GSList *a = per_app_settings;
+
+ while (a) {
+ ObAppSetting *app = (ObAppSetting *) a->data;
+
+ if (!strcmp(app->name, client->name)) {
+ ob_debug("Window matching: %s\n", app->name);
+
+ return (ObAppSetting *) a->data;
+ }
+
+ a = a->next;
+ }
+ return NULL;
+}
+
+void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y)
+{
+ gint px, py, i;
+ Rect *screen;
+
+ /* Find which head the pointer is on, partly taken from place.c */
+ if (setting->head == -1) {
+ screen_pointer_pos(&px, &py);
+
+ for (i = 0; i < screen_num_monitors; i++) {
+ screen = screen_area_monitor(client->desktop, i);
+ if (RECT_CONTAINS(*screen, px, py))
+ break;
+ }
+
+ if (i == screen_num_monitors)
+ screen = screen_area_monitor(client->desktop, 0);
+ }
+ else
+ screen = screen_area_monitor(client->desktop, setting->head);
+
+ if (setting->position.x == -1 && setting->center_x)
+ *x = screen->x + screen->width / 2 - client->area.width / 2;
+ else if (setting->position.x != -1)
+ *x = screen->x + setting->position.x;
+
+ if (setting->position.y == -1 && setting->center_y)
+ *y = screen->y + screen->height / 2 - client->area.height / 2;
+ else if (setting->position.y != -1)
+ *y = screen->y + setting->position.y;
+
+}
diff -uNr openbox.old/openbox/per_app_settings.h openbox/openbox/per_app_settings.h
--- openbox.old/openbox/per_app_settings.h 1970-01-01 01:00:00.000000000 +0100
+++ openbox/openbox/per_app_settings.h 2004-06-14 09:18:46.116364895 +0200
@@ -0,0 +1,30 @@
+#ifndef __per_app_settings_h
+#define __per_app_settings_h
+
+#include "client.h"
+
+typedef struct _ObAppSetting ObAppSetting;
+
+struct _ObAppSetting
+{
+ gchar *name;
+ gboolean decor;
+ gboolean shade;
+ gboolean focus;
+
+ Point position;
+ gboolean center_x;
+ gboolean center_y;
+
+ guint desktop;
+ guint head;
+
+ guint layer;
+};
+
+extern GSList *per_app_settings;
+
+ObAppSetting *get_client_settings(ObClient *client);
+void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y);
+
+#endif