summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2011-11-15 20:16:58 +0100
committerConnor Lane Smith <cls@lubutu.com>2011-11-15 20:16:58 +0100
commitb5068e32e9428ea2fe2c7b1e7b6b0f769ab119cb (patch)
tree10e816284809ff2e3b17d115e501598d27e7dd47
parentnew default colour scheme (diff)
downloaddwm-b5068e32e9428ea2fe2c7b1e7b6b0f769ab119cb.tar.gz
dwm-b5068e32e9428ea2fe2c7b1e7b6b0f769ab119cb.zip
add sloppy monitor focus
-rw-r--r--dwm.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index fd6f04d..1d78655 100644
--- a/dwm.c
+++ b/dwm.c
@@ -200,6 +200,7 @@ static void manage(Window w, XWindowAttributes *wa);
200static void mappingnotify(XEvent *e); 200static void mappingnotify(XEvent *e);
201static void maprequest(XEvent *e); 201static void maprequest(XEvent *e);
202static void monocle(Monitor *m); 202static void monocle(Monitor *m);
203static void motionnotify(XEvent *e);
203static void movemouse(const Arg *arg); 204static void movemouse(const Arg *arg);
204static Client *nexttiled(Client *c); 205static Client *nexttiled(Client *c);
205static void pop(Client *); 206static void pop(Client *);
@@ -271,6 +272,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
271 [KeyPress] = keypress, 272 [KeyPress] = keypress,
272 [MappingNotify] = mappingnotify, 273 [MappingNotify] = mappingnotify,
273 [MapRequest] = maprequest, 274 [MapRequest] = maprequest,
275 [MotionNotify] = motionnotify,
274 [PropertyNotify] = propertynotify, 276 [PropertyNotify] = propertynotify,
275 [UnmapNotify] = unmapnotify 277 [UnmapNotify] = unmapnotify
276}; 278};
@@ -1202,6 +1204,21 @@ monocle(Monitor *m) {
1202} 1204}
1203 1205
1204void 1206void
1207motionnotify(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
1221void
1205movemouse(const Arg *arg) { 1222movemouse(const Arg *arg) {
1206 int x, y, ocx, ocy, nx, ny; 1223 int x, y, ocx, ocy, nx, ny;
1207 Client *c; 1224 Client *c;
@@ -1614,9 +1631,8 @@ setup(void) {
1614 PropModeReplace, (unsigned char *) netatom, NetLast); 1631 PropModeReplace, (unsigned char *) netatom, NetLast);
1615 /* select for events */ 1632 /* select for events */
1616 wa.cursor = cursor[CurNormal]; 1633 wa.cursor = cursor[CurNormal];
1617 wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask 1634 wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
1618 |EnterWindowMask|LeaveWindowMask|StructureNotifyMask 1635 |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
1619 |PropertyChangeMask;
1620 XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); 1636 XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
1621 XSelectInput(dpy, root, wa.event_mask); 1637 XSelectInput(dpy, root, wa.event_mask);
1622 grabkeys(); 1638 grabkeys();