VirtualBox

Changeset 86046 in vbox for trunk/src


Ignore:
Timestamp:
Sep 7, 2020 3:27:58 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9760. Decoupling auto resize action from GA existence and restoring the window size after a cold boot

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

Legend:

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

    r84990 r86046  
    683683    /* Update action states: */
    684684    LogRel3(("GUI: UIMachineLogic::sltAdditionsStateChanged: Adjusting actions availability according to GA state.\n"));
    685     actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->setEnabled(uisession()->isGuestSupportsGraphics());
    686685    actionPool()->action(UIActionIndexRT_M_View_T_Seamless)->setEnabled(uisession()->isVisualStateAllowed(UIVisualStateType_Seamless) &&
    687686                                                                        uisession()->isGuestSupportsSeamless());
     
    19791978
    19801979        /* Normalize window geometry: */
    1981         pMachineWindow->normalizeGeometry(true /* adjust position */);
     1980        pMachineWindow->normalizeGeometry(true /* adjust position */, true /* resize window to guest display size */);
    19821981    }
    19831982}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r84792 r86046  
    375375        if (visualStateType() == UIVisualStateType_Normal &&
    376376            frameBufferSizeNew != frameBufferSizeOld)
    377             machineWindow()->normalizeGeometry(true /* adjust position */);
     377            machineWindow()->normalizeGeometry(true /* adjust position */, machineWindow()->shouldResizeToGuestDisplay());
    378378    }
    379379
     
    10741074            /* Normalize 'normal' machine-window geometry: */
    10751075            if (visualStateType() == UIVisualStateType_Normal)
    1076                 machineWindow()->normalizeGeometry(true /* adjust position */);
     1076                machineWindow()->normalizeGeometry(true /* adjust position */, machineWindow()->shouldResizeToGuestDisplay());
    10771077        }
    10781078
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r84790 r86046  
    2424
    2525/* GUI includes: */
     26#include "UIActionPoolRuntime.h"
    2627#include "UICommon.h"
    2728#include "UIConverter.h"
     
    232233    /* Send machine-view size-hint to the guest: */
    233234    machineView()->resendSizeHint();
     235}
     236
     237bool UIMachineWindow::shouldResizeToGuestDisplay() const
     238{
     239    return actionPool() &&
     240           actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize) &&
     241           actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->isChecked();
    234242}
    235243
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r82968 r86046  
    9393    /** Adjusts machine-window size to correspond current machine-view size.
    9494      * @param fAdjustPosition determines whether is it necessary to adjust position too.
     95      * @param fResizeToGuestDisplay determines if is it necessary to resize the window to fit to guest display size.
    9596      * @note  Reimplemented in sub-classes. Base implementation does nothing. */
    96     virtual void normalizeGeometry(bool fAdjustPosition) { Q_UNUSED(fAdjustPosition); }
     97    virtual void normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay) { Q_UNUSED(fAdjustPosition); Q_UNUSED(fResizeToGuestDisplay);}
    9798
    9899    /** Adjusts machine-view size to correspond current machine-window size. */
     
    101102    /** Sends machine-view size-hint to the guest. */
    102103    virtual void sendMachineViewSizeHint();
     104
     105    /** Returns true if the machine window should resize to fit to the guest display. Relevant only in normal (windowed) case. */
     106    bool shouldResizeToGuestDisplay() const;
    103107
    104108#ifdef VBOX_WITH_MASKED_SEAMLESS
     
    111115#ifdef VBOX_WS_X11
    112116    /** X11: Performs machine-window geometry normalization. */
    113     void sltNormalizeGeometry() { normalizeGeometry(true /* adjust position */); }
     117    void sltNormalizeGeometry() { normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay()); }
    114118#endif /* VBOX_WS_X11 */
    115119
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r84702 r86046  
    155155
    156156    /* Normalize geometry without moving: */
    157     normalizeGeometry(false /* adjust position */);
     157    normalizeGeometry(false /* adjust position */, shouldResizeToGuestDisplay());
     158
    158159}
    159160
     
    189190
    190191    /* Normalize geometry without moving: */
    191     normalizeGeometry(false /* adjust position */);
     192    normalizeGeometry(false /* adjust position */, shouldResizeToGuestDisplay());
    192193}
    193194
     
    386387            else
    387388            {
    388                 /* Restore only window position: */
    389                 m_normalGeometry = QRect(geo.x(), geo.y(), width(), height());
     389                m_normalGeometry = geo;
    390390                UICommon::setTopLevelGeometry(this, m_normalGeometry);
    391391                /* And normalize to the optimal-size: */
    392                 normalizeGeometry(false /* adjust position */);
     392                normalizeGeometry(false /* adjust position */, shouldResizeToGuestDisplay());
    393393            }
    394394
     
    406406
    407407            /* Normalize to the optimal size: */
    408             normalizeGeometry(true /* adjust position */);
     408            normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay());
    409409            /* Move newly created window to the screen-center: */
    410410            m_normalGeometry = geometry();
     
    417417        QTimer::singleShot(0, this, SLOT(sltNormalizeGeometry()));
    418418#else /* !VBOX_WS_X11 */
    419         normalizeGeometry(true /* adjust position */);
     419        normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay());
    420420#endif /* !VBOX_WS_X11 */
    421421    }
     
    427427    /* Save window geometry: */
    428428    {
     429        printf("UIMachineWindowNormal::saveSettings %d %d %d %d\n", m_normalGeometry.x(), m_normalGeometry.y(),
     430        m_normalGeometry.width(), m_normalGeometry.height());
    429431        gEDataManager->setMachineWindowGeometry(machineLogic()->visualStateType(),
    430432                                                m_uScreenId, m_normalGeometry,
     
    535537
    536538    /* Normalize machine-window geometry: */
    537     normalizeGeometry(true /* adjust position */);
     539    normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay());
    538540
    539541    /* Make sure machine-view have focus: */
     
    551553}
    552554
    553 void UIMachineWindowNormal::normalizeGeometry(bool fAdjustPosition)
     555void UIMachineWindowNormal::normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay)
    554556{
    555557#ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
     
    566568    const int db = frGeo.bottom() - geo.bottom();
    567569
    568     /* Get the best size w/o scroll-bars: */
    569     QSize sh = sizeHint();
    570 
    571     /* If guest-screen auto-resize is not enabled
    572      * or the guest-additions doesn't support graphics
    573      * we should take scroll-bars size-hints into account: */
    574     if (!machineView()->isGuestAutoresizeEnabled() || !uisession()->isGuestSupportsGraphics())
    575     {
    576         if (machineView()->verticalScrollBar()->isVisible())
    577             sh -= QSize(machineView()->verticalScrollBar()->sizeHint().width(), 0);
    578         if (machineView()->horizontalScrollBar()->isVisible())
    579             sh -= QSize(0, machineView()->horizontalScrollBar()->sizeHint().height());
    580     }
    581 
    582     /* Resize the frame to fit the contents: */
    583     sh -= size();
    584     frGeo.setRight(frGeo.right() + sh.width());
    585     frGeo.setBottom(frGeo.bottom() + sh.height());
     570    if (fResizeToGuestDisplay)
     571    {
     572        /* Get the best size w/o scroll-bars: */
     573        QSize sh = sizeHint();
     574
     575        /* If guest-screen auto-resize is not enabled
     576         * or the guest-additions doesn't support graphics
     577         * we should take scroll-bars size-hints into account: */
     578        if (!machineView()->isGuestAutoresizeEnabled() || !uisession()->isGuestSupportsGraphics())
     579        {
     580            if (machineView()->verticalScrollBar()->isVisible())
     581                sh -= QSize(machineView()->verticalScrollBar()->sizeHint().width(), 0);
     582            if (machineView()->horizontalScrollBar()->isVisible())
     583                sh -= QSize(0, machineView()->horizontalScrollBar()->sizeHint().height());
     584        }
     585
     586        /* Resize the frame to fit the contents: */
     587        sh -= size();
     588        frGeo.setRight(frGeo.right() + sh.width());
     589        frGeo.setBottom(frGeo.bottom() + sh.height());
     590    }
    586591
    587592    /* Adjust position if necessary: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r82968 r86046  
    118118    /** Performs window geometry normalization according to guest-size and host's available geometry.
    119119      * @param  fAdjustPosition  Determines whether is it necessary to adjust position as well. */
    120     virtual void normalizeGeometry(bool fAdjustPosition) /* override */;
     120    virtual void normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay) /* override */;
    121121
    122122    /** Common update routine. */
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