VirtualBox

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

FE/Qt: Multi-screen support: Rework multi-screen layout (part 8).

File:
1 edited

Legend:

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

    r44836 r44837  
    7575    for (int iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen)
    7676    {
    77         /* 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(iGuestScreen));
    79         bool fOk;
    80         int iHostScreen = strTest.toInt(&fOk);
    81         /* Check if valid: */
    82         if (!(   fOk /* Valid data */
    83               && iHostScreen >= 0 && iHostScreen < m_cHostScreens /* In the host screen bounds? */
    84               && m_screenMap.key(iHostScreen, -1) == -1)) /* Not taken already? */
    85         {
    86             /* If not, check the position of the guest window in normal mode.
     77        /* Initialize variables: */
     78        bool fValid = false;
     79        int iHostScreen = -1;
     80
     81        if (!fValid)
     82        {
     83            /* If the user ever selected a combination in the view menu, we have the following entry: */
     84            QString strTest = machine.GetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(iGuestScreen));
     85            bool fOk;
     86            /* Check is this value can be converted: */
     87            iHostScreen = strTest.toInt(&fOk);
     88            /* Revalidate: */
     89            fValid =    fOk /* Valid data */
     90                     && iHostScreen >= 0 && iHostScreen < m_cHostScreens /* In the host screen bounds? */
     91                     && m_screenMap.key(iHostScreen, -1) == -1; /* Not taken already? */
     92        }
     93
     94        if (!fValid)
     95        {
     96            /* Check the position of the guest window in normal mode.
    8797             * This makes sure that on first use the window opens on the same screen as the normal window was before.
    8898             * This even works with multi-screen. The user just have to move all the normal windows to the target screens
     
    97107                /* Check to which screen the position belongs: */
    98108                iHostScreen = pDW->screenNumber(p);
    99                 if (!(   fOk1 /* Valid data */
    100                       && fOk2 /* Valid data */
    101                       && iHostScreen >= 0 && iHostScreen < m_cHostScreens /* In the host screen bounds? */
    102                       && m_screenMap.key(iHostScreen, -1) == -1)) /* Not taken already? */
    103                     /* If not, simply pick the next one of the still available host screens: */
    104                     iHostScreen = availableScreens.first();
     109                /* Revalidate: */
     110                fValid =    fOk1 && fOk2 /* Valid data */
     111                         && iHostScreen >= 0 && iHostScreen < m_cHostScreens /* In the host screen bounds? */
     112                         && m_screenMap.key(iHostScreen, -1) == -1; /* Not taken already? */
    105113            }
    106             else
    107                 /* If not, simply pick the next one of the still available host screens: */
     114        }
     115
     116        if (!fValid)
     117        {
     118            /* If still not valid, pick the next one
     119             * if there is still available host screen: */
     120            if (!availableScreens.isEmpty())
     121            {
    108122                iHostScreen = availableScreens.first();
    109         }
    110         m_screenMap.insert(iGuestScreen, iHostScreen);
    111         /* Remove the just selected screen from the list of available: */
    112         availableScreens.removeOne(iHostScreen);
     123                fValid = true;
     124            }
     125        }
     126
     127        if (fValid)
     128        {
     129            /* Register host screen for the guest screen: */
     130            m_screenMap.insert(iGuestScreen, iHostScreen);
     131            /* Remove it from the list of available host screens: */
     132            availableScreens.removeOne(iHostScreen);
     133        }
    113134    }
    114135
     
    166187    QMap<int,int> tmpMap(m_screenMap);
    167188    int iCurrentGuestScreen = tmpMap.key(iRequestedHostScreen, -1);
    168     if (iCurrentGuestScreen != -1)
     189    if (iCurrentGuestScreen != -1 && tmpMap.contains(iRequestedGuestScreen))
    169190        tmpMap.insert(iCurrentGuestScreen, tmpMap.value(iRequestedGuestScreen));
    170     /* Set the new host screen: */
     191    else
     192        tmpMap.remove(iCurrentGuestScreen);
    171193    tmpMap.insert(iRequestedGuestScreen, iRequestedHostScreen);
    172194
     
    188210        }
    189211    }
    190     if (fSuccess)
    191     {
    192         /* Swap the temporary with the previous map. */
    193         m_screenMap = tmpMap;
    194     }
    195 
     212    /* Make sure memory requirements matched: */
     213    if (!fSuccess)
     214        return;
     215
     216    /* Swap the maps: */
     217    m_screenMap = tmpMap;
    196218    /* Update menu actions: */
    197219    updateMenuActions(true);
    198 
    199     /* On success inform the observer: */
    200     if (fSuccess)
    201         emit sigScreenLayoutChanged();
     220    /* Inform the observer: */
     221    emit sigScreenLayoutChanged();
    202222}
    203223
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