VirtualBox

Changeset 44833 in vbox


Ignore:
Timestamp:
Feb 26, 2013 4:41:59 PM (12 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

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

    r44832 r44833  
    2121#include <QApplication>
    2222#include <QDesktopWidget>
    23 #include <QMap>
    2423#include <QMenu>
    2524
     
    4140UIMultiScreenLayout::UIMultiScreenLayout(UIMachineLogic *pMachineLogic)
    4241    : m_pMachineLogic(pMachineLogic)
    43     , m_pScreenMap(new QMap<int, int>())
    4442    , m_pViewMenu(0)
    4543{
     
    5149UIMultiScreenLayout::~UIMultiScreenLayout()
    5250{
    53     /* Cleanup screen-map: */
    54     delete m_pScreenMap;
    5551    /* Cleanup view-menu: */
    5652    cleanupViewMenu();
     
    8581        if (!(   fOk /* Valid data */
    8682              && cScreen >= 0 && cScreen < m_cHostScreens /* In the host screen bounds? */
    87               && m_pScreenMap->key(cScreen, -1) == -1)) /* Not taken already? */
     83              && m_screenMap.key(cScreen, -1) == -1)) /* Not taken already? */
    8884        {
    8985            /* If not, check the position of the guest window in normal mode.
     
    105101                      && fOk2 /* Valid data */
    106102                      && cScreen >= 0 && cScreen < m_cHostScreens /* In the host screen bounds? */
    107                       && m_pScreenMap->key(cScreen, -1) == -1)) /* Not taken already? */
     103                      && m_screenMap.key(cScreen, -1) == -1)) /* Not taken already? */
    108104                    /* If not, simply pick the next one of the still available
    109105                     * host screens. */
     
    115111                cScreen = availableScreens.first();
    116112        }
    117         m_pScreenMap->insert(i, cScreen);
     113        m_screenMap.insert(i, cScreen);
    118114        /* Remove the just selected screen from the list of available screens. */
    119115        availableScreens.removeOne(cScreen);
     
    136132int UIMultiScreenLayout::hostScreenForGuestScreen(int iScreenId) const
    137133{
    138     return m_pScreenMap->value(iScreenId, 0);
     134    return m_screenMap.value(iScreenId, 0);
    139135}
    140136
    141137quint64 UIMultiScreenLayout::memoryRequirements() const
    142138{
    143     return memoryRequirements(m_pScreenMap);
     139    return memoryRequirements(m_screenMap);
    144140}
    145141
     
    153149     * is present. */
    154150    QDesktopWidget *pDW = QApplication::desktop();
    155     for (int i = 0; i < m_pScreenMap->size(); ++i)
    156     {
    157         int hostScreen = m_pScreenMap->value(i);
     151    for (int i = 0; i < m_screenMap.size(); ++i)
     152    {
     153        int hostScreen = m_screenMap.value(i);
    158154        if (pDW->availableGeometry(hostScreen) != pDW->screenGeometry(hostScreen))
    159155            return true;
     
    169165
    170166    CMachine machine = m_pMachineLogic->session().GetMachine();
    171     QMap<int,int> *pTmpMap = new QMap<int,int>(*m_pScreenMap);
     167    QMap<int,int> tmpMap(m_screenMap);
    172168    /* Search for the virtual screen which is currently displayed on the
    173169     * requested host screen. When there is one found, we swap both. */
    174     int r = pTmpMap->key(cHostScreen, -1);
     170    int r = tmpMap.key(cHostScreen, -1);
    175171    if (r != -1)
    176         pTmpMap->insert(r, pTmpMap->value(cGuestScreen));
     172        tmpMap.insert(r, tmpMap.value(cGuestScreen));
    177173    /* Set the new host screen */
    178     pTmpMap->insert(cGuestScreen, cHostScreen);
     174    tmpMap.insert(cGuestScreen, cHostScreen);
    179175
    180176    bool fSuccess = true;
     
    184180            * _1M /* MiB to bytes */
    185181            * 8; /* to bits */
    186         quint64 usedBits = memoryRequirements(pTmpMap);
     182        quint64 usedBits = memoryRequirements(tmpMap);
    187183
    188184        fSuccess = availBits >= usedBits;
     
    200196    {
    201197        /* Swap the temporary with the previous map. */
    202         delete m_pScreenMap;
    203         m_pScreenMap = pTmpMap;
     198        m_screenMap = tmpMap;
    204199    }
    205200
     
    281276    for (int i = 0; i < viewActions.size(); ++i)
    282277    {
    283         int iHostScreen = m_pScreenMap->value(i);
     278        int iHostScreen = m_screenMap.value(i);
    284279        if (fWithSave)
    285280            machine.SetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(i), QString::number(iHostScreen));
     
    296291}
    297292
    298 quint64 UIMultiScreenLayout::memoryRequirements(const QMap<int, int> *pScreenLayout) const
     293quint64 UIMultiScreenLayout::memoryRequirements(const QMap<int, int> &screenLayout) const
    299294{
    300295    ULONG width = 0;
     
    307302        QRect screen;
    308303        if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless)
    309             screen = QApplication::desktop()->availableGeometry(pScreenLayout->value(i, 0));
     304            screen = QApplication::desktop()->availableGeometry(screenLayout.value(i, 0));
    310305        else
    311             screen = QApplication::desktop()->screenGeometry(pScreenLayout->value(i, 0));
     306            screen = QApplication::desktop()->screenGeometry(screenLayout.value(i, 0));
    312307        display.GetScreenResolution(i, width, height, guestBpp);
    313308        usedBits += screen.width() * /* display width */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h

    r44832 r44833  
    2222/* Qt includes: */
    2323#include <QObject>
     24#include <QMap>
    2425
    2526/* Forward declarations: */
     
    2728class QMenu;
    2829class QAction;
    29 template <class Key, class T> class QMap;
    3030
    3131/* Multi-screen layout manager: */
     
    7575    /* Other helpers: */
    7676    void updateMenuActions(bool fWithSave);
    77     quint64 memoryRequirements(const QMap<int, int> *pScreenLayout) const;
     77    quint64 memoryRequirements(const QMap<int, int> &screenLayout) const;
    7878
    7979    /* Variables: */
     
    8181    int m_cGuestScreens;
    8282    int m_cHostScreens;
    83     QMap<int, int> *m_pScreenMap;
     83    QMap<int, int> m_screenMap;
    8484    QMenu *m_pViewMenu;
    8585    QList<QMenu*> m_screenMenuList;
Note: See TracChangeset for help on using the changeset viewer.

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