summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@comhem.se>2007-10-03 14:05:15 +0200
committerMikael Magnusson <mikachu@comhem.se>2007-10-03 14:07:45 +0200
commit9586ad246dae1f1de89f2070722cfa0c0c41c477 (patch)
treed49809e4dff7d501b9fadccea8fa2044f79a94d2 /openbox
parentf55ae9e56945892825928cfb021b5e739d0d5224 (diff)
Add complementing ShrinkToEdge action.
Diffstat (limited to 'openbox')
-rw-r--r--openbox/actions/growtoedge.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/openbox/actions/growtoedge.c b/openbox/actions/growtoedge.c
index 2e2b7011..44e52872 100644
--- a/openbox/actions/growtoedge.c
+++ b/openbox/actions/growtoedge.c
@@ -7,9 +7,11 @@
typedef struct {
ObDirection dir;
+ gboolean shrink;
} Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_shrink_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
@@ -20,6 +22,12 @@ void action_growtoedge_startup()
free_func,
run_func,
NULL, NULL);
+
+ actions_register("ShrinkToEdge",
+ setup_shrink_func,
+ free_func,
+ run_func,
+ NULL, NULL);
}
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
@@ -29,6 +37,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH;
+ o->shrink = FALSE;
if ((n = parse_find_node("direction", node))) {
gchar *s = parse_string(doc, n);
@@ -50,6 +59,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
+static gpointer setup_shrink_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+{
+ Options *o;
+
+ o = setup_func(i, doc, node);
+ o->shrink = TRUE;
+
+ return o;
+}
+
static void free_func(gpointer options)
{
Options *o = options;
@@ -98,11 +117,13 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
- /* try grow */
- client_find_resize_directional(data->client, o->dir, TRUE,
- &x, &y, &w, &h);
- if (do_grow(data, x, y, w, h))
- return FALSE;
+ if (!o->shrink) {
+ /* try grow */
+ client_find_resize_directional(data->client, o->dir, TRUE,
+ &x, &y, &w, &h);
+ if (do_grow(data, x, y, w, h))
+ return FALSE;
+ }
/* we couldn't grow, so try shrink! */
opp = (o->dir == OB_DIRECTION_NORTH ? OB_DIRECTION_SOUTH :