void UIMachineWindowFullscreen::sltEnterNativeFullscreen(UIMachineWindow *pMachineWindow)
{
    /* Make sure this slot is called only under ML and next: */
    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);

    /* Make sure it is NULL or 'this' window passed: */
    if (pMachineWindow && pMachineWindow != this)
        return;

    /* Make sure this window has fullscreen logic: */
    UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
    AssertPtrReturnVoid(pFullscreenLogic);

    /* Make sure this window should be shown and mapped to host-screen: */
    if (!uisession()->isScreenVisible(m_uScreenId) ||
        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
        return;

    /* Mark window 'transitioned to fullscreen': */
    m_fIsInFullscreenTransition = true;

    /* Enter native fullscreen mode if necessary: */
    if (   (pFullscreenLogic->screensHaveSeparateSpaces() || m_uScreenId == 0)
        && !darwinIsInFullscreenMode(this))
        darwinToggleFullscreenMode(this);
}
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();
    }
}
Ejemplo n.º 3
0
void UIMachineWindowFullscreen::showInNecessaryMode()
{
    /* Make sure window has fullscreen logic: */
    UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
    AssertPtrReturnVoid(pFullscreenLogic);

#if defined(VBOX_WS_MAC)

    /* If window shouldn't be shown or mapped to some host-screen: */
    if (!uisession()->isScreenVisible(m_uScreenId) ||
        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    {
        /* Hide window: */
        hide();
    }
    /* If window should be shown and mapped to some host-screen: */
    else
    {
        /* Make sure window have appropriate geometry: */
        placeOnScreen();

        /* Simple show() for ML and next, showFullScreen() otherwise: */
        if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
            show();
        else
            showFullScreen();

        /* Adjust machine-view size if necessary: */
        adjustMachineViewSize();

        /* Make sure machine-view have focus: */
        m_pMachineView->setFocus();
    }

#elif defined(VBOX_WS_WIN)

    /* If window shouldn't be shown or mapped to some host-screen: */
    if (!uisession()->isScreenVisible(m_uScreenId) ||
        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    {
        /* Remember whether the window was minimized: */
        if (isMinimized())
            m_fWasMinimized = true;

        /* Hide window and reset it's state to NONE: */
        setWindowState(Qt::WindowNoState);
        hide();
    }
    /* If window should be shown and mapped to some host-screen: */
    else
    {
        /* Check whether window was minimized: */
        const bool fWasMinimized = isMinimized() && isVisible();
        /* And reset it's state in such case before exposing: */
        if (fWasMinimized)
            setWindowState(Qt::WindowNoState);

        /* Make sure window have appropriate geometry: */
        placeOnScreen();

        /* Show window: */
        showFullScreen();

        /* Restore minimized state if necessary: */
        if (m_fWasMinimized || fWasMinimized)
        {
            m_fWasMinimized = false;
            QMetaObject::invokeMethod(this, "showMinimized", Qt::QueuedConnection);
        }

        /* Adjust machine-view size if necessary: */
        adjustMachineViewSize();

        /* Make sure machine-view have focus: */
        m_pMachineView->setFocus();
    }

#elif defined(VBOX_WS_X11)

    /* If window shouldn't be shown or mapped to some host-screen: */
    if (!uisession()->isScreenVisible(m_uScreenId) ||
        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    {
        /* Remember whether the window was minimized: */
        if (isMinimized())
            m_fWasMinimized = true;

        /* Hide window and reset it's state to NONE: */
        setWindowState(Qt::WindowNoState);
        hide();
    }
    /* If window should be shown and mapped to some host-screen: */
    else
    {
        /* Check whether window was minimized: */
        const bool fWasMinimized = isMinimized() && isVisible();
        /* And reset it's state in such case before exposing: */
        if (fWasMinimized)
            setWindowState(Qt::WindowNoState);

        /* Show window: */
        showFullScreen();

        /* Make sure window have appropriate geometry: */
        placeOnScreen();

        /* Restore full-screen state after placeOnScreen() call: */
        setWindowState(Qt::WindowFullScreen);

        /* Restore minimized state if necessary: */
        if (m_fWasMinimized || fWasMinimized)
        {
            m_fWasMinimized = false;
            QMetaObject::invokeMethod(this, "showMinimized", Qt::QueuedConnection);
        }

        /* Adjust machine-view size if necessary: */
        adjustMachineViewSize();

        /* Make sure machine-view have focus: */
        m_pMachineView->setFocus();
    }

#else

# warning "port me"

#endif
}
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();
}