VirtualBox

Changeset 52512 in vbox


Ignore:
Timestamp:
Aug 28, 2014 12:05:12 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: Runtime UI: Native full-screen: Do not show transient windows unless application is really active; show them on application activation.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r52478 r52512  
    3232#include "QIMenu.h"
    3333#ifdef Q_WS_MAC
     34# include "UICocoaApplication.h"
    3435# include "UIExtraDataManager.h"
    3536# include "VBoxUtils.h"
     
    511512
    512513#ifdef Q_WS_MAC
     514    /* For ML and next: */
     515    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
     516    {
     517        /* Register to native notifications: */
     518        UICocoaApplication::instance()->registerToNotificationOfWorkspace("NSWorkspaceDidActivateApplicationNotification", this,
     519                                                                          UIMachineLogicFullscreen::nativeHandlerForApplicationActivation);
     520    }
     521
    513522    /* We have to make sure that we are getting the front most process.
    514523     * This is necessary for Qt versions > 4.3.3: */
     
    599608        return;
    600609
     610#ifdef Q_WS_MAC
     611    /* For ML and next: */
     612    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
     613    {
     614        /* Unregister from native notifications: */
     615        UICocoaApplication::instance()->unregisterFromNotificationOfWorkspace("NSWorkspaceDidActivateApplicationNotification", this);
     616    }
     617#endif/* Q_WS_MAC */
     618
    601619    /* Mark machine-window(s) destroyed: */
    602620    setMachineWindowsCreated(false);
     
    688706
    689707    /* Get screen ID: */
    690     ulong uScreenID = pMachineWindow->screenId();
     708    const ulong uScreenID = pMachineWindow->screenId();
    691709    LogRel(("UIMachineLogicFullscreen::revalidateNativeFullScreen: For machine-window #%d.\n",
    692710            (int)uScreenID));
     
    695713    if (uScreenID != 0 && !screensHaveSeparateSpaces())
    696714    {
    697         /* If there is no fullscreen window or it's invalidated: */
    698         if (m_fullscreenMachineWindows.isEmpty() || !m_invalidFullscreenMachineWindows.isEmpty())
     715        /* We are hiding transient window if:
     716         * 1. application is inactive at all or
     717         * 2. there is no fullscreen window or it's invalidated. */
     718        if (   !UICocoaApplication::instance()->isActive()
     719            || m_fullscreenMachineWindows.isEmpty() || !m_invalidFullscreenMachineWindows.isEmpty())
    699720        {
    700721            LogRel(("UIMachineLogicFullscreen::revalidateNativeFullScreen: "
     
    794815        revalidateNativeFullScreen(pMachineWindow);
    795816}
     817
     818/* static */
     819void UIMachineLogicFullscreen::nativeHandlerForApplicationActivation(QObject *pObject, const QMap<QString, QString> &userInfo)
     820{
     821    /* Handle arrived notification: */
     822    UIMachineLogicFullscreen *pLogic = qobject_cast<UIMachineLogicFullscreen*>(pObject);
     823    AssertPtrReturnVoid(pLogic);
     824    {
     825        /* Redirect arrived notification: */
     826        pLogic->nativeHandlerForApplicationActivation(userInfo);
     827    }
     828}
     829
     830void UIMachineLogicFullscreen::nativeHandlerForApplicationActivation(const QMap<QString, QString> &userInfo)
     831{
     832    /* Make sure we have BundleIdentifier key: */
     833    AssertReturnVoid(userInfo.contains("BundleIdentifier"));
     834
     835    /* On VirtualBox activation: */
     836    if (userInfo.value("BundleIdentifier") == "org.virtualbox.app.VirtualBox")
     837    {
     838        LogRel(("UIMachineLogicFullscreen::nativeHandlerForApplicationActivation: BundleIdentifier = %s\n",
     839                userInfo.value("BundleIdentifier").toAscii().constData()));
     840
     841        /* Make sure all the transient machine-windows updated: */
     842        foreach (UIMachineWindow *pMachineWindow, machineWindows())
     843            if (pMachineWindow->screenId() != 0 && !screensHaveSeparateSpaces())
     844            {
     845                /* If there is no fullscreen window or it's invalidated: */
     846                if (m_fullscreenMachineWindows.isEmpty() || !m_invalidFullscreenMachineWindows.isEmpty())
     847                {
     848                    LogRel(("UIMachineLogicFullscreen::nativeHandlerForApplicationActivation: "
     849                            "Ask transient machine-window #%d to hide.\n", (int)pMachineWindow->screenId()));
     850
     851                    pMachineWindow->hide();
     852                }
     853                /* If there is valid fullscreen window: */
     854                else
     855                {
     856                    LogRel(("UIMachineLogicFullscreen::nativeHandlerForApplicationActivation: "
     857                            "Ask transient machine-window #%d to show/normalize.\n", (int)pMachineWindow->screenId()));
     858
     859                    /* Make sure window have proper geometry and shown: */
     860                    pMachineWindow->showInNecessaryMode();
     861                }
     862            }
     863    }
     864}
    796865#endif /* Q_WS_MAC */
    797866
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h

    r52300 r52512  
    139139    /** Mac OS X: Revalidates 'fullscreen' mode for all windows. */
    140140    void revalidateNativeFullScreen();
     141
     142    /** Mac OS X: Proxies native notification about active space change. */
     143    static void nativeHandlerForApplicationActivation(QObject *pObject, const QMap<QString, QString> &userInfo);
     144    /** Mac OS X: Handles native notification about active space change. */
     145    void nativeHandlerForApplicationActivation(const QMap<QString, QString> &userInfo);
    141146#endif /* Q_WS_MAC */
    142147
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette