event.c
changeset 164 21071ae1fe68
parent 163 e2e1de08341d
child 178 e848966a1ac6
equal deleted inserted replaced
163:e2e1de08341d 164:21071ae1fe68
     1 /*
     1 /*
     2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     3  * See LICENSE file for license details.
     3  * See LICENSE file for license details.
     4  */
     4  */
     5 #include "dwm.h"
     5 #include "dwm.h"
     6 
       
     7 #include <stdlib.h>
     6 #include <stdlib.h>
     8 #include <X11/keysym.h>
     7 #include <X11/keysym.h>
     9 #include <X11/Xatom.h>
     8 #include <X11/Xatom.h>
    10 
     9 
    11 /* static */
    10 /* static */
   149 static void
   148 static void
   150 configurerequest(XEvent *e)
   149 configurerequest(XEvent *e)
   151 {
   150 {
   152 	Client *c;
   151 	Client *c;
   153 	XConfigureRequestEvent *ev = &e->xconfigurerequest;
   152 	XConfigureRequestEvent *ev = &e->xconfigurerequest;
       
   153 	XEvent synev;
   154 	XWindowChanges wc;
   154 	XWindowChanges wc;
   155 
   155 	unsigned long newmask;
   156 	ev->value_mask &= ~CWSibling;
   156 
   157 	if((c = getclient(ev->window))) {
   157 	if((c = getclient(ev->window))) {
   158 		gravitate(c, True);
   158 		gravitate(c, True);
   159 		if(ev->value_mask & CWX)
   159 		if(c->isfloat) {
   160 			c->x = ev->x;
   160 			if(ev->value_mask & CWX)
   161 		if(ev->value_mask & CWY)
   161 				c->x = ev->x;
   162 			c->y = ev->y;
   162 			if(ev->value_mask & CWY)
   163 		if(ev->value_mask & CWWidth)
   163 				c->y = ev->y;
   164 			c->w = ev->width;
   164 			if(ev->value_mask & CWWidth)
   165 		if(ev->value_mask & CWHeight)
   165 				c->w = ev->width;
   166 			c->h = ev->height;
   166 			if(ev->value_mask & CWHeight)
       
   167 				c->h = ev->height;
       
   168 		}
   167 		if(ev->value_mask & CWBorderWidth)
   169 		if(ev->value_mask & CWBorderWidth)
   168 			c->border = 1;
   170 			c->border = ev->border_width;
   169 		gravitate(c, False);
   171 		gravitate(c, False);
       
   172 
   170 		resize(c, True, TopLeft);
   173 		resize(c, True, TopLeft);
   171 	}
   174 
   172 
   175 		wc.x = c->x;
   173 	wc.x = ev->x;
   176 		wc.y = c->y;
   174 	wc.y = ev->y;
   177 		wc.width = c->w;
   175 	wc.width = ev->width;
   178 		wc.height = c->h;
   176 	wc.height = ev->height;
   179 		newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
   177 	wc.border_width = 1;
   180 		if(newmask)
   178 	XConfigureWindow(dpy, ev->window,
   181 			XConfigureWindow(dpy, c->win, newmask, &wc);
   179 			CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
   182 		else {
       
   183 			synev.type = ConfigureNotify;
       
   184 			synev.xconfigure.display = dpy;
       
   185 			synev.xconfigure.event = c->win;
       
   186 			synev.xconfigure.window = c->win;
       
   187 			synev.xconfigure.x = c->x;
       
   188 			synev.xconfigure.y = c->y;
       
   189 			synev.xconfigure.width = c->w;
       
   190 			synev.xconfigure.height = c->h;
       
   191 			synev.xconfigure.border_width = c->border;
       
   192 			synev.xconfigure.above = None;
       
   193 			/* Send synthetic ConfigureNotify */
       
   194 			XSendEvent(dpy, c->win, True, NoEventMask, &synev);
       
   195 		}
       
   196 	}
       
   197 	else {
       
   198 		wc.x = ev->x;
       
   199 		wc.y = ev->y;
       
   200 		wc.width = ev->width;
       
   201 		wc.height = ev->height;
       
   202 		wc.border_width = ev->border_width;
       
   203 		wc.sibling = ev->above;
       
   204 		wc.stack_mode = ev->detail;
       
   205 		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
       
   206 	}
   180 	XSync(dpy, False);
   207 	XSync(dpy, False);
   181 }
   208 }
   182 
   209 
   183 static void
   210 static void
   184 destroynotify(XEvent *e)
   211 destroynotify(XEvent *e)