diff options
author | minus <minus@mnus.de> | 2015-08-25 18:25:36 +0200 |
---|---|---|
committer | minus <minus@mnus.de> | 2015-08-25 18:25:36 +0200 |
commit | 03e4a97dbe5391cfaa7e9d3f1da86fa0a5fa4b4f (patch) | |
tree | b7d17c06a4f0cc689e267fd993a96ee3b4209c93 | |
parent | refactored view visibility (diff) | |
download | sway-03e4a97dbe5391cfaa7e9d3f1da86fa0a5fa4b4f.tar.gz sway-03e4a97dbe5391cfaa7e9d3f1da86fa0a5fa4b4f.tar.zst sway-03e4a97dbe5391cfaa7e9d3f1da86fa0a5fa4b4f.zip |
added "move container to workspace"
makes the previous commit actually testable
-rw-r--r-- | include/layout.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 25 | ||||
-rw-r--r-- | sway/layout.c | 15 |
3 files changed, 40 insertions, 1 deletions
diff --git a/include/layout.h b/include/layout.h index 11bf1a28..8cc26ba8 100644 --- a/include/layout.h +++ b/include/layout.h | |||
@@ -22,6 +22,7 @@ swayc_t *remove_child(swayc_t *child); | |||
22 | void swap_container(swayc_t *a, swayc_t *b); | 22 | void swap_container(swayc_t *a, swayc_t *b); |
23 | 23 | ||
24 | void move_container(swayc_t* container,swayc_t* root,enum movement_direction direction); | 24 | void move_container(swayc_t* container,swayc_t* root,enum movement_direction direction); |
25 | void move_container_to(swayc_t* container, swayc_t* destination); | ||
25 | 26 | ||
26 | // Layout | 27 | // Layout |
27 | void update_geometry(swayc_t *view); | 28 | void update_geometry(swayc_t *view); |
diff --git a/sway/commands.c b/sway/commands.c index 21ff5c7f..23339b9d 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -344,7 +344,7 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char * | |||
344 | } | 344 | } |
345 | 345 | ||
346 | static bool cmd_move(struct sway_config *config, int argc, char **argv) { | 346 | static bool cmd_move(struct sway_config *config, int argc, char **argv) { |
347 | if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) { | 347 | if (!checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1)) { |
348 | return false; | 348 | return false; |
349 | } | 349 | } |
350 | 350 | ||
@@ -358,6 +358,29 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) { | |||
358 | move_container(view,&root_container,MOVE_UP); | 358 | move_container(view,&root_container,MOVE_UP); |
359 | } else if (strcasecmp(argv[0], "down") == 0) { | 359 | } else if (strcasecmp(argv[0], "down") == 0) { |
360 | move_container(view,&root_container,MOVE_DOWN); | 360 | move_container(view,&root_container,MOVE_DOWN); |
361 | } else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) { | ||
362 | // "move container to workspace x" | ||
363 | if (!checkarg(argc, "move container/window", EXPECTED_EQUAL_TO, 4) || | ||
364 | strcasecmp(argv[1], "to") != 0 || | ||
365 | strcasecmp(argv[2], "workspace") != 0) { | ||
366 | return false; | ||
367 | } | ||
368 | |||
369 | if (view->type != C_CONTAINER && view->type != C_VIEW) { | ||
370 | return false; | ||
371 | } | ||
372 | |||
373 | const char *ws_name = argv[3]; | ||
374 | if (argc == 5) { | ||
375 | // move "container to workspace number x" | ||
376 | ws_name = argv[4]; | ||
377 | } | ||
378 | |||
379 | swayc_t *ws = workspace_by_name(ws_name); | ||
380 | if (ws == NULL) { | ||
381 | ws = workspace_create(ws_name); | ||
382 | } | ||
383 | move_container_to(view, ws); | ||
361 | } else { | 384 | } else { |
362 | return false; | 385 | return false; |
363 | } | 386 | } |
diff --git a/sway/layout.c b/sway/layout.c index a37e137c..cd47037b 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -203,6 +203,21 @@ void move_container(swayc_t *container,swayc_t* root,enum movement_direction dir | |||
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | void move_container_to(swayc_t* container, swayc_t* destination) { | ||
207 | if (container->parent == destination) { | ||
208 | return; | ||
209 | } | ||
210 | destroy_container(remove_child(container)); | ||
211 | set_focused_container(get_focused_view(&root_container)); | ||
212 | if (container->is_floating) { | ||
213 | add_floating(destination, container); | ||
214 | } else { | ||
215 | add_child(destination, container); | ||
216 | } | ||
217 | update_visibility(container); | ||
218 | arrange_windows(&root_container, -1, -1); | ||
219 | } | ||
220 | |||
206 | void update_geometry(swayc_t *container) { | 221 | void update_geometry(swayc_t *container) { |
207 | if (container->type != C_VIEW) { | 222 | if (container->type != C_VIEW) { |
208 | return; | 223 | return; |