When comparing window requesting activation (i.e. focus stealing prevention),

don't use Workspace::activeClient() as the active client, but instead
the most recent should_get_focus client - that may make a difference
if a window was just activated, but the matching FocusIn event that'll
make it to be activeClient() wasn't yet processes. Visible with apps
that show several windows at the same time after startup.

svn path=/trunk/kdebase/kwin/; revision=270831
This commit is contained in:
Luboš Luňák 2003-12-02 17:52:10 +00:00
parent 962f313ada
commit 0b8ee9a5e4
2 changed files with 15 additions and 6 deletions

View file

@ -276,7 +276,7 @@ void Workspace::activateClient( Client* c, bool force )
requestFocus( c, force );
else
{
if( activeClient() != c )
if( mostRecentlyActivatedClient() != c )
c->demandAttention();
}
@ -422,7 +422,7 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
{
return true;
}
Client* ac = activeClient();
Client* ac = mostRecentlyActivatedClient();
if( focus_in )
{
if( should_get_focus.contains( const_cast< Client* >( c )))
@ -481,7 +481,7 @@ bool Workspace::allowFullClientRaising( const Client* c )
{
return true;
}
Client* ac = activeClient();
Client* ac = mostRecentlyActivatedClient();
if( options->focusStealingPreventionLevel == 0 ) // none
return true;
if( options->focusStealingPreventionLevel == 5 ) // extreme
@ -640,13 +640,13 @@ Time Client::readUserTimeMapTimestamp( const KStartupInfoData* asn_data,
// Otherwise, refuse activation of a window
// from already running application if this application
// is not the active one.
if( workspace()->activeClient() != NULL
&& !belongToSameApplication( workspace()->activeClient(), this, true ))
Client* act = workspace()->mostRecentlyActivatedClient();
if( act != NULL && !belongToSameApplication( act, this, true ))
{
bool first_window = true;
if( isTransient())
{
if( workspace()->activeClient()->hasTransient( this, true ))
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() && mainClients().isEmpty())

View file

@ -103,6 +103,10 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
* if no client has the focus)
*/
Client* activeClient() const;
// Client that was activated, but it's not yet really activeClient(), because
// we didn't process yet the matching FocusIn event. Used mostly in focus
// stealing prevention code.
Client* mostRecentlyActivatedClient() const;
void setActiveClient( Client*, allowed_t );
void activateClient( Client*, bool force = FALSE );
@ -561,6 +565,11 @@ inline Client* Workspace::activeClient() const
return active_client;
}
inline Client* Workspace::mostRecentlyActivatedClient() const
{
return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
}
inline int Workspace::currentDesktop() const
{
return current_desktop;