VirtualBox

Ignore:
Timestamp:
Mar 22, 2021 2:35:45 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143445
Message:

FE/Qt: bugref:9973: Runtime UI / Machine-view: A bit of cleanup for sltPerformGuestResize slot; Useful sanity checks and proper logging.

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

Legend:

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

    r86977 r88245  
    253253void UIMachineView::sltPerformGuestResize(const QSize &toSize)
    254254{
    255     /* If this slot is invoked directly then use the passed size otherwise get
    256      * the available size for the guest display. We assume here that centralWidget()
    257      * contains this view only and gives it all available space: */
    258     QSize size(toSize.isValid() ? toSize : machineWindow()->centralWidget()->size());
    259     AssertMsg(size.isValid(), ("Size should be valid!\n"));
     255    /* There is a couple of things to keep in mind:
     256     *
     257     * First of all, passed size can be invalid (or even not sane one, where one of values equal to zero).  Usually that happens
     258     * if this function being invoked with default argument for example by some slot.  In such case we get the available size for
     259     * the guest-screen we have.  We assume here that centralWidget() contains this view only and gives it all available space.
     260     * In all other cases we have a valid non-zero size which should be handled as usual.
     261     *
     262     * Besides that, passed size or size taken from centralWidget() is _not_ absolute one, it's in widget's coordinate system
     263     * which can and will be be transformed by scale-factor when appropriate, so before passing this size to a guest it has to
     264     * be scaled backward.  This is the key aspect in which internal resize differs from resize initiated from the outside. */
     265
     266    /* Make sure we have valid size to work with: */
     267    QSize size(  toSize.isValid() && toSize.width() > 0 && toSize.height() > 0
     268               ? toSize : machineWindow()->centralWidget()->size());
     269    AssertMsgReturnVoid(size.isValid() && size.width() > 0 && size.height() > 0,
     270                        ("Size should be valid (%dx%d)!\n", size.width(), size.height()));
    260271
    261272    /* Take the scale-factor(s) into account: */
    262273    size = scaledBackward(size);
    263274
    264     /* Expand current limitations: */
     275    /* Update current window size limitations: */
    265276    setMaxGuestSize(size);
    266277
    267     /* Send new size-hint to the guest: */
    268     LogRel(("GUI: UIMachineView::sltPerformGuestResize: "
    269             "Sending guest size-hint to screen %d as %dx%d if necessary\n",
    270             (int)screenId(), size.width(), size.height()));
    271 
    272     /* Record the hint to extra data, needed for guests using VMSVGA: */
    273     /* This should be done before the actual hint is sent in case the guest overrides it. */
    274     /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes. */
     278    /* Record the hint to extra data, needed for guests using VMSVGA:
     279     * This should be done before the actual hint is sent in case the guest overrides it.
     280     * Do not send a hint if nothing has changed to prevent the guest being notified about its own changes. */
    275281    if (   !isFullscreenOrSeamless()
    276282        && uisession()->isGuestSupportsGraphics()
     
    283289    if (gEDataManager->autoMountGuestScreensEnabled(uiCommon().managedVMUuid()))
    284290    {
    285         /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */
    286         if (   (int)m_pFrameBuffer->width() != size.width() || (int)m_pFrameBuffer->height() != size.height()
    287             || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId()))
    288         {
    289             /* If host and guest have same opinion about guest-screen visibility: */
    290             if (uisession()->isScreenVisible(screenId()) == uisession()->isScreenVisibleHostDesires(screenId()))
     291        /* If host and guest have same opinion about guest-screen visibility: */
     292        if (uisession()->isScreenVisible(screenId()) == uisession()->isScreenVisibleHostDesires(screenId()))
     293        {
     294            /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */
     295            if ((int)m_pFrameBuffer->width() != size.width() || (int)m_pFrameBuffer->height() != size.height())
     296            {
     297                LogRel(("GUI: UIMachineView::sltPerformGuestResize: Auto-pilot resizing screen %d as %dx%d\n",
     298                        (int)screenId(), size.width(), size.height()));
    291299                display().SetVideoModeHint(screenId(),
    292300                                           uisession()->isScreenVisible(screenId()),
    293                                            false, 0, 0, size.width(), size.height(), 0, true);
     301                                           false /* change origin? */,
     302                                           0 /* origin x */,
     303                                           0 /* origin y */,
     304                                           size.width(),
     305                                           size.height(),
     306                                           0 /* bits per pixel */,
     307                                           true /* notify? */);
     308            }
     309        }
     310        else
     311        {
     312            /* If host desires to have guest-screen enabled and guest-screen is disabled, retrying: */
     313            if (uisession()->isScreenVisibleHostDesires(screenId()))
     314            {
     315                /* Send enabling size-hint to the guest: */
     316                LogRel(("GUI: UIMachineView::sltPerformGuestResize: Auto-pilot enabling guest-screen %d\n", (int)screenId()));
     317                display().SetVideoModeHint(screenId(),
     318                                           true /* enabled? */,
     319                                           false /* change origin? */,
     320                                           0 /* origin x */,
     321                                           0 /* origin y */,
     322                                           size.width(),
     323                                           size.height(),
     324                                           0 /* bits per pixel */,
     325                                           true /* notify? */);
     326            }
    294327            /* If host desires to have guest-screen disabled and guest-screen is enabled, retrying: */
    295             else if (!uisession()->isScreenVisibleHostDesires(screenId()))
    296                 display().SetVideoModeHint(screenId(), false, false, 0, 0, 0, 0, 0, true);
    297             /* If host desires to have guest-screen enabled and guest-screen is disabled, retrying: */
    298             else if (uisession()->isScreenVisibleHostDesires(screenId()))
    299                 display().SetVideoModeHint(screenId(), true, false, 0, 0, size.width(), size.height(), 0, true);
     328            else
     329            {
     330                /* Send disabling size-hint to the guest: */
     331                LogRel(("GUI: UIMachineView::sltPerformGuestResize: Auto-pilot disabling guest-screen %d\n", (int)screenId()));
     332                display().SetVideoModeHint(screenId(),
     333                                           false /* enabled? */,
     334                                           false /* change origin? */,
     335                                           0 /* origin x */,
     336                                           0 /* origin y */,
     337                                           0 /* width */,
     338                                           0 /* height */,
     339                                           0 /* bits per pixel */,
     340                                           true /* notify? */);
     341            }
    300342        }
    301343    }
     
    305347        /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */
    306348        if ((int)m_pFrameBuffer->width() != size.width() || (int)m_pFrameBuffer->height() != size.height())
     349        {
     350            LogRel(("GUI: UIMachineView::sltPerformGuestResize: Sending guest size-hint to screen %d as %dx%d\n",
     351                    (int)screenId(), size.width(), size.height()));
    307352            display().SetVideoModeHint(screenId(),
    308353                                       uisession()->isScreenVisible(screenId()),
    309                                        false, 0, 0, size.width(), size.height(), 0, true);
     354                                       false /* change origin? */,
     355                                       0 /* origin x */,
     356                                       0 /* origin y */,
     357                                       size.width(),
     358                                       size.height(),
     359                                       0 /* bits per pixel */,
     360                                       true /* notify? */);
     361        }
    310362    }
    311363}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r86977 r88245  
    107107protected slots:
    108108
    109     /* Slot to perform guest resize: */
    110     void sltPerformGuestResize(const QSize &aSize = QSize());
     109    /* Performs guest-screen resize to a size specified.
     110     * @param  toSize  Brings the size guest-screen needs to be resized to.
     111     * @note   If toSize isn't valid or sane one, it will be replaced with actual
     112     *         size of centralWidget() containing this machine-view currently.
     113     * @note   Also, take into acount that since this method is also called to
     114     *         resize to centralWidget() size, the size passed is expected to be
     115     *         tranformed to internal coordinate system and thus to be restored to
     116     *         guest coordinate system (absolute one) before passing to guest. */
     117    void sltPerformGuestResize(const QSize &toSize = QSize());
    111118
    112119    /* Handler: Frame-buffer NotifyChange stuff: */
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