VirtualBox

Changeset 97978 in vbox


Ignore:
Timestamp:
Jan 4, 2023 2:24:31 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Unify and a bit simplify acquiring of last guest-screen size-hint for normal and full-screen/seamless modes.

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

Legend:

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

    r97977 r97978  
    12661266}
    12671267
     1268QSize UIMachineView::requestedGuestScreenSizeHint() const
     1269{
     1270    /* Acquire last guest-screen size-hint set, if any: */
     1271    BOOL fEnabled, fChangeOrigin;
     1272    LONG iOriginX, iOriginY;
     1273    ULONG uWidth, uHeight, uBitsPerPixel;
     1274    display().GetVideoModeHint(screenId(), fEnabled, fChangeOrigin,
     1275                               iOriginX, iOriginY, uWidth, uHeight, uBitsPerPixel);
     1276
     1277    /* Acquire effective frame-buffer size otherwise: */
     1278    if (uWidth == 0 || uHeight == 0)
     1279    {
     1280        uWidth = frameBuffer()->width();
     1281        uHeight = frameBuffer()->height();
     1282    }
     1283
     1284    /* Return result: */
     1285    return QSize((int)uWidth, (int)uHeight);
     1286}
     1287
    12681288bool UIMachineView::guestScreenVisibilityStatus() const
    12691289{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r97977 r97978  
    240240    void setStoredGuestScreenSizeHint(const QSize &sizeHint);
    241241
     242    /** Retrieves the sent guest-screen size-hint from display or frame-buffer. */
     243    QSize requestedGuestScreenSizeHint() const;
     244
    242245    /** Retrieves the last guest-screen visibility status from extra-data. */
    243246    bool guestScreenVisibilityStatus() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r97976 r97978  
    7474                /* Send guest-resize hint only if top window resizing to required dimension: */
    7575                QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
    76                 if (pResizeEvent->size() != workingArea().size())
     76                if (pResizeEvent->size() != calculateMaxGuestSize())
    7777                    break;
    7878
     
    150150    if (!fAdjust)
    151151    {
    152         /* Acquire frame-buffer size: */
    153         QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
     152        /* Acquire requested guest-screen size-hint or at least actual frame-buffer size: */
     153        QSize guestScreenSizeHint = requestedGuestScreenSizeHint();
    154154        /* Take the scale-factor(s) into account: */
    155         frameBufferSize = scaledForward(frameBufferSize);
    156 
    157         /* Acquire working-area size: */
    158         const QSize workingAreaSize = workingArea().size();
    159 
    160         if (frameBufferSize != workingAreaSize)
     155        guestScreenSizeHint = scaledForward(guestScreenSizeHint);
     156
     157        /* Calculate maximum possible guest screen size: */
     158        const QSize maximumGuestScreenSize = calculateMaxGuestSize();
     159
     160        if (guestScreenSizeHint != maximumGuestScreenSize)
    161161        {
    162162            LogRel2(("GUI: UIMachineViewFullscreen::adjustGuestScreenSize: Guest-screen is of another size than necessary, adjustment is required.\n"));
     
    197197    {
    198198        frameBuffer()->setAutoEnabled(false);
    199         sltPerformGuestResize(workingArea().size());
     199        sltPerformGuestResize(calculateMaxGuestSize());
    200200        /* And remember the size to know what we are resizing out of when we exit: */
    201         uisession()->setLastFullScreenSize(screenId(), scaledForward(scaledBackward(workingArea().size())));
     201        uisession()->setLastFullScreenSize(screenId(), scaledForward(scaledBackward(calculateMaxGuestSize())));
    202202    }
    203203}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r97977 r97978  
    181181    LogRel(("GUI: UIMachineViewNormal::adjustGuestScreenSize: Adjust guest-screen size if necessary\n"));
    182182
    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);
     183    /* Acquire requested guest-screen size-hint or at least actual frame-buffer size: */
     184    QSize guestScreenSizeHint = requestedGuestScreenSizeHint();
    199185    /* 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 maximumGuestSize = calculateMaxGuestSize();
    204     if (   maximumGuestSize.width() < frameBufferSize.width()
    205         || maximumGuestSize.height() < frameBufferSize.height())
     186    guestScreenSizeHint = scaledForward(guestScreenSizeHint);
     187
     188    /* Calculate maximum possible guest screen size: */
     189    const QSize maximumGuestScreenSize = calculateMaxGuestSize();
     190
     191    /* Adjust guest-screen size if the requested one is too big for the screen: */
     192    if (   guestScreenSizeHint.width() > maximumGuestScreenSize.width()
     193        || guestScreenSizeHint.height() > maximumGuestScreenSize.height())
    206194        sltPerformGuestResize(machineWindow()->centralWidget()->size());
    207195}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r97976 r97978  
    8585                /* Send guest-resize hint only if top window resizing to required dimension: */
    8686                QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
    87                 if (pResizeEvent->size() != workingArea().size())
     87                if (pResizeEvent->size() != calculateMaxGuestSize())
    8888                    break;
    8989
     
    163163    if (!fAdjust)
    164164    {
    165         /* Acquire frame-buffer size: */
    166         QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
     165        /* Acquire requested guest-screen size-hint or at least actual frame-buffer size: */
     166        QSize guestScreenSizeHint = requestedGuestScreenSizeHint();
    167167        /* Take the scale-factor(s) into account: */
    168         frameBufferSize = scaledForward(frameBufferSize);
    169 
    170         /* Acquire working-area size: */
    171         const QSize workingAreaSize = workingArea().size();
    172 
    173         if (frameBufferSize != workingAreaSize)
     168        guestScreenSizeHint = scaledForward(guestScreenSizeHint);
     169
     170        /* Calculate maximum possible guest screen size: */
     171        const QSize maximumGuestScreenSize = calculateMaxGuestSize();
     172
     173        if (guestScreenSizeHint != maximumGuestScreenSize)
    174174        {
    175175            LogRel2(("GUI: UIMachineViewSeamless::adjustGuestScreenSize: Guest-screen is of another size than necessary, adjustment is required.\n"));
     
    201201    {
    202202        frameBuffer()->setAutoEnabled(false);
    203         sltPerformGuestResize(workingArea().size());
     203        sltPerformGuestResize(calculateMaxGuestSize());
    204204        /* And remember the size to know what we are resizing out of when we exit: */
    205         uisession()->setLastFullScreenSize(screenId(), scaledForward(scaledBackward(workingArea().size())));
     205        uisession()->setLastFullScreenSize(screenId(), scaledForward(scaledBackward(calculateMaxGuestSize())));
    206206    }
    207207}
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