Exemple #1
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;
    }
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;
}
Exemple #3
0
// deactivates 'c' and activates next client
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())))
        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,
              // first try to transfer focus to the first suitable window in the group
            Client* get_focus = NULL;
            const ClientList windows = ( c != NULL ? c->group()->members() : ClientList());
	    for ( int i = focus_chain[ currentDesktop() ].size() - 1;
                  i >= 0;
                  --i )
                {
                Client* ci = focus_chain[ currentDesktop() ].at( i );
                if( c == ci || !ci->isShown( false )
                    || !ci->isOnCurrentDesktop())
                    continue;
                if( options->separateScreenFocus )
                    {
                    if( c != NULL && !ci->isOnScreen( c->screen()))
                        continue;
                    if( c == NULL && !ci->isOnScreen( activeScreen()))
                        continue;
                    }
                if( windows.contains( ci ))
                    {
                    get_focus = ci;
                    break;
                    }
                if( get_focus == NULL )
                    get_focus = ci;
                }
            if( get_focus == NULL )
                get_focus = findDesktop( true, currentDesktop());
            if( get_focus != NULL )
                requestFocus( get_focus );
            else
                focusToNull();
            }
            else
                return false;
        }
    else
        // if blocking focus, move focus to the desktop later if needed
        // in order to avoid flickering
        focusToNull();
    return true;
    }
Exemple #4
0
// deactivates 'c' and activates next client
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())))
        return false;
    closeActivePopup();
    if( c != NULL )
        {
        if( c == active_client )
            {
            setActiveClient( NULL, Allowed );
            }
        should_get_focus.remove( c );
        }
    if( focusChangeEnabled())
        {
        if ( options->focusPolicyIsReasonable())
            { // search the focus_chain for a client to transfer focus to
              // if 'c' is transient, transfer focus to the first suitable mainwindow
            Client* get_focus = NULL;
            const ClientList mainwindows = ( c != NULL ? c->mainClients() : ClientList());
            for( ClientList::ConstIterator it = focus_chain[currentDesktop()].fromLast();
                 it != focus_chain[currentDesktop()].end();
                 --it )
                {
                if( !(*it)->isShown( false ) || !(*it)->isOnCurrentDesktop())
                    continue;
                if( options->separateScreenFocus )
                    {
                    if( c != NULL && !(*it)->isOnScreen( c->screen()))
                        continue;
                    if( c == NULL && !(*it)->isOnScreen( activeScreen()))
                        continue;
                    }
                if( mainwindows.contains( *it ))
                    {
                    get_focus = *it;
                    break;
                    }
                if( get_focus == NULL )
                    get_focus = *it;
                }
            if( get_focus == NULL )
                get_focus = findDesktop( true, currentDesktop());
            if( get_focus != NULL )
                {
                requestFocus( get_focus );
                }
            else
                focusToNull();
            }
            else
                return false;
        }
    else
        // if blocking focus, move focus to the desktop later if needed
        // in order to avoid flickering
        focusToNull();
    return true;
    }
// deactivates 'c' and activates next client
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())))
        return false;

    closeActivePopup();

    if (c != NULL) {
        if (c == active_client)
            setActiveClient(NULL, Allowed);
        should_get_focus.removeAll(c);
    }

    // if blocking focus, move focus to the desktop later if needed
    // in order to avoid flickering
    if (!focusChangeEnabled()) {
        focusToNull();
        return true;
    }

    if (!options->focusPolicyIsReasonable())
        return false;

    Client* get_focus = NULL;

    if (options->isNextFocusPrefersMouse()) {
        get_focus = clientUnderMouse(c ? c->screen() : activeScreen());
        if (get_focus && (get_focus == c || get_focus->isDesktop())) {
            // should rather not happen, but it cannot get the focus. rest of usability is tested above
            get_focus = 0;
        }
    }

    if (!get_focus) { // no suitable window under the mouse -> find sth. else

        // first try to pass the focus to the (former) active clients leader
        if (c  && (get_focus = c->transientFor()) && isUsableFocusCandidate(get_focus, c, options->isSeparateScreenFocus())) {
            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 from the inline assignment above
            for (int i = focus_chain[ currentDesktop()].size() - 1; i >= 0; --i) {
                Client* ci = focus_chain[ currentDesktop()].at(i);
                if (isUsableFocusCandidate(ci, c, options->isSeparateScreenFocus())) {
                    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)
        requestFocus(get_focus);
    else
        focusToNull();

    return true;

}