diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 24 | ||||
-rw-r--r-- | sway/layout.c | 44 |
2 files changed, 67 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index d1bbdc89..cb96703e 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -206,7 +206,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
206 | if (!view->is_floating) { | 206 | if (!view->is_floating) { |
207 | // Remove view from its current location | 207 | // Remove view from its current location |
208 | destroy_container(remove_child(view)); | 208 | destroy_container(remove_child(view)); |
209 | 209 | ||
210 | // and move it into workspace floating | 210 | // and move it into workspace floating |
211 | add_floating(active_workspace,view); | 211 | add_floating(active_workspace,view); |
212 | view->x = (active_workspace->width - view->width)/2; | 212 | view->x = (active_workspace->width - view->width)/2; |
@@ -341,6 +341,27 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char * | |||
341 | return true; | 341 | return true; |
342 | } | 342 | } |
343 | 343 | ||
344 | static bool cmd_move(struct sway_config *config, int argc, char **argv) { | ||
345 | if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) { | ||
346 | return false; | ||
347 | } | ||
348 | |||
349 | swayc_t *view = get_focused_container(&root_container); | ||
350 | |||
351 | if (strcasecmp(argv[0], "left") == 0) { | ||
352 | move_container(view,&root_container,MOVE_LEFT); | ||
353 | } else if (strcasecmp(argv[0], "right") == 0) { | ||
354 | move_container(view,&root_container,MOVE_RIGHT); | ||
355 | } else if (strcasecmp(argv[0], "up") == 0) { | ||
356 | move_container(view,&root_container,MOVE_UP); | ||
357 | } else if (strcasecmp(argv[0], "down") == 0) { | ||
358 | move_container(view,&root_container,MOVE_DOWN); | ||
359 | } else { | ||
360 | return false; | ||
361 | } | ||
362 | return true; | ||
363 | } | ||
364 | |||
344 | static bool cmd_gaps(struct sway_config *config, int argc, char **argv) { | 365 | static bool cmd_gaps(struct sway_config *config, int argc, char **argv) { |
345 | if (!checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1)) { | 366 | if (!checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1)) { |
346 | return false; | 367 | return false; |
@@ -736,6 +757,7 @@ static struct cmd_handler handlers[] = { | |||
736 | { "kill", cmd_kill }, | 757 | { "kill", cmd_kill }, |
737 | { "layout", cmd_layout }, | 758 | { "layout", cmd_layout }, |
738 | { "log_colors", cmd_log_colors }, | 759 | { "log_colors", cmd_log_colors }, |
760 | { "move", cmd_move}, | ||
739 | { "reload", cmd_reload }, | 761 | { "reload", cmd_reload }, |
740 | { "resize", cmd_resize }, | 762 | { "resize", cmd_resize }, |
741 | { "set", cmd_set }, | 763 | { "set", cmd_set }, |
diff --git a/sway/layout.c b/sway/layout.c index 35aa4942..7eaa9ea4 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -108,6 +108,50 @@ swayc_t *remove_child(swayc_t *child) { | |||
108 | return parent; | 108 | return parent; |
109 | } | 109 | } |
110 | 110 | ||
111 | //TODO: Implement horizontal movement. | ||
112 | //TODO: Implement move to a different workspace. | ||
113 | void move_container(swayc_t *container,swayc_t* root,enum movement_direction direction){ | ||
114 | sway_log(L_DEBUG, "Moved window"); | ||
115 | swayc_t *temp; | ||
116 | int i; | ||
117 | uint clength = root->children->length; | ||
118 | //Rearrange | ||
119 | for (i = 0; i < clength; ++i) { | ||
120 | swayc_t *child = root->children->items[i]; | ||
121 | if (child->handle == container->handle){ | ||
122 | if (clength == 1){ | ||
123 | //Only one container, meh. | ||
124 | break; | ||
125 | } | ||
126 | if (direction == MOVE_LEFT && i > 0){ | ||
127 | temp = root->children->items[i-1]; | ||
128 | root->children->items[i] = temp; | ||
129 | root->children->items[i-1] = container; | ||
130 | arrange_windows(&root_container,-1,-1); | ||
131 | } | ||
132 | else if (direction == MOVE_RIGHT && i < clength-1){ | ||
133 | temp = root->children->items[i+1]; | ||
134 | root->children->items[i] = temp; | ||
135 | root->children->items[i+1] = container; | ||
136 | arrange_windows(&root_container,-1,-1); | ||
137 | |||
138 | } | ||
139 | else if (direction == MOVE_UP){ | ||
140 | sway_log(L_INFO, "Moving up not implemented"); | ||
141 | } | ||
142 | else if (direction == MOVE_DOWN){ | ||
143 | sway_log(L_INFO, "Moving down not implemented"); | ||
144 | } | ||
145 | |||
146 | break; | ||
147 | } | ||
148 | else if (child->children != NULL){ | ||
149 | move_container(container,child,direction); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||
111 | 155 | ||
112 | void arrange_windows(swayc_t *container, double width, double height) { | 156 | void arrange_windows(swayc_t *container, double width, double height) { |
113 | int i; | 157 | int i; |