VirtualBox

Ignore:
Timestamp:
Jun 28, 2019 9:46:46 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131644
Message:

FE/Qt: UIMachineViewNormal: base adjust guest screen size on last size hint.
bugref:9482: FE/Qt and Additions/WINNT: move away from *adjust size...*
At regular intervals the GUI performs checks to see if it should send the
guest machine a new preferred size. Up until now this has been done if the
current size of the guest screen is too large for the host screen it is
located on. However this triggered unwanted resizes as the check was also
performed when the guest enabled dynamic resizing, but before it was able
to set a size itself. This change modifies the behaviour, so that the GUI
now checks whether the last set preferred size for the guest screen will fit
on the host screen.

File:
1 edited

Legend:

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

    r78995 r79403  
    179179void UIMachineViewNormal::adjustGuestScreenSize()
    180180{
    181     /* Should we adjust guest-screen size? Logging paranoia is required here to reveal the truth. */
    182181    LogRel(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Adjust guest-screen size if necessary\n"));
    183     bool fAdjust = false;
    184 
    185     /* Step 1: Is the guest-screen of another size than necessary? */
    186     if (!fAdjust)
    187     {
    188         /* Acquire frame-buffer size: */
    189         QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
    190         /* Take the scale-factor(s) into account: */
    191         frameBufferSize = scaledForward(frameBufferSize);
    192 
    193         /* Acquire central-widget size: */
    194         const QSize centralWidgetSize = machineWindow()->centralWidget()->size();
    195 
    196         if (frameBufferSize != centralWidgetSize)
    197         {
    198             LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-screen is of another size than necessary, adjustment is required.\n"));
    199             fAdjust = true;
    200         }
    201     }
    202 
    203     /* Step 2: Is guest-additions supports graphics? */
    204     if (fAdjust)
    205     {
    206         if (!uisession()->isGuestSupportsGraphics())
    207         {
    208             LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-additions are not supporting graphics, adjustment is omitted.\n"));
    209             fAdjust = false;
    210         }
    211     }
    212     /* Step 3: Is guest-screen visible? */
    213     if (fAdjust)
    214     {
    215         if (!uisession()->isScreenVisible(screenId()))
    216         {
    217             LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-screen is not visible, adjustment is omitted.\n"));
    218             fAdjust = false;
    219         }
    220     }
    221     /* Step 4: Is guest-screen auto-resize enabled? */
    222     if (fAdjust)
    223     {
    224         if (!m_bIsGuestAutoresizeEnabled)
    225         {
    226             LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Guest-screen auto-resize is disabled, adjustment is omitted.\n"));
    227             fAdjust = false;
    228         }
    229     }
    230     /* Step 5: Is another visual representation mode requested? */
    231     if (fAdjust)
    232     {
    233         if (uisession()->requestedVisualState() == UIVisualStateType_Seamless) // Seamless only for now.
    234         {
    235             LogRel2(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Seamless mode is requested, adjustment is omitted.\n"));
    236             fAdjust = false;
    237         }
    238     }
    239 
    240     /* Final step: Adjust if requested/allowed. */
    241     if (fAdjust)
    242     {
     182
     183    /* Get last monitor size set, if any: */
     184    BOOL fEnabled, fChangeOrigin;
     185    LONG iOriginX, iOriginY;
     186    ULONG uWidth, uHeight, uBitsPerPixel;
     187    display().GetVideoModeHint(screenId(), fEnabled, fChangeOrigin,
     188                               iOriginX, iOriginY, uWidth, uHeight, uBitsPerPixel);
     189
     190    /* Acquire effective frame-buffer size otherwise: */
     191    if (uWidth == 0 || uHeight == 0)
     192    {
     193        uWidth = frameBuffer()->width();
     194        uHeight = frameBuffer()->height();
     195    }
     196
     197    /* Compose frame-buffer size: */
     198    QSize frameBufferSize(uWidth, uHeight);
     199    /* Take the scale-factor(s) into account: */
     200    frameBufferSize = scaledForward(frameBufferSize);
     201
     202    /* Adjust guest-screen size if the last size hint is too big for the screen: */
     203    const QSize maxGuestSize = calculateMaxGuestSize();
     204    if (   maxGuestSize.width() < frameBufferSize.width()
     205        || maxGuestSize.height() < frameBufferSize.height())
    243206        sltPerformGuestResize(machineWindow()->centralWidget()->size());
    244     }
    245207}
    246208
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette