Changeset 50681 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 4, 2014 4:47:28 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r49506 r50681 23 23 #include "UIMachineLogic.h" 24 24 #include "UIMachineWindow.h" 25 #ifdef Q_WS_MAC26 # include <ApplicationServices/ApplicationServices.h>27 #endif /* Q_WS_MAC */28 25 29 26 /* Visual state interface: */ … … 40 37 , m_pSession(pSession) 41 38 , m_pMachineLogic(0) 42 #ifdef Q_WS_MAC43 , m_fadeToken(kCGDisplayFadeReservationInvalidToken)44 #endif /* Q_WS_MAC */45 39 { 46 40 } … … 66 60 67 61 /* Method to prepare change one visual state to another: */ 68 bool prepareChange( UIVisualStateType previousVisualStateType)62 bool prepareChange() 69 63 { 70 64 m_pMachineLogic = UIMachineLogic::create(this, m_pSession, visualStateType()); 71 bool fResult = m_pMachineLogic->checkAvailability(); 72 #ifdef Q_WS_MAC 73 /* If the new is or the old type was fullscreen we add the blending 74 * transition between the mode switches. 75 * TODO: make this more general. */ 76 if ( fResult 77 && ( visualStateType() == UIVisualStateType_Fullscreen 78 || previousVisualStateType == UIVisualStateType_Fullscreen)) 79 { 80 /* Fade to black */ 81 CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &m_fadeToken); 82 CGDisplayFade(m_fadeToken, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, true); 83 } 84 #else /* Q_WS_MAC */ 85 Q_UNUSED(previousVisualStateType); 86 #endif /* !Q_WS_MAC */ 87 return fResult; 65 return m_pMachineLogic->checkAvailability(); 88 66 } 89 67 … … 93 71 /* Prepare the logic object: */ 94 72 m_pMachineLogic->prepare(); 95 }96 97 /* Method to finish change one visual state to another: */98 void finishChange()99 {100 #ifdef Q_WS_MAC101 /* If there is a valid fade token, fade back to normal color in any102 * case. */103 if (m_fadeToken != kCGDisplayFadeReservationInvalidToken)104 {105 /* Fade back to the normal gamma */106 CGDisplayFade(m_fadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);107 CGReleaseDisplayFadeReservation(m_fadeToken);108 m_fadeToken = kCGDisplayFadeReservationInvalidToken;109 }110 #endif /* Q_WS_MAC */111 73 } 112 74 … … 117 79 UISession *m_pSession; 118 80 UIMachineLogic *m_pMachineLogic; 119 #ifdef Q_WS_MAC120 CGDisplayFadeReservationToken m_fadeToken;121 #endif /* Q_WS_MAC */122 81 }; 123 82 … … 200 159 UIVisualState *pNewVisualState = new UIVisualState(this, m_pSession, newVisualStateType); 201 160 202 /* Get previous visual state type: */203 UIVisualStateType previousVisualStateType = m_pVisualState ? m_pVisualState->visualStateType() : UIVisualStateType_Normal;204 205 161 /* First we have to check if the selected mode is available at all. 206 162 * Only then we delete the old mode and switch to the new mode. */ 207 if (pNewVisualState->prepareChange( previousVisualStateType))163 if (pNewVisualState->prepareChange()) 208 164 { 209 165 /* Delete previous state: */ … … 213 169 m_pVisualState = pNewVisualState; 214 170 m_pVisualState->change(); 215 216 /* Finish any setup: */217 m_pVisualState->finishChange();218 171 } 219 172 else -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r50679 r50681 36 36 UIMachineLogicFullscreen::UIMachineLogicFullscreen(QObject *pParent, UISession *pSession) 37 37 : UIMachineLogic(pParent, pSession, UIVisualStateType_Fullscreen) 38 #ifdef Q_WS_MAC 39 , m_fadeToken(kCGDisplayFadeReservationInvalidToken) 40 #endif /* Q_WS_MAC */ 38 41 { 39 42 /* Create multiscreen layout: */ … … 99 102 100 103 #ifdef RT_OS_DARWIN 101 void UIMachineLogicFullscreen::sltHandleNativeFullscreen DidEnter()104 void UIMachineLogicFullscreen::sltHandleNativeFullscreenWillEnter() 102 105 { 103 106 /* Make sure this method is only used for ML and next: */ … … 108 111 AssertReturnVoid(pMachineWindow); 109 112 113 /* Fade to black: */ 114 fadeToBlack(); 115 } 116 117 void UIMachineLogicFullscreen::sltHandleNativeFullscreenDidEnter() 118 { 119 /* Make sure this method is only used for ML and next: */ 120 AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion); 121 122 /* Get sender machine-window: */ 123 UIMachineWindow *pMachineWindow = qobject_cast<UIMachineWindow*>(sender()); 124 AssertReturnVoid(pMachineWindow); 125 110 126 /* Add machine-window to corresponding set: */ 111 127 m_fullscreenMachineWindows.insert(pMachineWindow); 112 128 AssertReturnVoid(m_fullscreenMachineWindows.contains(pMachineWindow)); 129 130 /* Fade to normal if necessary: */ 131 QSet<UIMachineWindow*> visibleMachineWindows; 132 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 133 if (uisession()->isScreenVisible(pMachineWindow->screenId())) 134 visibleMachineWindows << pMachineWindow; 135 if ( !darwinScreensHaveSeparateSpaces() 136 || m_fullscreenMachineWindows == visibleMachineWindows) 137 fadeToNormal(); 138 } 139 140 void UIMachineLogicFullscreen::sltHandleNativeFullscreenWillExit() 141 { 142 /* Make sure this method is only used for ML and next: */ 143 AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion); 144 145 /* Get sender machine-window: */ 146 UIMachineWindow *pMachineWindow = qobject_cast<UIMachineWindow*>(sender()); 147 AssertReturnVoid(pMachineWindow); 148 149 /* Fade to black: */ 150 fadeToBlack(); 113 151 } 114 152 … … 164 202 uisession()->setRequestedVisualState(UIVisualStateType_Invalid); 165 203 uisession()->changeVisualState(type); 204 205 /* Fade to normal: */ 206 fadeToNormal(); 166 207 } 167 208 } … … 360 401 * This is necessary for Qt versions > 4.3.3: */ 361 402 darwinSetFrontMostProcess(); 403 404 /* Fade to black: */ 405 fadeToBlack(); 362 406 #endif /* Q_WS_MAC */ 363 407 … … 376 420 /* Activate 'presentation mode': */ 377 421 setPresentationModeEnabled(true); 422 423 /* For Lion and previous fade to normal: */ 424 if (vboxGlobal().osRelease() <= MacOSXRelease_Lion) 425 fadeToNormal(); 426 378 427 /* For ML and next: */ 379 428 if (vboxGlobal().osRelease() > MacOSXRelease_Lion) … … 388 437 pMachineWindow, SLOT(sltExitNativeFullscreen(UIMachineWindow*))); 389 438 /* Window => logic signals: */ 439 connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenWillEnter()), 440 this, SLOT(sltHandleNativeFullscreenWillEnter())); 390 441 connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidEnter()), 391 442 this, SLOT(sltHandleNativeFullscreenDidEnter())); 443 connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenWillExit()), 444 this, SLOT(sltHandleNativeFullscreenWillExit())); 392 445 connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidExit()), 393 446 this, SLOT(sltHandleNativeFullscreenDidExit())); … … 418 471 return; 419 472 473 #ifdef Q_WS_MAC 474 /* For Lion and previous fade to black: */ 475 if (vboxGlobal().osRelease() <= MacOSXRelease_Lion) 476 fadeToBlack(); 477 #endif/* Q_WS_MAC */ 478 420 479 /* Mark machine-window(s) destroyed: */ 421 480 setMachineWindowsCreated(false); … … 428 487 /* Deactivate 'presentation mode': */ 429 488 setPresentationModeEnabled(false); 489 490 /* Fade to normal: */ 491 fadeToNormal(); 430 492 #endif/* Q_WS_MAC */ 431 493 } … … 499 561 } 500 562 563 void UIMachineLogicFullscreen::fadeToBlack() 564 { 565 /* Make sure fade-token invalid: */ 566 if (m_fadeToken != kCGDisplayFadeReservationInvalidToken) 567 return; 568 569 /* Acquire fade-token: */ 570 CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &m_fadeToken); 571 CGDisplayFade(m_fadeToken, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, true); 572 } 573 574 void UIMachineLogicFullscreen::fadeToNormal() 575 { 576 /* Make sure fade-token valid: */ 577 if (m_fadeToken == kCGDisplayFadeReservationInvalidToken) 578 return; 579 580 /* Release fade-token: */ 581 CGDisplayFade(m_fadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false); 582 CGReleaseDisplayFadeReservation(m_fadeToken); 583 m_fadeToken = kCGDisplayFadeReservationInvalidToken; 584 } 585 501 586 void UIMachineLogicFullscreen::revalidateFullscreenWindow(UIMachineWindow *pMachineWindow) 502 587 { … … 534 619 LogRel(("UIMachineLogicFullscreen::revalidateFullscreenWindow: " 535 620 "Ask machine-window #%d to enter fullscreen.\n", (int)uScreenID)); 621 622 /* Fade to black: */ 623 fadeToBlack(); 536 624 537 625 /* Update 'presentation mode': */ … … 569 657 "Ask machine-window #%d to exit fullscreen.\n", (int)uScreenID)); 570 658 659 /* Fade to black: */ 660 fadeToBlack(); 661 571 662 /* Mark window as invalidated: */ 572 663 m_invalidFullscreenMachineWindows << pMachineWindow; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h
r50679 r50681 18 18 #define ___UIMachineLogicFullscreen_h___ 19 19 20 /* Localincludes: */20 /* GUI includes: */ 21 21 #include "UIMachineLogic.h" 22 23 /* Other includes: */ 24 #ifdef Q_WS_MAC 25 # include <ApplicationServices/ApplicationServices.h> 26 #endif /* Q_WS_MAC */ 22 27 23 28 /* Forward declarations: */ … … 54 59 55 60 #ifdef RT_OS_DARWIN 56 /** Mac OS X: Marks sender() machine-window as 'fullscreen' one. */ 61 /** Mac OS X: Handles native notification about 'fullscreen' will be entered. */ 62 void sltHandleNativeFullscreenWillEnter(); 63 /** Mac OS X: Handles native notification about 'fullscreen' entered. */ 57 64 void sltHandleNativeFullscreenDidEnter(); 58 /** Mac OS X: Marks sender() machine-window as 'non-fullscreen' one, 59 * changes visual-state to requested if there is/are no more fullscreen window(s). */ 65 /** Mac OS X: Handles native notification about 'fullscreen' will be exited. */ 66 void sltHandleNativeFullscreenWillExit(); 67 /** Mac OS X: Handles native notification about 'fullscreen' exited. */ 60 68 void sltHandleNativeFullscreenDidExit(); 61 69 … … 104 112 void setPresentationModeEnabled(bool fEnabled); 105 113 114 /** Mac OS X: Performs fade to black if possible. */ 115 void fadeToBlack(); 116 /** Mac OS X: Performs fade to normal if possible. */ 117 void fadeToNormal(); 118 106 119 /** Mac OS X: Revalidates 'fullscreen' mode for @a pMachineWindow. */ 107 120 void revalidateFullscreenWindow(UIMachineWindow *pMachineWindow); … … 114 127 115 128 #ifdef Q_WS_MAC 129 /** Mac OS X: Fade token. */ 130 CGDisplayFadeReservationToken m_fadeToken; 131 116 132 /** Mac OS X: Contains machine-window(s) marked as 'fullscreen'. */ 117 133 QSet<UIMachineWindow*> m_fullscreenMachineWindows; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r50679 r50681 60 60 strNativeNotificationName.toAscii().constData())); 61 61 62 /* Handle 'NSWindowWillEnterFullScreenNotification' notification: */ 63 if (strNativeNotificationName == "NSWindowWillEnterFullScreenNotification") 64 { 65 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: " 66 "Native fullscreen mode about to enter, notifying listener...\n")); 67 emit sigNotifyAboutNativeFullscreenWillEnter(); 68 } 62 69 /* Handle 'NSWindowDidEnterFullScreenNotification' notification: */ 63 if (strNativeNotificationName == "NSWindowDidEnterFullScreenNotification")70 else if (strNativeNotificationName == "NSWindowDidEnterFullScreenNotification") 64 71 { 65 72 /* Mark window transition complete: */ … … 68 75 "Native fullscreen mode entered, notifying listener...\n")); 69 76 emit sigNotifyAboutNativeFullscreenDidEnter(); 77 } 78 /* Handle 'NSWindowWillExitFullScreenNotification' notification: */ 79 else if (strNativeNotificationName == "NSWindowWillExitFullScreenNotification") 80 { 81 LogRel(("UIMachineWindowFullscreen::handleNativeNotification: " 82 "Native fullscreen mode about to exit, notifying listener...\n")); 83 emit sigNotifyAboutNativeFullscreenWillExit(); 70 84 } 71 85 /* Handle 'NSWindowDidExitFullScreenNotification' notification: */ … … 189 203 darwinEnableTransienceSupport(this); 190 204 /* Register to native fullscreen notifications: */ 205 UICocoaApplication::instance()->registerToNativeNotification("NSWindowWillEnterFullScreenNotification", this, 206 UIMachineWindow::handleNativeNotification); 191 207 UICocoaApplication::instance()->registerToNativeNotification("NSWindowDidEnterFullScreenNotification", this, 208 UIMachineWindow::handleNativeNotification); 209 UICocoaApplication::instance()->registerToNativeNotification("NSWindowWillExitFullScreenNotification", this, 192 210 UIMachineWindow::handleNativeNotification); 193 211 UICocoaApplication::instance()->registerToNativeNotification("NSWindowDidExitFullScreenNotification", this, … … 252 270 { 253 271 /* Unregister from native fullscreen notifications: */ 272 UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowWillEnterFullScreenNotification", this); 254 273 UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowDidEnterFullScreenNotification", this); 274 UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowWillExitFullScreenNotification", this); 255 275 UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowDidExitFullScreenNotification", this); 256 276 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h
r50679 r50681 33 33 #ifdef RT_OS_DARWIN 34 34 signals: 35 /** Mac OS X: Notifies listener about native 'fullscreen' will be entered. */ 36 void sigNotifyAboutNativeFullscreenWillEnter(); 35 37 /** Mac OS X: Notifies listener about native 'fullscreen' entered. */ 36 38 void sigNotifyAboutNativeFullscreenDidEnter(); 39 /** Mac OS X: Notifies listener about native 'fullscreen' will be exited. */ 40 void sigNotifyAboutNativeFullscreenWillExit(); 37 41 /** Mac OS X: Notifies listener about native 'fullscreen' exited. */ 38 42 void sigNotifyAboutNativeFullscreenDidExit();
Note:
See TracChangeset
for help on using the changeset viewer.