VirtualBox

Changeset 44836 in vbox


Ignore:
Timestamp:
Feb 26, 2013 5:25:09 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83976
Message:

FE/Qt: Multi-screen support: Cleanup multi-screen layout (part 7).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp

    r44834 r44836  
    7373    CMachine machine = m_pMachineLogic->session().GetMachine();
    7474    QDesktopWidget *pDW = QApplication::desktop();
    75     for (int i = 0; i < m_cGuestScreens; ++i)
     75    for (int iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen)
    7676    {
    7777        /* If the user ever selected a combination in the view menu, we have the following entry: */
    78         QString strTest = machine.GetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(i));
     78        QString strTest = machine.GetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(iGuestScreen));
    7979        bool fOk;
    80         int cScreen = strTest.toInt(&fOk);
     80        int iHostScreen = strTest.toInt(&fOk);
    8181        /* Check if valid: */
    8282        if (!(   fOk /* Valid data */
    83               && cScreen >= 0 && cScreen < m_cHostScreens /* In the host screen bounds? */
    84               && m_screenMap.key(cScreen, -1) == -1)) /* Not taken already? */
     83              && iHostScreen >= 0 && iHostScreen < m_cHostScreens /* In the host screen bounds? */
     84              && m_screenMap.key(iHostScreen, -1) == -1)) /* Not taken already? */
    8585        {
    8686            /* If not, check the position of the guest window in normal mode.
     
    8888             * This even works with multi-screen. The user just have to move all the normal windows to the target screens
    8989             * and they will magically open there in seamless/fullscreen also. */
    90             QString strTest1 = machine.GetExtraData(GUI_LastNormalWindowPosition + (i > 0 ? QString::number(i): ""));
     90            QString strTest1 = machine.GetExtraData(GUI_LastNormalWindowPosition + (iGuestScreen > 0 ? QString::number(iGuestScreen): ""));
    9191            QRegExp posParser("(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+)");
    9292            if (posParser.exactMatch(strTest1))
     
    9696                QPoint p(posParser.cap(1).toInt(&fOk1), posParser.cap(2).toInt(&fOk2));
    9797                /* Check to which screen the position belongs: */
    98                 cScreen = pDW->screenNumber(p);
     98                iHostScreen = pDW->screenNumber(p);
    9999                if (!(   fOk1 /* Valid data */
    100100                      && fOk2 /* Valid data */
    101                       && cScreen >= 0 && cScreen < m_cHostScreens /* In the host screen bounds? */
    102                       && m_screenMap.key(cScreen, -1) == -1)) /* Not taken already? */
     101                      && iHostScreen >= 0 && iHostScreen < m_cHostScreens /* In the host screen bounds? */
     102                      && m_screenMap.key(iHostScreen, -1) == -1)) /* Not taken already? */
    103103                    /* If not, simply pick the next one of the still available host screens: */
    104                     cScreen = availableScreens.first();
     104                    iHostScreen = availableScreens.first();
    105105            }
    106106            else
    107107                /* If not, simply pick the next one of the still available host screens: */
    108                 cScreen = availableScreens.first();
     108                iHostScreen = availableScreens.first();
    109109        }
    110         m_screenMap.insert(i, cScreen);
     110        m_screenMap.insert(iGuestScreen, iHostScreen);
    111111        /* Remove the just selected screen from the list of available: */
    112         availableScreens.removeOne(cScreen);
     112        availableScreens.removeOne(iHostScreen);
    113113    }
    114114
     
    159159    /* Parse incoming information: */
    160160    int a = pAction->data().toInt();
    161     int cGuestScreen = RT_LOWORD(a);
    162     int cHostScreen = RT_HIWORD(a);
     161    int iRequestedGuestScreen = RT_LOWORD(a);
     162    int iRequestedHostScreen = RT_HIWORD(a);
    163163
    164164    /* Search for the virtual screen which is currently displayed on the
    165165     * requested host screen. When there is one found, we swap both. */
    166166    QMap<int,int> tmpMap(m_screenMap);
    167     int r = tmpMap.key(cHostScreen, -1);
    168     if (r != -1)
    169         tmpMap.insert(r, tmpMap.value(cGuestScreen));
    170     /* Set the new host screen */
    171     tmpMap.insert(cGuestScreen, cHostScreen);
     167    int iCurrentGuestScreen = tmpMap.key(iRequestedHostScreen, -1);
     168    if (iCurrentGuestScreen != -1)
     169        tmpMap.insert(iCurrentGuestScreen, tmpMap.value(iRequestedGuestScreen));
     170    /* Set the new host screen: */
     171    tmpMap.insert(iRequestedGuestScreen, iRequestedHostScreen);
    172172
    173173    /* Check the memory requirements first: */
     
    176176    if (m_pMachineLogic->uisession()->isGuestAdditionsActive())
    177177    {
    178         quint64 availBits = machine.GetVRAMSize() /* VRAM */
    179             * _1M /* MiB to bytes */
    180             * 8; /* to bits */
     178        quint64 availBits = machine.GetVRAMSize() * _1M * 8;
    181179        quint64 usedBits = memoryRequirements(tmpMap);
    182180        fSuccess = availBits >= usedBits;
     
    199197    updateMenuActions(true);
    200198
    201     /* On success inform the observer. */
     199    /* On success inform the observer: */
    202200    if (fSuccess)
    203201        emit sigScreenLayoutChanged();
     
    233231    if (m_cHostScreens > 1)
    234232    {
    235         for (int i = 0; i < m_cGuestScreens; ++i)
     233        for (int iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen)
    236234        {
    237             m_screenMenuList << m_pViewMenu->addMenu(tr("Virtual Screen %1").arg(i + 1));
     235            m_screenMenuList << m_pViewMenu->addMenu(tr("Virtual Screen %1").arg(iGuestScreen + 1));
    238236            m_screenMenuList.last()->menuAction()->setData(true);
    239237            QActionGroup *pScreenGroup = new QActionGroup(m_screenMenuList.last());
     
    244242                QAction *pAction = pScreenGroup->addAction(tr("Use Host Screen %1").arg(a + 1));
    245243                pAction->setCheckable(true);
    246                 pAction->setData(RT_MAKE_U32(i, a));
     244                pAction->setData(RT_MAKE_U32(iGuestScreen, a));
    247245            }
    248246            m_screenMenuList.last()->addActions(pScreenGroup->actions());
     
    273271    /* Update view actions: */
    274272    CMachine machine = m_pMachineLogic->session().GetMachine();
    275     for (int i = 0; i < viewActions.size(); ++i)
    276     {
    277         int iHostScreen = m_screenMap.value(i);
     273    for (int iGuestScreen = 0; iGuestScreen < viewActions.size(); ++iGuestScreen)
     274    {
     275        int iHostScreen = m_screenMap.value(iGuestScreen);
    278276        if (fWithSave)
    279             machine.SetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(i), QString::number(iHostScreen));
    280         QList<QAction*> screenActions = viewActions.at(i)->menu()->actions();
     277            machine.SetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(iGuestScreen), QString::number(iHostScreen));
     278        QList<QAction*> screenActions = viewActions.at(iGuestScreen)->menu()->actions();
    281279        /* Update screen actions: */
    282280        for (int j = 0; j < screenActions.size(); ++j)
     
    297295    quint64 usedBits = 0;
    298296    CDisplay display = m_pMachineLogic->uisession()->session().GetConsole().GetDisplay();
    299     for (int i = 0; i < m_cGuestScreens; ++ i)
     297    for (int iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen)
    300298    {
    301299        QRect screen;
    302300        if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless)
    303             screen = QApplication::desktop()->availableGeometry(screenLayout.value(i, 0));
     301            screen = QApplication::desktop()->availableGeometry(screenLayout.value(iGuestScreen, 0));
    304302        else
    305             screen = QApplication::desktop()->screenGeometry(screenLayout.value(i, 0));
    306         display.GetScreenResolution(i, width, height, guestBpp);
     303            screen = QApplication::desktop()->screenGeometry(screenLayout.value(iGuestScreen, 0));
     304        display.GetScreenResolution(iGuestScreen, width, height, guestBpp);
    307305        usedBits += screen.width() * /* display width */
    308306                    screen.height() * /* display height */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette