diff options
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | monsterwm.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 0cbc185..429423e 100644 --- a/config.def.h +++ b/config.def.h @@ -78,6 +78,7 @@ static key keys[] = { static Button buttons[] = { { MOD1, Button1, mousemove, {NULL}}, + { MOD1, Button3, mouseresize, {NULL}}, { MOD4, Button3, spawn, {.com = dmenucmd}}, }; #endif diff --git a/monsterwm.c b/monsterwm.c index 8a71e8d..5537ef1 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -86,6 +86,7 @@ static void maprequest(XEvent *e); static void move_down(); static void move_up(); static void mousemove(const Arg *arg); +static void mouseresize(const Arg *arg); static void next_win(); static void prev_win(); static void propertynotify(XEvent *e); @@ -409,6 +410,32 @@ void mousemove(const Arg *arg) { XUngrabPointer(dis, CurrentTime); } +void mouseresize(const Arg *arg) { + if (!current || !arg) return; + static XWindowAttributes wa; + XGetWindowAttributes(dis, current->win, &wa); + + if (XGrabPointer(dis, root, False, BUTTONMASK|PointerMotionMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) != GrabSuccess) return; + int x, y, z; unsigned int v; Window w; + XQueryPointer(dis, root, &w, &w, &x, &y, &z, &z, &v); + + XEvent ev; + do { + XMaskEvent(dis, BUTTONMASK|PointerMotionMask|SubstructureRedirectMask, &ev); + switch (ev.type) { + case ConfigureRequest: + case MapRequest: + events[ev.type](&ev); + break; + case MotionNotify: + XResizeWindow(dis, current->win, wa.width + ev.xmotion.x - x, wa.height + ev.xmotion.y - y); + break; + } + } while(ev.type != ButtonRelease); + XUngrabPointer(dis, CurrentTime); +} + /* move the current client, to current->next * and current->next to current client's position */ |
