[hackers] [wmii] Don't adjust column in grabbox move until the mouse actually moves. Closes issue #51. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 29 May 2010 14:38:10 +0000 (UTC)

changeset: 2670:bc83f33f5cd6
tag: tip
parent: 2668:a41c27c7d8be
user: Kris Maglione <kris_AT_suckless.org>
date: Sat May 29 10:37:51 2010 -0400
files: cmd/wmii/layout.c
description:
Don't adjust column in grabbox move until the mouse actually moves. Closes issue #51.

diff -r a41c27c7d8be -r bc83f33f5cd6 cmd/wmii/layout.c
--- a/cmd/wmii/layout.c Fri May 28 20:30:20 2010 -0400
+++ b/cmd/wmii/layout.c Sat May 29 10:37:51 2010 -0400
@@ -86,7 +86,6 @@
         frameadjust(fw, pt, orientation, n);
         reshapewin(fw->w, framerect(fw));
 
- mapwin(fw->w);
         raisewin(fw->w);
 
         return fw;
@@ -237,9 +236,9 @@
         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 @@
         TFloat,
 };
 
-static int (*tramp[])(Frame*) = {
+static int (*tramp[])(Frame*, bool) = {
         0,
         tvcol,
         thcol,
@@ -261,18 +260,26 @@
  */
 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 @@
 }
 
 static int
-thcol(Frame *f) {
+thcol(Frame *f, bool moved) {
         Framewin *fw;
         Frame *fp, *fn;
         Area *a;
@@ -414,21 +421,31 @@
         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 @@
                         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 @@
         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 @@
         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 @@
 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 @@
                 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 @@
                 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);
Received on Sat May 29 2010 - 14:38:10 UTC

This archive was generated by hypermail 2.2.0 : Sat May 29 2010 - 14:48:02 UTC