summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 8a790384..b123b5dc 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
346static bool cmd_move(struct sway_config *config, int argc, char **argv) { 346static bool cmd_move(struct sway_config *config, int argc, char **argv) {
347 if (!checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1)) { 347 if (!checkarg(argc, "move", EXPECTED_AT_LEAST, 1)) {
348 return false; 348 return false;
349 } 349 }
350 350
@@ -381,6 +381,24 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) {
381 ws = workspace_create(ws_name); 381 ws = workspace_create(ws_name);
382 } 382 }
383 move_container_to(view, get_focused_container(ws)); 383 move_container_to(view, get_focused_container(ws));
384 } else if (strcasecmp(argv[0], "scratchpad") == 0) {
385 if (view->type != C_CONTAINER && view->type != C_VIEW) {
386 return false;
387 }
388 swayc_t *view = get_focused_container(&root_container);
389 list_add(scratchpad, view);
390 if (!view->is_floating) {
391 destroy_container(remove_child(view));
392 } else {
393 remove_child(view);
394 }
395 wlc_view_set_mask(view->handle, 0);
396 arrange_windows(swayc_active_workspace(), -1, -1);
397 swayc_t *focused = container_under_pointer();
398 if (focused == NULL) {
399 focused = swayc_active_workspace();
400 }
401 set_focused_container(focused);
384 } else { 402 } else {
385 return false; 403 return false;
386 } 404 }
@@ -572,6 +590,37 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
572 return false; 590 return false;
573} 591}
574 592
593static bool cmd_scratchpad(struct sway_config *config, int argc, char **argv) {
594 if (!checkarg(argc, "scratchpad", EXPECTED_EQUAL_TO, 1)) {
595 return false;
596 }
597 if (strcasecmp(argv[0], "show") == 0) {
598 if (scratchpad->length > 0) {
599 swayc_t *view = scratchpad->items[0];
600 list_del(scratchpad, 0);
601 add_floating(swayc_active_workspace(), view);
602 view->x = (swayc_active_workspace()->width - view->width)/2;
603 view->y = (swayc_active_workspace()->height - view->height)/2;
604 if (view->desired_width != -1) {
605 view->width = view->desired_width;
606 }
607 if (view->desired_height != -1) {
608 view->height = view->desired_height;
609 }
610 wlc_view_set_mask(view->handle, VISIBLE);
611 arrange_windows(swayc_active_workspace(), -1, -1);
612 swayc_t *focused = container_under_pointer();
613 if (focused == NULL) {
614 focused = swayc_active_workspace();
615 }
616 set_focused_container(focused);
617 }
618 return true;
619 } else {
620 return false;
621 }
622}
623
575static bool cmd_set(struct sway_config *config, int argc, char **argv) { 624static bool cmd_set(struct sway_config *config, int argc, char **argv) {
576 if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) { 625 if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) {
577 return false; 626 return false;
@@ -742,6 +791,7 @@ static struct cmd_handler handlers[] = {
742 { "output", cmd_output}, 791 { "output", cmd_output},
743 { "reload", cmd_reload }, 792 { "reload", cmd_reload },
744 { "resize", cmd_resize }, 793 { "resize", cmd_resize },
794 { "scratchpad", cmd_scratchpad },
745 { "set", cmd_set }, 795 { "set", cmd_set },
746 { "split", cmd_split }, 796 { "split", cmd_split },
747 { "splith", cmd_splith }, 797 { "splith", cmd_splith },