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
master
Toby Dickenson 16 years ago
parent 27187f2c15
commit 0c166b6ecb

@ -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;

@ -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<unsigned int>(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<unsigned int>(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<wwi.height; ++j)
{
for (unsigned int i=0; i<wwi.width; ++i)
{
Pair v = { magnitude*(i/qreal(wwi.width-1)-0.5), magnitude*(j/qreal(wwi.height-1)-0.5) };
wwi.velocity[j*wwi.width+i] = v;
}
}
}
void WobblyWindowsEffect::windowAdded(EffectWindow* w)
{
if (m_openEffectEnabled)

@ -62,6 +62,8 @@ class WobblyWindowsEffect : public Effect
private:
void startMovedResized(EffectWindow* w);
void stepMovedResized(EffectWindow* w);
bool updateWindowWobblyDatas(EffectWindow* w, qreal time);
struct WindowWobblyInfos

@ -2169,6 +2169,8 @@ void Client::setMaximize( bool vertically, bool horizontally )
max_mode & MaximizeVertical ? !vertically : vertically,
max_mode & MaximizeHorizontal ? !horizontally : horizontally,
false );
if( effects )
static_cast<EffectsHandlerImpl*>(effects)->windowUserMovedResized( effectWindow(), true, true );
}
void Client::changeMaximize( bool vertical, bool horizontal, bool adjust )

Loading…
Cancel
Save