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:
parent
de67ff5bad
commit
e1fb4aa2b6
4 changed files with 88 additions and 45 deletions
77
client.cpp
77
client.cpp
|
@ -488,25 +488,9 @@ void Client::hideClient( bool hide )
|
|||
if( hidden == hide )
|
||||
return;
|
||||
hidden = hide;
|
||||
info->setState( hidden ? NET::Hidden : 0, NET::Hidden );
|
||||
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
|
||||
}
|
||||
}
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Returns whether the window is minimizable or not
|
||||
*/
|
||||
|
@ -551,12 +535,10 @@ void Client::minimize( bool avoid_animation )
|
|||
Notify::raise( Notify::Minimize );
|
||||
|
||||
// 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
|
||||
|
||||
setMappingState( IconicState );
|
||||
info->setState( NET::Hidden, NET::Hidden );
|
||||
rawHide();
|
||||
updateVisibility();
|
||||
updateAllowedActions();
|
||||
workspace()->updateMinimizedOfTransients( this );
|
||||
updateWindowRules();
|
||||
|
@ -568,16 +550,13 @@ void Client::unminimize( bool avoid_animation )
|
|||
return;
|
||||
|
||||
Notify::raise( Notify::UnMinimize );
|
||||
minimized = false;
|
||||
info->setState( 0, NET::Hidden );
|
||||
if( isOnCurrentDesktop())
|
||||
minimized = false;
|
||||
if( isOnCurrentDesktop() && isShown( true ))
|
||||
{
|
||||
if( mainClients().isEmpty() && !avoid_animation )
|
||||
animateMinimizeOrUnminimize( FALSE );
|
||||
if( isShown( false ))
|
||||
setMappingState( NormalState );
|
||||
rawShow(); // is either visible or shaded
|
||||
}
|
||||
updateVisibility();
|
||||
updateAllowedActions();
|
||||
workspace()->updateMinimizedOfTransients( this );
|
||||
updateWindowRules();
|
||||
|
@ -841,22 +820,42 @@ void Client::toggleShade()
|
|||
setShade( shade_mode == ShadeNone ? ShadeNormal : ShadeNone );
|
||||
}
|
||||
|
||||
void Client::virtualDesktopChange()
|
||||
void Client::updateVisibility()
|
||||
{
|
||||
if( hidden || minimized )
|
||||
return; // no visibility change
|
||||
// from here it can be only shaded or normally shown
|
||||
if( isOnCurrentDesktop())
|
||||
bool show = true;
|
||||
if( hidden )
|
||||
{
|
||||
if( !isShade())
|
||||
setMappingState( NormalState );
|
||||
rawShow();
|
||||
setMappingState( IconicState );
|
||||
info->setState( NET::Hidden, NET::Hidden );
|
||||
setSkipTaskbar( true, false ); // also hide from taskbar
|
||||
rawHide();
|
||||
show = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !isShade())
|
||||
setMappingState( IconicState );
|
||||
setSkipTaskbar( original_skip_taskbar, false );
|
||||
}
|
||||
if( minimized )
|
||||
{
|
||||
setMappingState( IconicState );
|
||||
info->setState( NET::Hidden, NET::Hidden );
|
||||
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 )
|
||||
decoration->desktopChange();
|
||||
virtualDesktopChange(); // hide/show if needed
|
||||
updateVisibility();
|
||||
updateWindowRules();
|
||||
}
|
||||
|
||||
|
|
4
client.h
4
client.h
|
@ -229,10 +229,10 @@ class Client : public QObject, public KDecorationDefines
|
|||
|
||||
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
|
||||
void hideClient( bool hide );
|
||||
// updates visibility depending on whether it's on the current desktop
|
||||
void virtualDesktopChange();
|
||||
|
||||
QString caption( bool full = true ) const;
|
||||
void updateCaption();
|
||||
|
|
46
manage.cpp
46
manage.cpp
|
@ -425,6 +425,50 @@ bool Client::manage( Window w, bool isMapped )
|
|||
if( isTopMenu()) // they're shown in Workspace::addClient() if their mainwindow
|
||||
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( isDialog())
|
||||
|
@ -473,7 +517,7 @@ bool Client::manage( Window w, bool isMapped )
|
|||
}
|
||||
else
|
||||
{
|
||||
virtualDesktopChange();
|
||||
updateVisibility();
|
||||
workspace()->raiseClient( this );
|
||||
if( !session && !isMapped )
|
||||
demandAttention();
|
||||
|
|
|
@ -1081,14 +1081,14 @@ bool Workspace::setCurrentDesktop( int new_desktop )
|
|||
ObscuringWindows obs_wins;
|
||||
|
||||
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)
|
||||
if ( !(*it)->isOnDesktop( new_desktop ) && (*it) != movingClient )
|
||||
{
|
||||
if( (*it)->isShown( true ) && (*it)->isOnDesktop( old_desktop ))
|
||||
obs_wins.create( *it );
|
||||
(*it)->virtualDesktopChange();
|
||||
(*it)->updateVisibility();
|
||||
}
|
||||
|
||||
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)
|
||||
if ( (*it)->isOnDesktop( new_desktop ) )
|
||||
(*it)->virtualDesktopChange();
|
||||
(*it)->updateVisibility();
|
||||
}
|
||||
|
||||
// restore the focus on this desktop
|
||||
|
|
Loading…
Reference in a new issue