Esempio n. 1
0
// basically the same like allowClientActivation(), this time allowing
// a window to be fully raised upon its own request (XRaiseWindow),
// if refused, it will be raised only on top of windows belonging
// to the same application
bool Workspace::allowFullClientRaising( const Client* c, Time time )
    {
    int level = c->rules()->checkFSP( options->focusStealingPreventionLevel );
    if( session_saving && level <= 2 ) // <= normal
        {
        return true;
        }
    Client* ac = mostRecentlyActivatedClient();
    if( level == 0 ) // none
        return true;
    if( level == 4 ) // extreme
        return false;
    if( ac == NULL || ac->isDesktop())
        {
//        kdDebug( 1212 ) << "Raising: No client active, allowing" << endl;
        return true; // no active client -> always allow
        }
    if( c->ignoreFocusStealing())
        return true;
    // TODO window urgency  -> return true?
    if( Client::belongToSameApplication( c, ac, true ))
        {
//        kdDebug( 1212 ) << "Raising: Belongs to active application" << endl;
        return true;
        }
    if( level == 3 ) // high
        return false;
    Time user_time = ac->userTime();
//    kdDebug( 1212 ) << "Raising, compared:" << time << ":" << user_time
//        << ":" << ( timestampCompare( time, user_time ) >= 0 ) << endl;
    return timestampCompare( time, user_time ) >= 0; // time >= user_time
    }
Esempio n. 2
0
void Workspace::setCurrentScreen( int new_screen )
    {
    if (new_screen < 0 || new_screen > numScreens())
        return;
    if ( !options->focusPolicyIsReasonable())
        return;
    closeActivePopup();
    Client* get_focus = NULL;
    for( ClientList::ConstIterator it = focus_chain[currentDesktop()].fromLast();
         it != focus_chain[currentDesktop()].end();
         --it )
        {
        if( !(*it)->isShown( false ) || !(*it)->isOnCurrentDesktop())
            continue;
        if( !(*it)->screen() == new_screen )
            continue;
        get_focus = *it;
        break;
        }
    if( get_focus == NULL )
        get_focus = findDesktop( true, currentDesktop());
    if( get_focus != NULL && get_focus != mostRecentlyActivatedClient())
        requestFocus( get_focus );
    active_screen = new_screen;
    }
Esempio n. 3
0
void Workspace::setCurrentScreen(int new_screen)
{
    if (new_screen < 0 || new_screen >= numScreens())
        return;
    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())
            continue;
        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;
}
Esempio n. 4
0
// 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)
{
    // 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
    // 2 - normal  - focus stealing prevention is applied normally, when unsure, activation is not allowed,
    //              this is the default
    // 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)
        time = c->userTime();
    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)))
            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
        return false;
    if (level == 0)   // none
        return true;
    if (level == 4)   // extreme
        return false;
    if (!ignore_desktop && !c->isOnCurrentDesktop())
        return false; // allow only with level == 0
    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";
        return true;
    }
    if (level == 3)   // high
        return false;
    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
        // maps again already used window, i.e. this won't happen after app startup
        return false;
    }
    // level == 2 // normal
    Time user_time = ac->userTime();
    kDebug(1212) << "Activation, compared:" << c << ":" << time << ":" << user_time
                 << ":" << (timestampCompare(time, user_time) >= 0) << endl;
    return timestampCompare(time, user_time) >= 0;   // time >= user_time
}