summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
Diffstat (limited to 'openbox')
-rw-r--r--openbox/config.c107
-rw-r--r--openbox/config.h24
-rw-r--r--openbox/geom.h17
-rw-r--r--openbox/moveresize.c42
-rw-r--r--openbox/place.c16
5 files changed, 85 insertions, 121 deletions
diff --git a/openbox/config.c b/openbox/config.c
index 05853666..7ec2b3e0 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -64,12 +64,7 @@ gboolean config_resize_redraw;
gboolean config_resize_four_corners;
gint config_resize_popup_show;
ObResizePopupPos config_resize_popup_pos;
-gboolean config_resize_popup_x_center;
-gboolean config_resize_popup_y_center;
-gboolean config_resize_popup_x_opposite;
-gboolean config_resize_popup_y_opposite;
-gint config_resize_popup_x;
-gint config_resize_popup_y;
+GravityPoint config_resize_popup_fixed;
ObStackingLayer config_dock_layer;
gboolean config_dock_floating;
@@ -143,16 +138,28 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
if (src->pos_given) {
dst->pos_given = TRUE;
- dst->center_x = src->center_x;
- dst->center_y = src->center_y;
- dst->opposite_x = src->opposite_x;
- dst->opposite_y = src->opposite_y;
- dst->position.x = src->position.x;
- dst->position.y = src->position.y;
+ dst->position = src->position;
dst->monitor = src->monitor;
}
}
+static void config_parse_gravity_coord(xmlDocPtr doc, xmlNodePtr node,
+ GravityCoord *c)
+{
+ gchar *s = parse_string(doc, node);
+ if (!g_ascii_strcasecmp(s, "center"))
+ c->center = TRUE;
+ else {
+ if (s[0] == '-')
+ c->opposite = TRUE;
+ if (s[0] == '-' || s[0] == '+')
+ c->pos = atoi(s+1);
+ else
+ c->pos = atoi(s);
+ }
+ g_free(s);
+}
+
/*
<applications>
<application name="aterm">
@@ -218,38 +225,16 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
if ((n = parse_find_node("position", app->children))) {
if ((c = parse_find_node("x", n->children)))
if (!parse_contains("default", doc, c)) {
- gchar *s = parse_string(doc, c);
- if (!g_ascii_strcasecmp(s, "center")) {
- settings->center_x = TRUE;
- x_pos_given = TRUE;
- } else {
- if (s[0] == '-')
- settings->opposite_x = TRUE;
- if (s[0] == '-' || s[0] == '+')
- settings->position.x = atoi(s+1);
- else
- settings->position.x = atoi(s);
- x_pos_given = TRUE;
- }
- g_free(s);
+ config_parse_gravity_coord(doc, c,
+ &settings->position.x);
+ settings->pos_given = TRUE;
}
if (x_pos_given && (c = parse_find_node("y", n->children)))
if (!parse_contains("default", doc, c)) {
- gchar *s = parse_string(doc, c);
- if (!g_ascii_strcasecmp(s, "center")) {
- settings->center_y = TRUE;
- settings->pos_given = TRUE;
- } else {
- if (s[0] == '-')
- settings->opposite_y = TRUE;
- if (s[0] == '-' || s[0] == '+')
- settings->position.y = atoi(s+1);
- else
- settings->position.y = atoi(s);
- settings->pos_given = TRUE;
- }
- g_free(s);
+ config_parse_gravity_coord(doc, c,
+ &settings->position.y);
+ settings->pos_given = TRUE;
}
if (settings->pos_given &&
@@ -677,34 +662,12 @@ static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
if ((n = parse_find_node("popupFixedPosition", node))) {
xmlNodePtr n2;
- if ((n2 = parse_find_node("x", n->children))) {
- gchar *s = parse_string(doc, n2);
- if (!g_ascii_strcasecmp(s, "center"))
- config_resize_popup_x_center = TRUE;
- else {
- if (s[0] == '-')
- config_resize_popup_x_opposite = TRUE;
- if (s[0] == '-' || s[0] == '+')
- config_resize_popup_x = atoi(s+1);
- else
- config_resize_popup_x = atoi(s);
- }
- }
- if ((n2 = parse_find_node("y", n->children))) {
- gchar *s = parse_string(doc, n2);
- if (!g_ascii_strcasecmp(s, "center"))
- config_resize_popup_y_center = TRUE;
- else {
- if (s[0] == '-')
- config_resize_popup_y_opposite = TRUE;
- if (s[0] == '-' || s[0] == '+')
- config_resize_popup_y = atoi(s+1);
- else
- config_resize_popup_y = atoi(s);
- }
- }
- g_print("X %d %d %d\n", config_resize_popup_x_center, config_resize_popup_x_opposite, config_resize_popup_x);
- g_print("Y %d %d %d\n", config_resize_popup_y_center, config_resize_popup_y_opposite, config_resize_popup_y);
+ if ((n2 = parse_find_node("x", n->children)))
+ config_parse_gravity_coord(doc, n2,
+ &config_resize_popup_fixed.x);
+ if ((n2 = parse_find_node("y", n->children)))
+ config_parse_gravity_coord(doc, n2,
+ &config_resize_popup_fixed.y);
}
}
}
@@ -956,12 +919,8 @@ void config_startup(ObParseInst *i)
config_resize_four_corners = FALSE;
config_resize_popup_show = 1; /* nonpixel increments */
config_resize_popup_pos = OB_RESIZE_POS_CENTER;
- config_resize_popup_x_center = FALSE;
- config_resize_popup_x_opposite = FALSE;
- config_resize_popup_x = 0;
- config_resize_popup_y_center = FALSE;
- config_resize_popup_y_opposite = FALSE;
- config_resize_popup_y = 0;
+ GRAVITY_COORD_SET(config_resize_popup_fixed.x, 0, FALSE, FALSE);
+ GRAVITY_COORD_SET(config_resize_popup_fixed.y, 0, FALSE, FALSE);
parse_register(i, "resize", parse_resize, NULL);
diff --git a/openbox/config.h b/openbox/config.h
index 4fa9c70b..240b04f1 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -39,11 +39,7 @@ struct _ObAppSettings
GPatternSpec *name;
GPatternSpec *role;
- Point position;
- gboolean center_x;
- gboolean center_y;
- gboolean opposite_x;
- gboolean opposite_y;
+ GravityPoint position;
gboolean pos_given;
guint desktop;
@@ -95,22 +91,8 @@ extern gboolean config_resize_redraw;
extern gint config_resize_popup_show;
/*! where to show the resize popup */
extern ObResizePopupPos config_resize_popup_pos;
-/*! if the resize popup should be centered horizontally if it is being
- placed in a fixed position */
-extern gboolean config_resize_popup_x_center;
-/*! if the resize popup should be centered vertically if it is being
- placed in a fixed position */
-extern gboolean config_resize_popup_y_center;
-/*! if the resize popup should be placed from the right side of the screen when
- placed in a fixed position */
-extern gboolean config_resize_popup_x_opposite;
-/*! if the resize popup should be placed from the bottom side of the screen
- when placed in a fixed position */
-extern gboolean config_resize_popup_y_opposite;
-/*! where the resize popup should be if it is placed in a fixed position */
-extern gint config_resize_popup_x;
-/*! where the resize popup should be if it is placed in a fixed position */
-extern gint config_resize_popup_y;
+/*! where to place the popup if it's in a fixed position */
+extern GravityPoint config_resize_popup_fixed;
/*! The stacking layer the dock will reside in */
extern ObStackingLayer config_dock_layer;
diff --git a/openbox/geom.h b/openbox/geom.h
index 43eb8ea3..bdcd3c55 100644
--- a/openbox/geom.h
+++ b/openbox/geom.h
@@ -20,6 +20,23 @@
#ifndef __geom_h
#define __geom_h
+#include <glib.h>
+
+typedef struct _GravityCoord {
+ int pos;
+ gboolean center;
+ gboolean opposite;
+} GravityCoord;
+
+typedef struct _GravityPoint {
+ GravityCoord x;
+ GravityCoord y;
+} GravityPoint;
+
+#define GRAVITY_COORD_SET(c, p, cen, opp) \
+ (c).pos = (p), (c).center = (cen), (c).opposite = (opp)
+
+
typedef struct _Point {
int x;
int y;
diff --git a/openbox/moveresize.c b/openbox/moveresize.c
index 07b8e22b..8dc122c7 100644
--- a/openbox/moveresize.c
+++ b/openbox/moveresize.c
@@ -116,36 +116,42 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b)
Rect *area = screen_physical_area_active();
gint gravity, x, y;
- x = config_resize_popup_x;
- if (config_resize_popup_x_center) x = area->x + area->width/2;
- else if (config_resize_popup_x_opposite) x = RECT_RIGHT(*area) - x;
- else x = area->x + x;
-
- y = config_resize_popup_y;
- if (config_resize_popup_y_center) y = area->y + area->height/2;
- else if (config_resize_popup_y_opposite) y = RECT_BOTTOM(*area) - y;
- else y = area->y + y;
-
- if (config_resize_popup_x_center) {
- if (config_resize_popup_y_center)
+ x = config_resize_popup_fixed.x.pos;
+ if (config_resize_popup_fixed.x.center)
+ x = area->x + area->width/2;
+ else if (config_resize_popup_fixed.x.opposite)
+ x = RECT_RIGHT(*area) - x;
+ else
+ x = area->x + x;
+
+ y = config_resize_popup_fixed.y.pos;
+ if (config_resize_popup_fixed.y.center)
+ y = area->y + area->width/2;
+ else if (config_resize_popup_fixed.y.opposite)
+ y = RECT_RIGHT(*area) - y;
+ else
+ y = area->y + y;
+
+ if (config_resize_popup_fixed.x.center) {
+ if (config_resize_popup_fixed.y.center)
gravity = CenterGravity;
- else if (config_resize_popup_y_opposite)
+ else if (config_resize_popup_fixed.y.opposite)
gravity = SouthGravity;
else
gravity = NorthGravity;
}
- else if (config_resize_popup_x_opposite) {
- if (config_resize_popup_y_center)
+ else if (config_resize_popup_fixed.x.opposite) {
+ if (config_resize_popup_fixed.y.center)
gravity = EastGravity;
- else if (config_resize_popup_y_opposite)
+ else if (config_resize_popup_fixed.y.opposite)
gravity = SouthEastGravity;
else
gravity = NorthEastGravity;
}
else {
- if (config_resize_popup_y_center)
+ if (config_resize_popup_fixed.y.center)
gravity = WestGravity;
- else if (config_resize_popup_y_opposite)
+ else if (config_resize_popup_fixed.y.opposite)
gravity = SouthWestGravity;
else
gravity = NorthWestGravity;
diff --git a/openbox/place.c b/openbox/place.c
index 276d9288..058bbfbe 100644
--- a/openbox/place.c
+++ b/openbox/place.c
@@ -407,21 +407,21 @@ static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
g_free(areas);
}
- if (settings->center_x)
+ if (settings->position.x.center)
*x = screen->x + screen->width / 2 - client->area.width / 2;
- else if (settings->opposite_x)
+ else if (settings->position.x.opposite)
*x = screen->x + screen->width - client->frame->area.width -
- settings->position.x;
+ settings->position.x.pos;
else
- *x = screen->x + settings->position.x;
+ *x = screen->x + settings->position.x.pos;
- if (settings->center_y)
+ if (settings->position.y.center)
*y = screen->y + screen->height / 2 - client->area.height / 2;
- else if (settings->opposite_y)
+ else if (settings->position.y.opposite)
*y = screen->y + screen->height - client->frame->area.height -
- settings->position.y;
+ settings->position.y.pos;
else
- *y = screen->y + settings->position.y;
+ *y = screen->y + settings->position.y.pos;
g_free(screen);
return TRUE;