From d334b4b0a72efe2ab33b14e0f7c1f649eeaf3033 Mon Sep 17 00:00:00 2001 From: ProsperousPotato Date: Sat, 9 Aug 2025 11:52:09 +0100 Subject: update quicksearch --- config.h | 3 ++- quicksearch.c | 31 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/config.h b/config.h index 74b8594..0c3ec8b 100755 --- a/config.h +++ b/config.h @@ -130,7 +130,8 @@ static const Key keys[] = { { MODKEY, XK_Print, spawn, SHCMD("maimpick") }, { MODKEY, XK_c, spawn, SHCMD("pgrep xcompmgr && pkill -9 xcompmgr || xcompmgr &") }, - { MODKEY, XK_p, quicksearch, {0} }, + { MODKEY, XK_p, quicksearch, {.i = 0} }, + { MODKEY|ShiftMask, XK_p, quicksearch, {.i = 1} }, }; /* button definitions */ diff --git a/quicksearch.c b/quicksearch.c index 9fa107a..3d6b5a2 100755 --- a/quicksearch.c +++ b/quicksearch.c @@ -9,6 +9,7 @@ quicksearch(const Arg *arg) int client_count = 0; Client **clients = NULL; size_t clients_size = 0; + int mode = arg->i; for (m = mons; m; m = m->next) { for (c = m->clients; c; c = c->next) { @@ -20,7 +21,6 @@ quicksearch(const Arg *arg) int first = 1; for (int i = 0; i < LENGTH(tags); i++) { if (c->tags & (1 << i)) { - if (!first) tag_len += snprintf(tag_str + tag_len, sizeof(tag_str) - tag_len, ","); tag_len += snprintf(tag_str + tag_len, sizeof(tag_str) - tag_len, "%d", i + 1); first = 0; @@ -87,14 +87,29 @@ quicksearch(const Arg *arg) if (strcmp(clients[i]->name, client_name) == 0) { Client *selected_client = clients[i]; - if (selected_client->mon != selmon) - selmon = selected_client->mon; - - Arg view_arg; - view_arg.ui = selected_client->tags; - view(&view_arg); + if (mode == 1) { + selected_client->tags = selmon->tagset[selmon->seltags]; + + if (selected_client->mon != selmon) { + detach(selected_client); + detachstack(selected_client); + selected_client->mon = selmon; + attach(selected_client); + attachstack(selected_client); + } - focus(selected_client); + focus(selected_client); + arrange(selmon); + } else { + if (selected_client->mon != selmon) + selmon = selected_client->mon; + + Arg view_arg; + view_arg.ui = selected_client->tags; + view(&view_arg); + + focus(selected_client); + } if (selected_client != nexttiled(selmon->clients)) { zoom(0); -- cgit v1.2.3