commit 2411d4584ced2823195a50bd748cb00c9c4e6c0f
parent 7fbd5c7663a6f7811ee58595f1de51da8b165bc3
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:
M | dwm.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());
}
}
}
@@ -1311,7 +1311,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;
}
@@ -1372,7 +1372,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());
}
}
@@ -1574,7 +1574,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());
}
}
@@ -1736,8 +1736,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
@@ -2273,8 +2273,8 @@ tag(const Arg *arg)
{
if (selmon->sel && arg->ui & TAGMASK) {
selmon->sel->tags = arg->ui & TAGMASK;
- focus(NULL);
arrange(selmon);
+ focus(getclientundermouse());
}
}
@@ -2352,13 +2352,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);
}
@@ -2373,8 +2373,8 @@ toggletag(const Arg *arg)
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if (newtags) {
selmon->sel->tags = newtags;
- focus(NULL);
arrange(selmon);
+ focus(getclientundermouse());
}
}
@@ -2409,8 +2409,8 @@ toggleview(const Arg *arg)
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
togglebar(NULL);
- focus(NULL);
arrange(selmon);
+ focus(getclientundermouse());
}
}
@@ -2742,8 +2742,8 @@ view(const Arg *arg)
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
togglebar(NULL);
- focus(NULL);
arrange(selmon);
+ focus(getclientundermouse());
}
void
@@ -2883,6 +2883,8 @@ focusmaster(const Arg *arg)
c = nexttiled(selmon->clients);
- if (c)
+ if (c) {
focus(c);
+ restack(selmon);
+ }
}