From 0c166b6ecb8dd2f97d5897f71cddb959f6176f98 Mon Sep 17 00:00:00 2001 From: Toby Dickenson Date: Mon, 2 Mar 2009 20:18:35 +0000 Subject: [PATCH] call the windowUserMovedResized hook for maximize/restore. That method has two boolean parameters which indicate whether this is the first move in a sequence, and the last. For maximize/restore we set both to true, and several effects need tweaking to handle this case. Also include an addition to the wobbly windows effect to include a slight 'throb' when maximized/restored. This makes it easier for your eye to track where your de-maxized window went to. FEATURE 185014 svn path=/trunk/KDE/kdebase/workspace/; revision=934346 --- effects/snaphelper/snaphelper.cpp | 2 +- effects/wobblywindows/wobblywindows.cpp | 130 ++++++++++++++++-------- effects/wobblywindows/wobblywindows.h | 2 + geometry.cpp | 2 + 4 files changed, 92 insertions(+), 44 deletions(-) diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp index 9dfaa72df3..733dcde0d3 100644 --- a/effects/snaphelper/snaphelper.cpp +++ b/effects/snaphelper/snaphelper.cpp @@ -174,7 +174,7 @@ void SnapHelperEffect::windowClosed( EffectWindow* w ) void SnapHelperEffect::windowUserMovedResized( EffectWindow* w, bool first, bool last ) { - if( first && w->isMovable() ) + if( first && !last && w->isMovable() ) { m_active = true; m_window = w; diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index d93eb23ff5..d30482b496 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -370,55 +370,23 @@ void WobblyWindowsEffect::postPaintScreen() void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last) { - if (m_moveEffectEnabled && first && !w->isSpecialWindow() && - ((w->isUserMove() && m_moveWobble) || (w->isUserResize() && m_resizeWobble))) - { - if (!windows.contains(w)) - { - WindowWobblyInfos new_wwi; - initWobblyInfo(new_wwi, w->geometry()); - windows[w] = new_wwi; - } - - WindowWobblyInfos& wwi = windows[w]; - wwi.status = Moving; - const QRectF& rect = w->geometry(); - - qreal x_increment = rect.width() / (wwi.width-1.0); - qreal y_increment = rect.height() / (wwi.height-1.0); - - Pair picked = {cursorPos().x(), cursorPos().y()}; - int indx = (picked.x - rect.x()) / x_increment + 0.5; - int indy = (picked.y - rect.y()) / y_increment + 0.5; - int pickedPointIndex = indy*wwi.width + indx; - if (pickedPointIndex < 0) - { - kDebug(1212) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")"; - pickedPointIndex = 0; - } - else if (static_cast(pickedPointIndex) > wwi.count - 1) - { - kDebug(1212) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")"; - pickedPointIndex = wwi.count - 1; - } -#if defined VERBOSE_MODE - kDebug(1212) << "Original Picked point -- x : " << picked.x << " - y : " << picked.y; -#endif - wwi.constraint[pickedPointIndex] = true; + if (!m_moveEffectEnabled || w->isSpecialWindow()) + return; - if (w->isUserResize()) + if (first) + { + if(last && m_moveWobble && m_resizeWobble) { - // on a resize, do not allow any edges to wobble until it has been moved from - // its original location - wwi.can_wobble_top = wwi.can_wobble_left = wwi.can_wobble_right = wwi.can_wobble_bottom = false; - wwi.resize_original_rect = w->geometry(); + // both first and last - a step change like Maximize + stepMovedResized(w); } - else + else if ((w->isUserMove() && m_moveWobble) || (w->isUserResize() && m_resizeWobble)) { - wwi.can_wobble_top = wwi.can_wobble_left = wwi.can_wobble_right = wwi.can_wobble_bottom = true; + startMovedResized(w); } } - else if (m_moveEffectEnabled && last) + + if (last) { if (windows.contains(w)) { @@ -438,6 +406,82 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo } } + +void WobblyWindowsEffect::startMovedResized(EffectWindow* w) +{ + if (!windows.contains(w)) + { + WindowWobblyInfos new_wwi; + initWobblyInfo(new_wwi, w->geometry()); + windows[w] = new_wwi; + } + + WindowWobblyInfos& wwi = windows[w]; + wwi.status = Moving; + const QRectF& rect = w->geometry(); + + qreal x_increment = rect.width() / (wwi.width-1.0); + qreal y_increment = rect.height() / (wwi.height-1.0); + + Pair picked = {cursorPos().x(), cursorPos().y()}; + int indx = (picked.x - rect.x()) / x_increment + 0.5; + int indy = (picked.y - rect.y()) / y_increment + 0.5; + int pickedPointIndex = indy*wwi.width + indx; + if (pickedPointIndex < 0) + { + kDebug(1212) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")"; + pickedPointIndex = 0; + } + else if (static_cast(pickedPointIndex) > wwi.count - 1) + { + kDebug(1212) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")"; + pickedPointIndex = wwi.count - 1; + } +#if defined VERBOSE_MODE + kDebug(1212) << "Original Picked point -- x : " << picked.x << " - y : " << picked.y; +#endif + wwi.constraint[pickedPointIndex] = true; + + if (w->isUserResize()) + { + // on a resize, do not allow any edges to wobble until it has been moved from + // its original location + wwi.can_wobble_top = wwi.can_wobble_left = wwi.can_wobble_right = wwi.can_wobble_bottom = false; + wwi.resize_original_rect = w->geometry(); + } + else + { + wwi.can_wobble_top = wwi.can_wobble_left = wwi.can_wobble_right = wwi.can_wobble_bottom = true; + } +} + +void WobblyWindowsEffect::stepMovedResized(EffectWindow* w) +{ + QRect new_geometry = w->geometry(); + if (!windows.contains(w)) + { + WindowWobblyInfos new_wwi; + initWobblyInfo(new_wwi, new_geometry); + windows[w] = new_wwi; + } + + WindowWobblyInfos& wwi = windows[w]; + wwi.status = Free; + + QRect maximized_area = effects->clientArea(MaximizeArea,w); + bool throb_direction_out = (new_geometry.top()==maximized_area.top()&&new_geometry.bottom()==maximized_area.bottom()) || + (new_geometry.left()==maximized_area.left()&&new_geometry.right()==maximized_area.right()); + qreal magnitude = throb_direction_out ? 10 : -30; // a small throb out when maximized, a larger throb inwards when restored + for (unsigned int j=0; j(effects)->windowUserMovedResized( effectWindow(), true, true ); } void Client::changeMaximize( bool vertical, bool horizontal, bool adjust )