dwm

Suckless' dwm with my personal patches
git clone https://git.instinctive.eu/dwm.git
Log | Files | Refs | README | LICENSE

commit f4ad670dae0843dfe82025d7728f3c8fe53052d6
parent c0173ec3923a663e179c6444a3c769655f74500f
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Sun, 21 May 2023 00:41:08 +0200

[nat] focus the window under the mouse by default

Diffstat:
Mdwm.c | 28+++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/dwm.c b/dwm.c @@ -474,7 +474,7 @@ buttonpress(XEvent *e) if ((m = wintomon(ev->window)) && m != selmon) { unfocus(selmon->sel, 1); selmon = m; - focus(NULL); + focus(getclientundermouse()); } if (ev->window == selmon->barwin) { i = x = 0; @@ -626,8 +626,8 @@ configurenotify(XEvent *e) resizeclient(c, m->mx, m->my, m->mw, m->mh); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); } - focus(NULL); arrange(NULL); + focus(getclientundermouse()); } } } @@ -1312,7 +1312,7 @@ motionnotify(XEvent *e) if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { unfocus(selmon->sel, 1); selmon = m; - focus(NULL); + focus(getclientundermouse()); } mon = m; } @@ -1373,7 +1373,7 @@ movemouse(const Arg *arg) if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { sendmon(c, m); selmon = m; - focus(NULL); + focus(getclientundermouse()); } } @@ -1575,7 +1575,7 @@ resizemouse(const Arg *arg) if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { sendmon(c, m); selmon = m; - focus(NULL); + focus(getclientundermouse()); } } @@ -1737,8 +1737,8 @@ sendmon(Client *c, Monitor *m) c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; attachbottom(c); attachstack(c); - focus(NULL); arrange(NULL); + focus(getclientundermouse()); } void @@ -2272,8 +2272,8 @@ tag(const Arg *arg) { if (selmon->sel && arg->ui & TAGMASK) { selmon->sel->tags = arg->ui & TAGMASK; - focus(NULL); arrange(selmon); + focus(getclientundermouse()); } } @@ -2351,13 +2351,13 @@ togglescratch(const Arg *arg) unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; - focus(NULL); arrange(selmon); } if (ISVISIBLE(c)) { focus(c); restack(selmon); - } + } else + focus(getclientundermouse()); } else spawn(arg); } @@ -2372,8 +2372,8 @@ toggletag(const Arg *arg) newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); if (newtags) { selmon->sel->tags = newtags; - focus(NULL); arrange(selmon); + focus(getclientundermouse()); } } @@ -2408,8 +2408,8 @@ toggleview(const Arg *arg) if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) togglebar(NULL); - focus(NULL); arrange(selmon); + focus(getclientundermouse()); } } @@ -2741,8 +2741,8 @@ view(const Arg *arg) if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) togglebar(NULL); - focus(NULL); arrange(selmon); + focus(getclientundermouse()); } void @@ -2882,6 +2882,8 @@ focusmaster(const Arg *arg) c = nexttiled(selmon->clients); - if (c) + if (c) { focus(c); + restack(selmon); + } }