dwm-meillo

annotate mouse.c @ 41:fc9ccd34b8ab

removed obsolete stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 10:25:57 +0200
parents 386649deb651
children
rev   line source
garbeam@18 1 /*
garbeam@18 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
garbeam@18 3 * See LICENSE file for license details.
garbeam@18 4 */
garbeam@18 5
garbeam@18 6 #include <stdlib.h>
garbeam@18 7 #include <string.h>
garbeam@18 8 #include <unistd.h>
garbeam@18 9
garbeam@18 10 #include "wm.h"
garbeam@18 11
garbeam@18 12 #define ButtonMask (ButtonPressMask | ButtonReleaseMask)
garbeam@18 13 #define MouseMask (ButtonMask | PointerMotionMask)
garbeam@18 14
garbeam@18 15 void
garbeam@18 16 mresize(Client *c)
garbeam@18 17 {
garbeam@18 18 XEvent ev;
garbeam@41 19 int ocx, ocy;
garbeam@18 20
garbeam@41 21 ocx = c->x;
garbeam@41 22 ocy = c->y;
garbeam@19 23 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
garbeam@18 24 None, cursor[CurResize], CurrentTime) != GrabSuccess)
garbeam@18 25 return;
garbeam@20 26 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
garbeam@18 27 for(;;) {
garbeam@26 28 XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
garbeam@18 29 switch(ev.type) {
garbeam@18 30 default: break;
garbeam@26 31 case Expose:
garbeam@26 32 handler[Expose](&ev);
garbeam@26 33 break;
garbeam@18 34 case MotionNotify:
garbeam@26 35 XFlush(dpy);
garbeam@41 36 c->w = abs(ocx - ev.xmotion.x);
garbeam@41 37 c->h = abs(ocy - ev.xmotion.y);
garbeam@41 38 c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
garbeam@41 39 c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
garbeam@31 40 resize(c);
garbeam@18 41 break;
garbeam@18 42 case ButtonRelease:
garbeam@18 43 XUngrabPointer(dpy, CurrentTime);
garbeam@18 44 return;
garbeam@18 45 }
garbeam@18 46 }
garbeam@18 47 }
garbeam@18 48
garbeam@18 49 void
garbeam@18 50 mmove(Client *c)
garbeam@18 51 {
garbeam@18 52 XEvent ev;
garbeam@41 53 int x1, y1, ocx, ocy, di;
garbeam@18 54 unsigned int dui;
garbeam@18 55 Window dummy;
garbeam@18 56
garbeam@41 57 ocx = c->x;
garbeam@41 58 ocy = c->y;
garbeam@19 59 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
garbeam@18 60 None, cursor[CurMove], CurrentTime) != GrabSuccess)
garbeam@18 61 return;
garbeam@18 62 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
garbeam@18 63 for(;;) {
garbeam@26 64 XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
garbeam@18 65 switch (ev.type) {
garbeam@18 66 default: break;
garbeam@26 67 case Expose:
garbeam@26 68 handler[Expose](&ev);
garbeam@26 69 break;
garbeam@18 70 case MotionNotify:
garbeam@26 71 XFlush(dpy);
garbeam@41 72 c->x = ocx + (ev.xmotion.x - x1);
garbeam@41 73 c->y = ocy + (ev.xmotion.y - y1);
garbeam@31 74 resize(c);
garbeam@18 75 break;
garbeam@18 76 case ButtonRelease:
garbeam@18 77 XUngrabPointer(dpy, CurrentTime);
garbeam@18 78 return;
garbeam@18 79 }
garbeam@18 80 }
garbeam@18 81 }