dwm-meillo

annotate mouse.c @ 40:c18081cb9f10

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