From 168235a2f8714fe4eb39ea482f5420b5504cd787 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Wed, 1 May 2024 23:09:46 +0200 Subject: [PATCH] Focus nth client --- config.def.h | 1 + dwl.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/config.def.h b/config.def.h index 8847e58..e3300a8 100644 --- a/config.def.h +++ b/config.def.h @@ -143,6 +143,7 @@ static const Key keys[] = { { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} }, + { MODKEY, XKB_KEY_m, focusnthclient, {0} }, TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), diff --git a/dwl.c b/dwl.c index bf763df..e0dce0f 100644 --- a/dwl.c +++ b/dwl.c @@ -281,6 +281,7 @@ static Monitor *dirtomon(enum wlr_direction dir); static void focusclient(Client *c, int lift); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); +static void focusnthclient(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); static void handlesig(int signo); @@ -2569,6 +2570,22 @@ tagmon(const Arg *arg) setmon(sel, dirtomon(arg->i), 0); } +void +focusnthclient(const Arg *arg) +{ + Client *c; + unsigned int i = arg->ui; + + wl_list_for_each(c, &clients, link) { + if (i == 0) { + focusclient(c, 1); + return; + } + + i--; + } +} + void tile(Monitor *m) { -- 2.48.1