aewl

changeset 476:3e4596240abb

sander check this
author arg@mmvi
date Fri, 22 Sep 2006 09:43:21 +0200
parents 898c54484cb2
children bf3de99b7c0c
files event.c
diffstat 1 files changed, 37 insertions(+), 19 deletions(-) [+]
line diff
     1.1 --- a/event.c	Fri Sep 22 08:22:39 2006 +0200
     1.2 +++ b/event.c	Fri Sep 22 09:43:21 2006 +0200
     1.3 @@ -21,6 +21,23 @@
     1.4  #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
     1.5  
     1.6  static void
     1.7 +synconfig(Client *c, int x, int y, int w, int h, unsigned int border) {
     1.8 +	XEvent synev;
     1.9 +
    1.10 +	synev.type = ConfigureNotify;
    1.11 +	synev.xconfigure.display = dpy;
    1.12 +	synev.xconfigure.event = c->win;
    1.13 +	synev.xconfigure.window = c->win;
    1.14 +	synev.xconfigure.x = x;
    1.15 +	synev.xconfigure.y = y;
    1.16 +	synev.xconfigure.width = w;
    1.17 +	synev.xconfigure.height = h;
    1.18 +	synev.xconfigure.border_width = border;
    1.19 +	synev.xconfigure.above = None;
    1.20 +	XSendEvent(dpy, c->win, True, NoEventMask, &synev);
    1.21 +}
    1.22 +
    1.23 +static void
    1.24  movemouse(Client *c) {
    1.25  	int x1, y1, ocx, ocy, di;
    1.26  	unsigned int dui;
    1.27 @@ -34,10 +51,14 @@
    1.28  		return;
    1.29  	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
    1.30  	for(;;) {
    1.31 -		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
    1.32 +		XMaskEvent(dpy, MOUSEMASK | ExposureMask | StructureNotifyMask, &ev);
    1.33  		switch (ev.type) {
    1.34  		default:
    1.35  			break;
    1.36 +		case ConfigureRequest:
    1.37 +			synconfig(c, c->x, c->y, c->w, c->h, ev.xconfigure.border_width);
    1.38 +			XSync(dpy, False);
    1.39 +			break;
    1.40  		case Expose:
    1.41  			handler[Expose](&ev);
    1.42  			break;
    1.43 @@ -50,6 +71,11 @@
    1.44  		case ButtonRelease:
    1.45  			XUngrabPointer(dpy, CurrentTime);
    1.46  			return;
    1.47 +		case DestroyNotify:
    1.48 +		case UnmapNotify:
    1.49 +			XUngrabPointer(dpy, CurrentTime);
    1.50 +			handler[ev.type](&ev);
    1.51 +			return;
    1.52  		}
    1.53  	}
    1.54  }
    1.55 @@ -68,10 +94,14 @@
    1.56  		return;
    1.57  	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
    1.58  	for(;;) {
    1.59 -		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
    1.60 +		XMaskEvent(dpy, MOUSEMASK | ExposureMask | StructureNotifyMask, &ev);
    1.61  		switch(ev.type) {
    1.62  		default:
    1.63  			break;
    1.64 +		case ConfigureRequest:
    1.65 +			synconfig(c, c->x, c->y, c->w, c->h, ev.xconfigure.border_width);
    1.66 +			XSync(dpy, False);
    1.67 +			break;
    1.68  		case Expose:
    1.69  			handler[Expose](&ev);
    1.70  			break;
    1.71 @@ -92,6 +122,11 @@
    1.72  		case ButtonRelease:
    1.73  			XUngrabPointer(dpy, CurrentTime);
    1.74  			return;
    1.75 +		case DestroyNotify:
    1.76 +		case UnmapNotify:
    1.77 +			XUngrabPointer(dpy, CurrentTime);
    1.78 +			handler[ev.type](&ev);
    1.79 +			return;
    1.80  		}
    1.81  	}
    1.82  }
    1.83 @@ -146,23 +181,6 @@
    1.84  }
    1.85  
    1.86  static void
    1.87 -synconfig(Client *c, int x, int y, int w, int h, unsigned int border) {
    1.88 -	XEvent synev;
    1.89 -
    1.90 -	synev.type = ConfigureNotify;
    1.91 -	synev.xconfigure.display = dpy;
    1.92 -	synev.xconfigure.event = c->win;
    1.93 -	synev.xconfigure.window = c->win;
    1.94 -	synev.xconfigure.x = x;
    1.95 -	synev.xconfigure.y = y;
    1.96 -	synev.xconfigure.width = w;
    1.97 -	synev.xconfigure.height = h;
    1.98 -	synev.xconfigure.border_width = border;
    1.99 -	synev.xconfigure.above = None;
   1.100 -	XSendEvent(dpy, c->win, True, NoEventMask, &synev);
   1.101 -}
   1.102 -
   1.103 -static void
   1.104  configurerequest(XEvent *e) {
   1.105  	unsigned long newmask;
   1.106  	Client *c;