wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 3abbddaebc07658e7f1093d9245fbbf7b96d2cd0
parent fd8ecb12450cd1aa5b8aa8daeaf8053042d32c04
Author: Kris Maglione <kris@suckless.org>
Date:   Sat, 29 May 2010 10:37:51 -0400

Don't adjust column in grabbox move until the mouse actually moves. Closes issue #51.

Diffstat:
cmd/wmii/layout.c | 56+++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 41 insertions(+), 15 deletions(-)

diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c @@ -86,7 +86,6 @@ framewin(Frame *f, Point pt, int orientation, int n) { frameadjust(fw, pt, orientation, n); reshapewin(fw->w, framerect(fw)); - mapwin(fw->w); raisewin(fw->w); return fw; @@ -237,9 +236,9 @@ grabboxcenter(Frame *f) { return p; } -static int tvcol(Frame*); -static int thcol(Frame*); -static int tfloat(Frame*); +static int tvcol(Frame*, bool); +static int thcol(Frame*, bool); +static int tfloat(Frame*, bool); enum { TDone, @@ -248,7 +247,7 @@ enum { TFloat, }; -static int (*tramp[])(Frame*) = { +static int (*tramp[])(Frame*, bool) = { 0, tvcol, thcol, @@ -261,18 +260,26 @@ static int (*tramp[])(Frame*) = { */ static void trampoline(int fn, Frame *f, bool grabbox) { + int moved; + moved = 0; while(fn > 0) { - resizing = fn != TFloat; - view_update(f->view); if(grabbox) warppointer(grabboxcenter(f)); //f->collapsed = false; - fn = tramp[fn](f); + fn = tramp[fn](f, moved++); } ungrabpointer(); - resizing = false; - view_update(f->view); +} + +static void +resizemode(int mode) { + bool orig; + + orig = resizing; + resizing = mode && mode != TFloat; + if(resizing != orig) + view_update(selview); } void @@ -403,7 +410,7 @@ column_drop(Area *a, Frame *f, int y) { } static int -thcol(Frame *f) { +thcol(Frame *f, bool moved) { Framewin *fw; Frame *fp, *fn; Area *a; @@ -414,21 +421,31 @@ thcol(Frame *f) { focus(f->client, false); ret = TDone; - if(!grabpointer(&scr.root, nil, cursor[CurIcon], MouseMask)) + if(!grabpointer(&scr.root, nil, None, MouseMask)) return TDone; - pt = querypointer(&scr.root); + readmotion(&pt); pt2.x = f->area->r.min.x; pt2.y = pt.y; fw = framewin(f, pt2, OHoriz, Dx(f->area->r)); + if(moved) + goto casemotion; + vplace(fw, pt); for(;;) switch (readmouse(&pt, &button)) { case MotionNotify: + casemotion: + moved = 1; + resizemode(THCol); + if(mapwin(fw->w)) + grabpointer(&scr.root, nil, cursor[CurIcon], MouseMask); vplace(fw, pt); break; case ButtonRelease: + if(!moved) + goto done; if(button != 1) continue; SET(collapsed); @@ -477,12 +494,13 @@ thcol(Frame *f) { goto done; } done: + resizemode(0); framedestroy(fw); return ret; } static int -tvcol(Frame *f) { +tvcol(Frame *f, bool moved) { Framewin *fw; Window *cwin; Rectangle r; @@ -499,6 +517,7 @@ tvcol(Frame *f) { scrn = f->area->screen > -1 ? f->area->screen : find_area(pt) ? find_area(pt)->screen : 0; r = f->view->r[scrn]; fw = framewin(f, pt2, OVert, Dy(r)); + mapwin(fw->w); r.min.y += fw->grabbox.min.y + Dy(fw->grabbox)/2; r.max.y = r.min.y + 1; @@ -509,10 +528,13 @@ tvcol(Frame *f) { if(!grabpointer(&scr.root, cwin, cursor[CurIcon], MouseMask)) goto done; + resizemode(TVCol); + hplace(fw, pt); for(;;) switch (readmouse(&pt, &button)) { case MotionNotify: + moved = 1; hplace(fw, pt); continue; case ButtonPress: @@ -536,11 +558,12 @@ tvcol(Frame *f) { done: framedestroy(fw); destroywindow(cwin); + resizemode(0); return ret; } static int -tfloat(Frame *f) { +tfloat(Frame *f, bool moved) { Rectangle *rects; Rectangle frect, origin; Point pt, pt1; @@ -556,6 +579,8 @@ tfloat(Frame *f) { else if(f->aprev) f->aprev->colr.max.y = f->colr.max.y; area_moveto(f->view->floating, f); + view_update(f->view); + warppointer(grabboxcenter(f)); } map_frame(f->client); focus(f->client, false); @@ -578,6 +603,7 @@ shut_up_ken: switch (readmouse(&pt, &button)) { default: goto shut_up_ken; case MotionNotify: + moved = 1; case_motion: origin = rectaddpt(origin, subpt(pt, pt1)); origin = constrain(origin, -1);