Reduce wobblyness when resizing the window by locking the opposite window corner of the mouse cursor.

This greatly improve the wobbly experience when resizing.
Patch by Toby Dickenson

svn path=/trunk/KDE/kdebase/workspace/; revision=889857
remotes/origin/Plasma/5.0
Cédric Borgese 18 years ago
parent 1efa1b0376
commit 018bdfd26e
  1. 27
      effects/wobblywindows.cpp
  2. 8
      effects/wobblywindows.h

@ -400,6 +400,21 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo
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 @@ void WobblyWindowsEffect::wobblyOpenInit(WindowWobblyInfos& wwi) const
{
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 @@ void WobblyWindowsEffect::wobblyCloseInit(WindowWobblyInfos& wwi, EffectWindow*
{
unsigned int idx = j*4 + i;
wwi.constraint[idx] = false;
wwi.locked[idx] = false;
}
}
wwi.status = Closing;
@ -512,6 +529,7 @@ void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry)
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 @@ void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry)
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 @@ void WobblyWindowsEffect::freeWobblyInfo(WindowWobblyInfos& wwi) const
delete[] wwi.acceleration;
delete[] wwi.buffer;
delete[] wwi.constraint;
delete[] wwi.locked;
delete[] wwi.bezierSurface;
}
@ -590,7 +610,7 @@ WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWo
// ASSERT1(ty >= 0);
// ASSERT1(ty <= 1);
// compute polinomial coeff
// compute polynomial coeff
qreal px[4];
px[0] = (1-tx)*(1-tx)*(1-tx);
@ -618,6 +638,7 @@ WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWo
return res;
}
namespace
{
@ -1050,6 +1071,10 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
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])
{

@ -70,11 +70,13 @@ class WobblyWindowsEffect : public Effect
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;

Loading…
Cancel
Save