Changeset 50679 in vbox
- Timestamp:
- Mar 4, 2014 3:39:12 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r50647 r50679 30 30 # include "UIExtraDataEventHandler.h" 31 31 # include "VBoxUtils.h" 32 # include "UIFrameBuffer.h" 32 33 # include <Carbon/Carbon.h> 33 34 #endif /* Q_WS_MAC */ … … 35 36 UIMachineLogicFullscreen::UIMachineLogicFullscreen(QObject *pParent, UISession *pSession) 36 37 : UIMachineLogic(pParent, pSession, UIVisualStateType_Fullscreen) 37 #ifdef Q_WS_MAC38 , m_fIsFullscreenInvalidated(false)39 #endif /* Q_WS_MAC */40 38 { 41 39 /* Create multiscreen layout: */ … … 129 127 Q_UNUSED(fResult); 130 128 131 /* If there is/are still fullscreen window(s) present: */ 132 if (!m_fullscreenMachineWindows.isEmpty()) 133 { 134 /* Exit fullscreen mode if it was not invalidated yet: */ 135 if (!m_fIsFullscreenInvalidated) 129 /* If that window was invalidated: */ 130 if (m_invalidFullscreenMachineWindows.contains(pMachineWindow)) 131 { 132 LogRel(("UIMachineLogicFullscreen::sltHandleNativeFullscreenDidExit: " 133 "Machine-window #%d exited invalidated fullscreen, revalidate it.\n", 134 (int)pMachineWindow->screenId())); 135 136 /* Exclude window from invalidation list: */ 137 m_invalidFullscreenMachineWindows.remove(pMachineWindow); 138 139 /* Revalidate 'fullscreen' window: */ 140 revalidateFullscreenWindow(pMachineWindow); 141 } 142 /* If there are no invalidated windows: */ 143 else if (m_invalidFullscreenMachineWindows.isEmpty()) 144 { 145 /* If there are 'fullscreen' windows: */ 146 if (!m_fullscreenMachineWindows.isEmpty()) 147 { 148 LogRel(("UIMachineLogicFullscreen::sltHandleNativeFullscreenDidExit: " 149 "Machine-window exited fullscreen, asking others to exit too...\n")); 150 151 /* Ask window(s) to exit 'fullscreen' mode: */ 136 152 emit sigNotifyAboutNativeFullscreenShouldBeExited(); 137 } 138 /* If there is/are no more fullscreen window(s) left: */ 139 else 140 { 141 /* If fullscreen mode was just invalidated: */ 142 if (m_fIsFullscreenInvalidated) 143 { 144 LogRel(("UIMachineLogicFullscreen::sltHandleNativeFullscreenDidExit: " 145 "Machine-window(s) exited invalidated fullscreen, enter again...\n")); 146 147 /* Mark fullscreen mode valid again: */ 148 m_fIsFullscreenInvalidated = false; 149 /* Reactivate 'presentation mode': */ 150 setPresentationModeEnabled(true); 151 /* Make sure all machine-window(s) have proper geometry: */ 152 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 153 pMachineWindow->showInNecessaryMode(); 154 /* Ask all window(s) to re-enter fullscreen mode: */ 155 emit sigNotifyAboutNativeFullscreenShouldBeEntered(); 156 } 157 /* If fullscreen mode was manually exited: */ 153 } 154 /* If there are no 'fullscreen' windows: */ 158 155 else 159 156 { … … 181 178 /* Request 'normal' (window) visual-state: */ 182 179 uisession()->setRequestedVisualState(UIVisualStateType_Normal); 183 /* Ask all window(s) to exit fullscreenmode: */180 /* Ask window(s) to exit 'fullscreen' mode: */ 184 181 emit sigNotifyAboutNativeFullscreenShouldBeExited(); 185 182 } … … 196 193 /* Request 'seamless' visual-state: */ 197 194 uisession()->setRequestedVisualState(UIVisualStateType_Seamless); 198 /* Ask all window(s) to exit fullscreenmode: */195 /* Ask window(s) to exit 'fullscreen' mode: */ 199 196 emit sigNotifyAboutNativeFullscreenShouldBeExited(); 200 197 } … … 211 208 /* Request 'scale' visual-state: */ 212 209 uisession()->setRequestedVisualState(UIVisualStateType_Scale); 213 /* Ask all window(s) to exit fullscreenmode: */210 /* Ask window(s) to exit 'fullscreen' mode: */ 214 211 emit sigNotifyAboutNativeFullscreenShouldBeExited(); 215 212 } … … 248 245 void UIMachineLogicFullscreen::sltScreenLayoutChanged() 249 246 { 247 LogRel(("UIMachineLogicFullscreen: Multi-screen layout changed.\n")); 248 250 249 #ifdef Q_WS_MAC 251 250 /* For Lion and previous: */ … … 258 257 setPresentationModeEnabled(true); 259 258 } 260 /* Invalidate fullscreen mode for ML and next: */ 261 else if (shouldWeInvalidateFullscreenMode()) 262 invalidateFullscreenMode(); 263 else 264 { 265 /* Make sure all machine-window(s) have proper geometry: */ 266 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 267 pMachineWindow->showInNecessaryMode(); 268 } 259 /* Revalidate 'fullscreen' windows for ML and next: */ 260 else revalidateFullscreenWindows(); 269 261 #else /* !Q_WS_MAC */ 270 262 /* Make sure all machine-window(s) have proper geometry: */ … … 276 268 void UIMachineLogicFullscreen::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo) 277 269 { 278 LogRel Flow(("UIMachineLogicFullscreen: Guest-screen count changed.\n"));270 LogRel(("UIMachineLogicFullscreen: Guest-screen count changed.\n")); 279 271 280 272 /* Update multi-screen layout before any window update: */ … … 287 279 if (vboxGlobal().osRelease() <= MacOSXRelease_Lion) 288 280 UIMachineLogic::sltGuestMonitorChange(changeType, uScreenId, screenGeo); 289 /* Invalidate fullscreen mode for ML and next: */ 290 else if (shouldWeInvalidateFullscreenMode()) 291 invalidateFullscreenMode(); 292 /* Call to base-class otherwise: */ 293 else UIMachineLogic::sltGuestMonitorChange(changeType, uScreenId, screenGeo); 281 /* Revalidate 'fullscreen' windows for ML and next: */ 282 else revalidateFullscreenWindows(); 294 283 #else /* !Q_WS_MAC */ 295 284 /* Call to base-class: */ … … 300 289 void UIMachineLogicFullscreen::sltHostScreenCountChanged() 301 290 { 302 LogRel Flow(("UIMachineLogicFullscreen: Host-screen count changed.\n"));291 LogRel(("UIMachineLogicFullscreen: Host-screen count changed.\n")); 303 292 304 293 /* Update multi-screen layout before any window update: */ … … 309 298 if (vboxGlobal().osRelease() <= MacOSXRelease_Lion) 310 299 UIMachineLogic::sltHostScreenCountChanged(); 311 /* Invalidate fullscreen mode for ML and next: */ 312 else if (shouldWeInvalidateFullscreenMode()) 313 invalidateFullscreenMode(); 314 /* Call to base-class otherwise: */ 315 else UIMachineLogic::sltHostScreenCountChanged(); 300 /* Revalidate 'fullscreen' windows for ML and next: */ 301 else revalidateFullscreenWindows(); 316 302 #else /* !Q_WS_MAC */ 317 303 /* Call to base-class: */ … … 397 383 { 398 384 /* Logic => window signals: */ 399 connect(this, SIGNAL(sigNotifyAboutNativeFullscreenShouldBeEntered( )),400 pMachineWindow, SLOT(sltEnterNativeFullscreen( )));401 connect(this, SIGNAL(sigNotifyAboutNativeFullscreenShouldBeExited( )),402 pMachineWindow, SLOT(sltExitNativeFullscreen( )));385 connect(this, SIGNAL(sigNotifyAboutNativeFullscreenShouldBeEntered(UIMachineWindow*)), 386 pMachineWindow, SLOT(sltEnterNativeFullscreen(UIMachineWindow*))); 387 connect(this, SIGNAL(sigNotifyAboutNativeFullscreenShouldBeExited(UIMachineWindow*)), 388 pMachineWindow, SLOT(sltExitNativeFullscreen(UIMachineWindow*))); 403 389 /* Window => logic signals: */ 404 390 connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidEnter()), … … 407 393 this, SLOT(sltHandleNativeFullscreenDidExit())); 408 394 } 409 /* Ask all window(s) to enter fullscreen mode: */410 emit sigNotifyAboutNativeFullscreenShouldBeEntered();395 /* Revalidate 'fullscreen' windows: */ 396 revalidateFullscreenWindows(); 411 397 } 412 398 #endif /* Q_WS_MAC */ … … 513 499 } 514 500 515 bool UIMachineLogicFullscreen::shouldWeInvalidateFullscreenMode() const 516 { 517 /* Enumerate windows: */ 501 void UIMachineLogicFullscreen::revalidateFullscreenWindow(UIMachineWindow *pMachineWindow) 502 { 503 LogRel(("UIMachineLogicFullscreen::revalidateFullscreenWindow #%d begin.\n", pMachineWindow->screenId())); 504 505 /* Make sure window is not already invalidated: */ 506 if (m_invalidFullscreenMachineWindows.contains(pMachineWindow)) 507 return; 508 509 /* Ignore window if it is in 'fullscreen transition': */ 510 if (qobject_cast<UIMachineWindowFullscreen*>(pMachineWindow)->isInFullscreenTransition()) 511 return; 512 513 /* Get screen ID: */ 514 ulong uScreenID = pMachineWindow->screenId(); 515 516 /* Validate window which can't be fullscreen: */ 517 if (uScreenID != 0 && !darwinScreensHaveSeparateSpaces()) 518 { 519 /* Make sure window have proper geometry: */ 520 pMachineWindow->showInNecessaryMode(); 521 } 522 /* Validate window which can be fullscreen: */ 523 else 524 { 525 /* Validate window which is not in fullscreen: */ 526 if (!darwinIsInFullscreenMode(pMachineWindow)) 527 { 528 /* If that window 529 * 1. should really be shown and 530 * 2. is mapped to some host-screen: */ 531 if ( uisession()->isScreenVisible(uScreenID) 532 && hasHostScreenForGuestScreen(uScreenID)) 533 { 534 LogRel(("UIMachineLogicFullscreen::revalidateFullscreenWindow: " 535 "Ask machine-window #%d to enter fullscreen.\n", (int)uScreenID)); 536 537 /* Update 'presentation mode': */ 538 setPresentationModeEnabled(true); 539 540 /* Make sure window have proper geometry and shown: */ 541 pMachineWindow->showInNecessaryMode(); 542 543 /* Ask window to enter 'fullscreen' mode: */ 544 emit sigNotifyAboutNativeFullscreenShouldBeEntered(pMachineWindow); 545 } 546 /* Else make sure that window is hidden: */ 547 else pMachineWindow->showInNecessaryMode(); 548 } 549 /* Validate window which is in fullscreen: */ 550 else 551 { 552 /* Variables to compare: */ 553 const int iWantedHostScreenIndex = hostScreenForGuestScreen((int)uScreenID); 554 const int iCurrentHostScreenIndex = QApplication::desktop()->screenNumber(pMachineWindow); 555 const QSize frameBufferSize((int)uisession()->frameBuffer(uScreenID)->width(), (int)uisession()->frameBuffer(uScreenID)->height()); 556 const QSize screenSize = QApplication::desktop()->screenGeometry(iWantedHostScreenIndex).size(); 557 558 /* If that window 559 * 1. shouldn't really be shown or 560 * 2. isn't mapped to some host-screen or 561 * 3. should be located on another host-screen than currently or 562 * 4. have another frame-buffer size than actually should. */ 563 if ( !uisession()->isScreenVisible(uScreenID) 564 || !hasHostScreenForGuestScreen(uScreenID) 565 || iWantedHostScreenIndex != iCurrentHostScreenIndex 566 || frameBufferSize != screenSize) 567 { 568 LogRel(("UIMachineLogicFullscreen::revalidateFullscreenWindow: " 569 "Ask machine-window #%d to exit fullscreen.\n", (int)uScreenID)); 570 571 /* Mark window as invalidated: */ 572 m_invalidFullscreenMachineWindows << pMachineWindow; 573 574 /* Ask window to exit 'fullscreen' mode: */ 575 emit sigNotifyAboutNativeFullscreenShouldBeExited(pMachineWindow); 576 } 577 } 578 } 579 580 LogRel(("UIMachineLogicFullscreen::revalidateFullscreenWindow #%d end.\n", pMachineWindow->screenId())); 581 } 582 583 void UIMachineLogicFullscreen::revalidateFullscreenWindows() 584 { 585 /* Revalidate all fullscreen windows: */ 518 586 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 519 { 520 /* Cast to 'fullscreen' window: */ 521 UIMachineWindowFullscreen *pFullscreenMachineWindow = 522 qobject_cast<UIMachineWindowFullscreen*>(pMachineWindow); 523 /* Ignore window(s) which are in 'fullscreen transition': */ 524 if (pFullscreenMachineWindow->isInFullscreenTransition()) 525 continue; 526 527 /* Get screen ID: */ 528 ulong uScreenID = pMachineWindow->screenId(); 529 /* Check window which can be fullscreen: */ 530 if (uScreenID == 0 || darwinScreensHaveSeparateSpaces()) 531 { 532 /* Check window which is not in fullscreen: */ 533 if (!darwinIsInFullscreenMode(pMachineWindow)) 534 { 535 /* Check if that window should really 536 * be shown and is mapped to some host-screen: */ 537 if ( uisession()->isScreenVisible(uScreenID) 538 && hasHostScreenForGuestScreen(uScreenID)) 539 return true; 540 } 541 /* Check window which is in fullscreen: */ 542 else 543 { 544 /* Check if that window shouldn't really 545 * be shown or isn't mapped to some host-screen: */ 546 if ( !uisession()->isScreenVisible(uScreenID) 547 || !hasHostScreenForGuestScreen(uScreenID)) 548 return true; 549 /* Check if that window should be located 550 * on another host-screen than currently. */ 551 if (hostScreenForGuestScreen((int)uScreenID) != 552 QApplication::desktop()->screenNumber(pMachineWindow)) 553 return true; 554 } 555 } 556 } 557 558 /* False by default: */ 559 return false; 560 } 561 562 void UIMachineLogicFullscreen::invalidateFullscreenMode() 563 { 564 /* Make sure 'fullscreen' mode is not invalidated yet: */ 565 if (m_fIsFullscreenInvalidated) 566 return; 567 568 LogRel(("UIMachineLogicFullscreen::invalidateFullscreenMode: " 569 "Fullscreen mode invalidated...\n")); 570 571 /* Mark 'fullscreen' mode as invalidated: */ 572 m_fIsFullscreenInvalidated = true; 573 574 /* Ask all window(s) to exit fullscreen mode: */ 575 emit sigNotifyAboutNativeFullscreenShouldBeExited(); 587 revalidateFullscreenWindow(pMachineWindow); 576 588 } 577 589 #endif /* Q_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h
r50634 r50679 31 31 #ifdef RT_OS_DARWIN 32 32 signals: 33 /** Mac OS X: Notifies listener about native fullscreen mode should be entered. */34 void sigNotifyAboutNativeFullscreenShouldBeEntered( );35 /** Mac OS X: Notifies listener about native fullscreen mode should be exited. */36 void sigNotifyAboutNativeFullscreenShouldBeExited( );33 /** Mac OS X: Notifies listeners about native fullscreen mode should be entered on @a pMachineWindow. */ 34 void sigNotifyAboutNativeFullscreenShouldBeEntered(UIMachineWindow *pMachineWindow = 0); 35 /** Mac OS X: Notifies listeners about native fullscreen mode should be exited on @a pMachineWindow. */ 36 void sigNotifyAboutNativeFullscreenShouldBeExited(UIMachineWindow *pMachineWindow = 0); 37 37 #endif /* RT_OS_DARWIN */ 38 38 … … 104 104 void setPresentationModeEnabled(bool fEnabled); 105 105 106 /** Mac OS X: Checks if 'fullscreen' mode should be invalidated. */107 bool shouldWeInvalidateFullscreenMode() const;108 /** Mac OS X: Invalidates 'fullscreen' mode. */109 void invalidateFullscreenMode();106 /** Mac OS X: Revalidates 'fullscreen' mode for @a pMachineWindow. */ 107 void revalidateFullscreenWindow(UIMachineWindow *pMachineWindow); 108 /** Mac OS X: Revalidates 'fullscreen' mode for all windows. */ 109 void revalidateFullscreenWindows(); 110 110 #endif /* Q_WS_MAC */ 111 111 … … 116 116 /** Mac OS X: Contains machine-window(s) marked as 'fullscreen'. */ 117 117 QSet<UIMachineWindow*> m_fullscreenMachineWindows; 118 /** Mac OS X: Holds 'fullscreen' mode invalidation status. */119 bool m_fIsFullscreenInvalidated;118 /** Mac OS X: Contains machine-window(s) marked as 'invalid fullscreen'. */ 119 QSet<UIMachineWindow*> m_invalidFullscreenMachineWindows; 120 120 #endif /* Q_WS_MAC */ 121 121 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r50647 r50679 101 101 102 102 #ifdef Q_WS_MAC 103 void UIMachineWindowFullscreen::sltEnterNativeFullscreen( )103 void UIMachineWindowFullscreen::sltEnterNativeFullscreen(UIMachineWindow *pMachineWindow) 104 104 { 105 105 /* Make sure this slot is called only under ML and next: */ 106 106 AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion); 107 108 /* Make sure it is NULL or 'this' window passed: */ 109 if (pMachineWindow && pMachineWindow != this) 110 return; 107 111 108 112 /* Make sure this window should be shown at all: */ … … 128 132 } 129 133 130 void UIMachineWindowFullscreen::sltExitNativeFullscreen( )134 void UIMachineWindowFullscreen::sltExitNativeFullscreen(UIMachineWindow *pMachineWindow) 131 135 { 132 136 /* Make sure this slot is called only under ML and next: */ 133 137 AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion); 138 139 /* Make sure it is NULL or 'this' window passed: */ 140 if (pMachineWindow && pMachineWindow != this) 141 return; 134 142 135 143 /* Mark window 'transitioned from fullscreen': */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h
r50647 r50679 60 60 61 61 #ifdef RT_OS_DARWIN 62 /** Mac OS X: Commands window to enter native 'fullscreen' mode if possible. */63 void sltEnterNativeFullscreen( );64 /** Mac OS X: Commands window to exit native 'fullscreen' mode if possible. */65 void sltExitNativeFullscreen( );62 /** Mac OS X: Commands @a pMachineWindow to enter native 'fullscreen' mode if possible. */ 63 void sltEnterNativeFullscreen(UIMachineWindow *pMachineWindow); 64 /** Mac OS X: Commands @a pMachineWindow to exit native 'fullscreen' mode if possible. */ 65 void sltExitNativeFullscreen(UIMachineWindow *pMachineWindow); 66 66 #endif /* RT_OS_DARWIN */ 67 67
Note:
See TracChangeset
for help on using the changeset viewer.