Changeset 44836 in vbox
- Timestamp:
- Feb 26, 2013 5:25:09 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83976
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp
r44834 r44836 73 73 CMachine machine = m_pMachineLogic->session().GetMachine(); 74 74 QDesktopWidget *pDW = QApplication::desktop(); 75 for (int i = 0; i < m_cGuestScreens; ++i)75 for (int iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen) 76 76 { 77 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(i ));78 QString strTest = machine.GetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(iGuestScreen)); 79 79 bool fOk; 80 int cScreen = strTest.toInt(&fOk);80 int iHostScreen = strTest.toInt(&fOk); 81 81 /* Check if valid: */ 82 82 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? */ 85 85 { 86 86 /* If not, check the position of the guest window in normal mode. … … 88 88 * This even works with multi-screen. The user just have to move all the normal windows to the target screens 89 89 * 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): "")); 91 91 QRegExp posParser("(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+)"); 92 92 if (posParser.exactMatch(strTest1)) … … 96 96 QPoint p(posParser.cap(1).toInt(&fOk1), posParser.cap(2).toInt(&fOk2)); 97 97 /* Check to which screen the position belongs: */ 98 cScreen = pDW->screenNumber(p);98 iHostScreen = pDW->screenNumber(p); 99 99 if (!( fOk1 /* Valid data */ 100 100 && 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? */ 103 103 /* If not, simply pick the next one of the still available host screens: */ 104 cScreen = availableScreens.first();104 iHostScreen = availableScreens.first(); 105 105 } 106 106 else 107 107 /* If not, simply pick the next one of the still available host screens: */ 108 cScreen = availableScreens.first();108 iHostScreen = availableScreens.first(); 109 109 } 110 m_screenMap.insert(i , cScreen);110 m_screenMap.insert(iGuestScreen, iHostScreen); 111 111 /* Remove the just selected screen from the list of available: */ 112 availableScreens.removeOne( cScreen);112 availableScreens.removeOne(iHostScreen); 113 113 } 114 114 … … 159 159 /* Parse incoming information: */ 160 160 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); 163 163 164 164 /* Search for the virtual screen which is currently displayed on the 165 165 * requested host screen. When there is one found, we swap both. */ 166 166 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); 172 172 173 173 /* Check the memory requirements first: */ … … 176 176 if (m_pMachineLogic->uisession()->isGuestAdditionsActive()) 177 177 { 178 quint64 availBits = machine.GetVRAMSize() /* VRAM */ 179 * _1M /* MiB to bytes */ 180 * 8; /* to bits */ 178 quint64 availBits = machine.GetVRAMSize() * _1M * 8; 181 179 quint64 usedBits = memoryRequirements(tmpMap); 182 180 fSuccess = availBits >= usedBits; … … 199 197 updateMenuActions(true); 200 198 201 /* On success inform the observer .*/199 /* On success inform the observer: */ 202 200 if (fSuccess) 203 201 emit sigScreenLayoutChanged(); … … 233 231 if (m_cHostScreens > 1) 234 232 { 235 for (int i = 0; i < m_cGuestScreens; ++i)233 for (int iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen) 236 234 { 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)); 238 236 m_screenMenuList.last()->menuAction()->setData(true); 239 237 QActionGroup *pScreenGroup = new QActionGroup(m_screenMenuList.last()); … … 244 242 QAction *pAction = pScreenGroup->addAction(tr("Use Host Screen %1").arg(a + 1)); 245 243 pAction->setCheckable(true); 246 pAction->setData(RT_MAKE_U32(i , a));244 pAction->setData(RT_MAKE_U32(iGuestScreen, a)); 247 245 } 248 246 m_screenMenuList.last()->addActions(pScreenGroup->actions()); … … 273 271 /* Update view actions: */ 274 272 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); 278 276 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(); 281 279 /* Update screen actions: */ 282 280 for (int j = 0; j < screenActions.size(); ++j) … … 297 295 quint64 usedBits = 0; 298 296 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) 300 298 { 301 299 QRect screen; 302 300 if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless) 303 screen = QApplication::desktop()->availableGeometry(screenLayout.value(i , 0));301 screen = QApplication::desktop()->availableGeometry(screenLayout.value(iGuestScreen, 0)); 304 302 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); 307 305 usedBits += screen.width() * /* display width */ 308 306 screen.height() * /* display height */
Note:
See TracChangeset
for help on using the changeset viewer.