Move all code responsible for showing/hiding windows, setting mapping

state, NET::Hidden etc. to one function: Client::updateVisibility().

svn path=/trunk/kdebase/kwin/; revision=405104
This commit is contained in:
Luboš Luňák 2005-04-12 17:22:47 +00:00
parent de67ff5bad
commit e1fb4aa2b6
4 changed files with 88 additions and 45 deletions

View file

@ -488,25 +488,9 @@ void Client::hideClient( bool hide )
if( hidden == hide ) if( hidden == hide )
return; return;
hidden = hide; hidden = hide;
info->setState( hidden ? NET::Hidden : 0, NET::Hidden ); updateVisibility();
if( hidden )
{
setMappingState( IconicState );
rawHide();
setSkipTaskbar( true, false ); // also hide from taskbar
}
else // !hidden
{
setSkipTaskbar( original_skip_taskbar, false );
if( isOnCurrentDesktop())
{
if( isShown( false ))
setMappingState( NormalState );
rawShow(); // is either visible or shaded
}
}
} }
/* /*
Returns whether the window is minimizable or not Returns whether the window is minimizable or not
*/ */
@ -551,12 +535,10 @@ void Client::minimize( bool avoid_animation )
Notify::raise( Notify::Minimize ); Notify::raise( Notify::Minimize );
// SELI mainClients().isEmpty() ??? - and in unminimize() too // SELI mainClients().isEmpty() ??? - and in unminimize() too
if ( mainClients().isEmpty() && isOnCurrentDesktop() && !avoid_animation ) if ( mainClients().isEmpty() && isOnCurrentDesktop() && isShown( true ) && !avoid_animation )
animateMinimizeOrUnminimize( true ); // was visible or shaded animateMinimizeOrUnminimize( true ); // was visible or shaded
setMappingState( IconicState ); updateVisibility();
info->setState( NET::Hidden, NET::Hidden );
rawHide();
updateAllowedActions(); updateAllowedActions();
workspace()->updateMinimizedOfTransients( this ); workspace()->updateMinimizedOfTransients( this );
updateWindowRules(); updateWindowRules();
@ -568,16 +550,13 @@ void Client::unminimize( bool avoid_animation )
return; return;
Notify::raise( Notify::UnMinimize ); Notify::raise( Notify::UnMinimize );
minimized = false; minimized = false;
info->setState( 0, NET::Hidden ); if( isOnCurrentDesktop() && isShown( true ))
if( isOnCurrentDesktop())
{ {
if( mainClients().isEmpty() && !avoid_animation ) if( mainClients().isEmpty() && !avoid_animation )
animateMinimizeOrUnminimize( FALSE ); animateMinimizeOrUnminimize( FALSE );
if( isShown( false ))
setMappingState( NormalState );
rawShow(); // is either visible or shaded
} }
updateVisibility();
updateAllowedActions(); updateAllowedActions();
workspace()->updateMinimizedOfTransients( this ); workspace()->updateMinimizedOfTransients( this );
updateWindowRules(); updateWindowRules();
@ -841,22 +820,42 @@ void Client::toggleShade()
setShade( shade_mode == ShadeNone ? ShadeNormal : ShadeNone ); setShade( shade_mode == ShadeNone ? ShadeNormal : ShadeNone );
} }
void Client::virtualDesktopChange() void Client::updateVisibility()
{ {
if( hidden || minimized ) bool show = true;
return; // no visibility change if( hidden )
// from here it can be only shaded or normally shown
if( isOnCurrentDesktop())
{ {
if( !isShade()) setMappingState( IconicState );
setMappingState( NormalState ); info->setState( NET::Hidden, NET::Hidden );
rawShow(); setSkipTaskbar( true, false ); // also hide from taskbar
rawHide();
show = false;
} }
else else
{ {
if( !isShade()) setSkipTaskbar( original_skip_taskbar, false );
setMappingState( IconicState ); }
if( minimized )
{
setMappingState( IconicState );
info->setState( NET::Hidden, NET::Hidden );
rawHide(); rawHide();
show = false;
}
if( !isOnCurrentDesktop())
{
setMappingState( IconicState );
rawHide();
show = false;
}
if( show )
{
info->setState( 0, NET::Hidden );
if( isShade())
setMappingState( IconicState );
else
setMappingState( NormalState );
rawShow();
} }
} }
@ -1149,7 +1148,7 @@ void Client::setDesktop( int desktop )
} }
if( decoration != NULL ) if( decoration != NULL )
decoration->desktopChange(); decoration->desktopChange();
virtualDesktopChange(); // hide/show if needed updateVisibility();
updateWindowRules(); updateWindowRules();
} }

View file

@ -229,10 +229,10 @@ class Client : public QObject, public KDecorationDefines
Colormap colormap() const; Colormap colormap() const;
// updates visibility depending on being shaded, virtual desktop, etc.
void updateVisibility();
// hides a client - basically like minimize, but without effects, it's simply hidden // hides a client - basically like minimize, but without effects, it's simply hidden
void hideClient( bool hide ); void hideClient( bool hide );
// updates visibility depending on whether it's on the current desktop
void virtualDesktopChange();
QString caption( bool full = true ) const; QString caption( bool full = true ) const;
void updateCaption(); void updateCaption();

View file

@ -425,6 +425,50 @@ bool Client::manage( Window w, bool isMapped )
if( isTopMenu()) // they're shown in Workspace::addClient() if their mainwindow if( isTopMenu()) // they're shown in Workspace::addClient() if their mainwindow
hideClient( true ); // is the active one hideClient( true ); // is the active one
if( !doNotShow )
{
if( isDialog())
Notify::raise( Notify::TransNew );
if( isNormalWindow())
Notify::raise( Notify::New );
bool allow;
if( session )
allow = session->active && !workspace()->wasUserInteraction();
else
allow = workspace()->allowClientActivation( this, userTime(), false );
// if session saving, force showing new windows (i.e. "save file?" dialogs etc.)
// also force if activation is allowed
if( !isOnCurrentDesktop() && !isMapped && !session && ( allow || workspace()->sessionSaving()))
workspace()->setCurrentDesktop( desktop());
if( isOnCurrentDesktop() && !isMapped && !allow )
workspace()->restackClientUnderActive( this );
else
workspace()->raiseClient( this );
updateVisibility();
if( !isMapped )
{
if( allow && isOnCurrentDesktop())
{
if( !isSpecialWindow() || isOverride())
if ( options->focusPolicyIsReasonable() && wantsTabFocus() )
workspace()->requestFocus( this );
}
else
{
if( !session && ( !isSpecialWindow() || isOverride()))
demandAttention();
}
}
}
else // doNotShow
{ // SELI HACK !!!
hideClient( true );
}
if ( isShown( true ) && !doNotShow ) if ( isShown( true ) && !doNotShow )
{ {
if( isDialog()) if( isDialog())
@ -473,7 +517,7 @@ bool Client::manage( Window w, bool isMapped )
} }
else else
{ {
virtualDesktopChange(); updateVisibility();
workspace()->raiseClient( this ); workspace()->raiseClient( this );
if( !session && !isMapped ) if( !session && !isMapped )
demandAttention(); demandAttention();

View file

@ -1081,14 +1081,14 @@ bool Workspace::setCurrentDesktop( int new_desktop )
ObscuringWindows obs_wins; ObscuringWindows obs_wins;
int old_desktop = current_desktop; int old_desktop = current_desktop;
current_desktop = new_desktop; // change the desktop (so that Client::virtualDesktopChange() works) current_desktop = new_desktop; // change the desktop (so that Client::updateVisibility() works)
for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it)
if ( !(*it)->isOnDesktop( new_desktop ) && (*it) != movingClient ) if ( !(*it)->isOnDesktop( new_desktop ) && (*it) != movingClient )
{ {
if( (*it)->isShown( true ) && (*it)->isOnDesktop( old_desktop )) if( (*it)->isShown( true ) && (*it)->isOnDesktop( old_desktop ))
obs_wins.create( *it ); obs_wins.create( *it );
(*it)->virtualDesktopChange(); (*it)->updateVisibility();
} }
rootInfo->setCurrentDesktop( current_desktop ); // now propagate the change, after hiding, before showing rootInfo->setCurrentDesktop( current_desktop ); // now propagate the change, after hiding, before showing
@ -1098,7 +1098,7 @@ bool Workspace::setCurrentDesktop( int new_desktop )
for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it)
if ( (*it)->isOnDesktop( new_desktop ) ) if ( (*it)->isOnDesktop( new_desktop ) )
(*it)->virtualDesktopChange(); (*it)->updateVisibility();
} }
// restore the focus on this desktop // restore the focus on this desktop