[hackers] [dwm] add sloppy monitor focus || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Tue, 15 Nov 2011 20:17:05 +0100 (CET)

changeset: 1589:40bff70c312f
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Tue Nov 15 20:16:58 2011 +0100
files: dwm.c
description:
add sloppy monitor focus


diff -r ee36ffbd4252 -r 40bff70c312f dwm.c
--- a/dwm.c Sun Nov 06 20:36:23 2011 +0100
+++ b/dwm.c Tue Nov 15 20:16:58 2011 +0100
_AT_@ -200,6 +200,7 @@
 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 *);
_AT_@ -271,6 +272,7 @@
         [KeyPress] = keypress,
         [MappingNotify] = mappingnotify,
         [MapRequest] = maprequest,
+ [MotionNotify] = motionnotify,
         [PropertyNotify] = propertynotify,
         [UnmapNotify] = unmapnotify
 };
_AT_@ -1202,6 +1204,21 @@
 }
 
 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;
_AT_@ -1614,9 +1631,8 @@
                         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();
Received on Tue Nov 15 2011 - 20:17:05 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 15 2011 - 20:24:05 CET