VirtualBox

Changeset 98432 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 2, 2023 12:15:11 PM (23 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Pass machine-state stuff through UIMachine to detach rest of Runtime UI from UISession.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
14 edited

Legend:

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

    r98424 r98432  
    522522    void sltHandleMachineStateChange()
    523523    {
    524         if (m_pSession->machineState() == KMachineState_Running)
     524        if (m_pMachine->machineState() == KMachineState_Running)
    525525        {
    526526            /* Start auto-update timer otherwise: */
     
    10681068    void sltHandleMachineStateChange()
    10691069    {
    1070         if (m_pSession->machineState() == KMachineState_Running)
     1070        if (m_pMachine->machineState() == KMachineState_Running)
    10711071        {
    10721072            /* Start auto-update timer otherwise: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r98425 r98432  
    911911{
    912912    /* Get machine state: */
    913     KMachineState state = uisession()->machineState();
     913    KMachineState state = uimachine()->machineState();
    914914    /* Handle particular machine states: */
    915915    switch (state)
     
    12541254                {
    12551255                    /* Show a possible warning on key release which seems to be more expected by the end user: */
    1256                     if (uisession()->isPaused())
     1256                    if (uimachine()->isPaused())
    12571257                        UINotificationMessage::remindAboutPausedVMInput();
    12581258                }
     
    17451745
    17461746    /* If the VM is NOT paused: */
    1747     if (!uisession()->isPaused())
     1747    if (!uimachine()->isPaused())
    17481748    {
    17491749        /* If there are scan-codes to send: */
     
    19711971bool UIKeyboardHandler::isSessionRunning()
    19721972{
    1973     return uisession()->isRunning();
     1973    return uimachine()->isRunning();
    19741974}
    19751975
    19761976bool UIKeyboardHandler::isSessionStuck()
    19771977{
    1978     return uisession()->isStuck();
     1978    return uimachine()->isStuck();
    19791979}
    19801980
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98427 r98432  
    283283    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(comServer.GetEnabled());
    284284    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(false);
     285}
     286
     287KMachineState UIMachine::machineState() const
     288{
     289    return uisession()->machineState();
     290}
     291
     292void UIMachine::forgetPreviousMachineState()
     293{
     294    uisession()->forgetPreviousMachineState();
     295}
     296
     297bool UIMachine::isTurnedOff() const
     298{
     299    return uisession()->isTurnedOff();
     300}
     301
     302bool UIMachine::isPaused() const
     303{
     304    return uisession()->isPaused();
     305}
     306
     307bool UIMachine::wasPaused() const
     308{
     309    return uisession()->wasPaused();
     310}
     311
     312bool UIMachine::isRunning() const
     313{
     314    return uisession()->isRunning();
     315}
     316
     317bool UIMachine::isStuck() const
     318{
     319    return uisession()->isStuck();
     320}
     321
     322bool UIMachine::isGuestScreenUnDrawable() const
     323{
     324    return uisession()->isGuestScreenUnDrawable();
     325}
     326
     327bool UIMachine::pause()
     328{
     329    return uisession()->pause();
     330}
     331
     332bool UIMachine::unpause()
     333{
     334    return uisession()->unpause();
     335}
     336
     337bool UIMachine::setPause(bool fPause)
     338{
     339    return uisession()->setPause(fPause);
    285340}
    286341
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98427 r98432  
    209209    /** @} */
    210210
     211    /** @name Machine-state stuff.
     212     ** @{ */
     213        /** Returns machine state. */
     214        KMachineState machineState() const;
     215
     216        /** Resets previous state to be the same as current one. */
     217        void forgetPreviousMachineState();
     218
     219        /** Returns whether VM is in one of turned off states. */
     220        bool isTurnedOff() const;
     221        /** Returns whether VM is in one of paused states. */
     222        bool isPaused() const;
     223        /** Returns whether VM was in one of paused states. */
     224        bool wasPaused() const;
     225        /** Returns whether VM is in one of running states. */
     226        bool isRunning() const;
     227        /** Returns whether VM is in one of stuck states. */
     228        bool isStuck() const;
     229        /** Returns whether VM is one of states where guest-screen is undrawable. */
     230        bool isGuestScreenUnDrawable() const;
     231
     232        /** Performes VM pausing. */
     233        bool pause();
     234        /** Performes VM resuming. */
     235        bool unpause();
     236        /** Performes VM pausing/resuming depending on @a fPause state. */
     237        bool setPause(bool fPause);
     238    /** @} */
     239
    211240    /** @name Host-screen stuff.
    212241     ** @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98425 r98432  
    447447{
    448448    /* Get machine state: */
    449     KMachineState state = uisession()->machineState();
     449    KMachineState state = uimachine()->machineState();
    450450
    451451    /* Update action groups: */
    452     m_pRunningActions->setEnabled(uisession()->isRunning());
    453     m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused());
    454     m_pRunningOrPausedOrStackedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused() || uisession()->isStuck());
     452    m_pRunningActions->setEnabled(uimachine()->isRunning());
     453    m_pRunningOrPausedActions->setEnabled(uimachine()->isRunning() || uimachine()->isPaused());
     454    m_pRunningOrPausedOrStackedActions->setEnabled(uimachine()->isRunning() || uimachine()->isPaused() || uimachine()->isStuck());
    455455
    456456    switch (state)
     
    851851     * & we are in an state where the framebuffer is likely valid. Otherwise to
    852852     * the overlay stuff only. */
    853     KMachineState state = uisession()->machineState();
     853    KMachineState state = uimachine()->machineState();
    854854    if (m_fIsDockIconEnabled &&
    855855        (state == KMachineState_Running ||
     
    17371737void UIMachineLogic::sltPause(bool fOn)
    17381738{
    1739     uisession()->setPause(fOn);
     1739    uimachine()->setPause(fOn);
    17401740}
    17411741
     
    17481748{
    17491749    /* Make sure machine is in one of the allowed states: */
    1750     if (!uisession()->isRunning() && !uisession()->isPaused())
     1750    if (!uimachine()->isRunning() && !uimachine()->isPaused())
    17511751    {
    17521752        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     
    17611761{
    17621762    /* Make sure machine is in one of the allowed states: */
    1763     if (!uisession()->isRunning() && !uisession()->isPaused())
     1763    if (!uimachine()->isRunning() && !uimachine()->isPaused())
    17641764    {
    17651765        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     
    17741774{
    17751775    /* Make sure machine is in one of the allowed states: */
    1776     if (!uisession()->isRunning())
     1776    if (!uimachine()->isRunning())
    17771777    {
    17781778        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     
    17871787{
    17881788    /* Make sure machine is in one of the allowed states: */
    1789     if (!uisession()->isRunning() && !uisession()->isPaused() && !uisession()->isStuck())
     1789    if (!uimachine()->isRunning() && !uimachine()->isPaused() && !uimachine()->isStuck())
    17901790    {
    17911791        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r98425 r98432  
    603603
    604604    /* In some situations especially in some VM states, guest-screen is not drawable: */
    605     if (uisession()->isGuestScreenUnDrawable())
     605    if (uimachine()->isGuestScreenUnDrawable())
    606606        return;
    607607
     
    10531053{
    10541054    /* Get machine state: */
    1055     KMachineState state = uisession()->machineState();
     1055    KMachineState state = uimachine()->machineState();
    10561056    switch (state)
    10571057    {
     
    19901990#ifdef VBOX_WS_MAC
    19911991    /* Update the dock icon if we are in the running state: */
    1992     if (uisession()->isRunning())
     1992    if (uimachine()->isRunning())
    19931993        updateDockIcon();
    19941994#endif /* VBOX_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r98422 r98432  
    275275    {
    276276        /* Make sure machine state is one of valid: */
    277         const KMachineState enmState = uisession()->machineState();
     277        const KMachineState enmState = uimachine()->machineState();
    278278        if (enmState == KMachineState_Null)
    279279            return;
     
    381381
    382382    /* Make sure machine is in one of the allowed states: */
    383     if (!uisession()->isRunning() && !uisession()->isPaused() && !uisession()->isStuck())
     383    if (!uimachine()->isRunning() && !uimachine()->isPaused() && !uimachine()->isStuck())
    384384    {
    385385#if defined(VBOX_IS_QT6_OR_LATER) && defined(VBOX_WS_MAC) /** @todo qt6 ... */
     
    390390        /** @todo qt6: This could easily be caused by something else, but needs to be
    391391         * looked at by a proper GUI expert.  */
    392         if (uisession()->isTurnedOff()) /** @todo qt6: Better state check here? */
     392        if (uimachine()->isTurnedOff()) /** @todo qt6: Better state check here? */
    393393            pCloseEvent->accept();
    394394#endif
     
    421421            case MachineCloseAction_SaveState:
    422422            case MachineCloseAction_Shutdown:
    423                 closeAction = uisession()->isStuck() ? MachineCloseAction_Invalid : defaultCloseAction;
     423                closeAction = uimachine()->isStuck() ? MachineCloseAction_Invalid : defaultCloseAction;
    424424                break;
    425425            /* Otherwise we just use what we have: */
     
    448448            bool fShowCloseDialog = true;
    449449            /* Check if VM is paused or stuck: */
    450             const bool fWasPaused = uisession()->isPaused();
    451             const bool fIsStuck = uisession()->isStuck();
     450            const bool fWasPaused = uimachine()->isPaused();
     451            const bool fIsStuck = uimachine()->isStuck();
    452452            /* If VM is NOT paused and NOT stuck: */
    453453            if (!fWasPaused && !fIsStuck)
    454454            {
    455455                /* We should pause it first: */
    456                 const bool fIsPaused = uisession()->pause();
     456                const bool fIsPaused = uimachine()->pause();
    457457                /* If we were unable to pause VM: */
    458458                if (!fIsPaused)
     
    488488                /* If VM was not paused before but paused now,
    489489                 * we should resume it if user canceled dialog or chosen shutdown: */
    490                 if (!fWasPaused && uisession()->isPaused() &&
     490                if (!fWasPaused && uimachine()->isPaused() &&
    491491                    (closeAction == MachineCloseAction_Invalid ||
    492492                     closeAction == MachineCloseAction_Detach ||
     
    494494                {
    495495                    /* If we unable to resume VM, cancel closing: */
    496                     if (!uisession()->unpause())
     496                    if (!uimachine()->unpause())
    497497                        closeAction = MachineCloseAction_Invalid;
    498498                }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r98425 r98432  
    373373{
    374374    /* Get machine state: */
    375     KMachineState machineState = uisession()->machineState();
     375    KMachineState machineState = uimachine()->machineState();
    376376    /* Handle particular machine states: */
    377377    switch (machineState)
     
    447447    {
    448448        /* Do not annoy user while restoring VM: */
    449         if (uisession()->machineState() != KMachineState_Restoring)
     449        if (uimachine()->machineState() != KMachineState_Restoring)
    450450            UINotificationMessage::remindAboutMouseIntegration(uimachine()->isMouseSupportsAbsolute());
    451451    }
     
    463463     * 2. machine is NOT 'paused' and mouse is NOT 'captured' and 'integrated' and 'absolute' but host pointer is 'hidden' by the guest. */
    464464    if (uimachine()->isMouseCaptured() ||
    465         (!uisession()->isPaused() &&
     465        (!uimachine()->isPaused() &&
    466466         uimachine()->isMouseIntegrated() &&
    467467         uimachine()->isMouseSupportsAbsolute() &&
     
    477477    /* Otherwise we should show host pointer with guest shape assigned to it if:
    478478     * machine is NOT 'paused', mouse is 'integrated' and 'absolute' and valid pointer shape is present. */
    479     if (!uisession()->isPaused() &&
     479    if (!uimachine()->isPaused() &&
    480480        uimachine()->isMouseIntegrated() &&
    481481        uimachine()->isMouseSupportsAbsolute() &&
     
    927927
    928928    /* Check if machine is still running: */
    929     if (!uisession()->isRunning())
     929    if (!uimachine()->isRunning())
    930930        return true;
    931931
     
    11641164            if (m_views[uScreenId]->hasFocus() && (iEventType == QEvent::MouseButtonRelease && mouseButtons == Qt::NoButton))
    11651165            {
    1166                 if (uisession()->isPaused())
     1166                if (uimachine()->isPaused())
    11671167                    UINotificationMessage::remindAboutPausedVMInput();
    1168                 else if (uisession()->isRunning())
     1168                else if (uimachine()->isRunning())
    11691169                {
    11701170                    /* Temporarily disable auto capture that will take place after this dialog is dismissed because
     
    12001200{
    12011201    /* Eat if machine isn't running: */
    1202     if (!uisession()->isRunning())
     1202    if (!uimachine()->isRunning())
    12031203        return true;
    12041204
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98427 r98432  
    871871    if (sig == SIGUSR1)
    872872        if (gpMachine)
    873             gpMachine->uisession()->machineLogic()->keyboardHandler()->releaseAllPressedKeys();
     873            gpMachine->machineLogic()->keyboardHandler()->releaseAllPressedKeys();
    874874}
    875875#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r98423 r98432  
    342342{
    343343    LogRel(("GUI: UIMachineLogicFullscreen::sltCheckForRequestedVisualStateType: Requested-state=%d, Machine-state=%d\n",
    344             uimachine()->requestedVisualState(), uisession()->machineState()));
     344            uimachine()->requestedVisualState(), uimachine()->machineState()));
    345345
    346346    /* Do not try to change visual-state type if machine was not started yet: */
    347     if (!uisession()->isRunning() && !uisession()->isPaused())
     347    if (!uimachine()->isRunning() && !uimachine()->isPaused())
    348348        return;
    349349
     
    376376
    377377    /* If machine-state changed from 'paused' to 'running': */
    378     if (uisession()->isRunning() && uisession()->wasPaused())
     378    if (uimachine()->isRunning() && uimachine()->wasPaused())
    379379    {
    380380        LogRel(("GUI: UIMachineLogicFullscreen::sltMachineStateChanged:"
     
    383383
    384384        /* Make sure further code will be called just once: */
    385         uisession()->forgetPreviousMachineState();
     385        uimachine()->forgetPreviousMachineState();
    386386        /* Adjust machine-window geometry if necessary: */
    387387        adjustMachineWindowsGeometry();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r98419 r98432  
    7373{
    7474    LogRel(("GUI: UIMachineLogicNormal::sltCheckForRequestedVisualStateType: Requested-state=%d, Machine-state=%d\n",
    75             uimachine()->requestedVisualState(), uisession()->machineState()));
     75            uimachine()->requestedVisualState(), uimachine()->machineState()));
    7676
    7777    /* Do not try to change visual-state type if machine was not started yet: */
    78     if (!uisession()->isRunning() && !uisession()->isPaused())
     78    if (!uimachine()->isRunning() && !uimachine()->isPaused())
    7979        return;
    8080
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r98423 r98432  
    203203    /* Update status-bar indicators-pool: */
    204204    if (m_pIndicatorsPool)
    205         m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uisession()->isRunning());
     205        m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uimachine()->isRunning());
    206206
    207207    /* Normalize geometry without moving: */
     
    391391        statusBar()->setVisible(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->isChecked());
    392392        if (m_pIndicatorsPool)
    393             m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uisession()->isRunning());
     393            m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uimachine()->isRunning());
    394394    }
    395395
     
    731731    if (   m_pIndicatorsPool
    732732        && iElement & UIVisualElement_IndicatorPoolStuff)
    733         m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uisession()->isRunning());
     733        m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uimachine()->isRunning());
    734734    /* Update status-bar indicator-pool appearance only when status-bar is visible: */
    735735    if (   m_pIndicatorsPool
     
    737737    {
    738738        /* If VM is running: */
    739         if (uisession()->isRunning())
     739        if (uimachine()->isRunning())
    740740        {
    741741            if (iElement & UIVisualElement_HDStuff)
     
    759759        }
    760760        /* If VM is running or paused: */
    761         if (uisession()->isRunning() || uisession()->isPaused())
     761        if (uimachine()->isRunning() || uimachine()->isPaused())
    762762        {
    763763            if (iElement & UIVisualElement_Recording)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r98419 r98432  
    118118{
    119119    LogRel(("GUI: UIMachineLogicSeamless::sltCheckForRequestedVisualStateType: Requested-state=%d, Machine-state=%d\n",
    120             uimachine()->requestedVisualState(), uisession()->machineState()));
     120            uimachine()->requestedVisualState(), uimachine()->machineState()));
    121121
    122122    /* Do not try to change visual-state type if machine was not started yet: */
    123     if (!uisession()->isRunning() && !uisession()->isPaused())
     123    if (!uimachine()->isRunning() && !uimachine()->isPaused())
    124124        return;
    125125
     
    144144
    145145    /* If machine-state changed from 'paused' to 'running': */
    146     if (uisession()->isRunning() && uisession()->wasPaused())
     146    if (uimachine()->isRunning() && uimachine()->wasPaused())
    147147    {
    148148        LogRel(("GUI: UIMachineLogicSeamless::sltMachineStateChanged:"
     
    151151
    152152        /* Make sure further code will be called just once: */
    153         uisession()->forgetPreviousMachineState();
     153        uimachine()->forgetPreviousMachineState();
    154154        /* Adjust machine-window geometry if necessary: */
    155155        adjustMachineWindowsGeometry();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r98386 r98432  
    142142{
    143143    /* Reset seamless feature flag if possible: */
    144     if (uisession()->isRunning())
     144    if (uimachine()->isRunning())
    145145        display().SetSeamlessMode(false);
    146146}
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