simplified mouse resizals

This commit is contained in:
arg@mmvi 2006-09-25 21:19:18 +02:00
parent 7d7cde0fd6
commit bcb07de750
1 changed files with 16 additions and 43 deletions

59
event.c
View File

@ -20,23 +20,6 @@ KEYS
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
static void
synconfig(Client *c, int x, int y, int w, int h, unsigned int border) {
XEvent synev;
synev.type = ConfigureNotify;
synev.xconfigure.display = dpy;
synev.xconfigure.event = c->win;
synev.xconfigure.window = c->win;
synev.xconfigure.x = x;
synev.xconfigure.y = y;
synev.xconfigure.width = w;
synev.xconfigure.height = h;
synev.xconfigure.border_width = border;
synev.xconfigure.above = None;
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
}
static void static void
movemouse(Client *c) { movemouse(Client *c) {
int x1, y1, ocx, ocy, di; int x1, y1, ocx, ocy, di;
@ -52,14 +35,8 @@ movemouse(Client *c) {
c->ismax = False; c->ismax = False;
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
for(;;) { for(;;) {
XMaskEvent(dpy, MOUSEMASK | ExposureMask | StructureNotifyMask, &ev); XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
switch (ev.type) { switch (ev.type) {
default:
break;
case ConfigureRequest:
synconfig(c, c->x, c->y, c->w, c->h, ev.xconfigure.border_width);
XSync(dpy, False);
break;
case Expose: case Expose:
handler[Expose](&ev); handler[Expose](&ev);
break; break;
@ -72,11 +49,6 @@ movemouse(Client *c) {
case ButtonRelease: case ButtonRelease:
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(dpy, CurrentTime);
return; return;
case DestroyNotify:
case UnmapNotify:
XUngrabPointer(dpy, CurrentTime);
handler[ev.type](&ev);
return;
} }
} }
} }
@ -96,14 +68,8 @@ resizemouse(Client *c) {
c->ismax = False; c->ismax = False;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
for(;;) { for(;;) {
XMaskEvent(dpy, MOUSEMASK | ExposureMask | StructureNotifyMask, &ev); XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
switch(ev.type) { switch(ev.type) {
default:
break;
case ConfigureRequest:
synconfig(c, c->x, c->y, c->w, c->h, ev.xconfigure.border_width);
XSync(dpy, False);
break;
case Expose: case Expose:
handler[Expose](&ev); handler[Expose](&ev);
break; break;
@ -124,11 +90,6 @@ resizemouse(Client *c) {
case ButtonRelease: case ButtonRelease:
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(dpy, CurrentTime);
return; return;
case DestroyNotify:
case UnmapNotify:
XUngrabPointer(dpy, CurrentTime);
handler[ev.type](&ev);
return;
} }
} }
} }
@ -187,6 +148,7 @@ configurerequest(XEvent *e) {
unsigned long newmask; unsigned long newmask;
Client *c; Client *c;
XConfigureRequestEvent *ev = &e->xconfigurerequest; XConfigureRequestEvent *ev = &e->xconfigurerequest;
XEvent synev;
XWindowChanges wc; XWindowChanges wc;
if((c = getclient(ev->window))) { if((c = getclient(ev->window))) {
@ -210,8 +172,19 @@ configurerequest(XEvent *e) {
newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth)); newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
if(newmask) if(newmask)
XConfigureWindow(dpy, c->win, newmask, &wc); XConfigureWindow(dpy, c->win, newmask, &wc);
else else {
synconfig(c, c->x, c->y, c->w, c->h, c->border); synev.type = ConfigureNotify;
synev.xconfigure.display = dpy;
synev.xconfigure.event = c->win;
synev.xconfigure.window = c->win;
synev.xconfigure.x = c->x;
synev.xconfigure.y = c->y;
synev.xconfigure.width = c->w;
synev.xconfigure.height = c->h;
synev.xconfigure.border_width = c->border;
synev.xconfigure.above = None;
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
}
XSync(dpy, False); XSync(dpy, False);
if(c->isfloat) if(c->isfloat)
resize(c, False, TopLeft); resize(c, False, TopLeft);