void UIMachineWindowFullscreen::placeOnScreen() { /* Make sure this window has fullscreen logic: */ UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic()); AssertPtrReturnVoid(pFullscreenLogic); /* Get corresponding host-screen: */ const int iHostScreen = pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId); /* And corresponding working area: */ const QRect workingArea = vboxGlobal().screenGeometry(iHostScreen); Q_UNUSED(workingArea); #if defined(VBOX_WS_MAC) /* Move window to the appropriate position: */ move(workingArea.topLeft()); /* Resize window to the appropriate size on Lion and previous: */ if (vboxGlobal().osRelease() <= MacOSXRelease_Lion) resize(workingArea.size()); /* Resize window to the appropriate size on ML and next if it's screen has no own user-space: */ else if (!pFullscreenLogic->screensHaveSeparateSpaces() && m_uScreenId != 0) resize(workingArea.size()); else { /* Load normal geometry first of all: */ QRect geo = gEDataManager->machineWindowGeometry(UIVisualStateType_Normal, m_uScreenId, vboxGlobal().managedVMUuid()); /* If normal geometry is null => use frame-buffer size: */ if (geo.isNull()) { const UIFrameBuffer *pFrameBuffer = uisession()->frameBuffer(m_uScreenId); geo = QRect(QPoint(0, 0), QSize(pFrameBuffer->width(), pFrameBuffer->height()).boundedTo(workingArea.size())); } /* If normal geometry still null => use default size: */ if (geo.isNull()) geo = QRect(QPoint(0, 0), QSize(800, 600).boundedTo(workingArea.size())); /* Move window to the center of working-area: */ geo.moveCenter(workingArea.center()); setGeometry(geo); } #elif defined(VBOX_WS_WIN) # if QT_VERSION >= 0x050000 /* Map window onto required screen: */ windowHandle()->setScreen(qApp->screens().at(iHostScreen)); # endif /* QT_VERSION >= 0x050000 */ /* Set appropriate window size: */ resize(workingArea.size()); # if QT_VERSION < 0x050000 /* Move window onto required screen: */ move(workingArea.topLeft()); # endif /* QT_VERSION < 0x050000 */ #elif defined(VBOX_WS_X11) /* Determine whether we should use the native full-screen mode: */ const bool fUseNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() && !gEDataManager->legacyFullscreenModeRequested(); if (fUseNativeFullScreen) { /* Tell recent window managers which host-screen this window should be mapped to: */ VBoxGlobal::setFullScreenMonitorX11(this, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId)); } /* Set appropriate window geometry: */ resize(workingArea.size()); move(workingArea.topLeft()); #else # warning "port me" #endif }
void UIMachineWindowFullscreen::showInNecessaryMode() { /* Make sure window has fullscreen logic: */ UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic()); AssertPtrReturnVoid(pFullscreenLogic); /* Make sure window should be shown and mapped to some host-screen: */ if (!uisession()->isScreenVisible(m_uScreenId) || !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) { #if defined(Q_WS_WIN) || defined(Q_WS_X11) /* If there is a mini-toolbar: */ if (m_pMiniToolBar) { /* Hide mini-toolbar: */ m_pMiniToolBar->hide(); } #endif /* Q_WS_WIN || Q_WS_X11 */ /* Hide window: */ hide(); } else { /* Ignore if window minimized: */ if (isMinimized()) return; #ifdef Q_WS_X11 /* If WM doesn't support native stuff, we need to call for placeOnScreen(): */ const bool fSupportsNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() && !gEDataManager->legacyFullscreenModeRequested(); if (!fSupportsNativeFullScreen) { /* Make sure window have appropriate geometry: */ placeOnScreen(); } #else /* !Q_WS_X11 */ /* Make sure window have appropriate geometry: */ placeOnScreen(); #endif /* !Q_WS_X11 */ #if defined(Q_WS_MAC) /* ML and next using native stuff, so we can call for simple show(), * Lion and previous using Qt stuff, so we should call for showFullScreen(): */ const bool fSupportsNativeFullScreen = vboxGlobal().osRelease() > MacOSXRelease_Lion; if (fSupportsNativeFullScreen) { /* Show window in normal mode: */ show(); } else { /* Show window in fullscreen mode: */ showFullScreen(); } #elif defined(Q_WS_WIN) || defined(Q_WS_X11) /* Show window in fullscreen mode: */ showFullScreen(); /* If there is a mini-toolbar: */ if (m_pMiniToolBar) { /* Show mini-toolbar in full-screen mode: */ m_pMiniToolBar->showFullScreen(); } #endif /* Q_WS_WIN || Q_WS_X11 */ #ifdef Q_WS_X11 /* If WM supports native stuff, we need to map window to corresponding host-screen. */ if (fSupportsNativeFullScreen) { /* Tell recent window managers which host-screen this window should be mapped to: */ VBoxGlobal::setFullScreenMonitorX11(this, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId)); /* If there is a mini-toolbar: */ if (m_pMiniToolBar) { /* Tell recent window managers which host-screen this mini-toolbar should be mapped to: */ VBoxGlobal::setFullScreenMonitorX11(m_pMiniToolBar, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId)); } } #endif /* Q_WS_X11 */ /* Adjust machine-view size if necessary: */ adjustMachineViewSize(); /* Make sure machine-view have focus: */ m_pMachineView->setFocus(); } }
void UIMachineWindowFullscreen::showInNecessaryMode() { /* Make sure this window has fullscreen logic: */ UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic()); AssertPtrReturnVoid(pFullscreenLogic); #ifdef Q_WS_MAC /* ML and next using native stuff: */ const bool fSupportsNativeFullScreen = vboxGlobal().osRelease() > MacOSXRelease_Lion; #endif /* Q_WS_MAC */ /* Make sure this window should be shown and mapped to some host-screen: */ if (!uisession()->isScreenVisible(m_uScreenId) || !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId)) { #ifndef Q_WS_MAC /* If there is mini-toolbar: */ if (m_pMiniToolBar) { /* Just hide mini-toolbar: */ m_pMiniToolBar->hide(); } #endif /* !Q_WS_MAC */ /* Hide window: */ hide(); return; } /* Make sure this window is not minimized: */ if (isMinimized()) return; #ifdef Q_WS_X11 /* On X11 calling placeOnScreen() is only needed for legacy window managers * which we do not test, so this is 'best effort' code. With window managers which * support the _NET_WM_FULLSCREEN_MONITORS protocol this would interfere unreliable. */ const bool fSupportsNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() && !gEDataManager->legacyFullscreenModeRequested(); if (!fSupportsNativeFullScreen) placeOnScreen(); #else /* !Q_WS_X11 */ /* Make sure this window is maximized and placed on valid screen: */ placeOnScreen(); #endif /* !Q_WS_X11 */ #ifdef Q_WS_MAC /* ML and next using native stuff, so we can call for simple show(), * Lion and previous using Qt stuff, so we should call for showFullScreen(): */ if (fSupportsNativeFullScreen) show(); else showFullScreen(); #else /* !Q_WS_MAC */ /* Show in fullscreen mode: */ showFullScreen(); #endif /* !Q_WS_MAC */ #ifdef Q_WS_X11 if (fSupportsNativeFullScreen) { /* Tell recent window managers which screen this window should be mapped to. * Apparently some window managers will not respond to requests for * unmapped windows, so do this *after* the call to showFullScreen(). */ VBoxGlobal::setFullScreenMonitorX11(this, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId)); } else { /* On X11 calling placeOnScreen() is only needed for legacy window managers * which we do not test, so this is 'best effort' code. With window managers which * support the _NET_WM_FULLSCREEN_MONITORS protocol this would interfere unreliable. */ placeOnScreen(); } #endif /* Q_WS_X11 */ /* Adjust machine-view size if necessary: */ adjustMachineViewSize(); #ifndef Q_WS_MAC /* If there is mini-toolbar: */ if (m_pMiniToolBar) { # if defined(Q_WS_WIN) /* Just show mini-toolbar: */ m_pMiniToolBar->show(); # elif defined(Q_WS_X11) /* Allow mini-toolbar to be located on full-screen area: */ m_pMiniToolBar->showFullScreen(); /* On modern window managers: */ if (fSupportsNativeFullScreen) { /* We also can map mini-toolbar directly on corresponding machine-window: */ VBoxGlobal::setFullScreenMonitorX11(m_pMiniToolBar, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId)); } /* Make sure mini-toolbar is always on top of machine-window: */ VBoxGlobal::setTransientFor(m_pMiniToolBar, this); # endif /* Q_WS_X11 */ } #endif /* !Q_WS_MAC */ /* Make sure machine-view have focus: */ m_pMachineView->setFocus(); }