add sloppy monitor focus
Connor Lane Smith cls@lubutu.com
Tue, 15 Nov 2011 20:16:58 +0100
1 files changed,
19 insertions(+),
3 deletions(-)
jump to
M
dwm.c
→
dwm.c
@@ -200,6 +200,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 *);@@ -271,6 +272,7 @@ [FocusIn] = focusin,
[KeyPress] = keypress, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, + [MotionNotify] = motionnotify, [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify };@@ -1202,6 +1204,21 @@ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
} 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) { + selmon = m; + focus(NULL); + } + mon = m; +} + +void movemouse(const Arg *arg) { int x, y, ocx, ocy, nx, ny; Client *c;@@ -1614,9 +1631,8 @@ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
PropModeReplace, (unsigned char *) netatom, NetLast); /* select for events */ wa.cursor = cursor[CurNormal]; - wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask - |EnterWindowMask|LeaveWindowMask|StructureNotifyMask - |PropertyChangeMask; + wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask + |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); XSelectInput(dpy, root, wa.event_mask); grabkeys();