aewl

diff event.c @ 77:38c8f7f7d401

sanitized other stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Sat, 15 Jul 2006 17:19:19 +0200
parents 4bd49f404f10
children 0d71fb80b592
line diff
     1.1 --- a/event.c	Sat Jul 15 17:00:56 2006 +0200
     1.2 +++ b/event.c	Sat Jul 15 17:19:19 2006 +0200
     1.3 @@ -51,8 +51,73 @@
     1.4  
     1.5  /* static functions */
     1.6  
     1.7 -static void movemouse(Client *c);
     1.8 -static void resizemouse(Client *c);
     1.9 +static void
    1.10 +movemouse(Client *c)
    1.11 +{
    1.12 +	XEvent ev;
    1.13 +	int x1, y1, ocx, ocy, di;
    1.14 +	unsigned int dui;
    1.15 +	Window dummy;
    1.16 +
    1.17 +	ocx = c->x;
    1.18 +	ocy = c->y;
    1.19 +	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
    1.20 +				None, cursor[CurMove], CurrentTime) != GrabSuccess)
    1.21 +		return;
    1.22 +	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
    1.23 +	for(;;) {
    1.24 +		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
    1.25 +		switch (ev.type) {
    1.26 +		default: break;
    1.27 +		case Expose:
    1.28 +			handler[Expose](&ev);
    1.29 +			break;
    1.30 +		case MotionNotify:
    1.31 +			XFlush(dpy);
    1.32 +			c->x = ocx + (ev.xmotion.x - x1);
    1.33 +			c->y = ocy + (ev.xmotion.y - y1);
    1.34 +			resize(c, False);
    1.35 +			break;
    1.36 +		case ButtonRelease:
    1.37 +			XUngrabPointer(dpy, CurrentTime);
    1.38 +			return;
    1.39 +		}
    1.40 +	}
    1.41 +}
    1.42 +
    1.43 +static void
    1.44 +resizemouse(Client *c)
    1.45 +{
    1.46 +	XEvent ev;
    1.47 +	int ocx, ocy;
    1.48 +
    1.49 +	ocx = c->x;
    1.50 +	ocy = c->y;
    1.51 +	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
    1.52 +				None, cursor[CurResize], CurrentTime) != GrabSuccess)
    1.53 +		return;
    1.54 +	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
    1.55 +	for(;;) {
    1.56 +		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
    1.57 +		switch(ev.type) {
    1.58 +		default: break;
    1.59 +		case Expose:
    1.60 +			handler[Expose](&ev);
    1.61 +			break;
    1.62 +		case MotionNotify:
    1.63 +			XFlush(dpy);
    1.64 +			c->w = abs(ocx - ev.xmotion.x);
    1.65 +			c->h = abs(ocy - ev.xmotion.y);
    1.66 +			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
    1.67 +			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
    1.68 +			resize(c, True);
    1.69 +			break;
    1.70 +		case ButtonRelease:
    1.71 +			XUngrabPointer(dpy, CurrentTime);
    1.72 +			return;
    1.73 +		}
    1.74 +	}
    1.75 +}
    1.76  
    1.77  static void
    1.78  buttonpress(XEvent *e)
    1.79 @@ -214,40 +279,6 @@
    1.80  }
    1.81  
    1.82  static void
    1.83 -movemouse(Client *c)
    1.84 -{
    1.85 -	XEvent ev;
    1.86 -	int x1, y1, ocx, ocy, di;
    1.87 -	unsigned int dui;
    1.88 -	Window dummy;
    1.89 -
    1.90 -	ocx = c->x;
    1.91 -	ocy = c->y;
    1.92 -	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
    1.93 -				None, cursor[CurMove], CurrentTime) != GrabSuccess)
    1.94 -		return;
    1.95 -	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
    1.96 -	for(;;) {
    1.97 -		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
    1.98 -		switch (ev.type) {
    1.99 -		default: break;
   1.100 -		case Expose:
   1.101 -			handler[Expose](&ev);
   1.102 -			break;
   1.103 -		case MotionNotify:
   1.104 -			XFlush(dpy);
   1.105 -			c->x = ocx + (ev.xmotion.x - x1);
   1.106 -			c->y = ocy + (ev.xmotion.y - y1);
   1.107 -			resize(c, False);
   1.108 -			break;
   1.109 -		case ButtonRelease:
   1.110 -			XUngrabPointer(dpy, CurrentTime);
   1.111 -			return;
   1.112 -		}
   1.113 -	}
   1.114 -}
   1.115 -
   1.116 -static void
   1.117  propertynotify(XEvent *e)
   1.118  {
   1.119  	XPropertyEvent *ev = &e->xproperty;
   1.120 @@ -258,7 +289,7 @@
   1.121  		return; /* ignore */
   1.122  
   1.123  	if((c = getclient(ev->window))) {
   1.124 -		if(ev->atom == wm_atom[WMProtocols]) {
   1.125 +		if(ev->atom == wmatom[WMProtocols]) {
   1.126  			c->proto = getproto(c->win);
   1.127  			return;
   1.128  		}
   1.129 @@ -273,7 +304,7 @@
   1.130  				setsize(c);
   1.131  				break;
   1.132  		}
   1.133 -		if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
   1.134 +		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
   1.135  			settitle(c);
   1.136  			drawtitle(c);
   1.137  		}
   1.138 @@ -281,40 +312,6 @@
   1.139  }
   1.140  
   1.141  static void
   1.142 -resizemouse(Client *c)
   1.143 -{
   1.144 -	XEvent ev;
   1.145 -	int ocx, ocy;
   1.146 -
   1.147 -	ocx = c->x;
   1.148 -	ocy = c->y;
   1.149 -	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
   1.150 -				None, cursor[CurResize], CurrentTime) != GrabSuccess)
   1.151 -		return;
   1.152 -	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
   1.153 -	for(;;) {
   1.154 -		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
   1.155 -		switch(ev.type) {
   1.156 -		default: break;
   1.157 -		case Expose:
   1.158 -			handler[Expose](&ev);
   1.159 -			break;
   1.160 -		case MotionNotify:
   1.161 -			XFlush(dpy);
   1.162 -			c->w = abs(ocx - ev.xmotion.x);
   1.163 -			c->h = abs(ocy - ev.xmotion.y);
   1.164 -			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
   1.165 -			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
   1.166 -			resize(c, True);
   1.167 -			break;
   1.168 -		case ButtonRelease:
   1.169 -			XUngrabPointer(dpy, CurrentTime);
   1.170 -			return;
   1.171 -		}
   1.172 -	}
   1.173 -}
   1.174 -
   1.175 -static void
   1.176  unmapnotify(XEvent *e)
   1.177  {
   1.178  	Client *c;