|
|
@ -51,8 +51,73 @@ Key key[] = { |
|
|
|
|
|
|
|
|
|
|
|
/* static functions */ |
|
|
|
/* static functions */ |
|
|
|
|
|
|
|
|
|
|
|
static void movemouse(Client *c); |
|
|
|
static void |
|
|
|
static void resizemouse(Client *c); |
|
|
|
movemouse(Client *c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XEvent ev; |
|
|
|
|
|
|
|
int x1, y1, ocx, ocy, di; |
|
|
|
|
|
|
|
unsigned int dui; |
|
|
|
|
|
|
|
Window dummy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocx = c->x; |
|
|
|
|
|
|
|
ocy = c->y; |
|
|
|
|
|
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
|
|
|
|
|
None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
|
|
|
|
|
|
|
for(;;) { |
|
|
|
|
|
|
|
XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
|
|
|
|
|
|
switch (ev.type) { |
|
|
|
|
|
|
|
default: break; |
|
|
|
|
|
|
|
case Expose: |
|
|
|
|
|
|
|
handler[Expose](&ev); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case MotionNotify: |
|
|
|
|
|
|
|
XFlush(dpy); |
|
|
|
|
|
|
|
c->x = ocx + (ev.xmotion.x - x1); |
|
|
|
|
|
|
|
c->y = ocy + (ev.xmotion.y - y1); |
|
|
|
|
|
|
|
resize(c, False); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ButtonRelease: |
|
|
|
|
|
|
|
XUngrabPointer(dpy, CurrentTime); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
resizemouse(Client *c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XEvent ev; |
|
|
|
|
|
|
|
int ocx, ocy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocx = c->x; |
|
|
|
|
|
|
|
ocy = c->y; |
|
|
|
|
|
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
|
|
|
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
|
|
|
|
|
|
|
for(;;) { |
|
|
|
|
|
|
|
XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
|
|
|
|
|
|
switch(ev.type) { |
|
|
|
|
|
|
|
default: break; |
|
|
|
|
|
|
|
case Expose: |
|
|
|
|
|
|
|
handler[Expose](&ev); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case MotionNotify: |
|
|
|
|
|
|
|
XFlush(dpy); |
|
|
|
|
|
|
|
c->w = abs(ocx - ev.xmotion.x); |
|
|
|
|
|
|
|
c->h = abs(ocy - ev.xmotion.y); |
|
|
|
|
|
|
|
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; |
|
|
|
|
|
|
|
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; |
|
|
|
|
|
|
|
resize(c, True); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ButtonRelease: |
|
|
|
|
|
|
|
XUngrabPointer(dpy, CurrentTime); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
buttonpress(XEvent *e) |
|
|
|
buttonpress(XEvent *e) |
|
|
@ -213,40 +278,6 @@ maprequest(XEvent *e) |
|
|
|
manage(ev->window, &wa); |
|
|
|
manage(ev->window, &wa); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
movemouse(Client *c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XEvent ev; |
|
|
|
|
|
|
|
int x1, y1, ocx, ocy, di; |
|
|
|
|
|
|
|
unsigned int dui; |
|
|
|
|
|
|
|
Window dummy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocx = c->x; |
|
|
|
|
|
|
|
ocy = c->y; |
|
|
|
|
|
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
|
|
|
|
|
None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
|
|
|
|
|
|
|
for(;;) { |
|
|
|
|
|
|
|
XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
|
|
|
|
|
|
switch (ev.type) { |
|
|
|
|
|
|
|
default: break; |
|
|
|
|
|
|
|
case Expose: |
|
|
|
|
|
|
|
handler[Expose](&ev); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case MotionNotify: |
|
|
|
|
|
|
|
XFlush(dpy); |
|
|
|
|
|
|
|
c->x = ocx + (ev.xmotion.x - x1); |
|
|
|
|
|
|
|
c->y = ocy + (ev.xmotion.y - y1); |
|
|
|
|
|
|
|
resize(c, False); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ButtonRelease: |
|
|
|
|
|
|
|
XUngrabPointer(dpy, CurrentTime); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
propertynotify(XEvent *e) |
|
|
|
propertynotify(XEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -258,7 +289,7 @@ propertynotify(XEvent *e) |
|
|
|
return; /* ignore */ |
|
|
|
return; /* ignore */ |
|
|
|
|
|
|
|
|
|
|
|
if((c = getclient(ev->window))) { |
|
|
|
if((c = getclient(ev->window))) { |
|
|
|
if(ev->atom == wm_atom[WMProtocols]) { |
|
|
|
if(ev->atom == wmatom[WMProtocols]) { |
|
|
|
c->proto = getproto(c->win); |
|
|
|
c->proto = getproto(c->win); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -273,47 +304,13 @@ propertynotify(XEvent *e) |
|
|
|
setsize(c); |
|
|
|
setsize(c); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) { |
|
|
|
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { |
|
|
|
settitle(c); |
|
|
|
settitle(c); |
|
|
|
drawtitle(c); |
|
|
|
drawtitle(c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
resizemouse(Client *c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XEvent ev; |
|
|
|
|
|
|
|
int ocx, ocy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocx = c->x; |
|
|
|
|
|
|
|
ocy = c->y; |
|
|
|
|
|
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
|
|
|
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
|
|
|
|
|
|
|
for(;;) { |
|
|
|
|
|
|
|
XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
|
|
|
|
|
|
switch(ev.type) { |
|
|
|
|
|
|
|
default: break; |
|
|
|
|
|
|
|
case Expose: |
|
|
|
|
|
|
|
handler[Expose](&ev); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case MotionNotify: |
|
|
|
|
|
|
|
XFlush(dpy); |
|
|
|
|
|
|
|
c->w = abs(ocx - ev.xmotion.x); |
|
|
|
|
|
|
|
c->h = abs(ocy - ev.xmotion.y); |
|
|
|
|
|
|
|
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; |
|
|
|
|
|
|
|
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; |
|
|
|
|
|
|
|
resize(c, True); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ButtonRelease: |
|
|
|
|
|
|
|
XUngrabPointer(dpy, CurrentTime); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
unmapnotify(XEvent *e) |
|
|
|
unmapnotify(XEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
|