summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-05-06 22:57:49 +0000
committerDana Jansens <danakj@orodu.net>2007-05-06 22:57:49 +0000
commit7ffa091d5b464ce508023c3b5e5bc50a36be53fb (patch)
tree3cbd3840af488e4ef1de2caf0614047ef507e5c3 /openbox
parent6cd5f7ea380e155dbd7b29f01dd3fcfb5858ad61 (diff)
change the perapp settings "head" option to "monitor" i think its easier to understand.
some cleanup for perapp settings. make monitor and desktop be specified starting at 1, like elsewhere in the config file.
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client.h26
-rw-r--r--openbox/config.c97
-rw-r--r--openbox/config.h27
-rw-r--r--openbox/place.c19
4 files changed, 95 insertions, 74 deletions
diff --git a/openbox/client.h b/openbox/client.h
index 6b28d457..2863a98f 100644
--- a/openbox/client.h
+++ b/openbox/client.h
@@ -295,32 +295,6 @@ struct _ObClient
guint32 user_time;
};
-struct _ObAppSettings
-{
- gchar *class;
- gchar *name;
- gchar *role;
-
- Point position;
- gboolean center_x;
- gboolean center_y;
- gboolean pos_given;
-
- guint desktop;
- gint shade;
- gint decor;
- gint focus;
- gint head;
- gint iconic;
- gint skip_pager;
- gint skip_taskbar;
- gint max_horz;
- gint max_vert;
- gint fullscreen;
-
- gint layer;
-};
-
extern GList *client_list;
void client_startup(gboolean reconfig);
diff --git a/openbox/config.c b/openbox/config.c
index f18b77c9..d6adb975 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -102,22 +102,23 @@ GSList *config_per_app_settings;
<position>
<x>700</x>
<y>0</y>
- <head>1</head>
+ <monitor>1</monitor>
</position>
+ .. there is a lot more settings available
</application>
</applications>
*/
/* Manages settings for individual applications.
- Some notes: head is the screen number in a multi monitor
+ Some notes: monitor is the screen number in a multi monitor
(Xinerama) setup (starting from 0) or mouse, meaning the
- head the pointer is on. Default: mouse.
+ monitor the pointer is on. Default: mouse.
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 <position><x>center</x></position><head>1</head>
- will center the window on the second head.
+ center the window in the specified axis. Position is within
+ the monitor, so <position><x>center</x></position><monitor>2</monitor>
+ will center the window on the second monitor.
*/
static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
xmlNodePtr node, gpointer d)
@@ -176,7 +177,7 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
}
if (x_pos_given && (c = parse_find_node("y", n->children)))
- if (!parse_contains("default", doc, )) {
+ if (!parse_contains("default", doc, c)) {
gchar *s = parse_string(doc, c);
if (!strcmp(s, "center")) {
settings->center_y = TRUE;
@@ -189,13 +190,13 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
}
if (settings->pos_given &&
- (c = parse_find_node("head", n->children)))
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ (c = parse_find_node("monitor", n->children)))
+ if (!parse_contains("default", doc, c)) {
+ gchar *s = parse_string(doc, c);
if (!strcmp(s, "mouse"))
- settings->head = -1;
+ settings->monitor = 0;
else
- settings->head = parse_int(doc, n);
+ settings->monitor = parse_int(doc, c) + 1;
g_free(s);
}
}
@@ -205,61 +206,69 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
if (!parse_contains("default", doc, n))
settings->focus = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", app->children)))
+ if ((n = parse_find_node("desktop", app->children))) {
if (!parse_contains("default", doc, n)) {
gchar *s = parse_string(doc, n);
if (!strcmp(s, "all"))
settings->desktop = DESKTOP_ALL;
- else
- settings->desktop = parse_int(doc, n);
+ else {
+ gint i = parse_int(doc, n);
+ if (i > 0)
+ settings->desktop = i;
g_free(s);
} else
- /* lets hope the user doesn't have 2^32 desktops */
- settings->desktop = DESKTOP_ALL - 1;
+ settings->desktop = 0;
+ }
settings->layer = -2;
- if ((n = parse_find_node("layer", app->children))) {
- gchar *s = parse_string(doc, n);
- if (!strcmp(s, "above"))
- settings->layer = 1;
- else if (!strcmp(s, "below"))
- settings->layer = -1;
- else
- settings->layer = 0;
- g_free(s);
- }
+ if ((n = parse_find_node("layer", app->children)))
+ if (!parse_contains("default", doc, n)) {
+ gchar *s = parse_string(doc, n);
+ if (!strcmp(s, "above"))
+ settings->layer = 1;
+ else if (!strcmp(s, "below"))
+ settings->layer = -1;
+ else
+ settings->layer = 0;
+ g_free(s);
+ }
settings->iconic = -1;
if ((n = parse_find_node("iconic", app->children)))
- settings->iconic = parse_bool(doc, n);
+ if (!parse_contains("default", doc, n))
+ settings->iconic = parse_bool(doc, n);
settings->skip_pager = -1;
if ((n = parse_find_node("skip_pager", app->children)))
- settings->skip_pager = parse_bool(doc, n);
+ if (!parse_contains("default", doc, n))
+ settings->skip_pager = parse_bool(doc, n);
settings->skip_taskbar = -1;
if ((n = parse_find_node("skip_taskbar", app->children)))
- settings->skip_taskbar = parse_bool(doc, n);
+ if (!parse_contains("default", doc, n))
+ settings->skip_taskbar = parse_bool(doc, n);
settings->fullscreen = -1;
if ((n = parse_find_node("fullscreen", app->children)))
- settings->fullscreen = parse_bool(doc, n);
+ if (!parse_contains("default", doc, n))
+ settings->fullscreen = parse_bool(doc, n);
settings->max_horz = -1;
settings->max_vert = -1;
- if ((n = parse_find_node("maximized", app->children))) {
- gchar *s = parse_string(doc, n);
- if (!strcmp(s, "horizontal")) {
- settings->max_horz = TRUE;
- settings->max_vert = FALSE;
- } else if (!strcmp(s, "vertical")) {
- settings->max_horz = FALSE;
- settings->max_vert = TRUE;
- } else
- settings->max_horz = settings->max_vert =
- parse_bool(doc, n);
- g_free(s);
- }
+ if ((n = parse_find_node("maximized", app->children)))
+ if (!parse_contains("default", doc, n)) {
+ gchar *s = parse_string(doc, n);
+ if (!strcmp(s, "horizontal")) {
+ settings->max_horz = TRUE;
+ settings->max_vert = FALSE;
+ } else if (!strcmp(s, "vertical")) {
+ settings->max_horz = FALSE;
+ settings->max_vert = TRUE;
+ } else
+ settings->max_horz = settings->max_vert =
+ parse_bool(doc, n);
+ g_free(s);
+ }
config_per_app_settings = g_slist_append(config_per_app_settings,
(gpointer) settings);
diff --git a/openbox/config.h b/openbox/config.h
index f85f4f11..41cf7482 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -23,12 +23,39 @@
#include "misc.h"
#include "stacking.h"
#include "place.h"
+#include "geom.h"
#include "render/render.h"
#include <glib.h>
struct _ObParseInst;
+struct _ObAppSettings
+{
+ gchar *class;
+ gchar *name;
+ gchar *role;
+
+ Point position;
+ gboolean center_x;
+ gboolean center_y;
+ gboolean pos_given;
+
+ guint desktop;
+ gint shade;
+ gint decor;
+ gint focus;
+ gint monitor;
+ gint iconic;
+ gint skip_pager;
+ gint skip_taskbar;
+ gint max_horz;
+ gint max_vert;
+ gint fullscreen;
+
+ gint layer;
+};
+
/*! Should new windows be focused */
extern gboolean config_focus_new;
/*! Focus windows when the mouse enters them */
diff --git a/openbox/place.c b/openbox/place.c
index ac902d2d..f37973b3 100644
--- a/openbox/place.c
+++ b/openbox/place.c
@@ -52,6 +52,9 @@ static Rect *pick_pointer_head(ObClient *c)
g_assert_not_reached();
}
+/*! Pick a monitor to place a window on.
+ The returned array value should be freed with g_free. The areas within the
+ array should not be freed. */
static Rect **pick_head(ObClient *c)
{
Rect **area;
@@ -388,16 +391,24 @@ static gboolean place_under_mouse(ObClient *client, gint *x, gint *y)
static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
ObAppSettings *settings)
{
- Rect *screen;
+ Rect *screen = NULL;
if (!settings || (settings && !settings->pos_given))
return FALSE;
/* Find which head the pointer is on */
- if (settings->head == -1)
+ if (settings->monitor == 0)
screen = pick_pointer_head(client);
- else
- screen = screen_area_monitor(client->desktop, settings->head);
+ else if (settings->monitor > 0 &&
+ (guint)settings->monitor <= screen_num_monitors)
+ screen = screen_area_monitor(client->desktop,
+ (guint)settings->monitor - 1);
+ else {
+ Rect **all = NULL;
+ all = pick_head(client);
+ screen = all[0];
+ g_free(all); /* the areas themselves don't need to be freed */
+ }
if (settings->center_x)
*x = screen->x + screen->width / 2 - client->area.width / 2;