-void (*handler[LASTEvent]) (XEvent *) = {
- [ButtonPress] = buttonpress,
- [ConfigureRequest] = configurerequest,
- [DestroyNotify] = destroynotify,
- [EnterNotify] = enternotify,
- [LeaveNotify] = leavenotify,
- [Expose] = expose,
- [KeyPress] = keypress,
- [KeymapNotify] = keymapnotify,
- [MapRequest] = maprequest,
- [PropertyNotify] = propertynotify,
- [UnmapNotify] = unmapnotify
-};
+KEYS
+
+#define CLEANMASK(mask) (mask & ~(NUMLOCKMASK | LockMask))
+
+static void
+movemouse(Client *c)
+{
+ int x1, y1, ocx, ocy, di;
+ unsigned int dui;
+ Window dummy;
+ XEvent ev;
+
+ ocx = c->x;
+ ocy = c->y;
+ if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurMove], CurrentTime) != GrabSuccess)
+ return;
+ XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
+ for(;;) {
+ XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
+ switch (ev.type) {
+ default: break;
+ case Expose:
+ handler[Expose](&ev);
+ break;
+ case MotionNotify:
+ XSync(dpy, False);
+ c->x = ocx + (ev.xmotion.x - x1);
+ c->y = ocy + (ev.xmotion.y - y1);
+ resize(c, False, TopLeft);
+ break;
+ case ButtonRelease:
+ XUngrabPointer(dpy, CurrentTime);
+ return;
+ }
+ }
+}
+
+static void
+resizemouse(Client *c)
+{
+ int ocx, ocy;
+ Corner sticky;
+ XEvent ev;
+
+ ocx = c->x;
+ ocy = c->y;
+ if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurResize], CurrentTime) != GrabSuccess)
+ return;
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
+ for(;;) {
+ XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
+ switch(ev.type) {
+ default: break;
+ case Expose:
+ handler[Expose](&ev);
+ break;
+ case MotionNotify:
+ XSync(dpy, False);
+ c->w = abs(ocx - ev.xmotion.x);
+ c->h = abs(ocy - ev.xmotion.y);
+ c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
+ c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
+ if(ocx <= ev.xmotion.x)
+ sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
+ else
+ sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
+ resize(c, True, sticky);
+ break;
+ case ButtonRelease:
+ XUngrabPointer(dpy, CurrentTime);
+ return;
+ }
+ }
+}