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/resize.c | |
parent | Merge pull request #2452 from janza/position-command-fix-args (diff) | |
download | sway-b4a0363d1721b2ad2d5afb65764ecb575bd55fa4.tar.gz sway-b4a0363d1721b2ad2d5afb65764ecb575bd55fa4.tar.zst sway-b4a0363d1721b2ad2d5afb65764ecb575bd55fa4.zip |
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/resize.c')
-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) { | |||
158 | return normalize_axis(a) == RESIZE_AXIS_HORIZONTAL ? c->width : c->height; | 158 | return normalize_axis(a) == RESIZE_AXIS_HORIZONTAL ? c->width : c->height; |
159 | } | 159 | } |
160 | 160 | ||
161 | static void resize_tiled(int amount, enum resize_axis axis) { | 161 | static void resize_tiled(struct sway_container *parent, int amount, |
162 | struct sway_container *parent = config->handler_context.current_container; | 162 | enum resize_axis axis) { |
163 | struct sway_container *focused = parent; | 163 | struct sway_container *focused = parent; |
164 | if (!parent) { | 164 | if (!parent) { |
165 | return; | 165 | return; |
@@ -297,6 +297,28 @@ static void resize_tiled(int amount, enum resize_axis axis) { | |||
297 | arrange_windows(parent->parent); | 297 | arrange_windows(parent->parent); |
298 | } | 298 | } |
299 | 299 | ||
300 | void container_resize_tiled(struct sway_container *parent, | ||
301 | enum wlr_edges edge, int amount) { | ||
302 | enum resize_axis axis = RESIZE_AXIS_INVALID; | ||
303 | switch (edge) { | ||
304 | case WLR_EDGE_TOP: | ||
305 | axis = RESIZE_AXIS_UP; | ||
306 | break; | ||
307 | case WLR_EDGE_RIGHT: | ||
308 | axis = RESIZE_AXIS_RIGHT; | ||
309 | break; | ||
310 | case WLR_EDGE_BOTTOM: | ||
311 | axis = RESIZE_AXIS_DOWN; | ||
312 | break; | ||
313 | case WLR_EDGE_LEFT: | ||
314 | axis = RESIZE_AXIS_LEFT; | ||
315 | break; | ||
316 | case WLR_EDGE_NONE: | ||
317 | break; | ||
318 | } | ||
319 | resize_tiled(parent, amount, axis); | ||
320 | } | ||
321 | |||
300 | /** | 322 | /** |
301 | * Implement `resize <grow|shrink>` for a floating container. | 323 | * Implement `resize <grow|shrink>` for a floating container. |
302 | */ | 324 | */ |
@@ -398,7 +420,7 @@ static struct cmd_results *resize_adjust_tiled(enum resize_axis axis, | |||
398 | } | 420 | } |
399 | } | 421 | } |
400 | 422 | ||
401 | resize_tiled(amount->amount, axis); | 423 | resize_tiled(current, amount->amount, axis); |
402 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 424 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
403 | } | 425 | } |
404 | 426 | ||
@@ -421,7 +443,8 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con, | |||
421 | } | 443 | } |
422 | } | 444 | } |
423 | if (width->unit == RESIZE_UNIT_PX) { | 445 | if (width->unit == RESIZE_UNIT_PX) { |
424 | resize_tiled(width->amount - con->width, RESIZE_AXIS_HORIZONTAL); | 446 | resize_tiled(con, width->amount - con->width, |
447 | RESIZE_AXIS_HORIZONTAL); | ||
425 | } | 448 | } |
426 | } | 449 | } |
427 | 450 | ||
@@ -439,7 +462,8 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con, | |||
439 | } | 462 | } |
440 | } | 463 | } |
441 | if (height->unit == RESIZE_UNIT_PX) { | 464 | if (height->unit == RESIZE_UNIT_PX) { |
442 | resize_tiled(height->amount - con->height, RESIZE_AXIS_VERTICAL); | 465 | resize_tiled(con, height->amount - con->height, |
466 | RESIZE_AXIS_HORIZONTAL); | ||
443 | } | 467 | } |
444 | } | 468 | } |
445 | 469 | ||