[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwin
Subject:    Re: kwin wobbly windows resize patch
From:       Toby Dickenson <toby () tarind ! com>
Date:       2008-11-23 12:03:48
Message-ID: 200811231203.48207 () trumpet ! tarind ! com
[Download RAW message or body]

Thanks for taking the time to review this.

On Saturday 22 November 2008, Cédric Borgese wrote:
> I didn't tested it yet, but the patch looks good except line 1070, you set
> the position of each constrained point to its original position. this has
> at least twos effects :

Those effects were intentional for fixing the vibration seen on the opposite 
corner from the dragged point. I want that point to not move at all. Attached 
is a new patch which limits these effects to that case.

(This approach calms the worst of those vibrations, but the Resize operation 
is still not as fluid as Move. Pinning the opposite corner in this way is 
maybe too harsh, and the interior still vibrates rather than wobbles. I may 
yet come back with some further changes)

> On Saturday 22 November 2008 15:10:46 Lucas Murray wrote:
> > The patch is good, except if the user decides to resize a side instead
> > of a corner.

I think it still looks ok, although I agree my rationale breaks down.

I tried adding logic so that it constrains the opposite _side_ if dragging a 
_side_, but it doesnt look good. It doesnt wobble enough.

> > Do you have a Subversion account? If not resubmit the
> > updated patch.

No I dont have a svn account. Thanks for assisting with this.


-- 
Toby Dickenson

["wobblywindows_resize_patch.diff" (text/x-patch)]

Index: wobblywindows.h
===================================================================
--- wobblywindows.h	(revision 887045)
+++ wobblywindows.h	(working copy)
@@ -70,11 +70,13 @@
             Pair* acceleration;
             Pair* buffer;
 
-            // if true, the point is constraint to its "normal" destination
-            // given by the window position.
-            // if false, the point is free (i.e. use the physics system to move it)
+            // if true, the physics system moves this point based only on it "normal" destination
+            // given by the window position, ignoring neighbour points.
             bool* constraint;
 
+            // if true, the point is locked to its normal destination position.
+            bool* locked;
+
             unsigned int width;
             unsigned int height;
             unsigned int count;
Index: wobblywindows.cpp
===================================================================
--- wobblywindows.cpp	(revision 887045)
+++ wobblywindows.cpp	(working copy)
@@ -400,6 +400,21 @@
         kDebug(1212) << "Original Picked point -- x : " << picked.x << " - y : " << picked.y;
 #endif
         wwi.constraint[pickedPointIndex] = true;
+
+        if (w->isUserResize())
+        {
+            if (picked.x > rect.center().x())
+                if (picked.y > rect.center().y())
+                    // picked somewhere in the bottom right, so constrain the top left corner too
+                    wwi.locked[0] = wwi.constraint[0] = true;
+                else
+                    wwi.locked[wwi.count-wwi.width] = wwi.constraint[wwi.count-wwi.width] = true;
+            else
+                if (picked.y > rect.center().y())
+                    wwi.locked[wwi.width-1] = wwi.constraint[wwi.width-1] = true;
+                else
+                    wwi.locked[wwi.count-1] = wwi.constraint[wwi.count-1] = true;
+        }
     }
     else if (m_moveEffectEnabled && last)
     {
@@ -467,6 +482,7 @@
         {
             unsigned int idx = j*4 + i;
             wwi.constraint[idx] = false;
+            wwi.locked[idx] = false;
             wwi.position[idx].x = (wwi.position[idx].x + 3*middle.x)/4;
             wwi.position[idx].y = (wwi.position[idx].y + 3*middle.y)/4;
         }
@@ -491,6 +507,7 @@
         {
             unsigned int idx = j*4 + i;
             wwi.constraint[idx] = false;
+            wwi.locked[idx] = false;
         }
     }
     wwi.status = Closing;
@@ -512,6 +529,7 @@
     wwi.acceleration = new Pair[wwi.count];
     wwi.buffer = new Pair[wwi.count];
     wwi.constraint = new bool[wwi.count];
+    wwi.locked = new bool[wwi.count];
 
     wwi.bezierSurface = new Pair[wwi.bezierCount];
 
@@ -535,6 +553,7 @@
             wwi.position[idx] = initValue;
             wwi.velocity[idx] = nullPair;
             wwi.constraint[idx] = false;
+            wwi.locked[idx] = false;
             if (i != 4-2) // x grid count - 2, i.e. not the last point
             {
                 initValue.x += x_increment;
@@ -567,6 +586,7 @@
     delete[] wwi.acceleration;
     delete[] wwi.buffer;
     delete[] wwi.constraint;
+    delete[] wwi.locked;
 
     delete[] wwi.bezierSurface;
 }
@@ -1050,6 +1070,10 @@
 
         vel_sum += fabs(vel.x) + fabs(vel.y);
 
+        if (wwi.locked[i])
+        {
+            wwi.position[i] = wwi.origin[i];
+        }
 #if defined VERBOSE_MODE
         if (wwi.constraint[i])
         {


_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic