Changeset 27124 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 5, 2010 6:30:32 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r27081 r27124 26 26 /* Global includes */ 27 27 #include <QAbstractScrollArea> 28 #include <QEventLoop> 28 29 29 30 /* Local includes */ … … 281 282 }; 282 283 284 /* This maintenance class is a part of future roll-back mechanism. 285 * It allows to block main GUI thread until specific event received. 286 * Later it will become more abstract but now its just used to help 287 * fullscreen & seamless modes to restore normal guest size hint. */ 288 class UIMachineViewBlocker : public QEventLoop 289 { 290 Q_OBJECT; 291 292 public: 293 294 UIMachineViewBlocker(QObject *pWatchedObject) 295 : QEventLoop(0) 296 , m_iTimerId(0) 297 { 298 /* Install object event watcher: */ 299 pWatchedObject->installEventFilter(this); 300 301 /* Also start timer to unlock pool in case of 302 * required condition doesn't happens by some reason: */ 303 m_iTimerId = startTimer(3000); 304 } 305 306 virtual ~UIMachineViewBlocker() 307 { 308 /* Kill the timer: */ 309 killTimer(m_iTimerId); 310 } 311 312 protected: 313 314 bool eventFilter(QObject *pWatched, QEvent *pEvent) 315 { 316 switch (pEvent->type()) 317 { 318 case VBoxDefs::ResizeEventType: 319 { 320 /* Its a specific part related to fullscreen/seamless modes. 321 * Here we are waiting for guest resize event to be sure what 322 * non-normal modes successfully restored previous guest size hint. 323 * And we just unlocking the 'this' blocker afterwards: */ 324 exit(); 325 return false; 326 } 327 default: 328 break; 329 } 330 return QEventLoop::eventFilter(pWatched, pEvent); 331 } 332 333 void timerEvent(QTimerEvent *pEvent) 334 { 335 /* If that timer event occurs => it seems 336 * guest resize event doesn't comes in time, 337 * shame on it, but we just unlocking 'this': */ 338 QEventLoop::timerEvent(pEvent); 339 exit(); 340 } 341 342 int m_iTimerId; 343 }; 344 283 345 #endif // !___UIMachineViewNormal_h___ 284 346 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r26998 r27124 633 633 } 634 634 635 QSize UISession::guestSizeHint(ulong uScreenId) const 636 { 637 return (int)uScreenId < m_guestSizeHints.size() ? m_guestSizeHints[uScreenId] : QSize(); 638 } 639 635 640 bool UISession::setPause(bool fOn) 636 641 { … … 655 660 656 661 return ok; 662 } 663 664 void UISession::setGuestSizeHint(ulong uScreenId, QSize size) 665 { 666 if ((int)uScreenId < m_guestSizeHints.size()) 667 m_guestSizeHints[uScreenId] = size; 657 668 } 658 669 … … 923 934 } 924 935 925 926 936 /* Load extra-data settings: */ 927 937 { … … 945 955 pGuestAutoresizeSwitch->setChecked(strSettings != "off"); 946 956 pGuestAutoresizeSwitch->blockSignals(false); 957 } 958 959 /* Some initialization: */ 960 { 961 /* Initial guest size hints: */ 962 m_guestSizeHints.clear(); 963 for (ulong i = 0; i < machine.GetMonitorCount(); ++ i) 964 m_guestSizeHints << QSize(640, 480); 947 965 } 948 966 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r26996 r27124 80 80 UIActionsPool* actionsPool() const; 81 81 QMenuBar* newMenuBar(); 82 QSize guestSizeHint(ulong uScreenId) const; 82 83 83 84 bool isSaved() const { return machineState() == KMachineState_Saved; } … … 122 123 bool setPause(bool fOn); 123 124 void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; } 125 void setGuestSizeHint(ulong uScreenId, QSize size); 124 126 125 127 /* Keyboard setters: */ … … 191 193 HCURSOR m_alphaCursor; 192 194 #endif 195 QList<QSize> m_guestSizeHints; 193 196 194 197 /* Common flags: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r27101 r27124 80 80 UIMachineViewFullscreen::~UIMachineViewFullscreen() 81 81 { 82 /* Cleanup fullscreen: */ 83 cleanupFullscreen(); 84 82 85 /* Cleanup common things: */ 83 86 cleanupCommon(); … … 342 345 } 343 346 347 void UIMachineViewFullscreen::cleanupFullscreen() 348 { 349 /* Rollback fullscreen frame-buffer size to normal: */ 350 machineWindowWrapper()->machineWindow()->hide(); 351 UIMachineViewBlocker blocker(this); 352 sltPerformGuestResize(uisession()->guestSizeHint(screenId())); 353 blocker.exec(); 354 } 355 344 356 void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled) 345 357 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r27101 r27124 64 64 void prepareConnections(); 65 65 void prepareConsoleConnections(); 66 //void prepareFullscreen() {} 66 67 67 68 /* Cleanup routines: */ 69 void cleanupFullscreen(); 68 70 //void cleanupConsoleConnections() {} 69 71 //void cleanupConnections() {} -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r27093 r27124 80 80 UIMachineViewNormal::~UIMachineViewNormal() 81 81 { 82 /* Save machine view settings: */ 83 saveMachineViewSettings(); 84 82 85 /* Cleanup common things: */ 83 86 cleanupCommon(); … … 341 344 } 342 345 346 void UIMachineViewNormal::saveMachineViewSettings() 347 { 348 /* Store guest size hint: */ 349 uisession()->setGuestSizeHint(screenId(), QSize(frameBuffer()->width(), frameBuffer()->height())); 350 } 351 343 352 void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled) 344 353 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r27090 r27124 63 63 void prepareConnections(); 64 64 void prepareConsoleConnections(); 65 //void loadMachineViewSettings(); 65 66 66 67 /* Cleanup helpers: */ 68 void saveMachineViewSettings(); 67 69 //void cleanupConsoleConnections() {} 68 70 //void prepareConnections() {} -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r27101 r27124 94 94 } 95 95 96 void UIMachineViewSeamless::sltPerformGuestResize() 97 { 98 /* Get machine window: */ 99 QIMainDialog *pMachineWindow = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 100 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0; 101 102 /* Get the available size for the guest display. We assume here that 103 * centralWidget() contains only this machine view and gives it all available space: */ 104 QSize newSize(pMachineWindow ? pMachineWindow->centralWidget()->size() : QSize()); 105 AssertMsg(newSize.isValid(), ("Size should be valid!\n")); 106 107 /* Do not send the same hints as we already have: */ 108 if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height())) 109 return; 110 111 /* If we awaiting resize: */ 112 if (m_fShouldWeDoResize) 96 void UIMachineViewSeamless::sltPerformGuestResize(const QSize &toSize) 97 { 98 if (uisession()->isGuestSupportsGraphics()) 113 99 { 114 /* Remember the new size: */ 115 storeConsoleSize(newSize.width(), newSize.height()); 116 117 /* Send new size-hint to the guest: */ 118 session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId()); 100 /* Get machine window: */ 101 QIMainDialog *pMachineWindow = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 102 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0; 103 104 /* If this slot is invoked directly then use the passed size otherwise get 105 * the available size for the guest display. We assume here that centralWidget() 106 * contains this view only and gives it all available space: */ 107 QSize newSize(toSize.isValid() ? toSize : pMachineWindow ? pMachineWindow->centralWidget()->size() : QSize()); 108 AssertMsg(newSize.isValid(), ("Size should be valid!\n")); 109 110 /* Do not send the same hints as we already have: */ 111 if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height())) 112 return; 113 114 /* We only actually send the hint if either an explicit new size was given 115 * (e.g. if the request was triggered directly by a console resize event) or 116 * if no explicit size was specified but a resize is flagged as being needed 117 * (e.g. the autoresize was just enabled and the console was resized while it was disabled). */ 118 if (toSize.isValid() || m_fShouldWeDoResize) 119 { 120 /* Remember the new size: */ 121 storeConsoleSize(newSize.width(), newSize.height()); 122 123 /* Send new size-hint to the guest: */ 124 session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId()); 125 } 126 127 /* We had requested resize now, rejecting other accident requests: */ 128 m_fShouldWeDoResize = false; 119 129 } 120 121 /* We had requested resize now, rejecting other accident requests: */122 m_fShouldWeDoResize = false;123 130 } 124 131 … … 355 362 /* Reset seamless feature flag of the guest: */ 356 363 session().GetConsole().GetDisplay().SetSeamlessMode(false); 364 365 /* Rollback seamless frame-buffer size to normal: */ 366 machineWindowWrapper()->machineWindow()->hide(); 367 UIMachineViewBlocker blocker(this); 368 sltPerformGuestResize(uisession()->guestSizeHint(screenId())); 369 blocker.exec(); 357 370 } 358 371 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
r27101 r27124 45 45 46 46 /* Slot to perform guest resize: */ 47 void sltPerformGuestResize( );47 void sltPerformGuestResize(const QSize &aSize = QSize()); 48 48 49 49 /* Console callback handlers: */
Note:
See TracChangeset
for help on using the changeset viewer.