summaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2023-03-12 15:37:11 +0000
committer0scar <qgt268@alumni.ku.dk>2024-10-01 11:57:23 +0000
commit1fadd97647f6849f04d673bb98b75c8fe2683ea8 (patch)
tree439fcbe47ddb43918ad6288aa2afa7e60dc6c1d7 /dwl.c
parente67193d9b10627b010cd35790962915c4327d845 (diff)
Patch: extend foccusstack to enable focus first or last
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/dwl.c b/dwl.c
index 663ef9f..6fc2969 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1610,7 +1610,21 @@ focusstack(const Arg *arg)
Client *c, *sel = focustop(selmon);
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
return;
- if (arg->i > 0) {
+ /* If i == 0 select the first client */
+ if (arg->i == 0) {
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen)
+ continue;
+ break;
+ }
+ /* If i == INT_MAX select the last client */
+ } else if (arg->i == INT_MAX) {
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen)
+ continue;
+ break;
+ }
+ } else if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
if (&c->link == &clients)
continue; /* wrap past the sentinel node */