aewl
diff client.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/client.c Tue Jul 11 18:59:09 2006 +0200 1.2 +++ b/client.c Tue Jul 11 21:24:10 2006 +0200 1.3 @@ -10,6 +10,8 @@ 1.4 #include "util.h" 1.5 #include "wm.h" 1.6 1.7 +#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask) 1.8 + 1.9 void 1.10 update_name(Client *c) 1.11 { 1.12 @@ -70,7 +72,7 @@ 1.13 c->r[RFloat].height = wa->height; 1.14 c->border = wa->border_width; 1.15 XSetWindowBorderWidth(dpy, c->win, 0); 1.16 - XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 1.17 + XSelectInput(dpy, c->win, CLIENT_MASK); 1.18 XGetTransientForHint(dpy, c->win, &c->trans); 1.19 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) 1.20 c->size.flags = PSize; 1.21 @@ -95,9 +97,34 @@ 1.22 c->snext = stack; 1.23 stack = c; 1.24 XMapWindow(dpy, c->win); 1.25 + XGrabButton(dpy, AnyButton, Mod1Mask, c->win, False, ButtonPressMask, 1.26 + GrabModeAsync, GrabModeSync, None, None); 1.27 focus(c); 1.28 } 1.29 1.30 +void 1.31 +resize(Client *c) 1.32 +{ 1.33 + XConfigureEvent e; 1.34 + 1.35 + XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, 1.36 + c->r[RFloat].width, c->r[RFloat].height); 1.37 + e.type = ConfigureNotify; 1.38 + e.event = c->win; 1.39 + e.window = c->win; 1.40 + e.x = c->r[RFloat].x; 1.41 + e.y = c->r[RFloat].y; 1.42 + e.width = c->r[RFloat].width; 1.43 + e.height = c->r[RFloat].height; 1.44 + e.border_width = c->border; 1.45 + e.above = None; 1.46 + e.override_redirect = False; 1.47 + XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); 1.48 + XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e); 1.49 + XSelectInput(dpy, c->win, CLIENT_MASK); 1.50 + XFlush(dpy); 1.51 +} 1.52 + 1.53 static int 1.54 dummy_error_handler(Display *dpy, XErrorEvent *error) 1.55 { 1.56 @@ -112,6 +139,7 @@ 1.57 XGrabServer(dpy); 1.58 XSetErrorHandler(dummy_error_handler); 1.59 1.60 + XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.61 XUnmapWindow(dpy, c->win); 1.62 XDestroyWindow(dpy, c->title); 1.63 1.64 @@ -126,7 +154,7 @@ 1.65 XFlush(dpy); 1.66 XSetErrorHandler(error_handler); 1.67 XUngrabServer(dpy); 1.68 - flush_events(EnterWindowMask); 1.69 + discard_events(EnterWindowMask); 1.70 if(stack) 1.71 focus(stack); 1.72 }