/*! Sets the client's active state to \a act. This function does only change the visual appearance of the client, it does not change the focus setting. Use Workspace::activateClient() or Workspace::requestFocus() instead. If a client receives or looses the focus, it calls setActive() on its own. */ void Client::setActive(bool act) { if (active == act) return; active = act; const int ruledOpacity = active ? rules()->checkOpacityActive(qRound(opacity() * 100.0)) : rules()->checkOpacityInactive(qRound(opacity() * 100.0)); setOpacity(ruledOpacity / 100.0); workspace()->setActiveClient(act ? this : NULL, Allowed); if (active) Notify::raise(Notify::Activate); if (!active) cancelAutoRaise(); if (!active && shade_mode == ShadeActivated) setShade(ShadeNormal); StackingUpdatesBlocker blocker(workspace()); workspace()->updateClientLayer(this); // active windows may get different layer ClientList mainclients = mainClients(); for (ClientList::ConstIterator it = mainclients.constBegin(); it != mainclients.constEnd(); ++it) if ((*it)->isFullScreen()) // fullscreens go high even if their transient is active workspace()->updateClientLayer(*it); if (decoration != NULL) decoration->activeChange(); emit activeChanged(); updateMouseGrab(); updateUrgency(); // demand attention again if it's still urgent workspace()->checkUnredirect(); }
/*! Sets the client's active state to \a act. This function does only change the visual appearance of the client, it does not change the focus setting. Use Workspace::activateClient() or Workspace::requestFocus() instead. If a client receives or looses the focus, it calls setActive() on its own. */ void Client::setActive( bool act, bool updateOpacity_) { if ( active == act ) return; active = act; workspace()->setActiveClient( act ? this : NULL, Allowed ); if (updateOpacity_) updateOpacity(); if (isModal() && transientFor()) { if (!act) transientFor()->updateOpacity(); else if (!transientFor()->custom_opacity) transientFor()->setOpacity(options->translucentActiveWindows, options->activeWindowOpacity); } updateShadowSize(); if ( active ) { Notify::raise( Notify::Activate ); if (options->shadowEnabled(true)) { if (options->shadowEnabled(false)) { // Wait for inactive shadow to expose occluded windows and give // them a chance to redraw before painting the active shadow removeShadow(); drawDelayedShadow(); if (!isDesktop() && this != workspace()->topClientOnDesktop(desktop())) // If the newly activated window's isn't the desktop, wait // for its shadow to draw, then redraw any shadows // overlapping it. drawOverlappingShadows(true); } else drawShadow(); } } else { removeShadow(); if (options->shadowEnabled(false)) { if (this == workspace()->topClientOnDesktop(desktop())) { /* If the newly deactivated window is the top client on the * desktop, then the newly activated window is below it; ensure * that the deactivated window's shadow draws after the * activated window's shadow. */ if ((shadowAfterClient = workspace()->activeClient())) { drawShadowAfter(shadowAfterClient); } } else { drawDelayedShadow(); } } } if( !active ) cancelAutoRaise(); if( !active && shade_mode == ShadeActivated ) setShade( ShadeNormal ); StackingUpdatesBlocker blocker( workspace()); workspace()->updateClientLayer( this ); // active windows may get different layer // TODO optimize? mainClients() may be a bit expensive ClientList mainclients = mainClients(); for( ClientList::ConstIterator it = mainclients.begin(); it != mainclients.end(); ++it ) if( (*it)->isFullScreen()) // fullscreens go high even if their transient is active workspace()->updateClientLayer( *it ); if( decoration != NULL ) decoration->activeChange(); updateMouseGrab(); updateUrgency(); // demand attention again if it's still urgent }
Time Client::readUserTimeMapTimestamp( const TDEStartupInfoId* asn_id, const TDEStartupInfoData* asn_data, bool session ) const { Time time = info->userTime(); // kdDebug( 1212 ) << "User timestamp, initial:" << time << endl; // newer ASN timestamp always replaces user timestamp, unless user timestamp is 0 // helps e.g. with konqy reusing if( asn_data != NULL && time != 0 ) { // prefer timestamp from ASN id (timestamp from data is obsolete way) if( asn_id->timestamp() != 0 && ( time == -1U || timestampCompare( asn_id->timestamp(), time ) > 0 )) { time = asn_id->timestamp(); } else if( asn_data->timestamp() != -1U && ( time == -1U || timestampCompare( asn_data->timestamp(), time ) > 0 )) { time = asn_data->timestamp(); } } // kdDebug( 1212 ) << "User timestamp, ASN:" << time << endl; if( time == -1U ) { // The window doesn't have any timestamp. // If it's the first window for its application // (i.e. there's no other window from the same app), // use the _TDE_NET_WM_USER_CREATION_TIME trick. // Otherwise, refuse activation of a window // from already running application if this application // is not the active one (unless focus stealing prevention is turned off). Client* act = workspace()->mostRecentlyActivatedClient(); if( act != NULL && !belongToSameApplication( act, this, true )) { bool first_window = true; if( isTransient()) { if( act->hasTransient( this, true )) ; // is transient for currently active window, even though it's not // the same app (e.g. kcookiejar dialog) -> allow activation else if( groupTransient() && findClientInList( mainClients(), SameApplicationActiveHackPredicate( this )) == NULL ) ; // standalone transient else first_window = false; } else { if( workspace()->findClient( SameApplicationActiveHackPredicate( this ))) first_window = false; } // don't refuse if focus stealing prevention is turned off if( !first_window && rules()->checkFSP( options->focusStealingPreventionLevel ) > 0 ) { // kdDebug( 1212 ) << "User timestamp, already exists:" << 0 << endl; return 0; // refuse activation } } // Creation time would just mess things up during session startup, // as possibly many apps are started up at the same time. // If there's no active window yet, no timestamp will be needed, // as plain Workspace::allowClientActivation() will return true // in such case. And if there's already active window, // it's better not to activate the new one. // Unless it was the active window at the time // of session saving and there was no user interaction yet, // this check will be done in manage(). if( session ) return -1U; if( ignoreFocusStealing() && act != NULL ) time = act->userTime(); else time = readUserCreationTime(); } // kdDebug( 1212 ) << "User timestamp, final:" << this << ":" << time << endl; return time; }