From 86453ba85dbae3c8ae26079093536cc3fd6cdcee Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Sat, 28 Oct 2023 22:48:46 +0200 Subject: update --- dwm.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 8540612..fc1d697 100644 --- a/dwm.c +++ b/dwm.c @@ -176,6 +176,7 @@ static void detachstack(Client *c); static Monitor *dirtomon(int dir); static void drawbar(Monitor *m); static void drawbars(void); +static void enternotify(XEvent *e); static void expose(XEvent *e); static void focus(Client *c); static void focusin(XEvent *e); @@ -194,6 +195,7 @@ static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); static void monocle(Monitor *m); +static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *c); @@ -267,11 +269,13 @@ static void (*handler[LASTEvent]) (XEvent *) = { [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, [DestroyNotify] = destroynotify, + [EnterNotify] = enternotify, [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, + [MotionNotify] = motionnotify, [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify }; @@ -493,8 +497,7 @@ buttonpress(XEvent *e) click = ClkRootWin; /* focus monitor if necessary */ - if ((m = wintomon(ev->window)) && m != selmon - && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) { + if ((m = wintomon(ev->window)) && m != selmon) { unfocus(selmon->sel, 1); selmon = m; focus(NULL); @@ -514,8 +517,8 @@ buttonpress(XEvent *e) else click = ClkWinTitle; } else if ((c = wintoclient(ev->window))) { - if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) - focus(c); + focus(c); + restack(selmon); XAllowEvents(dpy, ReplayPointer, CurrentTime); click = ClkClientWin; } @@ -829,6 +832,25 @@ drawbars(void) drawbar(m); } +void +enternotify(XEvent *e) +{ + Client *c; + Monitor *m; + XCrossingEvent *ev = &e->xcrossing; + + if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) + return; + c = wintoclient(ev->window); + m = c ? c->mon : wintomon(ev->window); + if (m != selmon) { + unfocus(selmon->sel, 1); + selmon = m; + } else if (!c || c == selmon->sel) + return; + focus(c); +} + void expose(XEvent *e) { @@ -1182,6 +1204,23 @@ monocle(Monitor *m) resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); } +void +motionnotify(XEvent *e) +{ + static Monitor *mon = NULL; + Monitor *m; + XMotionEvent *ev = &e->xmotion; + + if (ev->window != root) + return; + if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { + unfocus(selmon->sel, 1); + selmon = m; + focus(NULL); + } + mon = m; +} + void movemouse(const Arg *arg) { -- cgit v1.2.3