From: Mikael Magnusson Date: Wed, 13 Jun 2007 17:08:32 +0000 (+0000) Subject: add center option to placement section X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=e048751f914d16cb6346f7e7ca6532eaae44ce31;p=chaz%2Fopenbox add center option to placement section --- diff --git a/data/rc.xml b/data/rc.xml index a5e9bd11..1a4230c7 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -32,6 +32,9 @@ Smart +
yes
+
diff --git a/data/rc.xsd b/data/rc.xsd index 15154191..3e6b312b 100644 --- a/data/rc.xsd +++ b/data/rc.xsd @@ -53,6 +53,7 @@ defines how new windows are placed + diff --git a/openbox/config.c b/openbox/config.c index 10a60fb4..2eb8e13c 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -36,6 +36,7 @@ gboolean config_focus_last; gboolean config_focus_under_mouse; ObPlacePolicy config_place_policy; +gboolean config_place_center; gchar *config_theme; gboolean config_theme_keepborder; @@ -495,6 +496,8 @@ static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, if ((n = parse_find_node("policy", node))) if (parse_contains("UnderMouse", doc, n)) config_place_policy = OB_PLACE_POLICY_MOUSE; + if ((n = parse_find_node("center", node))) + config_place_center = parse_bool(doc, n); } static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, @@ -869,6 +872,7 @@ void config_startup(ObParseInst *i) parse_register(i, "focus", parse_focus, NULL); config_place_policy = OB_PLACE_POLICY_SMART; + config_place_center = TRUE; parse_register(i, "placement", parse_placement, NULL); diff --git a/openbox/config.h b/openbox/config.h index f45196e2..e8c70eb2 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -76,6 +76,8 @@ extern gboolean config_focus_last; extern gboolean config_focus_under_mouse; extern ObPlacePolicy config_place_policy; +/*! Place windows in the center of the free area */ +extern gboolean config_place_center; /*! When true windows' contents are refreshed while they are resized; otherwise they are not updated until the resize is complete */ diff --git a/openbox/place.c b/openbox/place.c index adbb1f4b..845becdb 100644 --- a/openbox/place.c +++ b/openbox/place.c @@ -326,8 +326,12 @@ static gboolean place_nooverlap(ObClient *c, gint *x, gint *y) Rect *r = maxit->data; /* center it in the area */ - *x = r->x + (r->width - c->frame->area.width) / 2; - *y = r->y + (r->height - c->frame->area.height) / 2; + *x = r->x; + *y = r->y; + if (config_place_center) { + *x += (r->width - c->frame->area.width) / 2; + *y += (r->height - c->frame->area.height) / 2; + } ret = TRUE; }