aboutsummaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
authorCalvin Lee <cyrus296@gmail.com>2017-02-27 20:30:58 -0700
committerCalvin Lee <cyrus296@gmail.com>2017-03-01 11:00:16 -0700
commitb35782bcade4eb21b8e7dab455dad64ab721438d (patch)
tree18dd68d4a4f06da3dc069cfde54a3ebd2fe64f77 /sway/layout.c
parent21ad45b622eb1fc2c68d1036fd9763a37fec668b (diff)
i3 feature support: Moving flotaing containers
This commit lets the 'move' command apply to floating containers as well as tiled ones. The command may be appended with a number of pixels and then optionally the string `px` (like '10 px') in order to move the container more or fewer than the standard ten pixels.
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sway/layout.c b/sway/layout.c
index 5e144cd8..e196ebd3 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -349,10 +349,31 @@ static void swap_children(swayc_t *container, int a, int b) {
}
}
-void move_container(swayc_t *container, enum movement_direction dir) {
+void move_container(swayc_t *container, enum movement_direction dir, int move_amt) {
enum swayc_layouts layout = L_NONE;
swayc_t *parent = container->parent;
- if (container->is_floating || (container->type != C_VIEW && container->type != C_CONTAINER)) {
+ if (container->is_floating) {
+ swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
+ switch(dir) {
+ case MOVE_LEFT:
+ container->x = MAX(0, container->x - move_amt);
+ break;
+ case MOVE_RIGHT:
+ container->x = MIN(output->width - container->width, container->x + move_amt);
+ break;
+ case MOVE_UP:
+ container->y = MAX(0, container->y - move_amt);
+ break;
+ case MOVE_DOWN:
+ container->y = MIN(output->height - container->height, container->y + move_amt);
+ break;
+ default:
+ break;
+ }
+ update_geometry(container);
+ return;
+ }
+ if (container->type != C_VIEW && container->type != C_CONTAINER) {
return;
}
if (dir == MOVE_UP || dir == MOVE_DOWN) {