Changeset 98386 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 1, 2023 1:16:52 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo
-
old new 19 19 /branches/dsen/gui2:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644 20 20 /branches/dsen/gui3:79645-79692 21 /branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285 21 /branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288 22 22 /trunk/src:92342,154921
-
- Property svn:mergeinfo
-
trunk/src/VBox
- Property svn:mergeinfo
-
old new 19 19 /branches/dsen/gui2/src/VBox:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644 20 20 /branches/dsen/gui3/src/VBox:79645-79692 21 /branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285 21 /branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288
-
- Property svn:mergeinfo
-
trunk/src/VBox/Frontends
- Property svn:mergeinfo
-
old new 16 16 /branches/dsen/gui2/src/VBox/Frontends:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644 17 17 /branches/dsen/gui3/src/VBox/Frontends:79645-79692 18 /branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285 18 /branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288
-
- Property svn:mergeinfo
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r98385 r98386 30 30 # include <QBitmap> 31 31 #endif 32 #ifdef VBOX_WS_MAC 33 # include <QTimer> 34 #endif 32 35 33 36 /* GUI includes: */ 34 37 #include "UICommon.h" 38 #include "UIDesktopWidgetWatchdog.h" 35 39 #include "UIExtraDataManager.h" 36 40 #include "UIIconPool.h" … … 41 45 #include "UIMachineWindow.h" 42 46 #include "UIMessageCenter.h" 47 #ifdef VBOX_WS_MAC 48 # include "UICocoaApplication.h" 49 # include "VBoxUtils-darwin.h" 50 #endif 43 51 44 52 /* COM includes: */ 53 #include "CConsole.h" 54 #include "CGraphicsAdapter.h" 45 55 #include "CMachine.h" 56 #include "CProgress.h" 46 57 #include "CSession.h" 47 #include "CConsole.h"48 58 #include "CSnapshot.h" 49 #include "CProgress.h" 59 60 61 #ifdef VBOX_WS_MAC 62 /** 63 * MacOS X: Application Services: Core Graphics: Display reconfiguration callback. 64 * 65 * Notifies UIMachine about @a display configuration change. 66 * Corresponding change described by Core Graphics @a flags. 67 * Uses UIMachine @a pHandler to process this change. 68 * 69 * @note Last argument (@a pHandler) must always be valid pointer to UIMachine object. 70 * @note Calls for UIMachine::sltHandleHostDisplayAboutToChange() slot if display configuration changed. 71 */ 72 void cgDisplayReconfigurationCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *pHandler) 73 { 74 /* Which flags we are handling? */ 75 int iHandledFlags = kCGDisplayAddFlag /* display added */ 76 | kCGDisplayRemoveFlag /* display removed */ 77 | kCGDisplaySetModeFlag /* display mode changed */; 78 79 /* Handle 'display-add' case: */ 80 if (flags & kCGDisplayAddFlag) 81 LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display added.\n")); 82 /* Handle 'display-remove' case: */ 83 else if (flags & kCGDisplayRemoveFlag) 84 LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display removed.\n")); 85 /* Handle 'mode-set' case: */ 86 else if (flags & kCGDisplaySetModeFlag) 87 LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display mode changed.\n")); 88 89 /* Ask handler to process our callback: */ 90 if (flags & iHandledFlags) 91 QTimer::singleShot(0, static_cast<UIMachine*>(pHandler), 92 SLOT(sltHandleHostDisplayAboutToChange())); 93 94 Q_UNUSED(display); 95 } 96 #endif /* VBOX_WS_MAC */ 50 97 51 98 … … 169 216 } 170 217 218 bool UIMachine::isScreenVisibleHostDesires(ulong uScreenId) const 219 { 220 /* Make sure index feats the bounds: */ 221 AssertReturn(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size(), false); 222 223 /* Return 'actual' (host-desire) visibility status: */ 224 return m_monitorVisibilityVectorHostDesires.value((int)uScreenId); 225 } 226 227 void UIMachine::setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible) 228 { 229 /* Make sure index feats the bounds: */ 230 AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size()); 231 232 /* Remember 'actual' (host-desire) visibility status: */ 233 m_monitorVisibilityVectorHostDesires[(int)uScreenId] = fIsMonitorVisible; 234 235 /* And remember the request in extra data for guests with VMSVGA: */ 236 /* This should be done before the actual hint is sent in case the guest overrides it. */ 237 gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid()); 238 } 239 240 bool UIMachine::isScreenVisible(ulong uScreenId) const 241 { 242 /* Make sure index feats the bounds: */ 243 AssertReturn(uScreenId < (ulong)m_monitorVisibilityVector.size(), false); 244 245 /* Return 'actual' visibility status: */ 246 return m_monitorVisibilityVector.value((int)uScreenId); 247 } 248 249 void UIMachine::setScreenVisible(ulong uScreenId, bool fIsMonitorVisible) 250 { 251 /* Make sure index feats the bounds: */ 252 AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVector.size()); 253 254 /* Remember 'actual' visibility status: */ 255 m_monitorVisibilityVector[(int)uScreenId] = fIsMonitorVisible; 256 /* Remember 'desired' visibility status: */ 257 // See note in UIMachineView::sltHandleNotifyChange() regarding the graphics controller check. */ 258 if (uisession()->machine().GetGraphicsAdapter().GetGraphicsControllerType() != KGraphicsControllerType_VMSVGA) 259 gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid()); 260 261 /* Make sure action-pool knows guest-screen visibility status: */ 262 uisession()->actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible); 263 } 264 265 int UIMachine::countOfVisibleWindows() 266 { 267 int cCountOfVisibleWindows = 0; 268 for (int i = 0; i < m_monitorVisibilityVector.size(); ++i) 269 if (m_monitorVisibilityVector[i]) 270 ++cCountOfVisibleWindows; 271 return cCountOfVisibleWindows; 272 } 273 274 QList<int> UIMachine::listOfVisibleWindows() const 275 { 276 QList<int> visibleWindows; 277 for (int i = 0; i < m_monitorVisibilityVector.size(); ++i) 278 if (m_monitorVisibilityVector.at(i)) 279 visibleWindows.push_back(i); 280 return visibleWindows; 281 } 282 283 QSize UIMachine::lastFullScreenSize(ulong uScreenId) const 284 { 285 /* Make sure index fits the bounds: */ 286 AssertReturn(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size(), QSize(-1, -1)); 287 288 /* Return last full-screen size: */ 289 return m_monitorLastFullScreenSizeVector.value((int)uScreenId); 290 } 291 292 void UIMachine::setLastFullScreenSize(ulong uScreenId, QSize size) 293 { 294 /* Make sure index fits the bounds: */ 295 AssertReturnVoid(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size()); 296 297 /* Remember last full-screen size: */ 298 m_monitorLastFullScreenSizeVector[(int)uScreenId] = size; 299 } 300 171 301 void UIMachine::closeRuntimeUI() 172 302 { … … 217 347 enterInitialVisualState(); 218 348 } 349 } 350 351 void UIMachine::sltHandleHostScreenCountChange() 352 { 353 LogRelFlow(("GUI: UIMachine: Host-screen count changed.\n")); 354 355 /* Recache display data: */ 356 updateHostScreenData(); 357 358 /* Notify current machine-logic: */ 359 emit sigHostScreenCountChange(); 360 } 361 362 void UIMachine::sltHandleHostScreenGeometryChange() 363 { 364 LogRelFlow(("GUI: UIMachine: Host-screen geometry changed.\n")); 365 366 /* Recache display data: */ 367 updateHostScreenData(); 368 369 /* Notify current machine-logic: */ 370 emit sigHostScreenGeometryChange(); 371 } 372 373 void UIMachine::sltHandleHostScreenAvailableAreaChange() 374 { 375 LogRelFlow(("GUI: UIMachine: Host-screen available-area changed.\n")); 376 377 /* Notify current machine-logic: */ 378 emit sigHostScreenAvailableAreaChange(); 379 } 380 381 #ifdef VBOX_WS_MAC 382 void UIMachine::sltHandleHostDisplayAboutToChange() 383 { 384 LogRelFlow(("GUI: UIMachine::sltHandleHostDisplayAboutToChange()\n")); 385 386 if (m_pWatchdogDisplayChange->isActive()) 387 m_pWatchdogDisplayChange->stop(); 388 m_pWatchdogDisplayChange->setProperty("tryNumber", 1); 389 m_pWatchdogDisplayChange->start(); 390 } 391 392 void UIMachine::sltCheckIfHostDisplayChanged() 393 { 394 LogRelFlow(("GUI: UIMachine::sltCheckIfHostDisplayChanged()\n")); 395 396 /* Check if display count changed: */ 397 if (UIDesktopWidgetWatchdog::screenCount() != m_hostScreens.size()) 398 { 399 /* Reset watchdog: */ 400 m_pWatchdogDisplayChange->setProperty("tryNumber", 0); 401 /* Notify listeners about screen-count changed: */ 402 return sltHandleHostScreenCountChange(); 403 } 404 else 405 { 406 /* Check if at least one display geometry changed: */ 407 for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex) 408 { 409 if (gpDesktop->screenGeometry(iScreenIndex) != m_hostScreens.at(iScreenIndex)) 410 { 411 /* Reset watchdog: */ 412 m_pWatchdogDisplayChange->setProperty("tryNumber", 0); 413 /* Notify listeners about screen-geometry changed: */ 414 return sltHandleHostScreenGeometryChange(); 415 } 416 } 417 } 418 419 /* Check if watchdog expired, restart if not: */ 420 int cTryNumber = m_pWatchdogDisplayChange->property("tryNumber").toInt(); 421 if (cTryNumber > 0 && cTryNumber < 40) 422 { 423 /* Restart watchdog again: */ 424 m_pWatchdogDisplayChange->setProperty("tryNumber", ++cTryNumber); 425 m_pWatchdogDisplayChange->start(); 426 } 427 else 428 { 429 /* Reset watchdog: */ 430 m_pWatchdogDisplayChange->setProperty("tryNumber", 0); 431 } 432 } 433 #endif /* VBOX_WS_MAC */ 434 435 void UIMachine::sltHandleGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo) 436 { 437 /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */ 438 if (changeType == KGuestMonitorChangedEventType_NewOrigin) 439 return; 440 /* Ignore KGuestMonitorChangedEventType_Disabled event for primary screen: */ 441 AssertMsg(countOfVisibleWindows() > 0, ("All machine windows are hidden!")); 442 if (changeType == KGuestMonitorChangedEventType_Disabled && uScreenId == 0) 443 return; 444 445 /* Process KGuestMonitorChangedEventType_Enabled change event: */ 446 if ( !isScreenVisible(uScreenId) 447 && changeType == KGuestMonitorChangedEventType_Enabled) 448 setScreenVisible(uScreenId, true); 449 /* Process KGuestMonitorChangedEventType_Disabled change event: */ 450 else if ( isScreenVisible(uScreenId) 451 && changeType == KGuestMonitorChangedEventType_Disabled) 452 setScreenVisible(uScreenId, false); 453 454 /* Notify listeners about the change: */ 455 emit sigGuestMonitorChange(changeType, uScreenId, screenGeo); 219 456 } 220 457 … … 344 581 , m_pMachineLogic(0) 345 582 , m_pMachineWindowIcon(0) 583 #ifdef VBOX_WS_MAC 584 , m_pWatchdogDisplayChange(0) 585 #endif 346 586 , m_fNumLock(false) 347 587 , m_fCapsLock(false) … … 385 625 /* Prepare stuff: */ 386 626 prepareSessionConnections(); 627 prepareScreens(); 387 628 prepareMachineWindowIcon(); 388 629 prepareMachineLogic(); … … 418 659 this, &UIMachine::sigDnDModeChange); 419 660 connect(uisession(), &UISession::sigGuestMonitorChange, 420 this, &UIMachine::s igGuestMonitorChange);661 this, &UIMachine::sltHandleGuestMonitorChange); 421 662 connect(uisession(), &UISession::sigMachineStateChange, 422 663 this, &UIMachine::sigMachineStateChange); … … 457 698 } 458 699 700 void UIMachine::prepareScreens() 701 { 702 /* Recache display data: */ 703 updateHostScreenData(); 704 705 #ifdef VBOX_WS_MAC 706 /* Prepare display-change watchdog: */ 707 m_pWatchdogDisplayChange = new QTimer(this); 708 { 709 m_pWatchdogDisplayChange->setInterval(500); 710 m_pWatchdogDisplayChange->setSingleShot(true); 711 connect(m_pWatchdogDisplayChange, &QTimer::timeout, 712 this, &UIMachine::sltCheckIfHostDisplayChanged); 713 } 714 #endif /* VBOX_WS_MAC */ 715 716 #ifdef VBOX_WS_MAC 717 /* Install native display reconfiguration callback: */ 718 CGDisplayRegisterReconfigurationCallback(cgDisplayReconfigurationCallback, this); 719 #else /* !VBOX_WS_MAC */ 720 /* Install Qt display reconfiguration callbacks: */ 721 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenCountChanged, 722 this, &UIMachine::sltHandleHostScreenCountChange); 723 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenResized, 724 this, &UIMachine::sltHandleHostScreenGeometryChange); 725 # if defined(VBOX_WS_X11) && !defined(VBOX_GUI_WITH_CUSTOMIZATIONS1) 726 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaRecalculated, 727 this, &UIMachine::sltHandleHostScreenAvailableAreaChange); 728 # else /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 729 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaResized, 730 this, &UIMachine::sltHandleHostScreenAvailableAreaChange); 731 # endif /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 732 #endif /* !VBOX_WS_MAC */ 733 734 /* Prepare initial screen visibility status: */ 735 m_monitorVisibilityVector.resize(uisession()->machine().GetGraphicsAdapter().GetMonitorCount()); 736 m_monitorVisibilityVector.fill(false); 737 m_monitorVisibilityVector[0] = true; 738 739 /* Prepare empty last full-screen size vector: */ 740 m_monitorLastFullScreenSizeVector.resize(uisession()->machine().GetGraphicsAdapter().GetMonitorCount()); 741 m_monitorLastFullScreenSizeVector.fill(QSize(-1, -1)); 742 743 /* If machine is in 'saved' state: */ 744 if (uisession()->isSaved()) 745 { 746 /* Update screen visibility status from saved-state: */ 747 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex) 748 { 749 BOOL fEnabled = true; 750 ULONG uGuestOriginX = 0, uGuestOriginY = 0, uGuestWidth = 0, uGuestHeight = 0; 751 uisession()->machine().QuerySavedGuestScreenInfo(iScreenIndex, 752 uGuestOriginX, uGuestOriginY, 753 uGuestWidth, uGuestHeight, fEnabled); 754 m_monitorVisibilityVector[iScreenIndex] = fEnabled; 755 } 756 /* And make sure at least one of them is visible (primary if others are hidden): */ 757 if (countOfVisibleWindows() < 1) 758 m_monitorVisibilityVector[0] = true; 759 } 760 else if (uiCommon().isSeparateProcess()) 761 { 762 /* Update screen visibility status from display directly: */ 763 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex) 764 { 765 KGuestMonitorStatus enmStatus = KGuestMonitorStatus_Disabled; 766 ULONG uGuestWidth = 0, uGuestHeight = 0, uBpp = 0; 767 LONG iGuestOriginX = 0, iGuestOriginY = 0; 768 uisession()->display().GetScreenResolution(iScreenIndex, 769 uGuestWidth, uGuestHeight, uBpp, 770 iGuestOriginX, iGuestOriginY, enmStatus); 771 m_monitorVisibilityVector[iScreenIndex] = ( enmStatus == KGuestMonitorStatus_Enabled 772 || enmStatus == KGuestMonitorStatus_Blank); 773 } 774 /* And make sure at least one of them is visible (primary if others are hidden): */ 775 if (countOfVisibleWindows() < 1) 776 m_monitorVisibilityVector[0] = true; 777 } 778 779 /* Prepare initial screen visibility status of host-desires (same as facts): */ 780 m_monitorVisibilityVectorHostDesires.resize(uisession()->machine().GetGraphicsAdapter().GetMonitorCount()); 781 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex) 782 m_monitorVisibilityVectorHostDesires[iScreenIndex] = m_monitorVisibilityVector[iScreenIndex]; 783 784 /* Make sure action-pool knows guest-screen visibility status: */ 785 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex) 786 uisession()->actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_monitorVisibilityVector.at(iScreenIndex)); 787 } 788 459 789 void UIMachine::prepareMachineWindowIcon() 460 790 { … … 535 865 } 536 866 867 void UIMachine::cleanupScreens() 868 { 869 #ifdef VBOX_WS_MAC 870 /* Remove display reconfiguration callback: */ 871 CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this); 872 #endif /* VBOX_WS_MAC */ 873 } 874 537 875 void UIMachine::cleanupSession() 538 876 { … … 550 888 cleanupMachineLogic(); 551 889 cleanupMachineWindowIcon(); 890 cleanupScreens(); 552 891 553 892 /* Cleanup session UI: */ … … 558 897 { 559 898 sltChangeVisualState(m_initialVisualState); 899 } 900 901 void UIMachine::updateHostScreenData() 902 { 903 /* Rebuild host-screen data vector: */ 904 m_hostScreens.clear(); 905 for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex) 906 m_hostScreens << gpDesktop->screenGeometry(iScreenIndex); 907 908 /* Make sure action-pool knows host-screen count: */ 909 uisession()->actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size()); 560 910 } 561 911 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r98385 r98386 51 51 class UISession; 52 52 class UIMachineLogic; 53 #ifdef VBOX_WS_MAC 54 class QTimer; 55 #endif 53 56 54 57 /** Singleton QObject extension … … 129 132 /** @} */ 130 133 134 /** @name Host-screen stuff. 135 ** @{ */ 136 /** Notifies about host-screen count change. */ 137 void sigHostScreenCountChange(); 138 /** Notifies about host-screen geometry change. */ 139 void sigHostScreenGeometryChange(); 140 /** Notifies about host-screen available-area change. */ 141 void sigHostScreenAvailableAreaChange(); 142 /** @} */ 143 131 144 public: 132 145 … … 167 180 QString machineWindowNamePostfix() const { return m_strMachineWindowNamePostfix; } 168 181 #endif 182 /** @} */ 183 184 /** @name Host-screen stuff. 185 ** @{ */ 186 /** Returns the list of host-screen geometries we currently have. */ 187 QList<QRect> hostScreens() const { return m_hostScreens; } 188 /** @} */ 189 190 /** @name Guest-screen stuff. 191 ** @{ */ 192 /** Returns whether guest-screen with @a uScreenId specified is expected to be visible. */ 193 bool isScreenVisibleHostDesires(ulong uScreenId) const; 194 /** Defines whether guest-screen with @a uScreenId specified is expected to be @a fVisible. */ 195 void setScreenVisibleHostDesires(ulong uScreenId, bool fVisible); 196 197 /** Returns whether guest-screen with @a uScreenId specified is actually visible. */ 198 bool isScreenVisible(ulong uScreenId) const; 199 /** Defines whether guest-screen with @a uScreenId specified is actually @a fVisible. */ 200 void setScreenVisible(ulong uScreenId, bool fIsMonitorVisible); 201 202 /** Returns a number of visible guest-windows. */ 203 int countOfVisibleWindows(); 204 /** Returns the list of visible guest-windows. */ 205 QList<int> listOfVisibleWindows() const; 206 207 /** Returns last full-screen size for guest-screen with index @a uScreenId. */ 208 QSize lastFullScreenSize(ulong uScreenId) const; 209 /** Defines last full-screen @a size for guest-screen with index @a uScreenId. */ 210 void setLastFullScreenSize(ulong uScreenId, QSize size); 169 211 /** @} */ 170 212 … … 257 299 /** Visual state-change handler. */ 258 300 void sltChangeVisualState(UIVisualStateType visualStateType); 301 302 /** @name Host-screen stuff. 303 * @{ */ 304 /** Handles host-screen count change. */ 305 void sltHandleHostScreenCountChange(); 306 /** Handles host-screen geometry change. */ 307 void sltHandleHostScreenGeometryChange(); 308 /** Handles host-screen available-area change. */ 309 void sltHandleHostScreenAvailableAreaChange(); 310 311 #ifdef VBOX_WS_MAC 312 /** MacOS X: Restarts display-reconfiguration watchdog timer from the beginning. 313 * @note Watchdog is trying to determine display reconfiguration in 314 * UISession::sltCheckIfHostDisplayChanged() slot every 500ms for 40 tries. */ 315 void sltHandleHostDisplayAboutToChange(); 316 /** MacOS X: Determines display reconfiguration. 317 * @note Calls for UISession::sltHandleHostScreenCountChange() if screen count changed. 318 * @note Calls for UISession::sltHandleHostScreenGeometryChange() if screen geometry changed. */ 319 void sltCheckIfHostDisplayChanged(); 320 #endif /* VBOX_WS_MAC */ 321 /** @} */ 322 323 /** @name Guest-screen stuff. 324 * @{ */ 325 /** Handles guest-monitor state change. */ 326 void sltHandleGuestMonitorChange(KGuestMonitorChangedEventType enmChangeType, ulong uScreenId, QRect screenGeo); 327 /** @} */ 259 328 260 329 /** @name Keyboard stuff. … … 301 370 /** Prepare routine: Session connection stuff. */ 302 371 void prepareSessionConnections(); 372 /** Prepare routine: Screens stuff. */ 373 void prepareScreens(); 303 374 /** Prepare routine: Machine-window icon. */ 304 375 void prepareMachineWindowIcon(); … … 313 384 /** Cleanup routine: Machine-window icon. */ 314 385 void cleanupMachineWindowIcon(); 386 /** Cleanup routine: Screens stuff. */ 387 void cleanupScreens(); 315 388 /** Cleanup routine: Session stuff. */ 316 389 void cleanupSession(); … … 320 393 /** Moves VM to initial state. */ 321 394 void enterInitialVisualState(); 395 396 /** @name Host-screen stuff. 397 * @{ */ 398 /** Update host-screen data. */ 399 void updateHostScreenData(); 400 /** @} */ 322 401 323 402 /** @name Mouse cursor stuff. … … 380 459 /** @} */ 381 460 461 /** @name Host-screen stuff. 462 * @{ */ 463 /** Holds the list of host-screen geometries we currently have. */ 464 QList<QRect> m_hostScreens; 465 466 #ifdef VBOX_WS_MAC 467 /** Mac OS X: Watchdog timer looking for display reconfiguration. */ 468 QTimer *m_pWatchdogDisplayChange; 469 #endif 470 /** @} */ 471 472 /** @name Guest-screen stuff. 473 * @{ */ 474 /** Holds the list of desired guest-screen visibility flags. */ 475 QVector<bool> m_monitorVisibilityVectorHostDesires; 476 /** Holds the list of actual guest-screen visibility flags. */ 477 QVector<bool> m_monitorVisibilityVector; 478 479 /** Holds the list of guest-screen full-screen sizes. */ 480 QVector<QSize> m_monitorLastFullScreenSizeVector; 481 /** @} */ 482 382 483 /** @name Keyboard stuff. 383 484 ** @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r98385 r98386 898 898 899 899 /* We should watch for host-screen-change events: */ 900 connect(ui session(), &UISession::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange);901 connect(ui session(), &UISession::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange);902 connect(ui session(), &UISession::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange);900 connect(uimachine(), &UIMachine::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange); 901 connect(uimachine(), &UIMachine::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange); 902 connect(uimachine(), &UIMachine::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange); 903 903 904 904 /* We should notify about frame-buffer events: */ … … 1210 1210 1211 1211 /* If we have more than one visible window: */ 1212 const QList<int> visibleWindowsList = ui session()->listOfVisibleWindows();1212 const QList<int> visibleWindowsList = uimachine()->listOfVisibleWindows(); 1213 1213 const int cVisibleGuestScreens = visibleWindowsList.size(); 1214 1214 if (cVisibleGuestScreens > 1) … … 1322 1322 } 1323 1323 } 1324 const QList<int> visibleWindowsList = ui session()->listOfVisibleWindows();1324 const QList<int> visibleWindowsList = uimachine()->listOfVisibleWindows(); 1325 1325 const int cVisibleGuestScreens = visibleWindowsList.size(); 1326 1326 if (cVisibleGuestScreens > 1) … … 1448 1448 1449 1449 /* We should stop watching for host-screen-change events: */ 1450 disconnect(ui session(), &UISession::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange);1451 disconnect(ui session(), &UISession::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange);1452 disconnect(ui session(), &UISession::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange);1450 disconnect(uimachine(), &UIMachine::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange); 1451 disconnect(uimachine(), &UIMachine::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange); 1452 disconnect(uimachine(), &UIMachine::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange); 1453 1453 1454 1454 /* We should stop notify about frame-buffer events: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r98385 r98386 630 630 631 631 /* Forget the last full-screen size: */ 632 ui session()->setLastFullScreenSize(screenId(), QSize(-1, -1));632 uimachine()->setLastFullScreenSize(screenId(), QSize(-1, -1)); 633 633 } 634 634 /* For other than 'scale' mode: */ … … 641 641 m_sizeHintOverride = QSize(-1, -1); 642 642 if (visualStateType() == UIVisualStateType_Normal) 643 ui session()->setLastFullScreenSize(screenId(), QSize(-1, -1));643 uimachine()->setLastFullScreenSize(screenId(), QSize(-1, -1)); 644 644 645 645 /* Force machine-window update own layout: */ … … 782 782 && ( (int)frameBuffer()->width() != size.width() 783 783 || (int)frameBuffer()->height() != size.height() 784 || ui session()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))784 || uimachine()->isScreenVisible(screenId()) != uimachine()->isScreenVisibleHostDesires(screenId()))) 785 785 setStoredGuestScreenSizeHint(size); 786 786 … … 789 789 { 790 790 /* If host and guest have same opinion about guest-screen visibility: */ 791 if (ui session()->isScreenVisible(screenId()) == uisession()->isScreenVisibleHostDesires(screenId()))791 if (uimachine()->isScreenVisible(screenId()) == uimachine()->isScreenVisibleHostDesires(screenId())) 792 792 { 793 793 /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */ … … 797 797 (int)screenId(), size.width(), size.height())); 798 798 display().SetVideoModeHint(screenId(), 799 ui session()->isScreenVisible(screenId()),799 uimachine()->isScreenVisible(screenId()), 800 800 false /* change origin? */, 801 801 0 /* origin x */, … … 810 810 { 811 811 /* If host desires to have guest-screen enabled and guest-screen is disabled, retrying: */ 812 if (ui session()->isScreenVisibleHostDesires(screenId()))812 if (uimachine()->isScreenVisibleHostDesires(screenId())) 813 813 { 814 814 /* Send enabling size-hint to the guest: */ … … 865 865 (int)screenId(), size.width(), size.height())); 866 866 display().SetVideoModeHint(screenId(), 867 ui session()->isScreenVisible(screenId()),867 uimachine()->isScreenVisible(screenId()), 868 868 false /* change origin? */, 869 869 0 /* origin x */, … … 896 896 897 897 /* Update desirable screen status: */ 898 ui session()->setScreenVisibleHostDesires(screenId(), fEnabled);898 uimachine()->setScreenVisibleHostDesires(screenId(), fEnabled); 899 899 900 900 /* Send enabling size-hint: */ … … 917 917 && ( frameBuffer()->width() != uWidth 918 918 || frameBuffer()->height() != uHeight 919 || ui session()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))919 || uimachine()->isScreenVisible(screenId()) != uimachine()->isScreenVisibleHostDesires(screenId()))) 920 920 setStoredGuestScreenSizeHint(QSize(uWidth, uHeight)); 921 921 … … 968 968 && ( (int)frameBuffer()->width() != size.width() 969 969 || (int)frameBuffer()->height() != size.height() 970 || ui session()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))970 || uimachine()->isScreenVisible(screenId()) != uimachine()->isScreenVisibleHostDesires(screenId()))) 971 971 setStoredGuestScreenSizeHint(size); 972 972 … … 1479 1479 frameBufferSize = scaledForward(frameBufferSize); 1480 1480 /* Check against the last full-screen size. */ 1481 if (frameBufferSize == ui session()->lastFullScreenSize(screenId()) && m_sizeHintOverride.isValid())1481 if (frameBufferSize == uimachine()->lastFullScreenSize(screenId()) && m_sizeHintOverride.isValid()) 1482 1482 return m_sizeHintOverride; 1483 1483 … … 1562 1562 1563 1563 /* If machine-window is visible: */ 1564 if (ui session()->isScreenVisible(m_uScreenId))1564 if (uimachine()->isScreenVisible(m_uScreenId)) 1565 1565 { 1566 1566 /* For 'scale' mode: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp
r98103 r98386 37 37 #include "UIFrameBuffer.h" 38 38 #include "UISession.h" 39 #include "UIMachine.h" 39 40 #include "UIMessageCenter.h" 40 41 #include "UIExtraDataManager.h" … … 139 140 /* Then we have to disable excessive guest-screen: */ 140 141 LogRel(("GUI: UIMultiScreenLayout::update: Disabling excessive guest-screen %d\n", iGuestScreen)); 141 m_pMachineLogic->ui session()->setScreenVisibleHostDesires(iGuestScreen, false);142 m_pMachineLogic->uimachine()->setScreenVisibleHostDesires(iGuestScreen, false); 142 143 m_pMachineLogic->display().SetVideoModeHint(iGuestScreen, false, false, 0, 0, 0, 0, 0, true); 143 144 } … … 172 173 LogRel(("GUI: UIMultiScreenLayout::update: Enabling guest-screen %d with following resolution: %dx%d\n", 173 174 iGuestScreen, uWidth, uHeight)); 174 m_pMachineLogic->ui session()->setScreenVisibleHostDesires(iGuestScreen, true);175 m_pMachineLogic->uimachine()->setScreenVisibleHostDesires(iGuestScreen, true); 175 176 m_pMachineLogic->display().SetVideoModeHint(iGuestScreen, true, false, 0, 0, uWidth, uHeight, 32, true); 176 177 } … … 277 278 m_disabledGuestScreens.clear(); 278 279 for (uint iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen) 279 if (m_pMachineLogic->ui session()->isScreenVisible(iGuestScreen))280 if (m_pMachineLogic->uimachine()->isScreenVisible(iGuestScreen)) 280 281 m_guestScreens << iGuestScreen; 281 282 else -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98385 r98386 30 30 #include <QMenuBar> 31 31 #include <QWidget> 32 #ifdef VBOX_WS_MAC33 # include <QTimer>34 #endif35 32 #ifdef VBOX_WS_WIN 36 33 # include <iprt/win/windows.h> /* Workaround for compile errors if included directly by QtWin. */ … … 40 37 /* GUI includes: */ 41 38 #include "UICommon.h" 42 #include "UIDesktopWidgetWatchdog.h"43 39 #include "UIExtraDataManager.h" 44 40 #include "UISession.h" … … 55 51 #include "UIFrameBuffer.h" 56 52 #include "UISettingsDialogSpecific.h" 57 #ifdef VBOX_WS_MAC58 # include "UICocoaApplication.h"59 # include "VBoxUtils-darwin.h"60 #endif61 53 #ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER 62 54 # include "UIKeyboardHandler.h" … … 94 86 #endif 95 87 96 #ifdef VBOX_WS_MAC97 /**98 * MacOS X: Application Services: Core Graphics: Display reconfiguration callback.99 *100 * Notifies UISession about @a display configuration change.101 * Corresponding change described by Core Graphics @a flags.102 * Uses UISession @a pHandler to process this change.103 *104 * @note Last argument (@a pHandler) must always be valid pointer to UISession object.105 * @note Calls for UISession::sltHandleHostDisplayAboutToChange() slot if display configuration changed.106 */107 void cgDisplayReconfigurationCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *pHandler)108 {109 /* Which flags we are handling? */110 int iHandledFlags = kCGDisplayAddFlag /* display added */111 | kCGDisplayRemoveFlag /* display removed */112 | kCGDisplaySetModeFlag /* display mode changed */;113 114 /* Handle 'display-add' case: */115 if (flags & kCGDisplayAddFlag)116 LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display added.\n"));117 /* Handle 'display-remove' case: */118 else if (flags & kCGDisplayRemoveFlag)119 LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display removed.\n"));120 /* Handle 'mode-set' case: */121 else if (flags & kCGDisplaySetModeFlag)122 LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display mode changed.\n"));123 124 /* Ask handler to process our callback: */125 if (flags & iHandledFlags)126 QTimer::singleShot(0, static_cast<UISession*>(pHandler),127 SLOT(sltHandleHostDisplayAboutToChange()));128 129 Q_UNUSED(display);130 }131 #endif /* VBOX_WS_MAC */132 133 88 /* static */ 134 89 bool UISession::create(UISession *&pSession, UIMachine *pMachine) … … 561 516 } 562 517 563 void UISession::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)564 {565 /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */566 if (changeType == KGuestMonitorChangedEventType_NewOrigin)567 return;568 /* Ignore KGuestMonitorChangedEventType_Disabled event for primary screen: */569 AssertMsg(countOfVisibleWindows() > 0, ("All machine windows are hidden!"));570 if (changeType == KGuestMonitorChangedEventType_Disabled && uScreenId == 0)571 return;572 573 /* Process KGuestMonitorChangedEventType_Enabled change event: */574 if ( !isScreenVisible(uScreenId)575 && changeType == KGuestMonitorChangedEventType_Enabled)576 setScreenVisible(uScreenId, true);577 /* Process KGuestMonitorChangedEventType_Disabled change event: */578 else if ( isScreenVisible(uScreenId)579 && changeType == KGuestMonitorChangedEventType_Disabled)580 setScreenVisible(uScreenId, false);581 582 /* Notify listeners about the change: */583 emit sigGuestMonitorChange(changeType, uScreenId, screenGeo);584 }585 586 518 void UISession::sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent) 587 519 { … … 612 544 emit sigAudioAdapterChange(); 613 545 614 }615 616 #ifdef RT_OS_DARWIN617 /**618 * MacOS X: Restarts display-reconfiguration watchdog timer from the beginning.619 * @note Watchdog is trying to determine display reconfiguration in620 * UISession::sltCheckIfHostDisplayChanged() slot every 500ms for 40 tries.621 */622 void UISession::sltHandleHostDisplayAboutToChange()623 {624 LogRelFlow(("GUI: UISession::sltHandleHostDisplayAboutToChange()\n"));625 626 if (m_pWatchdogDisplayChange->isActive())627 m_pWatchdogDisplayChange->stop();628 m_pWatchdogDisplayChange->setProperty("tryNumber", 1);629 m_pWatchdogDisplayChange->start();630 }631 632 /**633 * MacOS X: Determines display reconfiguration.634 * @note Calls for UISession::sltHandleHostScreenCountChange() if screen count changed.635 * @note Calls for UISession::sltHandleHostScreenGeometryChange() if screen geometry changed.636 */637 void UISession::sltCheckIfHostDisplayChanged()638 {639 LogRelFlow(("GUI: UISession::sltCheckIfHostDisplayChanged()\n"));640 641 /* Check if display count changed: */642 if (UIDesktopWidgetWatchdog::screenCount() != m_hostScreens.size())643 {644 /* Reset watchdog: */645 m_pWatchdogDisplayChange->setProperty("tryNumber", 0);646 /* Notify listeners about screen-count changed: */647 return sltHandleHostScreenCountChange();648 }649 else650 {651 /* Check if at least one display geometry changed: */652 for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)653 {654 if (gpDesktop->screenGeometry(iScreenIndex) != m_hostScreens.at(iScreenIndex))655 {656 /* Reset watchdog: */657 m_pWatchdogDisplayChange->setProperty("tryNumber", 0);658 /* Notify listeners about screen-geometry changed: */659 return sltHandleHostScreenGeometryChange();660 }661 }662 }663 664 /* Check if watchdog expired, restart if not: */665 int cTryNumber = m_pWatchdogDisplayChange->property("tryNumber").toInt();666 if (cTryNumber > 0 && cTryNumber < 40)667 {668 /* Restart watchdog again: */669 m_pWatchdogDisplayChange->setProperty("tryNumber", ++cTryNumber);670 m_pWatchdogDisplayChange->start();671 }672 else673 {674 /* Reset watchdog: */675 m_pWatchdogDisplayChange->setProperty("tryNumber", 0);676 }677 }678 #endif /* RT_OS_DARWIN */679 680 void UISession::sltHandleHostScreenCountChange()681 {682 LogRelFlow(("GUI: UISession: Host-screen count changed.\n"));683 684 /* Recache display data: */685 updateHostScreenData();686 687 /* Notify current machine-logic: */688 emit sigHostScreenCountChange();689 }690 691 void UISession::sltHandleHostScreenGeometryChange()692 {693 LogRelFlow(("GUI: UISession: Host-screen geometry changed.\n"));694 695 /* Recache display data: */696 updateHostScreenData();697 698 /* Notify current machine-logic: */699 emit sigHostScreenGeometryChange();700 }701 702 void UISession::sltHandleHostScreenAvailableAreaChange()703 {704 LogRelFlow(("GUI: UISession: Host-screen available-area changed.\n"));705 706 /* Notify current machine-logic: */707 emit sigHostScreenAvailableAreaChange();708 546 } 709 547 … … 795 633 , m_machineStatePrevious(KMachineState_Null) 796 634 , m_machineState(KMachineState_Null) 797 #ifdef VBOX_WS_MAC798 , m_pWatchdogDisplayChange(0)799 #endif /* VBOX_WS_MAC */800 635 , m_defaultCloseAction(MachineCloseAction_Invalid) 801 636 , m_restrictedCloseActions(MachineCloseAction_Invalid) … … 835 670 prepareActions(); 836 671 prepareConnections(); 837 prepareScreens();838 672 prepareSignalHandling(); 839 673 … … 922 756 this, &UISession::sigDnDModeChange); 923 757 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigGuestMonitorChange, 924 this, &UISession::s ltGuestMonitorChange);758 this, &UISession::sigGuestMonitorChange); 925 759 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMediumChange, 926 760 this, &UISession::sigMediumChange); … … 1001 835 /* UICommon connections: */ 1002 836 connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UISession::sltDetachCOM); 1003 1004 #ifdef VBOX_WS_MAC1005 /* Install native display reconfiguration callback: */1006 CGDisplayRegisterReconfigurationCallback(cgDisplayReconfigurationCallback, this);1007 #else /* !VBOX_WS_MAC */1008 /* Install Qt display reconfiguration callbacks: */1009 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenCountChanged,1010 this, &UISession::sltHandleHostScreenCountChange);1011 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenResized,1012 this, &UISession::sltHandleHostScreenGeometryChange);1013 # if defined(VBOX_WS_X11) && !defined(VBOX_GUI_WITH_CUSTOMIZATIONS1)1014 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaRecalculated,1015 this, &UISession::sltHandleHostScreenAvailableAreaChange);1016 # else /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */1017 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaResized,1018 this, &UISession::sltHandleHostScreenAvailableAreaChange);1019 # endif /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */1020 #endif /* !VBOX_WS_MAC */1021 }1022 1023 void UISession::prepareScreens()1024 {1025 /* Recache display data: */1026 updateHostScreenData();1027 1028 #ifdef VBOX_WS_MAC1029 /* Prepare display-change watchdog: */1030 m_pWatchdogDisplayChange = new QTimer(this);1031 {1032 m_pWatchdogDisplayChange->setInterval(500);1033 m_pWatchdogDisplayChange->setSingleShot(true);1034 connect(m_pWatchdogDisplayChange, &QTimer::timeout,1035 this, &UISession::sltCheckIfHostDisplayChanged);1036 }1037 #endif /* VBOX_WS_MAC */1038 1039 /* Prepare initial screen visibility status: */1040 m_monitorVisibilityVector.resize(machine().GetGraphicsAdapter().GetMonitorCount());1041 m_monitorVisibilityVector.fill(false);1042 m_monitorVisibilityVector[0] = true;1043 1044 /* Prepare empty last full-screen size vector: */1045 m_monitorLastFullScreenSizeVector.resize(machine().GetGraphicsAdapter().GetMonitorCount());1046 m_monitorLastFullScreenSizeVector.fill(QSize(-1, -1));1047 1048 /* If machine is in 'saved' state: */1049 if (isSaved())1050 {1051 /* Update screen visibility status from saved-state: */1052 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)1053 {1054 BOOL fEnabled = true;1055 ULONG uGuestOriginX = 0, uGuestOriginY = 0, uGuestWidth = 0, uGuestHeight = 0;1056 machine().QuerySavedGuestScreenInfo(iScreenIndex,1057 uGuestOriginX, uGuestOriginY,1058 uGuestWidth, uGuestHeight, fEnabled);1059 m_monitorVisibilityVector[iScreenIndex] = fEnabled;1060 }1061 /* And make sure at least one of them is visible (primary if others are hidden): */1062 if (countOfVisibleWindows() < 1)1063 m_monitorVisibilityVector[0] = true;1064 }1065 else if (uiCommon().isSeparateProcess())1066 {1067 /* Update screen visibility status from display directly: */1068 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)1069 {1070 KGuestMonitorStatus enmStatus = KGuestMonitorStatus_Disabled;1071 ULONG uGuestWidth = 0, uGuestHeight = 0, uBpp = 0;1072 LONG iGuestOriginX = 0, iGuestOriginY = 0;1073 display().GetScreenResolution(iScreenIndex,1074 uGuestWidth, uGuestHeight, uBpp,1075 iGuestOriginX, iGuestOriginY, enmStatus);1076 m_monitorVisibilityVector[iScreenIndex] = ( enmStatus == KGuestMonitorStatus_Enabled1077 || enmStatus == KGuestMonitorStatus_Blank);1078 }1079 /* And make sure at least one of them is visible (primary if others are hidden): */1080 if (countOfVisibleWindows() < 1)1081 m_monitorVisibilityVector[0] = true;1082 }1083 1084 /* Prepare initial screen visibility status of host-desires (same as facts): */1085 m_monitorVisibilityVectorHostDesires.resize(machine().GetGraphicsAdapter().GetMonitorCount());1086 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)1087 m_monitorVisibilityVectorHostDesires[iScreenIndex] = m_monitorVisibilityVector[iScreenIndex];1088 1089 /* Make sure action-pool knows guest-screen visibility status: */1090 for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)1091 actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_monitorVisibilityVector.at(iScreenIndex));1092 837 } 1093 838 … … 1174 919 } 1175 920 1176 void UISession::cleanupConnections()1177 {1178 #ifdef VBOX_WS_MAC1179 /* Remove display reconfiguration callback: */1180 CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this);1181 #endif /* VBOX_WS_MAC */1182 }1183 1184 921 void UISession::cleanupActions() 1185 922 { … … 1273 1010 //cleanupSignalHandling(); 1274 1011 //cleanupScreens(); 1275 cleanupConnections();1012 //cleanupConnections(); 1276 1013 cleanupActions(); 1277 1014 } … … 1482 1219 } 1483 1220 1484 bool UISession::isScreenVisibleHostDesires(ulong uScreenId) const1485 {1486 /* Make sure index feats the bounds: */1487 AssertReturn(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size(), false);1488 1489 /* Return 'actual' (host-desire) visibility status: */1490 return m_monitorVisibilityVectorHostDesires.value((int)uScreenId);1491 }1492 1493 void UISession::setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible)1494 {1495 /* Make sure index feats the bounds: */1496 AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size());1497 1498 /* Remember 'actual' (host-desire) visibility status: */1499 m_monitorVisibilityVectorHostDesires[(int)uScreenId] = fIsMonitorVisible;1500 1501 /* And remember the request in extra data for guests with VMSVGA: */1502 /* This should be done before the actual hint is sent in case the guest overrides it. */1503 gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());1504 }1505 1506 bool UISession::isScreenVisible(ulong uScreenId) const1507 {1508 /* Make sure index feats the bounds: */1509 AssertReturn(uScreenId < (ulong)m_monitorVisibilityVector.size(), false);1510 1511 /* Return 'actual' visibility status: */1512 return m_monitorVisibilityVector.value((int)uScreenId);1513 }1514 1515 void UISession::setScreenVisible(ulong uScreenId, bool fIsMonitorVisible)1516 {1517 /* Make sure index feats the bounds: */1518 AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVector.size());1519 1520 /* Remember 'actual' visibility status: */1521 m_monitorVisibilityVector[(int)uScreenId] = fIsMonitorVisible;1522 /* Remember 'desired' visibility status: */1523 /* See note in UIMachineView::sltHandleNotifyChange() regarding the graphics controller check. */1524 if (machine().GetGraphicsAdapter().GetGraphicsControllerType() != KGraphicsControllerType_VMSVGA)1525 gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());1526 1527 /* Make sure action-pool knows guest-screen visibility status: */1528 actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible);1529 }1530 1531 QSize UISession::lastFullScreenSize(ulong uScreenId) const1532 {1533 /* Make sure index fits the bounds: */1534 AssertReturn(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size(), QSize(-1, -1));1535 1536 /* Return last full-screen size: */1537 return m_monitorLastFullScreenSizeVector.value((int)uScreenId);1538 }1539 1540 void UISession::setLastFullScreenSize(ulong uScreenId, QSize size)1541 {1542 /* Make sure index fits the bounds: */1543 AssertReturnVoid(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size());1544 1545 /* Remember last full-screen size: */1546 m_monitorLastFullScreenSizeVector[(int)uScreenId] = size;1547 }1548 1549 int UISession::countOfVisibleWindows()1550 {1551 int cCountOfVisibleWindows = 0;1552 for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)1553 if (m_monitorVisibilityVector[i])1554 ++cCountOfVisibleWindows;1555 return cCountOfVisibleWindows;1556 }1557 1558 QList<int> UISession::listOfVisibleWindows() const1559 {1560 QList<int> visibleWindows;1561 for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)1562 if (m_monitorVisibilityVector.at(i))1563 visibleWindows.push_back(i);1564 return visibleWindows;1565 }1566 1567 1221 CMediumVector UISession::machineMedia() const 1568 1222 { … … 1614 1268 } 1615 1269 1616 void UISession::updateHostScreenData()1617 {1618 /* Rebuild host-screen data vector: */1619 m_hostScreens.clear();1620 for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)1621 m_hostScreens << gpDesktop->screenGeometry(iScreenIndex);1622 1623 /* Make sure action-pool knows host-screen count: */1624 actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size());1625 }1626 1627 1270 void UISession::updateActionRestrictions() 1628 1271 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98385 r98386 134 134 void sigCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY); 135 135 136 /** Notifies about host-screen count change. */137 void sigHostScreenCountChange();138 /** Notifies about host-screen geometry change. */139 void sigHostScreenGeometryChange();140 /** Notifies about host-screen available-area change. */141 void sigHostScreenAvailableAreaChange();142 143 136 /** Notifies about frame-buffer resize. */ 144 137 void sigFrameBufferResize(); … … 191 184 WId mainMachineWindowId() const; 192 185 UIMachineWindow *activeMachineWindow() const; 193 194 /** @name Host-screen configuration variables.195 ** @{ */196 /** Returns the list of host-screen geometries we currently have. */197 QList<QRect> hostScreens() const { return m_hostScreens; }198 /** @} */199 186 200 187 /** @name Application Close configuration stuff. … … 262 249 void forgetPreviousMachineState() { m_machineStatePrevious = m_machineState; } 263 250 264 /* Screen visibility status for host-desires: */265 bool isScreenVisibleHostDesires(ulong uScreenId) const;266 void setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible);267 268 /* Screen visibility status: */269 bool isScreenVisible(ulong uScreenId) const;270 void setScreenVisible(ulong uScreenId, bool fIsMonitorVisible);271 272 /* Last screen full-screen size: */273 QSize lastFullScreenSize(ulong uScreenId) const;274 void setLastFullScreenSize(ulong uScreenId, QSize size);275 276 251 /** Returns whether guest-screen is undrawable. 277 252 * @todo: extend this method to all the states when guest-screen is undrawable. */ … … 310 285 KParavirtProvider paraVirtProvider() const { return m_paraVirtProvider; } 311 286 312 /** Returns the list of visible guest windows. */313 QList<int> listOfVisibleWindows() const;314 315 287 /** Returns a vector of media attached to the machine. */ 316 288 CMediumVector machineMedia() const; … … 343 315 void sltVRDEChange(); 344 316 void sltRecordingChange(); 345 void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);346 317 /** Handles storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */ 347 318 void sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent); 348 319 /** Handles audio adapter change. */ 349 320 void sltAudioAdapterChange(); 350 351 /* Handlers: Display reconfiguration stuff: */352 #ifdef RT_OS_DARWIN353 void sltHandleHostDisplayAboutToChange();354 void sltCheckIfHostDisplayChanged();355 #endif /* RT_OS_DARWIN */356 357 /** Handles host-screen count change. */358 void sltHandleHostScreenCountChange();359 /** Handles host-screen geometry change. */360 void sltHandleHostScreenGeometryChange();361 /** Handles host-screen available-area change. */362 void sltHandleHostScreenAvailableAreaChange();363 321 364 322 /** Handles signal about machine state saved. … … 391 349 void prepareActions(); 392 350 void prepareConnections(); 393 void prepareScreens();394 351 void prepareSignalHandling(); 395 352 … … 398 355 399 356 /* Cleanup helpers: */ 400 //void cleanupSignalHandling() ;357 //void cleanupSignalHandling() {} 401 358 //void cleanupScreens() {} 402 void cleanupConnections();359 //void cleanupConnections() {} 403 360 void cleanupActions(); 404 361 void cleanupFramebuffers(); … … 417 374 bool mountAdHocImage(KDeviceType enmDeviceType, UIMediumDeviceType enmMediumType, const QString &strMediumName); 418 375 bool postprocessInitialization(); 419 int countOfVisibleWindows();420 376 /** Loads VM settings. */ 421 377 void loadVMSettings(); 422 423 /** Update host-screen data. */424 void updateHostScreenData();425 378 426 379 /** Updates action restrictions. */ … … 461 414 #endif /* VBOX_WS_MAC */ 462 415 463 /* Screen visibility vector: */464 QVector<bool> m_monitorVisibilityVector;465 466 /* Screen visibility vector for host-desires: */467 QVector<bool> m_monitorVisibilityVectorHostDesires;468 469 /* Screen last full-screen size vector: */470 QVector<QSize> m_monitorLastFullScreenSizeVector;471 472 416 /* Frame-buffers vector: */ 473 417 QVector<UIFrameBuffer*> m_frameBufferVector; … … 476 420 KMachineState m_machineStatePrevious; 477 421 KMachineState m_machineState; 478 479 /** @name Host-screen configuration variables.480 * @{ */481 /** Holds the list of host-screen geometries we currently have. */482 QList<QRect> m_hostScreens;483 #ifdef VBOX_WS_MAC484 /** Mac OS X: Watchdog timer looking for display reconfiguration. */485 QTimer *m_pWatchdogDisplayChange;486 #endif /* VBOX_WS_MAC */487 /** @} */488 422 489 423 /** @name Application Close configuration variables. -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r98375 r98386 747 747 * 1. should really be shown and 748 748 * 2. is mapped to some host-screen: */ 749 if ( ui session()->isScreenVisible(uScreenID)749 if ( uimachine()->isScreenVisible(uScreenID) 750 750 && hasHostScreenForGuestScreen(uScreenID)) 751 751 { … … 783 783 * 2. isn't mapped to some host-screen or 784 784 * 3. should be located on another host-screen than currently. */ 785 if ( !ui session()->isScreenVisible(uScreenID)785 if ( !uimachine()->isScreenVisible(uScreenID) 786 786 || !hasHostScreenForGuestScreen(uScreenID) 787 787 || iWantedHostScreenIndex != iCurrentHostScreenIndex) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r98385 r98386 136 136 { 137 137 /* Step 1: Is guest-screen visible? */ 138 if (!ui session()->isScreenVisible(screenId()))138 if (!uimachine()->isScreenVisible(screenId())) 139 139 { 140 140 LogRel(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: " … … 172 172 sltPerformGuestResize(sizeToApply); 173 173 /* And remember the size to know what we are resizing out of when we exit: */ 174 ui session()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint));174 uimachine()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint)); 175 175 } 176 176 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r98103 r98386 34 34 35 35 /* GUI includes: */ 36 #include "UIActionPoolRuntime.h" 36 37 #include "UICommon.h" 37 38 #include "UIDesktopWidgetWatchdog.h" 38 39 #include "UIExtraDataManager.h" 39 #include "UI Session.h"40 #include "UI ActionPoolRuntime.h"40 #include "UIMachine.h" 41 #include "UIMachineView.h" 41 42 #include "UIMachineLogicFullscreen.h" 42 43 #include "UIMachineWindowFullscreen.h" 43 #include "UIMachineView.h"44 44 #include "UINotificationCenter.h" 45 #include "UISession.h" 45 46 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 46 47 # include "UIMachineDefs.h" … … 183 184 184 185 /* Make sure this window should be shown and mapped to host-screen: */ 185 if (!ui session()->isScreenVisible(m_uScreenId) ||186 if (!uimachine()->isScreenVisible(m_uScreenId) || 186 187 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) 187 188 return; … … 432 433 433 434 /* If window shouldn't be shown or mapped to some host-screen: */ 434 if (!ui session()->isScreenVisible(m_uScreenId) ||435 if (!uimachine()->isScreenVisible(m_uScreenId) || 435 436 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) 436 437 { … … 460 461 461 462 /* If window shouldn't be shown or mapped to some host-screen: */ 462 if (!ui session()->isScreenVisible(m_uScreenId) ||463 if (!uimachine()->isScreenVisible(m_uScreenId) || 463 464 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) 464 465 { … … 503 504 504 505 /* If window shouldn't be shown or mapped to some host-screen: */ 505 if (!ui session()->isScreenVisible(m_uScreenId) ||506 if (!uimachine()->isScreenVisible(m_uScreenId) || 506 507 !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) 507 508 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r98385 r98386 173 173 * hardware as before shutdown), and notifying would interfere with the Windows 174 174 * guest driver which saves the video mode to the registry on shutdown. */ 175 ui session()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus());175 uimachine()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus()); 176 176 display().SetVideoModeHint(screenId(), 177 177 guestScreenVisibilityStatus(), -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r98385 r98386 618 618 { 619 619 /* Make sure this window should be shown at all: */ 620 if (!ui session()->isScreenVisible(m_uScreenId))620 if (!uimachine()->isScreenVisible(m_uScreenId)) 621 621 return hide(); 622 622 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r98103 r98386 32 32 /* GUI includes */ 33 33 #include "UICommon.h" 34 #include "UIDesktopWidgetWatchdog.h" 35 #include "UIExtraDataManager.h" 36 #include "UIFrameBuffer.h" 37 #include "UIMachine.h" 38 #include "UIMachineLogic.h" 39 #include "UIMachineViewScale.h" 40 #include "UIMachineWindow.h" 34 41 #include "UISession.h" 35 #include "UIMachineLogic.h"36 #include "UIMachineWindow.h"37 #include "UIMachineViewScale.h"38 #include "UIFrameBuffer.h"39 #include "UIExtraDataManager.h"40 #include "UIDesktopWidgetWatchdog.h"41 42 42 43 /* COM includes: */ … … 175 176 176 177 /* Send saved size-hint to the guest: */ 177 ui session()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus());178 uimachine()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus()); 178 179 display().SetVideoModeHint(screenId(), 179 180 guestScreenVisibilityStatus(), -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp
r98103 r98386 39 39 #include "UIDesktopWidgetWatchdog.h" 40 40 #include "UIExtraDataManager.h" 41 #include "UI Session.h"41 #include "UIMachine.h" 42 42 #include "UIMachineLogic.h" 43 43 #include "UIMachineWindowScale.h" 44 44 #include "UIMachineView.h" 45 45 #include "UINotificationCenter.h" 46 #include "UISession.h" 46 47 #ifdef VBOX_WS_MAC 47 48 # include "VBoxUtils.h" … … 166 167 { 167 168 /* Make sure this window should be shown at all: */ 168 if (!ui session()->isScreenVisible(m_uScreenId))169 if (!uimachine()->isScreenVisible(m_uScreenId)) 169 170 return hide(); 170 171 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
r98385 r98386 149 149 { 150 150 /* Step 1: Is guest-screen visible? */ 151 if (!ui session()->isScreenVisible(screenId()))151 if (!uimachine()->isScreenVisible(screenId())) 152 152 { 153 153 LogRel(("GUI: UIMachineViewSeamless::adjustGuestScreenSize: " … … 177 177 sltPerformGuestResize(sizeToApply); 178 178 /* And remember the size to know what we are resizing out of when we exit: */ 179 ui session()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint));179 uimachine()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint)); 180 180 } 181 181 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
r98103 r98386 32 32 33 33 /* GUI includes: */ 34 #include "UIActionPoolRuntime.h" 34 35 #include "UICommon.h" 35 36 #include "UIDesktopWidgetWatchdog.h" 36 37 #include "UIExtraDataManager.h" 38 #include "UIMachine.h" 39 #include "UIMachineLogicSeamless.h" 40 #include "UIMachineView.h" 41 #include "UIMachineWindowSeamless.h" 37 42 #include "UISession.h" 38 #include "UIActionPoolRuntime.h"39 #include "UIMachineLogicSeamless.h"40 #include "UIMachineWindowSeamless.h"41 #include "UIMachineView.h"42 43 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 43 44 # include "UIMachineDefs.h" … … 250 251 251 252 /* If window shouldn't be shown or mapped to some host-screen: */ 252 if (!ui session()->isScreenVisible(m_uScreenId) ||253 if (!uimachine()->isScreenVisible(m_uScreenId) || 253 254 !pSeamlessLogic->hasHostScreenForGuestScreen(m_uScreenId)) 254 255 {
Note:
See TracChangeset
for help on using the changeset viewer.