add sloppy monitor focus
b5068e32
1 file(s) · +19 −3
| 200 | 200 | static void mappingnotify(XEvent *e); |
|
| 201 | 201 | static void maprequest(XEvent *e); |
|
| 202 | 202 | static void monocle(Monitor *m); |
|
| 203 | + | static void motionnotify(XEvent *e); |
|
| 203 | 204 | static void movemouse(const Arg *arg); |
|
| 204 | 205 | static Client *nexttiled(Client *c); |
|
| 205 | 206 | static void pop(Client *); |
|
| 271 | 272 | [KeyPress] = keypress, |
|
| 272 | 273 | [MappingNotify] = mappingnotify, |
|
| 273 | 274 | [MapRequest] = maprequest, |
|
| 275 | + | [MotionNotify] = motionnotify, |
|
| 274 | 276 | [PropertyNotify] = propertynotify, |
|
| 275 | 277 | [UnmapNotify] = unmapnotify |
|
| 276 | 278 | }; |
|
| 1202 | 1204 | } |
|
| 1203 | 1205 | ||
| 1204 | 1206 | void |
|
| 1207 | + | motionnotify(XEvent *e) { |
|
| 1208 | + | static Monitor *mon = NULL; |
|
| 1209 | + | Monitor *m; |
|
| 1210 | + | XMotionEvent *ev = &e->xmotion; |
|
| 1211 | + | ||
| 1212 | + | if(ev->window != root) |
|
| 1213 | + | return; |
|
| 1214 | + | if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { |
|
| 1215 | + | selmon = m; |
|
| 1216 | + | focus(NULL); |
|
| 1217 | + | } |
|
| 1218 | + | mon = m; |
|
| 1219 | + | } |
|
| 1220 | + | ||
| 1221 | + | void |
|
| 1205 | 1222 | movemouse(const Arg *arg) { |
|
| 1206 | 1223 | int x, y, ocx, ocy, nx, ny; |
|
| 1207 | 1224 | Client *c; |
|
| 1614 | 1631 | PropModeReplace, (unsigned char *) netatom, NetLast); |
|
| 1615 | 1632 | /* select for events */ |
|
| 1616 | 1633 | wa.cursor = cursor[CurNormal]; |
|
| 1617 | - | wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask |
|
| 1618 | - | |EnterWindowMask|LeaveWindowMask|StructureNotifyMask |
|
| 1619 | - | |PropertyChangeMask; |
|
| 1634 | + | wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask |
|
| 1635 | + | |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; |
|
| 1620 | 1636 | XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); |
|
| 1621 | 1637 | XSelectInput(dpy, root, wa.event_mask); |
|
| 1622 | 1638 | grabkeys(); |
|