VirtualBox

Ignore:
Timestamp:
Sep 7, 2020 4:17:11 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9760: Runtime UI: A bit of fixes for geometry restoring procedure taking into account changes done in r140259.

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

Legend:

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

    r86046 r86051  
    223223}
    224224
     225bool UIMachineWindow::shouldResizeToGuestDisplay() const
     226{
     227    return    actionPool()
     228           && actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)
     229           && actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->isChecked();
     230}
     231
    225232void UIMachineWindow::adjustMachineViewSize()
    226233{
     
    233240    /* Send machine-view size-hint to the guest: */
    234241    machineView()->resendSizeHint();
    235 }
    236 
    237 bool UIMachineWindow::shouldResizeToGuestDisplay() const
    238 {
    239     return actionPool() &&
    240            actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize) &&
    241            actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->isChecked();
    242242}
    243243
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r86046 r86051  
    8787    const QString& machineName() const;
    8888
     89    /** Returns whether the machine-window should resize to fit to the guest display.
     90      * @note Relevant only to normal (windowed) case. */
     91    bool shouldResizeToGuestDisplay() const;
     92
    8993    /** Restores cached window geometry.
    9094      * @note Reimplemented in sub-classes. Base implementation does nothing. */
     
    9599      * @param fResizeToGuestDisplay determines if is it necessary to resize the window to fit to guest display size.
    96100      * @note  Reimplemented in sub-classes. Base implementation does nothing. */
    97     virtual void normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay) { Q_UNUSED(fAdjustPosition); Q_UNUSED(fResizeToGuestDisplay);}
     101    virtual void normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay) { Q_UNUSED(fAdjustPosition); Q_UNUSED(fResizeToGuestDisplay); }
    98102
    99103    /** Adjusts machine-view size to correspond current machine-window size. */
     
    102106    /** Sends machine-view size-hint to the guest. */
    103107    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;
    107108
    108109#ifdef VBOX_WITH_MASKED_SEAMLESS
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r86050 r86051  
    156156    /* Normalize geometry without moving: */
    157157    normalizeGeometry(false /* adjust position */, shouldResizeToGuestDisplay());
    158 
    159158}
    160159
     
    377376        if (!geo.isNull())
    378377        {
    379             /* If previous machine-state was SAVED: */
    380             if (machine().GetState() == KMachineState_Saved)
    381             {
    382                 /* Restore window geometry: */
    383                 m_normalGeometry = geo;
    384                 UICommon::setTopLevelGeometry(this, m_normalGeometry);
    385             }
    386             /* If previous machine-state was NOT SAVED: */
    387             else
    388             {
    389                 m_normalGeometry = geo;
    390                 UICommon::setTopLevelGeometry(this, m_normalGeometry);
    391                 /* And normalize to the optimal-size: */
     378            /* Restore window geometry: */
     379            m_normalGeometry = geo;
     380            UICommon::setTopLevelGeometry(this, m_normalGeometry);
     381
     382            /* If previous machine-state was NOT SAVED => normalize window to the optimal-size: */
     383            if (machine().GetState() != KMachineState_Saved)
    392384                normalizeGeometry(false /* adjust position */, shouldResizeToGuestDisplay());
    393             }
    394 
    395             /* Maximize (if necessary): */
     385
     386            /* Maximize window (if necessary): */
    396387            if (gEDataManager->machineWindowShouldBeMaximized(machineLogic()->visualStateType(),
    397388                                                              m_uScreenId, uiCommon().managedVMUuid()))
     
    401392        else
    402393        {
    403             /* Get available geometry, for screen with (x,y) coords if possible: */
    404             QRect availableGeo = !geo.isNull() ? gpDesktop->availableGeometry(QPoint(geo.x(), geo.y())) :
    405                                                  gpDesktop->availableGeometry(this);
    406 
    407             /* Normalize to the optimal size: */
     394            /* Normalize window to the optimal size: */
    408395            normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay());
    409             /* Move newly created window to the screen-center: */
     396
     397            /* Move it to the screen-center: */
    410398            m_normalGeometry = geometry();
    411             m_normalGeometry.moveCenter(availableGeo.center());
     399            m_normalGeometry.moveCenter(gpDesktop->availableGeometry(this).center());
    412400            UICommon::setTopLevelGeometry(this, m_normalGeometry);
    413401        }
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