aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-29 00:33:33 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-29 00:33:33 -0500
commit167409702fbad100cf1f7ddce70d07b3c0281dfc (patch)
tree87b344790b633a0264005d0935ec13964593579b
parentAdded in scratchpad adding (diff)
downloadsway-167409702fbad100cf1f7ddce70d07b3c0281dfc.tar.gz
sway-167409702fbad100cf1f7ddce70d07b3c0281dfc.tar.zst
sway-167409702fbad100cf1f7ddce70d07b3c0281dfc.zip
Fixed move scratchpad and added in scratchpad show
-rw-r--r--sway/commands.c61
-rw-r--r--sway/layout.c18
2 files changed, 58 insertions, 21 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
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
597static bool cmd_set(struct sway_config *config, int argc, char **argv) { 624static 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;
diff --git a/sway/layout.c b/sway/layout.c
index c7c5c477..875115e7 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -26,10 +26,20 @@ void init_layout(void) {
26 26
27int index_child(const swayc_t *child) { 27int index_child(const swayc_t *child) {
28 swayc_t *parent = child->parent; 28 swayc_t *parent = child->parent;
29 int i, len = parent->children->length; 29 int i, len;
30 for (i = 0; i < len; ++i) { 30 if (!child->is_floating) {
31 if (parent->children->items[i] == child) { 31 len = parent->children->length;
32 break; 32 for (i = 0; i < len; ++i) {
33 if (parent->children->items[i] == child) {
34 break;
35 }
36 }
37 } else {
38 len = parent->floating->length;
39 for (i = 0; i < len; ++i) {
40 if (parent->floating->items[i] == child) {
41 break;
42 }
33 } 43 }
34 } 44 }
35 if (!sway_assert(i < len, "Stray container")) { 45 if (!sway_assert(i < len, "Stray container")) {