dwm-meillo

diff event.c @ 18:1efa34c6e1b6

added mouse-based resizals
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 21:24:10 +0200
parents 359b6e563b95
children b5510d0c6d43
line diff
     1.1 --- a/event.c	Tue Jul 11 18:59:09 2006 +0200
     1.2 +++ b/event.c	Tue Jul 11 21:24:10 2006 +0200
     1.3 @@ -12,6 +12,7 @@
     1.4  #include "wm.h"
     1.5  
     1.6  /* local functions */
     1.7 +static void buttonpress(XEvent *e);
     1.8  static void configurerequest(XEvent *e);
     1.9  static void destroynotify(XEvent *e);
    1.10  static void enternotify(XEvent *e);
    1.11 @@ -23,6 +24,7 @@
    1.12  static void unmapnotify(XEvent *e);
    1.13  
    1.14  void (*handler[LASTEvent]) (XEvent *) = {
    1.15 +	[ButtonPress] = buttonpress,
    1.16  	[ConfigureRequest] = configurerequest,
    1.17  	[DestroyNotify] = destroynotify,
    1.18  	[EnterNotify] = enternotify,
    1.19 @@ -36,7 +38,7 @@
    1.20  };
    1.21  
    1.22  unsigned int
    1.23 -flush_events(long even_mask)
    1.24 +discard_events(long even_mask)
    1.25  {
    1.26  	XEvent ev;
    1.27  	unsigned int n = 0;
    1.28 @@ -45,15 +47,37 @@
    1.29  }
    1.30  
    1.31  static void
    1.32 +buttonpress(XEvent *e)
    1.33 +{
    1.34 +	XButtonPressedEvent *ev = &e->xbutton;
    1.35 +	Client *c;
    1.36 +
    1.37 +	if((c = getclient(ev->window))) {
    1.38 +		switch(ev->button) {
    1.39 +		default:
    1.40 +			break;
    1.41 +		case Button1:
    1.42 +			mmove(c);
    1.43 +			break;
    1.44 +		case Button2:
    1.45 +			XLowerWindow(dpy, c->win);
    1.46 +			break;
    1.47 +		case Button3:
    1.48 +			mresize(c);
    1.49 +			break;
    1.50 +		}
    1.51 +	}
    1.52 +}
    1.53 +
    1.54 +static void
    1.55  configurerequest(XEvent *e)
    1.56  {
    1.57  	XConfigureRequestEvent *ev = &e->xconfigurerequest;
    1.58  	XWindowChanges wc;
    1.59  	Client *c;
    1.60  
    1.61 -	c = getclient(ev->window);
    1.62  	ev->value_mask &= ~CWSibling;
    1.63 -	if(c) {
    1.64 +	if((c = getclient(ev->window))) {
    1.65  		if(ev->value_mask & CWX)
    1.66  			c->r[RFloat].x = ev->x;
    1.67  		if(ev->value_mask & CWY)