From e1fb4aa2b6dc1dd93a19e796f2e175877dbd8e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 12 Apr 2005 17:22:47 +0000 Subject: [PATCH] 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 --- client.cpp | 77 +++++++++++++++++++++++++-------------------------- client.h | 4 +-- manage.cpp | 46 +++++++++++++++++++++++++++++- workspace.cpp | 6 ++-- 4 files changed, 88 insertions(+), 45 deletions(-) diff --git a/client.cpp b/client.cpp index fcae3d23a7..d8d61c5a8a 100644 --- a/client.cpp +++ b/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(); } diff --git a/client.h b/client.h index 7fa6556687..f0b4f2ab61 100644 --- a/client.h +++ b/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(); diff --git a/manage.cpp b/manage.cpp index 15ef469233..5a82cd2120 100644 --- a/manage.cpp +++ b/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(); diff --git a/workspace.cpp b/workspace.cpp index 2bb1a8059f..615fe86556 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -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