Exemple #1
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 #2
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;
    }
// register a new connection on consumer or provider of game
//     'SYSTEM_REGISTER CONSUMER [Game]' --> no answer
//     'SYSTEM_REGISTER PROVIDER [GameName MinPlayer MaxPlayer IAAvailable]' --> no answer
void ConnectionManager::registerConnection( ClientConnectionPtr connection,
                                            const std::string& message )
{
   // check if the connection already exist
   if ( connections.find( connection ) == connections.end() )
   {
      // register only if there is at least one game to consume/provide
      std::vector< std::string > messageParts;
      size_t size;
      if ( ( size = StringUtils::explode( message,
                                          ' ',
                                          messageParts ) ) > 1 )
      {
         // get the kind of the client
         if ( messageParts[ 0 ] == CONSUMER_PART )
         {
            for ( size_t i = 1;
                  i < size;
                  ++i )
            {
               // check if there is an already existing game by inserting it
               // either none exist and there is one created
               // or one already exist and we get the iterator
               ClientAggregat::iterator it = consumerByGame.insert( ClientAggregat::value_type( messageParts[ i ],
                                                                                                ClientList() ) ).first;
               it->second.insert( connection );
            }
         }
         else if ( messageParts[ 0 ] == PROVIDER_PART )
         {
            for ( size_t i = 1;
                  i < size;
                  i += 4 )
            {
               // check if there is an already existing game by checking the game description
               if ( gameDefinitions.find( messageParts[ i ] ) == gameDefinitions.end() )
               {
                  gameDefinitions.insert( GameDefinitionMap::value_type( messageParts[ i ],
                                                                         GameDefinition( messageParts[ i ],
                                                                                         atoi( messageParts[ i + 1 ].c_str() ),
                                                                                         atoi( messageParts[ i + 2 ].c_str() ),
                                                                                         atoi( messageParts[ i + 3 ].c_str() ) ) ) );
               }

               // inserting the connection whatever happens
               // either none exist and there is one created
               // or one already exist and we get the iterator
               ClientAggregat::iterator it = providerByGame.insert( ClientAggregat::value_type( messageParts[ i ],
                                                                                                ClientList() ) ).first;
               it->second.insert( connection );
            }
         }
         else
         {
            throw std::exception( std::string( "Not able to register correctly " + connection->getTechnicalId() + " name " + connection->getLogin() ).c_str() );
         }

         // register to the connections
         connections.insert( connection );
      }
   }
}