diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-10 14:10:09 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-12 10:45:54 +1000 |
commit | b4a0363d1721b2ad2d5afb65764ecb575bd55fa4 (patch) | |
tree | f6ec316550cd113040e82a7f0cee0429fff349e5 /sway/commands | |
parent | 146cc0a441f6901eeba7df691098f71d0de73a53 (diff) |
Implement resizing tiled containers via cursor
* The OP_RESIZE seat operation has been renamed to OP_RESIZE_FLOATING,
and OP_RESIZE_TILING has been introduced.
* Similar to the above, seat_begin_resize and handle_resize_motion have
been renamed and tiling variants introduced.
* resize.c's resize_tiled has to be used, so container_resize_tiled has
been introduced in resize.c to allow external code to call it.
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/resize.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index c3560985..0f3005f4 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -158,8 +158,8 @@ static int parallel_size(struct sway_container *c, enum resize_axis a) { return normalize_axis(a) == RESIZE_AXIS_HORIZONTAL ? c->width : c->height; } -static void resize_tiled(int amount, enum resize_axis axis) { - struct sway_container *parent = config->handler_context.current_container; +static void resize_tiled(struct sway_container *parent, int amount, + enum resize_axis axis) { struct sway_container *focused = parent; if (!parent) { return; @@ -297,6 +297,28 @@ static void resize_tiled(int amount, enum resize_axis axis) { arrange_windows(parent->parent); } +void container_resize_tiled(struct sway_container *parent, + enum wlr_edges edge, int amount) { + enum resize_axis axis = RESIZE_AXIS_INVALID; + switch (edge) { + case WLR_EDGE_TOP: + axis = RESIZE_AXIS_UP; + break; + case WLR_EDGE_RIGHT: + axis = RESIZE_AXIS_RIGHT; + break; + case WLR_EDGE_BOTTOM: + axis = RESIZE_AXIS_DOWN; + break; + case WLR_EDGE_LEFT: + axis = RESIZE_AXIS_LEFT; + break; + case WLR_EDGE_NONE: + break; + } + resize_tiled(parent, amount, axis); +} + /** * Implement `resize <grow|shrink>` for a floating container. */ @@ -398,7 +420,7 @@ static struct cmd_results *resize_adjust_tiled(enum resize_axis axis, } } - resize_tiled(amount->amount, axis); + resize_tiled(current, amount->amount, axis); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -421,7 +443,8 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con, } } if (width->unit == RESIZE_UNIT_PX) { - resize_tiled(width->amount - con->width, RESIZE_AXIS_HORIZONTAL); + resize_tiled(con, width->amount - con->width, + RESIZE_AXIS_HORIZONTAL); } } @@ -439,7 +462,8 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con, } } if (height->unit == RESIZE_UNIT_PX) { - resize_tiled(height->amount - con->height, RESIZE_AXIS_VERTICAL); + resize_tiled(con, height->amount - con->height, + RESIZE_AXIS_HORIZONTAL); } } |