dwm

dynamic window manager

git clone https://9o.is/git/dwm.git

commit 5587534f9bab8f70e323d9d68da9c3bacc3b5d24
parent 6befce5359a4667dcb9e82b0c13119ece7d9a8f8
Author: Jul <jul@9o.is>
Date:   Mon,  2 Feb 2026 12:18:47 -0500

arrow keys navigates windows in foreground

Diffstat:
Mdwm.c | 29+++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/dwm.c b/dwm.c @@ -153,12 +153,14 @@ static void applyrules(Client *c); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int *bw, int interact); static void arrange(Monitor *m); static void arrangemon(Monitor *m); +static void arrangeforegrounded(Monitor *m); static void attach(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); static void cleanup(void); static void cleanupmon(Monitor *mon); +static void clientforeground(Client *c); static void clientmessage(XEvent *e); static void configure(Client *c); static void configurenotify(XEvent *e); @@ -994,7 +996,13 @@ focusstack(const Arg *arg) if (ISVISIBLE(i)) c = i; } - if (c) { + if (c && selmon->sel->isforegrounded) { + clientforeground(selmon->sel); + clientforeground(c); + focus(c); + arrangeforegrounded(selmon); + arrange(selmon); + } else if (c) { focus(c); restack(selmon); XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); @@ -1974,19 +1982,24 @@ togglebar(const Arg *arg) } void -toggleforegrounded(const Arg *arg) +clientforeground(Client *c) { - if (!selmon->sel) + if (!c) return; - if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ + if (c->isfullscreen) /* no support for fullscreen windows */ return; - selmon->sel->isforegrounded || selmon->sel->isfloating ? - detachforegrounded(selmon->sel) : attachforegrounded(selmon->sel); + c->isforegrounded || c->isfloating ? + detachforegrounded(c) : attachforegrounded(c); - selmon->sel->isforegrounded = selmon->sel->isfloating = - !selmon->sel->isfloating && !selmon->sel->isforegrounded; + c->isforegrounded = c->isfloating = + !c->isfloating && !c->isforegrounded; +} +void +toggleforegrounded(const Arg *arg) +{ + clientforeground(selmon->sel); arrangeforegrounded(selmon); arrange(selmon); }