VirtualBox

Ignore:
Timestamp:
Feb 27, 2014 3:53:39 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: 7016: Native fullscreen multi-screen support: Fullscreen mode invalidation mechanism improvement.

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

    r50631 r50634  
    132132    if (!m_fullscreenMachineWindows.isEmpty())
    133133    {
    134         /* Ask remain window(s) to exit fullscreen too: */
    135         foreach (UIMachineWindow *pMachineWindow, machineWindows())
    136             if (darwinIsInFullscreenMode(pMachineWindow))
    137                 darwinToggleFullscreenMode(pMachineWindow);
     134        /* Exit fullscreen mode if it was not invalidated yet: */
     135        if (!m_fIsFullscreenInvalidated)
     136            emit sigNotifyAboutNativeFullscreenShouldBeExited();
    138137    }
    139138    /* If there is/are no more fullscreen window(s) left: */
     
    153152            foreach (UIMachineWindow *pMachineWindow, machineWindows())
    154153                pMachineWindow->showInNecessaryMode();
    155             /* Re-enter fullscreen mode: */
    156             foreach (UIMachineWindow *pMachineWindow, machineWindows())
    157                 if (   uisession()->isScreenVisible(pMachineWindow->screenId())
    158                     && (darwinScreensHaveSeparateSpaces() || pMachineWindow->screenId() == 0)
    159                     && !darwinIsInFullscreenMode(pMachineWindow))
    160                     darwinToggleFullscreenMode(pMachineWindow);
     154            /* Ask all window(s) to re-enter fullscreen mode: */
     155            emit sigNotifyAboutNativeFullscreenShouldBeEntered();
    161156        }
    162157        /* If fullscreen mode was manually exited: */
     
    186181        /* Request 'normal' (window) visual-state: */
    187182        uisession()->setRequestedVisualState(UIVisualStateType_Normal);
    188         /* Exit native fullscreen mode for each window: */
    189         foreach (UIMachineWindow *pMachineWindow, machineWindows())
    190             if (darwinIsInFullscreenMode(pMachineWindow))
    191                 darwinToggleFullscreenMode(pMachineWindow);
     183        /* Ask all window(s) to exit fullscreen mode: */
     184        emit sigNotifyAboutNativeFullscreenShouldBeExited();
    192185    }
    193186}
     
    203196        /* Request 'seamless' visual-state: */
    204197        uisession()->setRequestedVisualState(UIVisualStateType_Seamless);
    205         /* Exit native fullscreen mode for each window: */
    206         foreach (UIMachineWindow *pMachineWindow, machineWindows())
    207             if (darwinIsInFullscreenMode(pMachineWindow))
    208                 darwinToggleFullscreenMode(pMachineWindow);
     198        /* Ask all window(s) to exit fullscreen mode: */
     199        emit sigNotifyAboutNativeFullscreenShouldBeExited();
    209200    }
    210201}
     
    220211        /* Request 'scale' visual-state: */
    221212        uisession()->setRequestedVisualState(UIVisualStateType_Scale);
    222         /* Exit native fullscreen mode for each window: */
    223         foreach (UIMachineWindow *pMachineWindow, machineWindows())
    224             if (darwinIsInFullscreenMode(pMachineWindow))
    225                 darwinToggleFullscreenMode(pMachineWindow);
     213        /* Ask all window(s) to exit fullscreen mode: */
     214        emit sigNotifyAboutNativeFullscreenShouldBeExited();
    226215    }
    227216}
     
    270259    }
    271260    /* Invalidate fullscreen mode for ML and next: */
    272     else invalidateFullscreenMode();
     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    }
    273269#else /* !Q_WS_MAC */
    274270    /* Make sure all machine-window(s) have proper geometry: */
     
    292288        UIMachineLogic::sltGuestMonitorChange(changeType, uScreenId, screenGeo);
    293289    /* Invalidate fullscreen mode for ML and next: */
    294     else invalidateFullscreenMode();
     290    else if (shouldWeInvalidateFullscreenMode())
     291        invalidateFullscreenMode();
     292    /* Call to base-class otherwise: */
     293    else UIMachineLogic::sltGuestMonitorChange(changeType, uScreenId, screenGeo);
    295294#else /* !Q_WS_MAC */
    296295    /* Call to base-class: */
     
    311310        UIMachineLogic::sltHostScreenCountChanged();
    312311    /* Invalidate fullscreen mode for ML and next: */
    313     else invalidateFullscreenMode();
     312    else if (shouldWeInvalidateFullscreenMode())
     313        invalidateFullscreenMode();
     314    /* Call to base-class otherwise: */
     315    else UIMachineLogic::sltHostScreenCountChanged();
    314316#else /* !Q_WS_MAC */
    315317    /* Call to base-class: */
     
    391393    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
    392394    {
    393         /* For all the machine-window(s): */
     395        /* Enable native fullscreen support: */
    394396        foreach (UIMachineWindow *pMachineWindow, machineWindows())
    395397        {
    396             /* Watch for native fullscreen signals: */
     398            /* Logic => window signals: */
     399            connect(this, SIGNAL(sigNotifyAboutNativeFullscreenShouldBeEntered()),
     400                    pMachineWindow, SLOT(sltEnterNativeFullscreen()));
     401            connect(this, SIGNAL(sigNotifyAboutNativeFullscreenShouldBeExited()),
     402                    pMachineWindow, SLOT(sltExitNativeFullscreen()));
     403            /* Window => logic signals: */
    397404            connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidEnter()),
    398405                    this, SLOT(sltHandleNativeFullscreenDidEnter()));
    399406            connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidExit()),
    400407                    this, SLOT(sltHandleNativeFullscreenDidExit()));
    401             /* Enter native fullscreen mode: */
    402             if (   (darwinScreensHaveSeparateSpaces() || pMachineWindow->screenId() == 0)
    403                 && !darwinIsInFullscreenMode(pMachineWindow))
    404                 darwinToggleFullscreenMode(pMachineWindow);
    405         }
     408        }
     409        /* Ask all window(s) to enter fullscreen mode: */
     410        emit sigNotifyAboutNativeFullscreenShouldBeEntered();
    406411    }
    407412#endif /* Q_WS_MAC */
     
    508513}
    509514
     515bool UIMachineLogicFullscreen::shouldWeInvalidateFullscreenMode() const
     516{
     517    /* Prepare result: */
     518    bool fSomethingInvalid = false;
     519
     520    /* Enumerate windows: */
     521    foreach (UIMachineWindow *pMachineWindow, machineWindows())
     522    {
     523        /* Get screen ID: */
     524        ulong uScreenID = pMachineWindow->screenId();
     525        /* Check window which can be fullscreen: */
     526        if (uScreenID == 0 || darwinScreensHaveSeparateSpaces())
     527        {
     528            /* Check window which is not in fullscreen: */
     529            if (!darwinIsInFullscreenMode(pMachineWindow))
     530            {
     531                /* Check if that window should really
     532                 * be shown and is mapped to some host-screen: */
     533                if (   uisession()->isScreenVisible(uScreenID)
     534                    && hasHostScreenForGuestScreen(uScreenID))
     535                {
     536                    fSomethingInvalid = true;
     537                    break;
     538                }
     539            }
     540            /* Check window which is in fullscreen: */
     541            else
     542            {
     543                /* Check if that window shouldn't really
     544                 * be shown or isn't mapped to some host-screen: */
     545                if (   !uisession()->isScreenVisible(uScreenID)
     546                    || !hasHostScreenForGuestScreen(uScreenID))
     547                {
     548                    fSomethingInvalid = true;
     549                    break;
     550                }
     551            }
     552        }
     553    }
     554
     555    /* Return result: */
     556    return fSomethingInvalid;
     557}
     558
    510559void UIMachineLogicFullscreen::invalidateFullscreenMode()
    511560{
     
    514563        return;
    515564
     565    LogRel(("UIMachineLogicFullscreen::invalidateFullscreenMode: "
     566            "Fullscreen mode invalidated...\n"));
     567
    516568    /* Mark 'fullscreen' mode as invalidated: */
    517569    m_fIsFullscreenInvalidated = true;
    518570
    519     /* Exit fullscreen mode: */
    520     foreach (UIMachineWindow *pMachineWindow, machineWindows())
    521         if (darwinIsInFullscreenMode(pMachineWindow))
    522             darwinToggleFullscreenMode(pMachineWindow);
    523 }
    524 #endif /* Q_WS_MAC */
    525 
     571    /* Ask all window(s) to exit fullscreen mode: */
     572    emit sigNotifyAboutNativeFullscreenShouldBeExited();
     573}
     574#endif /* Q_WS_MAC */
     575
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h

    r50573 r50634  
    2828{
    2929    Q_OBJECT;
     30
     31#ifdef RT_OS_DARWIN
     32signals:
     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();
     37#endif /* RT_OS_DARWIN */
    3038
    3139protected:
     
    96104    void setPresentationModeEnabled(bool fEnabled);
    97105
     106    /** Mac OS X: Checks if 'fullscreen' mode should be invalidated. */
     107    bool shouldWeInvalidateFullscreenMode() const;
    98108    /** Mac OS X: Invalidates 'fullscreen' mode. */
    99109    void invalidateFullscreenMode();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r50631 r50634  
    9191    }
    9292}
     93
     94#ifdef Q_WS_MAC
     95void UIMachineWindowFullscreen::sltEnterNativeFullscreen()
     96{
     97    /* Make sure this slot is called only under ML and next: */
     98    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
     99
     100    /* Make sure this window should be shown at all: */
     101    if (!uisession()->isScreenVisible(m_uScreenId))
     102        return;
     103
     104    /* Make sure this window has fullscreen logic: */
     105    UIMachineLogicFullscreen *pFullscreenLogic = qobject_cast<UIMachineLogicFullscreen*>(machineLogic());
     106    if (!pFullscreenLogic)
     107        return;
     108
     109    /* Make sure this window mapped to some host-screen: */
     110    if (!pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
     111        return;
     112
     113    /* Enter native fullscreen mode if necessary: */
     114    if (   (darwinScreensHaveSeparateSpaces() || m_uScreenId == 0)
     115        && !darwinIsInFullscreenMode(this))
     116        darwinToggleFullscreenMode(this);
     117}
     118
     119void UIMachineWindowFullscreen::sltExitNativeFullscreen()
     120{
     121    /* Make sure this slot is called only under ML and next: */
     122    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
     123
     124    /* Exit native fullscreen mode if necessary: */
     125    if (   (darwinScreensHaveSeparateSpaces() || m_uScreenId == 0)
     126        && darwinIsInFullscreenMode(this))
     127        darwinToggleFullscreenMode(this);
     128}
     129#endif /* Q_WS_MAC */
    93130
    94131void UIMachineWindowFullscreen::prepareMenu()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h

    r50535 r50634  
    5757    void sltPopupMainMenu();
    5858
     59#ifdef RT_OS_DARWIN
     60    /** Mac OS X: Commands window to enter native 'fullscreen' mode if possible. */
     61    void sltEnterNativeFullscreen();
     62    /** Mac OS X: Commands window to exit native 'fullscreen' mode if possible. */
     63    void sltExitNativeFullscreen();
     64#endif /* RT_OS_DARWIN */
     65
    5966private:
    6067
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