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.
This commit is contained in:
Ryan Dwyer 2018-08-10 14:10:09 +10:00
parent 146cc0a441
commit b4a0363d17
10 changed files with 173 additions and 34 deletions

View file

@ -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);
}
}