From: Dana Jansens Date: Sun, 6 May 2007 22:57:49 +0000 (+0000) Subject: change the perapp settings "head" option to "monitor" i think its easier to understand. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=7ffa091d5b464ce508023c3b5e5bc50a36be53fb;p=chaz%2Fopenbox 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. --- diff --git a/data/rc.xml.in b/data/rc.xml.in index 45e144a3..ca4c7764 100644 --- a/data/rc.xml.in +++ b/data/rc.xml.in @@ -457,15 +457,16 @@ 200 - 0 - + 1 + yes 1 - + normal 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; 700 0 - 1 + 1 + .. there is a lot more settings available */ /* 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 center1 - will center the window on the second head. + center the window in the specified axis. Position is within + the monitor, so center2 + 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 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;