From 2a62c5c7fb71fc815663281793ba6a89d2b246ed Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Thu, 20 Aug 2015 21:27:38 +0100 Subject: Basic left right move command implemented. --- sway/layout.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'sway/layout.c') diff --git a/sway/layout.c b/sway/layout.c index 105359d2..9fdfd62a 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -91,6 +91,50 @@ swayc_t *remove_child(swayc_t *child) { return parent; } +void move_container(swayc_t *container,swayc_t* root,int direction){ + sway_log(L_DEBUG, "Moved window"); + swayc_t *temp; + int i; + uint clength = root->children->length; + //Rearrange + for (i = 0; i < clength; ++i) { + swayc_t *child = root->children->items[i]; + if(child->handle == container->handle){ + if(clength == 1){ + //Only one container, meh. + break; + } + + //TODO: Implement move to a different workspace. + if(direction == MOVE_LEFT && i > 0){ + temp = root->children->items[i-1]; + root->children->items[i] = temp; + root->children->items[i-1] = container; + arrange_windows(&root_container,-1,-1); + } + else if(direction == MOVE_RIGHT && i < clength-1){ + temp = root->children->items[i+1]; + root->children->items[i] = temp; + root->children->items[i+1] = container; + arrange_windows(&root_container,-1,-1); + + } + else if(direction == MOVE_UP){ + sway_log(L_INFO, "Moving up not implemented"); + } + else if(direction == MOVE_DOWN){ + sway_log(L_INFO, "Moving down not implemented"); + } + + break; + } + else if(child->children != NULL){ + move_container(container,child,direction); + } + } + +} + void arrange_windows(swayc_t *container, int width, int height) { int i; @@ -282,4 +326,3 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) { } return NULL; } - -- cgit v1.2.3 From 713bf29ec901b711d782e96721898c32fcd5d56e Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Thu, 20 Aug 2015 21:45:00 +0100 Subject: Few stray bits --- sway/layout.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sway/layout.c') diff --git a/sway/layout.c b/sway/layout.c index a48f15c4..0c1f736d 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -108,7 +108,9 @@ swayc_t *remove_child(swayc_t *child) { return parent; } -void move_container(swayc_t *container,swayc_t* root,int direction){ +//TODO: Implement horizontal movement. +//TODO: Implement move to a different workspace. +void move_container(swayc_t *container,swayc_t* root,enum movement_direction direction){ sway_log(L_DEBUG, "Moved window"); swayc_t *temp; int i; @@ -121,8 +123,6 @@ void move_container(swayc_t *container,swayc_t* root,int direction){ //Only one container, meh. break; } - //TODO: Implement horizontal movement. - //TODO: Implement move to a different workspace. if(direction == MOVE_LEFT && i > 0){ temp = root->children->items[i-1]; root->children->items[i] = temp; -- cgit v1.2.3 From 68213d57c5c758d05582ef8a9f0db226ddbaefc7 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Thu, 20 Aug 2015 22:29:36 +0100 Subject: Fixed style errors --- sway/layout.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sway/layout.c') diff --git a/sway/layout.c b/sway/layout.c index 0c1f736d..a7536727 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -118,34 +118,34 @@ void move_container(swayc_t *container,swayc_t* root,enum movement_direction dir //Rearrange for (i = 0; i < clength; ++i) { swayc_t *child = root->children->items[i]; - if(child->handle == container->handle){ - if(clength == 1){ + if (child->handle == container->handle){ + if (clength == 1){ //Only one container, meh. break; } - if(direction == MOVE_LEFT && i > 0){ + if (direction == MOVE_LEFT && i > 0){ temp = root->children->items[i-1]; root->children->items[i] = temp; root->children->items[i-1] = container; arrange_windows(&root_container,-1,-1); } - else if(direction == MOVE_RIGHT && i < clength-1){ + else if (direction == MOVE_RIGHT && i < clength-1){ temp = root->children->items[i+1]; root->children->items[i] = temp; root->children->items[i+1] = container; arrange_windows(&root_container,-1,-1); } - else if(direction == MOVE_UP){ + else if (direction == MOVE_UP){ sway_log(L_INFO, "Moving up not implemented"); } - else if(direction == MOVE_DOWN){ + else if (direction == MOVE_DOWN){ sway_log(L_INFO, "Moving down not implemented"); } break; } - else if(child->children != NULL){ + else if (child->children != NULL){ move_container(container,child,direction); } } -- cgit v1.2.3