VirtualBox

Changeset 50679 in vbox


Ignore:
Timestamp:
Mar 4, 2014 3:39:12 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: 7016: Native fullscreen multi-screen support: *revalidation* mechanism which replaces *invalidation* one, it supports separate validation for each machine-window.

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  
    3030# include "UIExtraDataEventHandler.h"
    3131# include "VBoxUtils.h"
     32# include "UIFrameBuffer.h"
    3233# include <Carbon/Carbon.h>
    3334#endif /* Q_WS_MAC */
     
    3536UIMachineLogicFullscreen::UIMachineLogicFullscreen(QObject *pParent, UISession *pSession)
    3637    : UIMachineLogic(pParent, pSession, UIVisualStateType_Fullscreen)
    37 #ifdef Q_WS_MAC
    38     , m_fIsFullscreenInvalidated(false)
    39 #endif /* Q_WS_MAC */
    4038{
    4139    /* Create multiscreen layout: */
     
    129127    Q_UNUSED(fResult);
    130128
    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: */
    136152            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: */
    158155        else
    159156        {
     
    181178        /* Request 'normal' (window) visual-state: */
    182179        uisession()->setRequestedVisualState(UIVisualStateType_Normal);
    183         /* Ask all window(s) to exit fullscreen mode: */
     180        /* Ask window(s) to exit 'fullscreen' mode: */
    184181        emit sigNotifyAboutNativeFullscreenShouldBeExited();
    185182    }
     
    196193        /* Request 'seamless' visual-state: */
    197194        uisession()->setRequestedVisualState(UIVisualStateType_Seamless);
    198         /* Ask all window(s) to exit fullscreen mode: */
     195        /* Ask window(s) to exit 'fullscreen' mode: */
    199196        emit sigNotifyAboutNativeFullscreenShouldBeExited();
    200197    }
     
    211208        /* Request 'scale' visual-state: */
    212209        uisession()->setRequestedVisualState(UIVisualStateType_Scale);
    213         /* Ask all window(s) to exit fullscreen mode: */
     210        /* Ask window(s) to exit 'fullscreen' mode: */
    214211        emit sigNotifyAboutNativeFullscreenShouldBeExited();
    215212    }
     
    248245void UIMachineLogicFullscreen::sltScreenLayoutChanged()
    249246{
     247    LogRel(("UIMachineLogicFullscreen: Multi-screen layout changed.\n"));
     248
    250249#ifdef Q_WS_MAC
    251250    /* For Lion and previous: */
     
    258257        setPresentationModeEnabled(true);
    259258    }
    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();
    269261#else /* !Q_WS_MAC */
    270262    /* Make sure all machine-window(s) have proper geometry: */
     
    276268void UIMachineLogicFullscreen::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
    277269{
    278     LogRelFlow(("UIMachineLogicFullscreen: Guest-screen count changed.\n"));
     270    LogRel(("UIMachineLogicFullscreen: Guest-screen count changed.\n"));
    279271
    280272    /* Update multi-screen layout before any window update: */
     
    287279    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
    288280        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();
    294283#else /* !Q_WS_MAC */
    295284    /* Call to base-class: */
     
    300289void UIMachineLogicFullscreen::sltHostScreenCountChanged()
    301290{
    302     LogRelFlow(("UIMachineLogicFullscreen: Host-screen count changed.\n"));
     291    LogRel(("UIMachineLogicFullscreen: Host-screen count changed.\n"));
    303292
    304293    /* Update multi-screen layout before any window update: */
     
    309298    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
    310299        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();
    316302#else /* !Q_WS_MAC */
    317303    /* Call to base-class: */
     
    397383        {
    398384            /* 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*)));
    403389            /* Window => logic signals: */
    404390            connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidEnter()),
     
    407393                    this, SLOT(sltHandleNativeFullscreenDidExit()));
    408394        }
    409         /* Ask all window(s) to enter fullscreen mode: */
    410         emit sigNotifyAboutNativeFullscreenShouldBeEntered();
     395        /* Revalidate 'fullscreen' windows: */
     396        revalidateFullscreenWindows();
    411397    }
    412398#endif /* Q_WS_MAC */
     
    513499}
    514500
    515 bool UIMachineLogicFullscreen::shouldWeInvalidateFullscreenMode() const
    516 {
    517     /* Enumerate windows: */
     501void 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
     583void UIMachineLogicFullscreen::revalidateFullscreenWindows()
     584{
     585    /* Revalidate all fullscreen windows: */
    518586    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);
    576588}
    577589#endif /* Q_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h

    r50634 r50679  
    3131#ifdef RT_OS_DARWIN
    3232signals:
    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);
    3737#endif /* RT_OS_DARWIN */
    3838
     
    104104    void setPresentationModeEnabled(bool fEnabled);
    105105
    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();
    110110#endif /* Q_WS_MAC */
    111111
     
    116116    /** Mac OS X: Contains machine-window(s) marked as 'fullscreen'. */
    117117    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;
    120120#endif /* Q_WS_MAC */
    121121
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r50647 r50679  
    101101
    102102#ifdef Q_WS_MAC
    103 void UIMachineWindowFullscreen::sltEnterNativeFullscreen()
     103void UIMachineWindowFullscreen::sltEnterNativeFullscreen(UIMachineWindow *pMachineWindow)
    104104{
    105105    /* Make sure this slot is called only under ML and next: */
    106106    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
     107
     108    /* Make sure it is NULL or 'this' window passed: */
     109    if (pMachineWindow && pMachineWindow != this)
     110        return;
    107111
    108112    /* Make sure this window should be shown at all: */
     
    128132}
    129133
    130 void UIMachineWindowFullscreen::sltExitNativeFullscreen()
     134void UIMachineWindowFullscreen::sltExitNativeFullscreen(UIMachineWindow *pMachineWindow)
    131135{
    132136    /* Make sure this slot is called only under ML and next: */
    133137    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
     138
     139    /* Make sure it is NULL or 'this' window passed: */
     140    if (pMachineWindow && pMachineWindow != this)
     141        return;
    134142
    135143    /* Mark window 'transitioned from fullscreen': */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h

    r50647 r50679  
    6060
    6161#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);
    6666#endif /* RT_OS_DARWIN */
    6767
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