VirtualBox

Ignore:
Timestamp:
Feb 1, 2023 1:16:52 PM (2 years ago)
Author:
vboxsync
Message:

Merging r155287 and r155288 from gui4 branch: FE/Qt: Runtime UI: Moving host-screen & guest-screen handling stuff from UISession to UIMachine; Dangerous a bit.

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3:79645-79692
        21 /branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285
         21/branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288
        2222/trunk/src:92342,154921
  • trunk/src/VBox

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2/src/VBox:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3/src/VBox:79645-79692
        21 /branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285
         21/branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288
  • trunk/src/VBox/Frontends

    • Property svn:mergeinfo
      •  

        old new  
        1616/branches/dsen/gui2/src/VBox/Frontends:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        1717/branches/dsen/gui3/src/VBox/Frontends:79645-79692
        18 /branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285
         18/branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98385 r98386  
    3030# include <QBitmap>
    3131#endif
     32#ifdef VBOX_WS_MAC
     33# include <QTimer>
     34#endif
    3235
    3336/* GUI includes: */
    3437#include "UICommon.h"
     38#include "UIDesktopWidgetWatchdog.h"
    3539#include "UIExtraDataManager.h"
    3640#include "UIIconPool.h"
     
    4145#include "UIMachineWindow.h"
    4246#include "UIMessageCenter.h"
     47#ifdef VBOX_WS_MAC
     48# include "UICocoaApplication.h"
     49# include "VBoxUtils-darwin.h"
     50#endif
    4351
    4452/* COM includes: */
     53#include "CConsole.h"
     54#include "CGraphicsAdapter.h"
    4555#include "CMachine.h"
     56#include "CProgress.h"
    4657#include "CSession.h"
    47 #include "CConsole.h"
    4858#include "CSnapshot.h"
    49 #include "CProgress.h"
     59
     60
     61#ifdef VBOX_WS_MAC
     62/**
     63 * MacOS X: Application Services: Core Graphics: Display reconfiguration callback.
     64 *
     65 * Notifies UIMachine about @a display configuration change.
     66 * Corresponding change described by Core Graphics @a flags.
     67 * Uses UIMachine @a pHandler to process this change.
     68 *
     69 * @note Last argument (@a pHandler) must always be valid pointer to UIMachine object.
     70 * @note Calls for UIMachine::sltHandleHostDisplayAboutToChange() slot if display configuration changed.
     71 */
     72void cgDisplayReconfigurationCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *pHandler)
     73{
     74    /* Which flags we are handling? */
     75    int iHandledFlags = kCGDisplayAddFlag     /* display added */
     76                        | kCGDisplayRemoveFlag  /* display removed */
     77                        | kCGDisplaySetModeFlag /* display mode changed */;
     78
     79    /* Handle 'display-add' case: */
     80    if (flags & kCGDisplayAddFlag)
     81        LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display added.\n"));
     82    /* Handle 'display-remove' case: */
     83    else if (flags & kCGDisplayRemoveFlag)
     84        LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display removed.\n"));
     85    /* Handle 'mode-set' case: */
     86    else if (flags & kCGDisplaySetModeFlag)
     87        LogRelFlow(("GUI: UIMachine::cgDisplayReconfigurationCallback: Display mode changed.\n"));
     88
     89    /* Ask handler to process our callback: */
     90    if (flags & iHandledFlags)
     91        QTimer::singleShot(0, static_cast<UIMachine*>(pHandler),
     92                           SLOT(sltHandleHostDisplayAboutToChange()));
     93
     94    Q_UNUSED(display);
     95}
     96#endif /* VBOX_WS_MAC */
    5097
    5198
     
    169216}
    170217
     218bool UIMachine::isScreenVisibleHostDesires(ulong uScreenId) const
     219{
     220    /* Make sure index feats the bounds: */
     221    AssertReturn(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size(), false);
     222
     223    /* Return 'actual' (host-desire) visibility status: */
     224    return m_monitorVisibilityVectorHostDesires.value((int)uScreenId);
     225}
     226
     227void UIMachine::setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible)
     228{
     229    /* Make sure index feats the bounds: */
     230    AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size());
     231
     232    /* Remember 'actual' (host-desire) visibility status: */
     233    m_monitorVisibilityVectorHostDesires[(int)uScreenId] = fIsMonitorVisible;
     234
     235    /* And remember the request in extra data for guests with VMSVGA: */
     236    /* This should be done before the actual hint is sent in case the guest overrides it. */
     237    gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());
     238}
     239
     240bool UIMachine::isScreenVisible(ulong uScreenId) const
     241{
     242    /* Make sure index feats the bounds: */
     243    AssertReturn(uScreenId < (ulong)m_monitorVisibilityVector.size(), false);
     244
     245    /* Return 'actual' visibility status: */
     246    return m_monitorVisibilityVector.value((int)uScreenId);
     247}
     248
     249void UIMachine::setScreenVisible(ulong uScreenId, bool fIsMonitorVisible)
     250{
     251    /* Make sure index feats the bounds: */
     252    AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVector.size());
     253
     254    /* Remember 'actual' visibility status: */
     255    m_monitorVisibilityVector[(int)uScreenId] = fIsMonitorVisible;
     256    /* Remember 'desired' visibility status: */
     257    // See note in UIMachineView::sltHandleNotifyChange() regarding the graphics controller check. */
     258    if (uisession()->machine().GetGraphicsAdapter().GetGraphicsControllerType() != KGraphicsControllerType_VMSVGA)
     259        gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());
     260
     261    /* Make sure action-pool knows guest-screen visibility status: */
     262    uisession()->actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible);
     263}
     264
     265int UIMachine::countOfVisibleWindows()
     266{
     267    int cCountOfVisibleWindows = 0;
     268    for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)
     269        if (m_monitorVisibilityVector[i])
     270            ++cCountOfVisibleWindows;
     271    return cCountOfVisibleWindows;
     272}
     273
     274QList<int> UIMachine::listOfVisibleWindows() const
     275{
     276    QList<int> visibleWindows;
     277    for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)
     278        if (m_monitorVisibilityVector.at(i))
     279            visibleWindows.push_back(i);
     280    return visibleWindows;
     281}
     282
     283QSize UIMachine::lastFullScreenSize(ulong uScreenId) const
     284{
     285    /* Make sure index fits the bounds: */
     286    AssertReturn(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size(), QSize(-1, -1));
     287
     288    /* Return last full-screen size: */
     289    return m_monitorLastFullScreenSizeVector.value((int)uScreenId);
     290}
     291
     292void UIMachine::setLastFullScreenSize(ulong uScreenId, QSize size)
     293{
     294    /* Make sure index fits the bounds: */
     295    AssertReturnVoid(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size());
     296
     297    /* Remember last full-screen size: */
     298    m_monitorLastFullScreenSizeVector[(int)uScreenId] = size;
     299}
     300
    171301void UIMachine::closeRuntimeUI()
    172302{
     
    217347        enterInitialVisualState();
    218348    }
     349}
     350
     351void UIMachine::sltHandleHostScreenCountChange()
     352{
     353    LogRelFlow(("GUI: UIMachine: Host-screen count changed.\n"));
     354
     355    /* Recache display data: */
     356    updateHostScreenData();
     357
     358    /* Notify current machine-logic: */
     359    emit sigHostScreenCountChange();
     360}
     361
     362void UIMachine::sltHandleHostScreenGeometryChange()
     363{
     364    LogRelFlow(("GUI: UIMachine: Host-screen geometry changed.\n"));
     365
     366    /* Recache display data: */
     367    updateHostScreenData();
     368
     369    /* Notify current machine-logic: */
     370    emit sigHostScreenGeometryChange();
     371}
     372
     373void UIMachine::sltHandleHostScreenAvailableAreaChange()
     374{
     375    LogRelFlow(("GUI: UIMachine: Host-screen available-area changed.\n"));
     376
     377    /* Notify current machine-logic: */
     378    emit sigHostScreenAvailableAreaChange();
     379}
     380
     381#ifdef VBOX_WS_MAC
     382void UIMachine::sltHandleHostDisplayAboutToChange()
     383{
     384    LogRelFlow(("GUI: UIMachine::sltHandleHostDisplayAboutToChange()\n"));
     385
     386    if (m_pWatchdogDisplayChange->isActive())
     387        m_pWatchdogDisplayChange->stop();
     388    m_pWatchdogDisplayChange->setProperty("tryNumber", 1);
     389    m_pWatchdogDisplayChange->start();
     390}
     391
     392void UIMachine::sltCheckIfHostDisplayChanged()
     393{
     394    LogRelFlow(("GUI: UIMachine::sltCheckIfHostDisplayChanged()\n"));
     395
     396    /* Check if display count changed: */
     397    if (UIDesktopWidgetWatchdog::screenCount() != m_hostScreens.size())
     398    {
     399        /* Reset watchdog: */
     400        m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
     401        /* Notify listeners about screen-count changed: */
     402        return sltHandleHostScreenCountChange();
     403    }
     404    else
     405    {
     406        /* Check if at least one display geometry changed: */
     407        for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)
     408        {
     409            if (gpDesktop->screenGeometry(iScreenIndex) != m_hostScreens.at(iScreenIndex))
     410            {
     411                /* Reset watchdog: */
     412                m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
     413                /* Notify listeners about screen-geometry changed: */
     414                return sltHandleHostScreenGeometryChange();
     415            }
     416        }
     417    }
     418
     419    /* Check if watchdog expired, restart if not: */
     420    int cTryNumber = m_pWatchdogDisplayChange->property("tryNumber").toInt();
     421    if (cTryNumber > 0 && cTryNumber < 40)
     422    {
     423        /* Restart watchdog again: */
     424        m_pWatchdogDisplayChange->setProperty("tryNumber", ++cTryNumber);
     425        m_pWatchdogDisplayChange->start();
     426    }
     427    else
     428    {
     429        /* Reset watchdog: */
     430        m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
     431    }
     432}
     433#endif /* VBOX_WS_MAC */
     434
     435void UIMachine::sltHandleGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
     436{
     437    /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
     438    if (changeType == KGuestMonitorChangedEventType_NewOrigin)
     439        return;
     440    /* Ignore KGuestMonitorChangedEventType_Disabled event for primary screen: */
     441    AssertMsg(countOfVisibleWindows() > 0, ("All machine windows are hidden!"));
     442    if (changeType == KGuestMonitorChangedEventType_Disabled && uScreenId == 0)
     443        return;
     444
     445    /* Process KGuestMonitorChangedEventType_Enabled change event: */
     446    if (   !isScreenVisible(uScreenId)
     447        && changeType == KGuestMonitorChangedEventType_Enabled)
     448        setScreenVisible(uScreenId, true);
     449    /* Process KGuestMonitorChangedEventType_Disabled change event: */
     450    else if (   isScreenVisible(uScreenId)
     451             && changeType == KGuestMonitorChangedEventType_Disabled)
     452        setScreenVisible(uScreenId, false);
     453
     454    /* Notify listeners about the change: */
     455    emit sigGuestMonitorChange(changeType, uScreenId, screenGeo);
    219456}
    220457
     
    344581    , m_pMachineLogic(0)
    345582    , m_pMachineWindowIcon(0)
     583#ifdef VBOX_WS_MAC
     584    , m_pWatchdogDisplayChange(0)
     585#endif
    346586    , m_fNumLock(false)
    347587    , m_fCapsLock(false)
     
    385625    /* Prepare stuff: */
    386626    prepareSessionConnections();
     627    prepareScreens();
    387628    prepareMachineWindowIcon();
    388629    prepareMachineLogic();
     
    418659            this, &UIMachine::sigDnDModeChange);
    419660    connect(uisession(), &UISession::sigGuestMonitorChange,
    420             this, &UIMachine::sigGuestMonitorChange);
     661            this, &UIMachine::sltHandleGuestMonitorChange);
    421662    connect(uisession(), &UISession::sigMachineStateChange,
    422663            this, &UIMachine::sigMachineStateChange);
     
    457698}
    458699
     700void UIMachine::prepareScreens()
     701{
     702    /* Recache display data: */
     703    updateHostScreenData();
     704
     705#ifdef VBOX_WS_MAC
     706    /* Prepare display-change watchdog: */
     707    m_pWatchdogDisplayChange = new QTimer(this);
     708    {
     709        m_pWatchdogDisplayChange->setInterval(500);
     710        m_pWatchdogDisplayChange->setSingleShot(true);
     711        connect(m_pWatchdogDisplayChange, &QTimer::timeout,
     712                this, &UIMachine::sltCheckIfHostDisplayChanged);
     713    }
     714#endif /* VBOX_WS_MAC */
     715
     716#ifdef VBOX_WS_MAC
     717    /* Install native display reconfiguration callback: */
     718    CGDisplayRegisterReconfigurationCallback(cgDisplayReconfigurationCallback, this);
     719#else /* !VBOX_WS_MAC */
     720    /* Install Qt display reconfiguration callbacks: */
     721    connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenCountChanged,
     722            this, &UIMachine::sltHandleHostScreenCountChange);
     723    connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenResized,
     724            this, &UIMachine::sltHandleHostScreenGeometryChange);
     725# if defined(VBOX_WS_X11) && !defined(VBOX_GUI_WITH_CUSTOMIZATIONS1)
     726    connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaRecalculated,
     727            this, &UIMachine::sltHandleHostScreenAvailableAreaChange);
     728# else /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */
     729    connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaResized,
     730            this, &UIMachine::sltHandleHostScreenAvailableAreaChange);
     731# endif /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */
     732#endif /* !VBOX_WS_MAC */
     733
     734    /* Prepare initial screen visibility status: */
     735    m_monitorVisibilityVector.resize(uisession()->machine().GetGraphicsAdapter().GetMonitorCount());
     736    m_monitorVisibilityVector.fill(false);
     737    m_monitorVisibilityVector[0] = true;
     738
     739    /* Prepare empty last full-screen size vector: */
     740    m_monitorLastFullScreenSizeVector.resize(uisession()->machine().GetGraphicsAdapter().GetMonitorCount());
     741    m_monitorLastFullScreenSizeVector.fill(QSize(-1, -1));
     742
     743    /* If machine is in 'saved' state: */
     744    if (uisession()->isSaved())
     745    {
     746        /* Update screen visibility status from saved-state: */
     747        for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
     748        {
     749            BOOL fEnabled = true;
     750            ULONG uGuestOriginX = 0, uGuestOriginY = 0, uGuestWidth = 0, uGuestHeight = 0;
     751            uisession()->machine().QuerySavedGuestScreenInfo(iScreenIndex,
     752                                                             uGuestOriginX, uGuestOriginY,
     753                                                             uGuestWidth, uGuestHeight, fEnabled);
     754            m_monitorVisibilityVector[iScreenIndex] = fEnabled;
     755        }
     756        /* And make sure at least one of them is visible (primary if others are hidden): */
     757        if (countOfVisibleWindows() < 1)
     758            m_monitorVisibilityVector[0] = true;
     759    }
     760    else if (uiCommon().isSeparateProcess())
     761    {
     762        /* Update screen visibility status from display directly: */
     763        for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
     764        {
     765            KGuestMonitorStatus enmStatus = KGuestMonitorStatus_Disabled;
     766            ULONG uGuestWidth = 0, uGuestHeight = 0, uBpp = 0;
     767            LONG iGuestOriginX = 0, iGuestOriginY = 0;
     768            uisession()->display().GetScreenResolution(iScreenIndex,
     769                                                       uGuestWidth, uGuestHeight, uBpp,
     770                                                       iGuestOriginX, iGuestOriginY, enmStatus);
     771            m_monitorVisibilityVector[iScreenIndex] = (   enmStatus == KGuestMonitorStatus_Enabled
     772                                                       || enmStatus == KGuestMonitorStatus_Blank);
     773        }
     774        /* And make sure at least one of them is visible (primary if others are hidden): */
     775        if (countOfVisibleWindows() < 1)
     776            m_monitorVisibilityVector[0] = true;
     777    }
     778
     779    /* Prepare initial screen visibility status of host-desires (same as facts): */
     780    m_monitorVisibilityVectorHostDesires.resize(uisession()->machine().GetGraphicsAdapter().GetMonitorCount());
     781    for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
     782        m_monitorVisibilityVectorHostDesires[iScreenIndex] = m_monitorVisibilityVector[iScreenIndex];
     783
     784    /* Make sure action-pool knows guest-screen visibility status: */
     785    for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
     786        uisession()->actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_monitorVisibilityVector.at(iScreenIndex));
     787}
     788
    459789void UIMachine::prepareMachineWindowIcon()
    460790{
     
    535865}
    536866
     867void UIMachine::cleanupScreens()
     868{
     869#ifdef VBOX_WS_MAC
     870    /* Remove display reconfiguration callback: */
     871    CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this);
     872#endif /* VBOX_WS_MAC */
     873}
     874
    537875void UIMachine::cleanupSession()
    538876{
     
    550888    cleanupMachineLogic();
    551889    cleanupMachineWindowIcon();
     890    cleanupScreens();
    552891
    553892    /* Cleanup session UI: */
     
    558897{
    559898    sltChangeVisualState(m_initialVisualState);
     899}
     900
     901void UIMachine::updateHostScreenData()
     902{
     903    /* Rebuild host-screen data vector: */
     904    m_hostScreens.clear();
     905    for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)
     906        m_hostScreens << gpDesktop->screenGeometry(iScreenIndex);
     907
     908    /* Make sure action-pool knows host-screen count: */
     909    uisession()->actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size());
    560910}
    561911
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98385 r98386  
    5151class UISession;
    5252class UIMachineLogic;
     53#ifdef VBOX_WS_MAC
     54 class QTimer;
     55#endif
    5356
    5457/** Singleton QObject extension
     
    129132    /** @} */
    130133
     134    /** @name Host-screen stuff.
     135     ** @{ */
     136        /** Notifies about host-screen count change. */
     137        void sigHostScreenCountChange();
     138        /** Notifies about host-screen geometry change. */
     139        void sigHostScreenGeometryChange();
     140        /** Notifies about host-screen available-area change. */
     141        void sigHostScreenAvailableAreaChange();
     142    /** @} */
     143
    131144public:
    132145
     
    167180        QString machineWindowNamePostfix() const { return m_strMachineWindowNamePostfix; }
    168181#endif
     182    /** @} */
     183
     184    /** @name Host-screen stuff.
     185     ** @{ */
     186        /** Returns the list of host-screen geometries we currently have. */
     187        QList<QRect> hostScreens() const { return m_hostScreens; }
     188    /** @} */
     189
     190    /** @name Guest-screen stuff.
     191     ** @{ */
     192        /** Returns whether guest-screen with @a uScreenId specified is expected to be visible. */
     193        bool isScreenVisibleHostDesires(ulong uScreenId) const;
     194        /** Defines whether guest-screen with @a uScreenId specified is expected to be @a fVisible. */
     195        void setScreenVisibleHostDesires(ulong uScreenId, bool fVisible);
     196
     197        /** Returns whether guest-screen with @a uScreenId specified is actually visible. */
     198        bool isScreenVisible(ulong uScreenId) const;
     199        /** Defines whether guest-screen with @a uScreenId specified is actually @a fVisible. */
     200        void setScreenVisible(ulong uScreenId, bool fIsMonitorVisible);
     201
     202        /** Returns a number of visible guest-windows. */
     203        int countOfVisibleWindows();
     204        /** Returns the list of visible guest-windows. */
     205        QList<int> listOfVisibleWindows() const;
     206
     207        /** Returns last full-screen size for guest-screen with index @a uScreenId. */
     208        QSize lastFullScreenSize(ulong uScreenId) const;
     209        /** Defines last full-screen @a size for guest-screen with index @a uScreenId. */
     210        void setLastFullScreenSize(ulong uScreenId, QSize size);
    169211    /** @} */
    170212
     
    257299    /** Visual state-change handler. */
    258300    void sltChangeVisualState(UIVisualStateType visualStateType);
     301
     302    /** @name Host-screen stuff.
     303     * @{ */
     304        /** Handles host-screen count change. */
     305        void sltHandleHostScreenCountChange();
     306        /** Handles host-screen geometry change. */
     307        void sltHandleHostScreenGeometryChange();
     308        /** Handles host-screen available-area change. */
     309        void sltHandleHostScreenAvailableAreaChange();
     310
     311#ifdef VBOX_WS_MAC
     312        /** MacOS X: Restarts display-reconfiguration watchdog timer from the beginning.
     313          * @note Watchdog is trying to determine display reconfiguration in
     314          *       UISession::sltCheckIfHostDisplayChanged() slot every 500ms for 40 tries. */
     315        void sltHandleHostDisplayAboutToChange();
     316        /** MacOS X: Determines display reconfiguration.
     317          * @note Calls for UISession::sltHandleHostScreenCountChange() if screen count changed.
     318          * @note Calls for UISession::sltHandleHostScreenGeometryChange() if screen geometry changed. */
     319        void sltCheckIfHostDisplayChanged();
     320#endif /* VBOX_WS_MAC */
     321    /** @} */
     322
     323    /** @name Guest-screen stuff.
     324     * @{ */
     325        /** Handles guest-monitor state change. */
     326        void sltHandleGuestMonitorChange(KGuestMonitorChangedEventType enmChangeType, ulong uScreenId, QRect screenGeo);
     327    /** @} */
    259328
    260329    /** @name Keyboard stuff.
     
    301370    /** Prepare routine: Session connection stuff. */
    302371    void prepareSessionConnections();
     372    /** Prepare routine: Screens stuff. */
     373    void prepareScreens();
    303374    /** Prepare routine: Machine-window icon. */
    304375    void prepareMachineWindowIcon();
     
    313384    /** Cleanup routine: Machine-window icon. */
    314385    void cleanupMachineWindowIcon();
     386    /** Cleanup routine: Screens stuff. */
     387    void cleanupScreens();
    315388    /** Cleanup routine: Session stuff. */
    316389    void cleanupSession();
     
    320393    /** Moves VM to initial state. */
    321394    void enterInitialVisualState();
     395
     396    /** @name Host-screen stuff.
     397     * @{ */
     398        /** Update host-screen data. */
     399        void updateHostScreenData();
     400    /** @} */
    322401
    323402    /** @name Mouse cursor stuff.
     
    380459    /** @} */
    381460
     461    /** @name Host-screen stuff.
     462     * @{ */
     463        /** Holds the list of host-screen geometries we currently have. */
     464        QList<QRect>  m_hostScreens;
     465
     466#ifdef VBOX_WS_MAC
     467        /** Mac OS X: Watchdog timer looking for display reconfiguration. */
     468        QTimer *m_pWatchdogDisplayChange;
     469#endif
     470    /** @} */
     471
     472    /** @name Guest-screen stuff.
     473     * @{ */
     474        /** Holds the list of desired guest-screen visibility flags. */
     475        QVector<bool>  m_monitorVisibilityVectorHostDesires;
     476        /** Holds the list of actual guest-screen visibility flags. */
     477        QVector<bool>  m_monitorVisibilityVector;
     478
     479        /** Holds the list of guest-screen full-screen sizes. */
     480        QVector<QSize>  m_monitorLastFullScreenSizeVector;
     481    /** @} */
     482
    382483    /** @name Keyboard stuff.
    383484     ** @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98385 r98386  
    898898
    899899    /* We should watch for host-screen-change events: */
    900     connect(uisession(), &UISession::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange);
    901     connect(uisession(), &UISession::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange);
    902     connect(uisession(), &UISession::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange);
     900    connect(uimachine(), &UIMachine::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange);
     901    connect(uimachine(), &UIMachine::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange);
     902    connect(uimachine(), &UIMachine::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange);
    903903
    904904    /* We should notify about frame-buffer events: */
     
    12101210
    12111211    /* If we have more than one visible window: */
    1212     const QList<int> visibleWindowsList = uisession()->listOfVisibleWindows();
     1212    const QList<int> visibleWindowsList = uimachine()->listOfVisibleWindows();
    12131213    const int cVisibleGuestScreens = visibleWindowsList.size();
    12141214    if (cVisibleGuestScreens > 1)
     
    13221322        }
    13231323    }
    1324     const QList<int> visibleWindowsList = uisession()->listOfVisibleWindows();
     1324    const QList<int> visibleWindowsList = uimachine()->listOfVisibleWindows();
    13251325    const int cVisibleGuestScreens = visibleWindowsList.size();
    13261326    if (cVisibleGuestScreens > 1)
     
    14481448
    14491449    /* We should stop watching for host-screen-change events: */
    1450     disconnect(uisession(), &UISession::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange);
    1451     disconnect(uisession(), &UISession::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange);
    1452     disconnect(uisession(), &UISession::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange);
     1450    disconnect(uimachine(), &UIMachine::sigHostScreenCountChange, this, &UIMachineLogic::sltHostScreenCountChange);
     1451    disconnect(uimachine(), &UIMachine::sigHostScreenGeometryChange, this, &UIMachineLogic::sltHostScreenGeometryChange);
     1452    disconnect(uimachine(), &UIMachine::sigHostScreenAvailableAreaChange, this, &UIMachineLogic::sltHostScreenAvailableAreaChange);
    14531453
    14541454    /* We should stop notify about frame-buffer events: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r98385 r98386  
    630630
    631631        /* Forget the last full-screen size: */
    632         uisession()->setLastFullScreenSize(screenId(), QSize(-1, -1));
     632        uimachine()->setLastFullScreenSize(screenId(), QSize(-1, -1));
    633633    }
    634634    /* For other than 'scale' mode: */
     
    641641        m_sizeHintOverride = QSize(-1, -1);
    642642        if (visualStateType() == UIVisualStateType_Normal)
    643             uisession()->setLastFullScreenSize(screenId(), QSize(-1, -1));
     643            uimachine()->setLastFullScreenSize(screenId(), QSize(-1, -1));
    644644
    645645        /* Force machine-window update own layout: */
     
    782782        && (   (int)frameBuffer()->width() != size.width()
    783783            || (int)frameBuffer()->height() != size.height()
    784             || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))
     784            || uimachine()->isScreenVisible(screenId()) != uimachine()->isScreenVisibleHostDesires(screenId())))
    785785        setStoredGuestScreenSizeHint(size);
    786786
     
    789789    {
    790790        /* If host and guest have same opinion about guest-screen visibility: */
    791         if (uisession()->isScreenVisible(screenId()) == uisession()->isScreenVisibleHostDesires(screenId()))
     791        if (uimachine()->isScreenVisible(screenId()) == uimachine()->isScreenVisibleHostDesires(screenId()))
    792792        {
    793793            /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */
     
    797797                        (int)screenId(), size.width(), size.height()));
    798798                display().SetVideoModeHint(screenId(),
    799                                            uisession()->isScreenVisible(screenId()),
     799                                           uimachine()->isScreenVisible(screenId()),
    800800                                           false /* change origin? */,
    801801                                           0 /* origin x */,
     
    810810        {
    811811            /* If host desires to have guest-screen enabled and guest-screen is disabled, retrying: */
    812             if (uisession()->isScreenVisibleHostDesires(screenId()))
     812            if (uimachine()->isScreenVisibleHostDesires(screenId()))
    813813            {
    814814                /* Send enabling size-hint to the guest: */
     
    865865                    (int)screenId(), size.width(), size.height()));
    866866            display().SetVideoModeHint(screenId(),
    867                                        uisession()->isScreenVisible(screenId()),
     867                                       uimachine()->isScreenVisible(screenId()),
    868868                                       false /* change origin? */,
    869869                                       0 /* origin x */,
     
    896896
    897897    /* Update desirable screen status: */
    898     uisession()->setScreenVisibleHostDesires(screenId(), fEnabled);
     898    uimachine()->setScreenVisibleHostDesires(screenId(), fEnabled);
    899899
    900900    /* Send enabling size-hint: */
     
    917917            && (   frameBuffer()->width() != uWidth
    918918                || frameBuffer()->height() != uHeight
    919                 || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))
     919                || uimachine()->isScreenVisible(screenId()) != uimachine()->isScreenVisibleHostDesires(screenId())))
    920920            setStoredGuestScreenSizeHint(QSize(uWidth, uHeight));
    921921
     
    968968        && (   (int)frameBuffer()->width() != size.width()
    969969            || (int)frameBuffer()->height() != size.height()
    970             || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))
     970            || uimachine()->isScreenVisible(screenId()) != uimachine()->isScreenVisibleHostDesires(screenId())))
    971971        setStoredGuestScreenSizeHint(size);
    972972
     
    14791479    frameBufferSize = scaledForward(frameBufferSize);
    14801480    /* Check against the last full-screen size. */
    1481     if (frameBufferSize == uisession()->lastFullScreenSize(screenId()) && m_sizeHintOverride.isValid())
     1481    if (frameBufferSize == uimachine()->lastFullScreenSize(screenId()) && m_sizeHintOverride.isValid())
    14821482        return m_sizeHintOverride;
    14831483
     
    15621562
    15631563    /* If machine-window is visible: */
    1564     if (uisession()->isScreenVisible(m_uScreenId))
     1564    if (uimachine()->isScreenVisible(m_uScreenId))
    15651565    {
    15661566        /* For 'scale' mode: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp

    r98103 r98386  
    3737#include "UIFrameBuffer.h"
    3838#include "UISession.h"
     39#include "UIMachine.h"
    3940#include "UIMessageCenter.h"
    4041#include "UIExtraDataManager.h"
     
    139140            /* Then we have to disable excessive guest-screen: */
    140141            LogRel(("GUI: UIMultiScreenLayout::update: Disabling excessive guest-screen %d\n", iGuestScreen));
    141             m_pMachineLogic->uisession()->setScreenVisibleHostDesires(iGuestScreen, false);
     142            m_pMachineLogic->uimachine()->setScreenVisibleHostDesires(iGuestScreen, false);
    142143            m_pMachineLogic->display().SetVideoModeHint(iGuestScreen, false, false, 0, 0, 0, 0, 0, true);
    143144        }
     
    172173            LogRel(("GUI: UIMultiScreenLayout::update: Enabling guest-screen %d with following resolution: %dx%d\n",
    173174                    iGuestScreen, uWidth, uHeight));
    174             m_pMachineLogic->uisession()->setScreenVisibleHostDesires(iGuestScreen, true);
     175            m_pMachineLogic->uimachine()->setScreenVisibleHostDesires(iGuestScreen, true);
    175176            m_pMachineLogic->display().SetVideoModeHint(iGuestScreen, true, false, 0, 0, uWidth, uHeight, 32, true);
    176177        }
     
    277278    m_disabledGuestScreens.clear();
    278279    for (uint iGuestScreen = 0; iGuestScreen < m_cGuestScreens; ++iGuestScreen)
    279         if (m_pMachineLogic->uisession()->isScreenVisible(iGuestScreen))
     280        if (m_pMachineLogic->uimachine()->isScreenVisible(iGuestScreen))
    280281            m_guestScreens << iGuestScreen;
    281282        else
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98385 r98386  
    3030#include <QMenuBar>
    3131#include <QWidget>
    32 #ifdef VBOX_WS_MAC
    33 # include <QTimer>
    34 #endif
    3532#ifdef VBOX_WS_WIN
    3633# include <iprt/win/windows.h> /* Workaround for compile errors if included directly by QtWin. */
     
    4037/* GUI includes: */
    4138#include "UICommon.h"
    42 #include "UIDesktopWidgetWatchdog.h"
    4339#include "UIExtraDataManager.h"
    4440#include "UISession.h"
     
    5551#include "UIFrameBuffer.h"
    5652#include "UISettingsDialogSpecific.h"
    57 #ifdef VBOX_WS_MAC
    58 # include "UICocoaApplication.h"
    59 # include "VBoxUtils-darwin.h"
    60 #endif
    6153#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
    6254# include "UIKeyboardHandler.h"
     
    9486#endif
    9587
    96 #ifdef VBOX_WS_MAC
    97 /**
    98  * MacOS X: Application Services: Core Graphics: Display reconfiguration callback.
    99  *
    100  * Notifies UISession about @a display configuration change.
    101  * Corresponding change described by Core Graphics @a flags.
    102  * Uses UISession @a pHandler to process this change.
    103  *
    104  * @note Last argument (@a pHandler) must always be valid pointer to UISession object.
    105  * @note Calls for UISession::sltHandleHostDisplayAboutToChange() slot if display configuration changed.
    106  */
    107 void cgDisplayReconfigurationCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *pHandler)
    108 {
    109     /* Which flags we are handling? */
    110     int iHandledFlags = kCGDisplayAddFlag     /* display added */
    111                       | kCGDisplayRemoveFlag  /* display removed */
    112                       | kCGDisplaySetModeFlag /* display mode changed */;
    113 
    114     /* Handle 'display-add' case: */
    115     if (flags & kCGDisplayAddFlag)
    116         LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display added.\n"));
    117     /* Handle 'display-remove' case: */
    118     else if (flags & kCGDisplayRemoveFlag)
    119         LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display removed.\n"));
    120     /* Handle 'mode-set' case: */
    121     else if (flags & kCGDisplaySetModeFlag)
    122         LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display mode changed.\n"));
    123 
    124     /* Ask handler to process our callback: */
    125     if (flags & iHandledFlags)
    126         QTimer::singleShot(0, static_cast<UISession*>(pHandler),
    127                            SLOT(sltHandleHostDisplayAboutToChange()));
    128 
    129     Q_UNUSED(display);
    130 }
    131 #endif /* VBOX_WS_MAC */
    132 
    13388/* static */
    13489bool UISession::create(UISession *&pSession, UIMachine *pMachine)
     
    561516}
    562517
    563 void UISession::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
    564 {
    565     /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
    566     if (changeType == KGuestMonitorChangedEventType_NewOrigin)
    567         return;
    568     /* Ignore KGuestMonitorChangedEventType_Disabled event for primary screen: */
    569     AssertMsg(countOfVisibleWindows() > 0, ("All machine windows are hidden!"));
    570     if (changeType == KGuestMonitorChangedEventType_Disabled && uScreenId == 0)
    571         return;
    572 
    573     /* Process KGuestMonitorChangedEventType_Enabled change event: */
    574     if (   !isScreenVisible(uScreenId)
    575         && changeType == KGuestMonitorChangedEventType_Enabled)
    576         setScreenVisible(uScreenId, true);
    577     /* Process KGuestMonitorChangedEventType_Disabled change event: */
    578     else if (   isScreenVisible(uScreenId)
    579              && changeType == KGuestMonitorChangedEventType_Disabled)
    580         setScreenVisible(uScreenId, false);
    581 
    582     /* Notify listeners about the change: */
    583     emit sigGuestMonitorChange(changeType, uScreenId, screenGeo);
    584 }
    585 
    586518void UISession::sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent)
    587519{
     
    612544    emit sigAudioAdapterChange();
    613545
    614 }
    615 
    616 #ifdef RT_OS_DARWIN
    617 /**
    618  * MacOS X: Restarts display-reconfiguration watchdog timer from the beginning.
    619  * @note Watchdog is trying to determine display reconfiguration in
    620  *       UISession::sltCheckIfHostDisplayChanged() slot every 500ms for 40 tries.
    621  */
    622 void UISession::sltHandleHostDisplayAboutToChange()
    623 {
    624     LogRelFlow(("GUI: UISession::sltHandleHostDisplayAboutToChange()\n"));
    625 
    626     if (m_pWatchdogDisplayChange->isActive())
    627         m_pWatchdogDisplayChange->stop();
    628     m_pWatchdogDisplayChange->setProperty("tryNumber", 1);
    629     m_pWatchdogDisplayChange->start();
    630 }
    631 
    632 /**
    633  * MacOS X: Determines display reconfiguration.
    634  * @note Calls for UISession::sltHandleHostScreenCountChange() if screen count changed.
    635  * @note Calls for UISession::sltHandleHostScreenGeometryChange() if screen geometry changed.
    636  */
    637 void UISession::sltCheckIfHostDisplayChanged()
    638 {
    639     LogRelFlow(("GUI: UISession::sltCheckIfHostDisplayChanged()\n"));
    640 
    641     /* Check if display count changed: */
    642     if (UIDesktopWidgetWatchdog::screenCount() != m_hostScreens.size())
    643     {
    644         /* Reset watchdog: */
    645         m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
    646         /* Notify listeners about screen-count changed: */
    647         return sltHandleHostScreenCountChange();
    648     }
    649     else
    650     {
    651         /* Check if at least one display geometry changed: */
    652         for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)
    653         {
    654             if (gpDesktop->screenGeometry(iScreenIndex) != m_hostScreens.at(iScreenIndex))
    655             {
    656                 /* Reset watchdog: */
    657                 m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
    658                 /* Notify listeners about screen-geometry changed: */
    659                 return sltHandleHostScreenGeometryChange();
    660             }
    661         }
    662     }
    663 
    664     /* Check if watchdog expired, restart if not: */
    665     int cTryNumber = m_pWatchdogDisplayChange->property("tryNumber").toInt();
    666     if (cTryNumber > 0 && cTryNumber < 40)
    667     {
    668         /* Restart watchdog again: */
    669         m_pWatchdogDisplayChange->setProperty("tryNumber", ++cTryNumber);
    670         m_pWatchdogDisplayChange->start();
    671     }
    672     else
    673     {
    674         /* Reset watchdog: */
    675         m_pWatchdogDisplayChange->setProperty("tryNumber", 0);
    676     }
    677 }
    678 #endif /* RT_OS_DARWIN */
    679 
    680 void UISession::sltHandleHostScreenCountChange()
    681 {
    682     LogRelFlow(("GUI: UISession: Host-screen count changed.\n"));
    683 
    684     /* Recache display data: */
    685     updateHostScreenData();
    686 
    687     /* Notify current machine-logic: */
    688     emit sigHostScreenCountChange();
    689 }
    690 
    691 void UISession::sltHandleHostScreenGeometryChange()
    692 {
    693     LogRelFlow(("GUI: UISession: Host-screen geometry changed.\n"));
    694 
    695     /* Recache display data: */
    696     updateHostScreenData();
    697 
    698     /* Notify current machine-logic: */
    699     emit sigHostScreenGeometryChange();
    700 }
    701 
    702 void UISession::sltHandleHostScreenAvailableAreaChange()
    703 {
    704     LogRelFlow(("GUI: UISession: Host-screen available-area changed.\n"));
    705 
    706     /* Notify current machine-logic: */
    707     emit sigHostScreenAvailableAreaChange();
    708546}
    709547
     
    795633    , m_machineStatePrevious(KMachineState_Null)
    796634    , m_machineState(KMachineState_Null)
    797 #ifdef VBOX_WS_MAC
    798     , m_pWatchdogDisplayChange(0)
    799 #endif /* VBOX_WS_MAC */
    800635    , m_defaultCloseAction(MachineCloseAction_Invalid)
    801636    , m_restrictedCloseActions(MachineCloseAction_Invalid)
     
    835670    prepareActions();
    836671    prepareConnections();
    837     prepareScreens();
    838672    prepareSignalHandling();
    839673
     
    922756            this, &UISession::sigDnDModeChange);
    923757    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigGuestMonitorChange,
    924             this, &UISession::sltGuestMonitorChange);
     758            this, &UISession::sigGuestMonitorChange);
    925759    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMediumChange,
    926760            this, &UISession::sigMediumChange);
     
    1001835    /* UICommon connections: */
    1002836    connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UISession::sltDetachCOM);
    1003 
    1004 #ifdef VBOX_WS_MAC
    1005     /* Install native display reconfiguration callback: */
    1006     CGDisplayRegisterReconfigurationCallback(cgDisplayReconfigurationCallback, this);
    1007 #else /* !VBOX_WS_MAC */
    1008     /* Install Qt display reconfiguration callbacks: */
    1009     connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenCountChanged,
    1010             this, &UISession::sltHandleHostScreenCountChange);
    1011     connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenResized,
    1012             this, &UISession::sltHandleHostScreenGeometryChange);
    1013 # if defined(VBOX_WS_X11) && !defined(VBOX_GUI_WITH_CUSTOMIZATIONS1)
    1014     connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaRecalculated,
    1015             this, &UISession::sltHandleHostScreenAvailableAreaChange);
    1016 # else /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    1017     connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaResized,
    1018             this, &UISession::sltHandleHostScreenAvailableAreaChange);
    1019 # endif /* !VBOX_WS_X11 || VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    1020 #endif /* !VBOX_WS_MAC */
    1021 }
    1022 
    1023 void UISession::prepareScreens()
    1024 {
    1025     /* Recache display data: */
    1026     updateHostScreenData();
    1027 
    1028 #ifdef VBOX_WS_MAC
    1029     /* Prepare display-change watchdog: */
    1030     m_pWatchdogDisplayChange = new QTimer(this);
    1031     {
    1032         m_pWatchdogDisplayChange->setInterval(500);
    1033         m_pWatchdogDisplayChange->setSingleShot(true);
    1034         connect(m_pWatchdogDisplayChange, &QTimer::timeout,
    1035                 this, &UISession::sltCheckIfHostDisplayChanged);
    1036     }
    1037 #endif /* VBOX_WS_MAC */
    1038 
    1039     /* Prepare initial screen visibility status: */
    1040     m_monitorVisibilityVector.resize(machine().GetGraphicsAdapter().GetMonitorCount());
    1041     m_monitorVisibilityVector.fill(false);
    1042     m_monitorVisibilityVector[0] = true;
    1043 
    1044     /* Prepare empty last full-screen size vector: */
    1045     m_monitorLastFullScreenSizeVector.resize(machine().GetGraphicsAdapter().GetMonitorCount());
    1046     m_monitorLastFullScreenSizeVector.fill(QSize(-1, -1));
    1047 
    1048     /* If machine is in 'saved' state: */
    1049     if (isSaved())
    1050     {
    1051         /* Update screen visibility status from saved-state: */
    1052         for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
    1053         {
    1054             BOOL fEnabled = true;
    1055             ULONG uGuestOriginX = 0, uGuestOriginY = 0, uGuestWidth = 0, uGuestHeight = 0;
    1056             machine().QuerySavedGuestScreenInfo(iScreenIndex,
    1057                                                 uGuestOriginX, uGuestOriginY,
    1058                                                 uGuestWidth, uGuestHeight, fEnabled);
    1059             m_monitorVisibilityVector[iScreenIndex] = fEnabled;
    1060         }
    1061         /* And make sure at least one of them is visible (primary if others are hidden): */
    1062         if (countOfVisibleWindows() < 1)
    1063             m_monitorVisibilityVector[0] = true;
    1064     }
    1065     else if (uiCommon().isSeparateProcess())
    1066     {
    1067         /* Update screen visibility status from display directly: */
    1068         for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
    1069         {
    1070             KGuestMonitorStatus enmStatus = KGuestMonitorStatus_Disabled;
    1071             ULONG uGuestWidth = 0, uGuestHeight = 0, uBpp = 0;
    1072             LONG iGuestOriginX = 0, iGuestOriginY = 0;
    1073             display().GetScreenResolution(iScreenIndex,
    1074                                           uGuestWidth, uGuestHeight, uBpp,
    1075                                           iGuestOriginX, iGuestOriginY, enmStatus);
    1076             m_monitorVisibilityVector[iScreenIndex] = (   enmStatus == KGuestMonitorStatus_Enabled
    1077                                                        || enmStatus == KGuestMonitorStatus_Blank);
    1078         }
    1079         /* And make sure at least one of them is visible (primary if others are hidden): */
    1080         if (countOfVisibleWindows() < 1)
    1081             m_monitorVisibilityVector[0] = true;
    1082     }
    1083 
    1084     /* Prepare initial screen visibility status of host-desires (same as facts): */
    1085     m_monitorVisibilityVectorHostDesires.resize(machine().GetGraphicsAdapter().GetMonitorCount());
    1086     for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
    1087         m_monitorVisibilityVectorHostDesires[iScreenIndex] = m_monitorVisibilityVector[iScreenIndex];
    1088 
    1089     /* Make sure action-pool knows guest-screen visibility status: */
    1090     for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
    1091         actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_monitorVisibilityVector.at(iScreenIndex));
    1092837}
    1093838
     
    1174919}
    1175920
    1176 void UISession::cleanupConnections()
    1177 {
    1178 #ifdef VBOX_WS_MAC
    1179     /* Remove display reconfiguration callback: */
    1180     CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this);
    1181 #endif /* VBOX_WS_MAC */
    1182 }
    1183 
    1184921void UISession::cleanupActions()
    1185922{
     
    12731010    //cleanupSignalHandling();
    12741011    //cleanupScreens();
    1275     cleanupConnections();
     1012    //cleanupConnections();
    12761013    cleanupActions();
    12771014}
     
    14821219}
    14831220
    1484 bool UISession::isScreenVisibleHostDesires(ulong uScreenId) const
    1485 {
    1486     /* Make sure index feats the bounds: */
    1487     AssertReturn(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size(), false);
    1488 
    1489     /* Return 'actual' (host-desire) visibility status: */
    1490     return m_monitorVisibilityVectorHostDesires.value((int)uScreenId);
    1491 }
    1492 
    1493 void UISession::setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible)
    1494 {
    1495     /* Make sure index feats the bounds: */
    1496     AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVectorHostDesires.size());
    1497 
    1498     /* Remember 'actual' (host-desire) visibility status: */
    1499     m_monitorVisibilityVectorHostDesires[(int)uScreenId] = fIsMonitorVisible;
    1500 
    1501     /* And remember the request in extra data for guests with VMSVGA: */
    1502     /* This should be done before the actual hint is sent in case the guest overrides it. */
    1503     gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());
    1504 }
    1505 
    1506 bool UISession::isScreenVisible(ulong uScreenId) const
    1507 {
    1508     /* Make sure index feats the bounds: */
    1509     AssertReturn(uScreenId < (ulong)m_monitorVisibilityVector.size(), false);
    1510 
    1511     /* Return 'actual' visibility status: */
    1512     return m_monitorVisibilityVector.value((int)uScreenId);
    1513 }
    1514 
    1515 void UISession::setScreenVisible(ulong uScreenId, bool fIsMonitorVisible)
    1516 {
    1517     /* Make sure index feats the bounds: */
    1518     AssertReturnVoid(uScreenId < (ulong)m_monitorVisibilityVector.size());
    1519 
    1520     /* Remember 'actual' visibility status: */
    1521     m_monitorVisibilityVector[(int)uScreenId] = fIsMonitorVisible;
    1522     /* Remember 'desired' visibility status: */
    1523     /* See note in UIMachineView::sltHandleNotifyChange() regarding the graphics controller check. */
    1524     if (machine().GetGraphicsAdapter().GetGraphicsControllerType() != KGraphicsControllerType_VMSVGA)
    1525         gEDataManager->setLastGuestScreenVisibilityStatus(uScreenId, fIsMonitorVisible, uiCommon().managedVMUuid());
    1526 
    1527     /* Make sure action-pool knows guest-screen visibility status: */
    1528     actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible);
    1529 }
    1530 
    1531 QSize UISession::lastFullScreenSize(ulong uScreenId) const
    1532 {
    1533     /* Make sure index fits the bounds: */
    1534     AssertReturn(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size(), QSize(-1, -1));
    1535 
    1536     /* Return last full-screen size: */
    1537     return m_monitorLastFullScreenSizeVector.value((int)uScreenId);
    1538 }
    1539 
    1540 void UISession::setLastFullScreenSize(ulong uScreenId, QSize size)
    1541 {
    1542     /* Make sure index fits the bounds: */
    1543     AssertReturnVoid(uScreenId < (ulong)m_monitorLastFullScreenSizeVector.size());
    1544 
    1545     /* Remember last full-screen size: */
    1546     m_monitorLastFullScreenSizeVector[(int)uScreenId] = size;
    1547 }
    1548 
    1549 int UISession::countOfVisibleWindows()
    1550 {
    1551     int cCountOfVisibleWindows = 0;
    1552     for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)
    1553         if (m_monitorVisibilityVector[i])
    1554             ++cCountOfVisibleWindows;
    1555     return cCountOfVisibleWindows;
    1556 }
    1557 
    1558 QList<int> UISession::listOfVisibleWindows() const
    1559 {
    1560     QList<int> visibleWindows;
    1561     for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)
    1562         if (m_monitorVisibilityVector.at(i))
    1563             visibleWindows.push_back(i);
    1564     return visibleWindows;
    1565 }
    1566 
    15671221CMediumVector UISession::machineMedia() const
    15681222{
     
    16141268}
    16151269
    1616 void UISession::updateHostScreenData()
    1617 {
    1618     /* Rebuild host-screen data vector: */
    1619     m_hostScreens.clear();
    1620     for (int iScreenIndex = 0; iScreenIndex < UIDesktopWidgetWatchdog::screenCount(); ++iScreenIndex)
    1621         m_hostScreens << gpDesktop->screenGeometry(iScreenIndex);
    1622 
    1623     /* Make sure action-pool knows host-screen count: */
    1624     actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size());
    1625 }
    1626 
    16271270void UISession::updateActionRestrictions()
    16281271{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98385 r98386  
    134134    void sigCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY);
    135135
    136     /** Notifies about host-screen count change. */
    137     void sigHostScreenCountChange();
    138     /** Notifies about host-screen geometry change. */
    139     void sigHostScreenGeometryChange();
    140     /** Notifies about host-screen available-area change. */
    141     void sigHostScreenAvailableAreaChange();
    142 
    143136    /** Notifies about frame-buffer resize. */
    144137    void sigFrameBufferResize();
     
    191184    WId mainMachineWindowId() const;
    192185    UIMachineWindow *activeMachineWindow() const;
    193 
    194     /** @name Host-screen configuration variables.
    195      ** @{ */
    196     /** Returns the list of host-screen geometries we currently have. */
    197     QList<QRect> hostScreens() const { return m_hostScreens; }
    198     /** @} */
    199186
    200187    /** @name Application Close configuration stuff.
     
    262249    void forgetPreviousMachineState() { m_machineStatePrevious = m_machineState; }
    263250
    264     /* Screen visibility status for host-desires: */
    265     bool isScreenVisibleHostDesires(ulong uScreenId) const;
    266     void setScreenVisibleHostDesires(ulong uScreenId, bool fIsMonitorVisible);
    267 
    268     /* Screen visibility status: */
    269     bool isScreenVisible(ulong uScreenId) const;
    270     void setScreenVisible(ulong uScreenId, bool fIsMonitorVisible);
    271 
    272     /* Last screen full-screen size: */
    273     QSize lastFullScreenSize(ulong uScreenId) const;
    274     void setLastFullScreenSize(ulong uScreenId, QSize size);
    275 
    276251    /** Returns whether guest-screen is undrawable.
    277252     *  @todo: extend this method to all the states when guest-screen is undrawable. */
     
    310285    KParavirtProvider paraVirtProvider() const { return m_paraVirtProvider; }
    311286
    312     /** Returns the list of visible guest windows. */
    313     QList<int> listOfVisibleWindows() const;
    314 
    315287    /** Returns a vector of media attached to the machine. */
    316288    CMediumVector machineMedia() const;
     
    343315    void sltVRDEChange();
    344316    void sltRecordingChange();
    345     void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
    346317    /** Handles storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */
    347318    void sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent);
    348319    /** Handles audio adapter change. */
    349320    void sltAudioAdapterChange();
    350 
    351     /* Handlers: Display reconfiguration stuff: */
    352 #ifdef RT_OS_DARWIN
    353     void sltHandleHostDisplayAboutToChange();
    354     void sltCheckIfHostDisplayChanged();
    355 #endif /* RT_OS_DARWIN */
    356 
    357     /** Handles host-screen count change. */
    358     void sltHandleHostScreenCountChange();
    359     /** Handles host-screen geometry change. */
    360     void sltHandleHostScreenGeometryChange();
    361     /** Handles host-screen available-area change. */
    362     void sltHandleHostScreenAvailableAreaChange();
    363321
    364322    /** Handles signal about machine state saved.
     
    391349    void prepareActions();
    392350    void prepareConnections();
    393     void prepareScreens();
    394351    void prepareSignalHandling();
    395352
     
    398355
    399356    /* Cleanup helpers: */
    400     //void cleanupSignalHandling();
     357    //void cleanupSignalHandling() {}
    401358    //void cleanupScreens() {}
    402     void cleanupConnections();
     359    //void cleanupConnections() {}
    403360    void cleanupActions();
    404361    void cleanupFramebuffers();
     
    417374    bool mountAdHocImage(KDeviceType enmDeviceType, UIMediumDeviceType enmMediumType, const QString &strMediumName);
    418375    bool postprocessInitialization();
    419     int countOfVisibleWindows();
    420376    /** Loads VM settings. */
    421377    void loadVMSettings();
    422 
    423     /** Update host-screen data. */
    424     void updateHostScreenData();
    425378
    426379    /** Updates action restrictions. */
     
    461414#endif /* VBOX_WS_MAC */
    462415
    463     /* Screen visibility vector: */
    464     QVector<bool> m_monitorVisibilityVector;
    465 
    466     /* Screen visibility vector for host-desires: */
    467     QVector<bool> m_monitorVisibilityVectorHostDesires;
    468 
    469     /* Screen last full-screen size vector: */
    470     QVector<QSize> m_monitorLastFullScreenSizeVector;
    471 
    472416    /* Frame-buffers vector: */
    473417    QVector<UIFrameBuffer*> m_frameBufferVector;
     
    476420    KMachineState m_machineStatePrevious;
    477421    KMachineState m_machineState;
    478 
    479     /** @name Host-screen configuration variables.
    480      * @{ */
    481     /** Holds the list of host-screen geometries we currently have. */
    482     QList<QRect> m_hostScreens;
    483 #ifdef VBOX_WS_MAC
    484     /** Mac OS X: Watchdog timer looking for display reconfiguration. */
    485     QTimer *m_pWatchdogDisplayChange;
    486 #endif /* VBOX_WS_MAC */
    487     /** @} */
    488422
    489423    /** @name Application Close configuration variables.
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r98375 r98386  
    747747             * 1. should really be shown and
    748748             * 2. is mapped to some host-screen: */
    749             if (   uisession()->isScreenVisible(uScreenID)
     749            if (   uimachine()->isScreenVisible(uScreenID)
    750750                && hasHostScreenForGuestScreen(uScreenID))
    751751            {
     
    783783             * 2. isn't mapped to some host-screen or
    784784             * 3. should be located on another host-screen than currently. */
    785             if (   !uisession()->isScreenVisible(uScreenID)
     785            if (   !uimachine()->isScreenVisible(uScreenID)
    786786                || !hasHostScreenForGuestScreen(uScreenID)
    787787                || iWantedHostScreenIndex != iCurrentHostScreenIndex)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r98385 r98386  
    136136{
    137137    /* Step 1: Is guest-screen visible? */
    138     if (!uisession()->isScreenVisible(screenId()))
     138    if (!uimachine()->isScreenVisible(screenId()))
    139139    {
    140140        LogRel(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: "
     
    172172    sltPerformGuestResize(sizeToApply);
    173173    /* And remember the size to know what we are resizing out of when we exit: */
    174     uisession()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint));
     174    uimachine()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint));
    175175}
    176176
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r98103 r98386  
    3434
    3535/* GUI includes: */
     36#include "UIActionPoolRuntime.h"
    3637#include "UICommon.h"
    3738#include "UIDesktopWidgetWatchdog.h"
    3839#include "UIExtraDataManager.h"
    39 #include "UISession.h"
    40 #include "UIActionPoolRuntime.h"
     40#include "UIMachine.h"
     41#include "UIMachineView.h"
    4142#include "UIMachineLogicFullscreen.h"
    4243#include "UIMachineWindowFullscreen.h"
    43 #include "UIMachineView.h"
    4444#include "UINotificationCenter.h"
     45#include "UISession.h"
    4546#if   defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    4647# include "UIMachineDefs.h"
     
    183184
    184185    /* Make sure this window should be shown and mapped to host-screen: */
    185     if (!uisession()->isScreenVisible(m_uScreenId) ||
     186    if (!uimachine()->isScreenVisible(m_uScreenId) ||
    186187        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    187188        return;
     
    432433
    433434    /* If window shouldn't be shown or mapped to some host-screen: */
    434     if (!uisession()->isScreenVisible(m_uScreenId) ||
     435    if (!uimachine()->isScreenVisible(m_uScreenId) ||
    435436        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    436437    {
     
    460461
    461462    /* If window shouldn't be shown or mapped to some host-screen: */
    462     if (!uisession()->isScreenVisible(m_uScreenId) ||
     463    if (!uimachine()->isScreenVisible(m_uScreenId) ||
    463464        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    464465    {
     
    503504
    504505    /* If window shouldn't be shown or mapped to some host-screen: */
    505     if (!uisession()->isScreenVisible(m_uScreenId) ||
     506    if (!uimachine()->isScreenVisible(m_uScreenId) ||
    506507        !pFullscreenLogic->hasHostScreenForGuestScreen(m_uScreenId))
    507508    {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r98385 r98386  
    173173     * hardware as before shutdown), and notifying would interfere with the Windows
    174174     * guest driver which saves the video mode to the registry on shutdown. */
    175     uisession()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus());
     175    uimachine()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus());
    176176    display().SetVideoModeHint(screenId(),
    177177                               guestScreenVisibilityStatus(),
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r98385 r98386  
    618618{
    619619    /* Make sure this window should be shown at all: */
    620     if (!uisession()->isScreenVisible(m_uScreenId))
     620    if (!uimachine()->isScreenVisible(m_uScreenId))
    621621        return hide();
    622622
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r98103 r98386  
    3232/* GUI includes */
    3333#include "UICommon.h"
     34#include "UIDesktopWidgetWatchdog.h"
     35#include "UIExtraDataManager.h"
     36#include "UIFrameBuffer.h"
     37#include "UIMachine.h"
     38#include "UIMachineLogic.h"
     39#include "UIMachineViewScale.h"
     40#include "UIMachineWindow.h"
    3441#include "UISession.h"
    35 #include "UIMachineLogic.h"
    36 #include "UIMachineWindow.h"
    37 #include "UIMachineViewScale.h"
    38 #include "UIFrameBuffer.h"
    39 #include "UIExtraDataManager.h"
    40 #include "UIDesktopWidgetWatchdog.h"
    4142
    4243/* COM includes: */
     
    175176
    176177    /* Send saved size-hint to the guest: */
    177     uisession()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus());
     178    uimachine()->setScreenVisibleHostDesires(screenId(), guestScreenVisibilityStatus());
    178179    display().SetVideoModeHint(screenId(),
    179180                               guestScreenVisibilityStatus(),
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r98103 r98386  
    3939#include "UIDesktopWidgetWatchdog.h"
    4040#include "UIExtraDataManager.h"
    41 #include "UISession.h"
     41#include "UIMachine.h"
    4242#include "UIMachineLogic.h"
    4343#include "UIMachineWindowScale.h"
    4444#include "UIMachineView.h"
    4545#include "UINotificationCenter.h"
     46#include "UISession.h"
    4647#ifdef VBOX_WS_MAC
    4748# include "VBoxUtils.h"
     
    166167{
    167168    /* Make sure this window should be shown at all: */
    168     if (!uisession()->isScreenVisible(m_uScreenId))
     169    if (!uimachine()->isScreenVisible(m_uScreenId))
    169170        return hide();
    170171
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r98385 r98386  
    149149{
    150150    /* Step 1: Is guest-screen visible? */
    151     if (!uisession()->isScreenVisible(screenId()))
     151    if (!uimachine()->isScreenVisible(screenId()))
    152152    {
    153153        LogRel(("GUI: UIMachineViewSeamless::adjustGuestScreenSize: "
     
    177177    sltPerformGuestResize(sizeToApply);
    178178    /* And remember the size to know what we are resizing out of when we exit: */
    179     uisession()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint));
     179    uimachine()->setLastFullScreenSize(screenId(), scaledForward(desiredSizeHint));
    180180}
    181181
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r98103 r98386  
    3232
    3333/* GUI includes: */
     34#include "UIActionPoolRuntime.h"
    3435#include "UICommon.h"
    3536#include "UIDesktopWidgetWatchdog.h"
    3637#include "UIExtraDataManager.h"
     38#include "UIMachine.h"
     39#include "UIMachineLogicSeamless.h"
     40#include "UIMachineView.h"
     41#include "UIMachineWindowSeamless.h"
    3742#include "UISession.h"
    38 #include "UIActionPoolRuntime.h"
    39 #include "UIMachineLogicSeamless.h"
    40 #include "UIMachineWindowSeamless.h"
    41 #include "UIMachineView.h"
    4243#if   defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    4344# include "UIMachineDefs.h"
     
    250251
    251252    /* If window shouldn't be shown or mapped to some host-screen: */
    252     if (!uisession()->isScreenVisible(m_uScreenId) ||
     253    if (!uimachine()->isScreenVisible(m_uScreenId) ||
    253254        !pSeamlessLogic->hasHostScreenForGuestScreen(m_uScreenId))
    254255    {
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