X-Git-Url: http://git.openbox.org/?p=dana%2Fopenbox.git;a=blobdiff_plain;f=openbox%2Factions%2Fgrowtoedge.c;h=630ead10c446861a103fbdd7ad9d0c009da43c05;hp=69b8ef77b33ce4db0621992c08ceafe9b26e7a15;hb=2b8b5da04b14af1639143cc332874c7e1a03a8bb;hpb=46f90bca8ab55a2f43bf33af1adf178bd0bd81d9 diff --git a/openbox/actions/growtoedge.c b/openbox/actions/growtoedge.c index 69b8ef7..630ead1 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(void) 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 :