diff options
author | 2015-08-29 00:33:33 -0500 | |
---|---|---|
committer | 2015-08-29 00:33:33 -0500 | |
commit | 167409702fbad100cf1f7ddce70d07b3c0281dfc (patch) | |
tree | 87b344790b633a0264005d0935ec13964593579b /sway/commands.c | |
parent | Added in scratchpad adding (diff) | |
download | sway-167409702fbad100cf1f7ddce70d07b3c0281dfc.tar.gz sway-167409702fbad100cf1f7ddce70d07b3c0281dfc.tar.zst sway-167409702fbad100cf1f7ddce70d07b3c0281dfc.zip |
Fixed move scratchpad and added in scratchpad show
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/sway/commands.c b/sway/commands.c index 55159a43..b123b5dc 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -382,27 +382,23 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) { | |||
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) { | 384 | } else if (strcasecmp(argv[0], "scratchpad") == 0) { |
385 | int i; | 385 | if (view->type != C_CONTAINER && view->type != C_VIEW) { |
386 | return false; | ||
387 | } | ||
386 | swayc_t *view = get_focused_container(&root_container); | 388 | swayc_t *view = get_focused_container(&root_container); |
387 | list_add(scratchpad, view); | 389 | list_add(scratchpad, view); |
388 | if (view->is_floating) { | 390 | if (!view->is_floating) { |
389 | for (i = 0; i < view->parent->floating; i++) { | 391 | destroy_container(remove_child(view)); |
390 | if (view->parent->floating->items[i] == view) { | ||
391 | list_del(view->parent->floating, i); | ||
392 | break; | ||
393 | } | ||
394 | } | ||
395 | wlc_view_set_mask(view->handle, 0); | ||
396 | } else { | 392 | } else { |
397 | for (i = 0; i < view->parent->children) { | 393 | remove_child(view); |
398 | if (view->parent->children->items[i] == view) { | 394 | } |
399 | list_del(view->parent->children, i); | 395 | wlc_view_set_mask(view->handle, 0); |
400 | break; | 396 | arrange_windows(swayc_active_workspace(), -1, -1); |
401 | } | 397 | swayc_t *focused = container_under_pointer(); |
402 | } | 398 | if (focused == NULL) { |
403 | wlc_view_set_mask(view->handle, 0); | 399 | focused = swayc_active_workspace(); |
404 | } | 400 | } |
405 | arrange_windows(&root_container, -1, -1); | 401 | set_focused_container(focused); |
406 | } else { | 402 | } else { |
407 | return false; | 403 | return false; |
408 | } | 404 | } |
@@ -594,6 +590,37 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
594 | return false; | 590 | return false; |
595 | } | 591 | } |
596 | 592 | ||
593 | static 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 | |||
597 | static bool cmd_set(struct sway_config *config, int argc, char **argv) { | 624 | static bool cmd_set(struct sway_config *config, int argc, char **argv) { |
598 | if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) { | 625 | if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) { |
599 | return false; | 626 | return false; |