Commit 4fd08556 authored by Martin Flöser's avatar Martin Flöser

KWin uses kdelibs coding style.

parent 63d5c0c7

Too many changes to show.

To preserve performance only 190 of 190+ files are displayed.
......@@ -224,54 +224,53 @@ namespace KWin
activeClient(). And of course, to propagate the active client to the
world.
*/
void Workspace::setActiveClient( Client* c, allowed_t )
{
if ( active_client == c )
void Workspace::setActiveClient(Client* c, allowed_t)
{
if (active_client == c)
return;
if(c != 0) {
emit clientActivated(c);
c->sl_activated();
if (c != 0) {
emit clientActivated(c);
c->sl_activated();
}
if( active_popup && active_popup_client != c && set_active_client_recursion == 0 )
if (active_popup && active_popup_client != c && set_active_client_recursion == 0)
closeActivePopup();
StackingUpdatesBlocker blocker( this );
StackingUpdatesBlocker blocker(this);
++set_active_client_recursion;
updateFocusMousePosition( cursorPos());
if( active_client != NULL )
{ // note that this may call setActiveClient( NULL ), therefore the recursion counter
active_client->setActive( false );
}
updateFocusMousePosition(cursorPos());
if (active_client != NULL) {
// note that this may call setActiveClient( NULL ), therefore the recursion counter
active_client->setActive(false);
}
active_client = c;
Q_ASSERT( c == NULL || c->isActive());
if( active_client != NULL )
Q_ASSERT(c == NULL || c->isActive());
if (active_client != NULL)
last_active_client = active_client;
if ( active_client )
{
updateFocusChains( active_client, FocusChainMakeFirst );
active_client->demandAttention( false );
}
if (active_client) {
updateFocusChains(active_client, FocusChainMakeFirst);
active_client->demandAttention(false);
}
pending_take_activity = NULL;
updateCurrentTopMenu();
updateToolWindows( false );
if( c )
disableGlobalShortcutsForClient( c->rules()->checkDisableGlobalShortcuts( false ));
updateToolWindows(false);
if (c)
disableGlobalShortcutsForClient(c->rules()->checkDisableGlobalShortcuts(false));
else
disableGlobalShortcutsForClient( false );
disableGlobalShortcutsForClient(false);
updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active
rootInfo->setActiveWindow( active_client? active_client->window() : 0 );
rootInfo->setActiveWindow(active_client ? active_client->window() : 0);
updateColormap();
if( effects )
static_cast<EffectsHandlerImpl*>(effects)->windowActivated( active_client ? active_client->effectWindow() : NULL );
if (effects)
static_cast<EffectsHandlerImpl*>(effects)->windowActivated(active_client ? active_client->effectWindow() : NULL);
if( tilingEnabled() )
notifyTilingWindowActivated( active_client );
if (tilingEnabled())
notifyTilingWindowActivated(active_client);
--set_active_client_recursion;
}
}
/*!
Tries to activate the client \a c. This function performs what you
......@@ -284,34 +283,31 @@ void Workspace::setActiveClient( Client* c, allowed_t )
\sa stActiveClient(), requestFocus()
*/
void Workspace::activateClient( Client* c, bool force )
{
if( c == NULL )
{
void Workspace::activateClient(Client* c, bool force)
{
if (c == NULL) {
focusToNull();
setActiveClient( NULL, Allowed );
setActiveClient(NULL, Allowed);
return;
}
raiseClient( c );
if (!c->isOnCurrentDesktop() )
{
}
raiseClient(c);
if (!c->isOnCurrentDesktop()) {
++block_focus;
setCurrentDesktop( c->desktop() );
setCurrentDesktop(c->desktop());
--block_focus;
}
if (!c->isOnCurrentActivity() )
{
}
if (!c->isOnCurrentActivity()) {
++block_focus;
//DBUS!
activityController_.setCurrentActivity( c->activities().first() ); //first isn't necessarily best, but it's easiest
activityController_.setCurrentActivity(c->activities().first()); //first isn't necessarily best, but it's easiest
--block_focus;
}
if( c->isMinimized())
}
if (c->isMinimized())
c->unminimize();
// TODO force should perhaps allow this only if the window already contains the mouse
if( options->focusPolicyIsReasonable() || force )
requestFocus( c, force );
if (options->focusPolicyIsReasonable() || force)
requestFocus(c, force);
// Don't update user time for clients that have focus stealing workaround.
// As they usually belong to the current active window but fail to provide
......@@ -320,9 +316,9 @@ void Workspace::activateClient( Client* c, bool force )
// E.g. typing URL in minicli which will show kio_uiserver dialog (with workaround),
// and then kdesktop shows dialog about SSL certificate.
// This needs also avoiding user creation time in Client::readUserTimeMapTimestamp().
if( !c->ignoreFocusStealing())
if (!c->ignoreFocusStealing())
c->updateUserTime();
}
}
/*!
Tries to activate the client by asking X for the input focus. This
......@@ -331,80 +327,73 @@ void Workspace::activateClient( Client* c, bool force )
\sa Workspace::activateClient()
*/
void Workspace::requestFocus( Client* c, bool force )
{
takeActivity( c, ActivityFocus | ( force ? ActivityFocusForce : 0 ), false);
}
void Workspace::takeActivity( Client* c, int flags, bool handled )
{
// the 'if( c == active_client ) return;' optimization mustn't be done here
if (!focusChangeEnabled() && ( c != active_client) )
void Workspace::requestFocus(Client* c, bool force)
{
takeActivity(c, ActivityFocus | (force ? ActivityFocusForce : 0), false);
}
void Workspace::takeActivity(Client* c, int flags, bool handled)
{
// the 'if ( c == active_client ) return;' optimization mustn't be done here
if (!focusChangeEnabled() && (c != active_client))
flags &= ~ActivityFocus;
if ( !c )
{
if (!c) {
focusToNull();
return;
}
}
if( flags & ActivityFocus )
{
if (flags & ActivityFocus) {
Client* modal = c->findModal();
if( modal != NULL && modal != c )
{
if( !modal->isOnDesktop( c->desktop()))
{
modal->setDesktop( c->desktop());
if( modal->desktop() != c->desktop()) // forced desktop
activateClient( modal );
}
if (modal != NULL && modal != c) {
if (!modal->isOnDesktop(c->desktop())) {
modal->setDesktop(c->desktop());
if (modal->desktop() != c->desktop()) // forced desktop
activateClient(modal);
}
// if the click was inside the window (i.e. handled is set),
// but it has a modal, there's no need to use handled mode, because
// the modal doesn't get the click anyway
// raising of the original window needs to be still done
if( flags & ActivityRaise )
raiseClient( c );
if (flags & ActivityRaise)
raiseClient(c);
c = modal;
handled = false;
}
cancelDelayFocus();
}
if ( !( flags & ActivityFocusForce ) && ( c->isTopMenu() || c->isDock() || c->isSplash()) )
cancelDelayFocus();
}
if (!(flags & ActivityFocusForce) && (c->isTopMenu() || c->isDock() || c->isSplash()))
flags &= ~ActivityFocus; // toplevel menus and dock windows don't take focus if not forced
if( c->isShade())
{
if( c->wantsInput() && ( flags & ActivityFocus ))
{
// client cannot accept focus, but at least the window should be active (window menu, et. al. )
c->setActive( true );
if (c->isShade()) {
if (c->wantsInput() && (flags & ActivityFocus)) {
// client cannot accept focus, but at least the window should be active (window menu, et. al. )
c->setActive(true);
focusToNull();
}
}
flags &= ~ActivityFocus;
handled = false; // no point, can't get clicks
}
if( c->clientGroup() && c->clientGroup()->visible() != c )
c->clientGroup()->setVisible( c );
if( !c->isShown( true )) // shouldn't happen, call activateClient() if needed
{
kWarning( 1212 ) << "takeActivity: not shown" ;
}
if (c->clientGroup() && c->clientGroup()->visible() != c)
c->clientGroup()->setVisible(c);
if (!c->isShown(true)) { // shouldn't happen, call activateClient() if needed
kWarning(1212) << "takeActivity: not shown" ;
return;
}
c->takeActivity( flags, handled, Allowed );
if( !c->isOnScreen( active_screen ))
active_screen = c->screen();
}
c->takeActivity(flags, handled, Allowed);
if (!c->isOnScreen(active_screen))
active_screen = c->screen();
}
void Workspace::handleTakeActivity( Client* c, Time /*timestamp*/, int flags )
{
if( pending_take_activity != c ) // pending_take_activity is reset when doing restack or activation
void Workspace::handleTakeActivity(Client* c, Time /*timestamp*/, int flags)
{
if (pending_take_activity != c) // pending_take_activity is reset when doing restack or activation
return;
if(( flags & ActivityRaise ) != 0 )
raiseClient( c );
if(( flags & ActivityFocus ) != 0 && c->isShown( false ))
c->takeFocus( Allowed );
if ((flags & ActivityRaise) != 0)
raiseClient(c);
if ((flags & ActivityFocus) != 0 && c->isShown(false))
c->takeFocus(Allowed);
pending_take_activity = NULL;
}
}
/*!
Informs the workspace that the client \a c has been hidden. If it
......@@ -413,126 +402,116 @@ void Workspace::handleTakeActivity( Client* c, Time /*timestamp*/, int flags )
\a c may already be destroyed
*/
void Workspace::clientHidden( Client* c )
{
assert( !c->isShown( true ) || !c->isOnCurrentDesktop() || !c->isOnCurrentActivity());
activateNextClient( c );
}
void Workspace::clientHidden(Client* c)
{
assert(!c->isShown(true) || !c->isOnCurrentDesktop() || !c->isOnCurrentActivity());
activateNextClient(c);
}
static inline bool isUsableFocusCandidate( Client *c, Client *prev, bool respectScreen )
{
static inline bool isUsableFocusCandidate(Client *c, Client *prev, bool respectScreen)
{
return c != prev &&
c->isShown( false ) && c->isOnCurrentDesktop() && c->isOnCurrentActivity() &&
( !respectScreen || c->isOnScreen( prev ? prev->screen() : Workspace::self()->activeScreen() ) );
}
c->isShown(false) && c->isOnCurrentDesktop() && c->isOnCurrentActivity() &&
(!respectScreen || c->isOnScreen(prev ? prev->screen() : Workspace::self()->activeScreen()));
}
// deactivates 'c' and activates next client
bool Workspace::activateNextClient( Client* c )
{
bool Workspace::activateNextClient(Client* c)
{
// if 'c' is not the active or the to-become active one, do nothing
if( !( c == active_client
|| ( should_get_focus.count() > 0 && c == should_get_focus.last())))
if (!(c == active_client
|| (should_get_focus.count() > 0 && c == should_get_focus.last())))
return false;
closeActivePopup();
if( c != NULL )
{
if( c == active_client )
setActiveClient( NULL, Allowed );
should_get_focus.removeAll( c );
}
if( focusChangeEnabled())
{
if ( options->focusPolicyIsReasonable())
{ // search the focus_chain for a client to transfer focus to,
if (c != NULL) {
if (c == active_client)
setActiveClient(NULL, Allowed);
should_get_focus.removeAll(c);
}
if (focusChangeEnabled()) {
if (options->focusPolicyIsReasonable()) {
// search the focus_chain for a client to transfer focus to,
Client* get_focus = NULL;
// first try to pass the focus to the (former) active clients leader
if ( c && ( get_focus = c->transientFor() ) &&
isUsableFocusCandidate( get_focus, c, options->separateScreenFocus ))
{
raiseClient( get_focus ); // also raise - we don't know where it came from
}
else // nope, ask the focus chain for the next candidate
{
if (c && (get_focus = c->transientFor()) &&
isUsableFocusCandidate(get_focus, c, options->separateScreenFocus)) {
raiseClient(get_focus); // also raise - we don't know where it came from
} else { // nope, ask the focus chain for the next candidate
get_focus = NULL; // reset
for ( int i = focus_chain[ currentDesktop() ].size() - 1; i >= 0; --i )
{
Client* ci = focus_chain[ currentDesktop() ].at( i );
if ( isUsableFocusCandidate( ci, c, options->separateScreenFocus ))
{
for (int i = focus_chain[ currentDesktop()].size() - 1; i >= 0; --i) {
Client* ci = focus_chain[ currentDesktop()].at(i);
if (isUsableFocusCandidate(ci, c, options->separateScreenFocus)) {
get_focus = ci;
break; // we're done
}
}
}
}
if( get_focus == NULL ) // last chance: focus the desktop
get_focus = findDesktop( true, currentDesktop());
if (get_focus == NULL) // last chance: focus the desktop
get_focus = findDesktop(true, currentDesktop());
if( get_focus != NULL )
requestFocus( get_focus );
if (get_focus != NULL)
requestFocus(get_focus);
else
focusToNull();
}
else
return false;
}
else
} else
return false;
} else
// if blocking focus, move focus to the desktop later if needed
// in order to avoid flickering
focusToNull();
return true;
}
}
void Workspace::setCurrentScreen( int new_screen )
{
void Workspace::setCurrentScreen(int new_screen)
{
if (new_screen < 0 || new_screen > numScreens())
return;
if ( !options->focusPolicyIsReasonable())
if (!options->focusPolicyIsReasonable())
return;
closeActivePopup();
Client* get_focus = NULL;
for( int i = focus_chain[ currentDesktop() ].count() - 1;
i >= 0;
--i )
{
Client* ci = focus_chain[ currentDesktop() ].at( i );
if( !ci->isShown( false ) || !ci->isOnCurrentDesktop() || !ci->isOnCurrentActivity())
for (int i = focus_chain[ currentDesktop()].count() - 1;
i >= 0;
--i) {
Client* ci = focus_chain[ currentDesktop()].at(i);
if (!ci->isShown(false) || !ci->isOnCurrentDesktop() || !ci->isOnCurrentActivity())
continue;
if( !ci->screen() == new_screen )
if (!ci->screen() == new_screen)
continue;
get_focus = ci;
break;
}
if( get_focus == NULL )
get_focus = findDesktop( true, currentDesktop());
if( get_focus != NULL && get_focus != mostRecentlyActivatedClient())
requestFocus( get_focus );
active_screen = new_screen;
}
if (get_focus == NULL)
get_focus = findDesktop(true, currentDesktop());
if (get_focus != NULL && get_focus != mostRecentlyActivatedClient())
requestFocus(get_focus);
active_screen = new_screen;
}
void Workspace::gotFocusIn( const Client* c )
{
if( should_get_focus.contains( const_cast< Client* >( c )))
{ // remove also all sooner elements that should have got FocusIn,
// but didn't for some reason (and also won't anymore, because they were sooner)
while( should_get_focus.first() != c )
void Workspace::gotFocusIn(const Client* c)
{
if (should_get_focus.contains(const_cast< Client* >(c))) {
// remove also all sooner elements that should have got FocusIn,
// but didn't for some reason (and also won't anymore, because they were sooner)
while (should_get_focus.first() != c)
should_get_focus.pop_front();
should_get_focus.pop_front(); // remove 'c'
}
}
}
void Workspace::setShouldGetFocus( Client* c )
{
should_get_focus.append( c );
void Workspace::setShouldGetFocus(Client* c)
{
should_get_focus.append(c);
updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active
}
}
// focus_in -> the window got FocusIn event
// ignore_desktop - call comes from _NET_ACTIVE_WINDOW message, don't refuse just because of window
// is on a different desktop
bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in, bool ignore_desktop )
{
bool Workspace::allowClientActivation(const Client* c, Time time, bool focus_in, bool ignore_desktop)
{
// options->focusStealingPreventionLevel :
// 0 - none - old KWin behaviour, new windows always get focus
// 1 - low - focus stealing prevention is applied normally, when unsure, activation is allowed
......@@ -541,150 +520,139 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
// 3 - high - new window gets focus only if it belongs to the active application,
// or when no window is currently active
// 4 - extreme - no window gets focus without user intervention
if( time == -1U )
if (time == -1U)
time = c->userTime();
int level = c->rules()->checkFSP( options->focusStealingPreventionLevel );
if( session_saving && level <= 2 ) // <= normal
{
int level = c->rules()->checkFSP(options->focusStealingPreventionLevel);
if (session_saving && level <= 2) { // <= normal
return true;
}
}
Client* ac = mostRecentlyActivatedClient();
if( focus_in )
{
if( should_get_focus.contains( const_cast< Client* >( c )))
if (focus_in) {
if (should_get_focus.contains(const_cast< Client* >(c)))
return true; // FocusIn was result of KWin's action
// Before getting FocusIn, the active Client already
// got FocusOut, and therefore got deactivated.
ac = last_active_client;
}
if( time == 0 ) // explicitly asked not to get focus
}
if (time == 0) // explicitly asked not to get focus
return false;
if( level == 0 ) // none
if (level == 0) // none
return true;
if( level == 4 ) // extreme
if (level == 4) // extreme
return false;
if( !ignore_desktop && !c->isOnCurrentDesktop())
if (!ignore_desktop && !c->isOnCurrentDesktop())
return false; // allow only with level == 0
if( c->ignoreFocusStealing())
if (c->ignoreFocusStealing())
return true;
if( ac == NULL || ac->isDesktop())
{
kDebug( 1212 ) << "Activation: No client active, allowing";
if (ac == NULL || ac->isDesktop()) {
kDebug(1212) << "Activation: No client active, allowing";
return true; // no active client -> always allow
}
}
// TODO window urgency -> return true?
if( Client::belongToSameApplication( c, ac, true ))
{
kDebug( 1212 ) << "Activation: Belongs to active application";
if (Client::belongToSameApplication(c, ac, true)) {
kDebug(1212) << "Activation: Belongs to active application";
return true;
}
if( level == 3 ) // high
}
if (level == 3) // high
return false;
if( time == -1U ) // no time known
{
kDebug( 1212 ) << "Activation: No timestamp at all";
if( level == 1 ) // low
if (time == -1U) { // no time known
kDebug(1212) << "Activation: No timestamp at all";
if (level == 1) // low
return true;
// no timestamp at all, don't activate - because there's also creation timestamp
// done on CreateNotify, this case should happen only in case application