aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-10-08 11:26:45 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-10-08 11:26:45 -0400
commit6271abd644da15070d29d2d06bc527f89a799375 (patch)
treea6b07648871ac884e5770f070224907973c5ac43
parentDocument new criteria (diff)
downloadsway-6271abd644da15070d29d2d06bc527f89a799375.tar.gz
sway-6271abd644da15070d29d2d06bc527f89a799375.tar.zst
sway-6271abd644da15070d29d2d06bc527f89a799375.zip
-rw-r--r--sway/commands/scratchpad.c14
-rw-r--r--sway/criteria.c8
2 files changed, 18 insertions, 4 deletions
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c
index dec32f51..6c5c92df 100644
--- a/sway/commands/scratchpad.c
+++ b/sway/commands/scratchpad.c
@@ -7,10 +7,8 @@
7#include "sway/layout.h" 7#include "sway/layout.h"
8 8
9static swayc_t *fetch_view_from_scratchpad() { 9static swayc_t *fetch_view_from_scratchpad() {
10 if (sp_index >= scratchpad->length) { 10 sp_index = (sp_index + 1) % scratchpad->length;
11 sp_index = 0; 11 swayc_t *view = scratchpad->items[sp_index];
12 }
13 swayc_t *view = scratchpad->items[sp_index++];
14 12
15 if (wlc_view_get_output(view->handle) != swayc_active_output()->handle) { 13 if (wlc_view_get_output(view->handle) != swayc_active_output()->handle) {
16 wlc_view_set_output(view->handle, swayc_active_output()->handle); 14 wlc_view_set_output(view->handle, swayc_active_output()->handle);
@@ -46,6 +44,14 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
46 44
47 if (strcasecmp(argv[0], "show") == 0 && scratchpad->length > 0) { 45 if (strcasecmp(argv[0], "show") == 0 && scratchpad->length > 0) {
48 if (!sp_view) { 46 if (!sp_view) {
47 if (current_container) {
48 // Haxor the scratchpad index if criteria'd
49 for (int i = 0; i < scratchpad->length; ++i) {
50 if (scratchpad->items[i] == current_container) {
51 sp_index = (i - 1) % scratchpad->length;
52 }
53 }
54 }
49 sp_view = fetch_view_from_scratchpad(); 55 sp_view = fetch_view_from_scratchpad();
50 } else { 56 } else {
51 if (swayc_active_workspace() != sp_view->parent) { 57 if (swayc_active_workspace() != sp_view->parent) {
diff --git a/sway/criteria.c b/sway/criteria.c
index f5fe40cb..e8978ebe 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -434,10 +434,18 @@ static void container_match_add(swayc_t *container, struct list_tokens *list_tok
434 list_add(list_tokens->list, container); 434 list_add(list_tokens->list, container);
435 } 435 }
436} 436}
437
437list_t *container_for(list_t *tokens) { 438list_t *container_for(list_t *tokens) {
438 struct list_tokens list_tokens = (struct list_tokens){create_list(), tokens}; 439 struct list_tokens list_tokens = (struct list_tokens){create_list(), tokens};
439 440
440 container_map(&root_container, (void (*)(swayc_t *, void *))container_match_add, &list_tokens); 441 container_map(&root_container, (void (*)(swayc_t *, void *))container_match_add, &list_tokens);
442
443 for (int i = 0; i < scratchpad->length; ++i) {
444 swayc_t *c = scratchpad->items[i];
445 if (criteria_test(c, tokens)) {
446 list_add(list_tokens.list, c);
447 }
448 }
441 449
442 return list_tokens.list; 450 return list_tokens.list;
443} 451}