diff options
author | rafa_99 <rafa99@protonmail.com> | 2021-06-10 02:23:59 +0100 |
---|---|---|
committer | rafa_99 <rafa99@protonmail.com> | 2021-06-10 02:23:59 +0100 |
commit | 9e63eaad8cb17a999ee625f962fae3547b6bb850 (patch) | |
tree | f1afed8024126b8cbe3d3263d37aa94d118300bb /dwm.c | |
parent | decbc5cf53c688eedfffe70cd498f82956da8257 (diff) |
Revert Replaced Mouse hovering with mouse click
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 51 |
1 files changed, 45 insertions, 6 deletions
@@ -173,6 +173,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); @@ -192,6 +193,7 @@ static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); static void monocle(Monitor *m); static void moveresize(const Arg *arg); +static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *); @@ -275,11 +277,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 }; @@ -500,8 +504,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); @@ -526,8 +529,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; } @@ -837,6 +840,25 @@ drawbars(void) } 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) { Monitor *m; @@ -1251,6 +1273,23 @@ moveresize(const Arg *arg) { } 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) { int x, y, ocx, ocy, nx, ny; @@ -2597,12 +2636,12 @@ fibonacci(Monitor *mon, int s) { for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); if(n == 0) return; - + nx = mon->wx; ny = 0; nw = mon->ww; nh = mon->wh; - + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { if((i % 2 && nh / 2 > 2 * c->bw) || (!(i % 2) && nw / 2 > 2 * c->bw)) { |