Minimize e.g. dialogs onto taskbar entries of their mainwindows.

If everything else fails, minimize to the center of the screen.

svn path=/branches/work/kwin_composite/; revision=627172
This commit is contained in:
Rivo Laks 2007-01-25 21:23:27 +00:00
parent 29b8d42e55
commit 8669b298be
2 changed files with 25 additions and 4 deletions

View file

@ -83,6 +83,16 @@ void MinimizeAnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion re
Client* c = static_cast< Client* >( w->window() ); Client* c = static_cast< Client* >( w->window() );
QRect geo = c->geometry(); QRect geo = c->geometry();
QRect icon = c->iconGeometry(); QRect icon = c->iconGeometry();
// For dialogs, try to use parent window's taskbar entry
if( !icon.isValid() )
{
Client* parent = findParentWithIconGeometry( c );
if( parent )
icon = parent->iconGeometry();
}
// If everything else fails, minimize to the center of the screen
if( !icon.isValid() )
icon = QRect( displayWidth() / 2, displayHeight() / 2, 0, 0 );
data.xScale *= interpolate(1.0, icon.width() / (float)geo.width(), progress); data.xScale *= interpolate(1.0, icon.width() / (float)geo.width(), progress);
data.yScale *= interpolate(1.0, icon.height() / (float)geo.height(), progress); data.yScale *= interpolate(1.0, icon.height() / (float)geo.height(), progress);
@ -106,8 +116,7 @@ void MinimizeAnimationEffect::postPaintScreen()
void MinimizeAnimationEffect::windowMinimized( EffectWindow* w ) void MinimizeAnimationEffect::windowMinimized( EffectWindow* w )
{ {
Client* client = static_cast< Client* >( w->window() ); if( !mAnimationProgress.contains(w) )
if( !mAnimationProgress.contains(w) && client->iconGeometry().isValid() )
{ {
mAnimationProgress[w] = 0.0f; mAnimationProgress[w] = 0.0f;
mActiveAnimations++; mActiveAnimations++;
@ -116,13 +125,22 @@ void MinimizeAnimationEffect::windowMinimized( EffectWindow* w )
void MinimizeAnimationEffect::windowUnminimized( EffectWindow* w ) void MinimizeAnimationEffect::windowUnminimized( EffectWindow* w )
{ {
Client* client = static_cast< Client* >( w->window() ); if( !mAnimationProgress.contains(w) )
if( !mAnimationProgress.contains(w) && client->iconGeometry().isValid() )
{ {
mAnimationProgress[w] = 1.0f; mAnimationProgress[w] = 1.0f;
mActiveAnimations++; mActiveAnimations++;
} }
} }
Client* MinimizeAnimationEffect::findParentWithIconGeometry( Client* c )
{
if( c->iconGeometry().isValid() )
return c;
else if( c->transientFor() )
return findParentWithIconGeometry( c->transientFor() );
else
return 0;
}
} // namespace } // namespace

View file

@ -35,6 +35,9 @@ class MinimizeAnimationEffect
virtual void windowMinimized( EffectWindow* c ); virtual void windowMinimized( EffectWindow* c );
virtual void windowUnminimized( EffectWindow* c ); virtual void windowUnminimized( EffectWindow* c );
protected:
Client* findParentWithIconGeometry( Client* c );
private: private:
Workspace* mWorkspace; Workspace* mWorkspace;
QMap< EffectWindow*, float > mAnimationProgress; QMap< EffectWindow*, float > mAnimationProgress;