예제 #1
0
void SessionManager::checkGUISessionShift()
{
    // this method doesn't do mutex locking - similar reasons to
    // sessionEntryAction(), see above for details

    Group* target;
    SessionGroup* parent = videoSessions;

    // just loop over video & available video for now
    for ( unsigned int i = 0; i < 2; i++ )
    {
        if ( parent == videoSessions )
        {
            target = availableVideoSessions;
        }
        else if ( parent == availableVideoSessions )
        {
            target = videoSessions;
        }

        std::vector<RectangleBase*> outsideList =
            parent->checkMemberIntersect();
        bool gotIntersect = false;

        for ( unsigned int i = 0; i < outsideList.size(); i++ )
        {
            SessionEntry* entry = dynamic_cast<SessionEntry*>( outsideList[i] );
            if ( entry == NULL )
            {
                gravUtil::logWarning( "SessionManager::checkGUISessionShift: "
                                      "invalid SessionGroup child?\n" );
            }
            else
            {
                // check intersect with projected destination, shift if so
                if ( entry->destIntersect( target ) )
                {
                    // we have to use the external method here to ensure that
                    // the side window GUI stays accurate - that will in turn
                    // call the shiftSession() method in this class
                    sessionTree->shiftSession( entry->getAddress(), false );
                    gotIntersect = true;
                }
            }
        }

        // rearrange when there was at least one object moved outside of the
        // group bounds but not in the target
        if ( outsideList.size() > 0 && !gotIntersect )
        {
            parent->rearrange();
        }

        parent = availableVideoSessions;
    }
}