From 1fadd97647f6849f04d673bb98b75c8fe2683ea8 Mon Sep 17 00:00:00 2001 From: 0scar Date: Sun, 12 Mar 2023 16:37:11 +0100 Subject: Patch: extend foccusstack to enable focus first or last --- dwl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'dwl.c') 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 */ -- cgit v1.3