VirtualBox

Changeset 53921 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 22, 2015 3:39:01 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97794
Message:

FE/Qt: Mac OS X: 6278: Support for unscaled HiDPI (Retina) video-output: Make sure scroll-bars allows to make shifted offscreen contents visible.

File:
1 edited

Legend:

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

    r53912 r53921  
    942942void UIMachineView::updateSliders()
    943943{
    944     QSize p = viewport()->size();
    945     QSize m = maximumViewportSize();
    946 
    947     QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
     944    /* Get current viewport size: */
     945    QSize curViewportSize = viewport()->size();
     946    /* Get maximum viewport size: */
     947    const QSize maxViewportSize = maximumViewportSize();
     948    /* Get current frame-buffer size: */
     949    QSize frameBufferSize = QSize(frameBuffer()->width(), frameBuffer()->height());
    948950
    949951    /* Take the scale-factor(s) into account: */
    950     v = scaledForward(v);
    951 
    952     /* No scroll bars needed: */
    953     if (m.expandedTo(v) == m)
    954         p = m;
    955 
    956     horizontalScrollBar()->setRange(0, v.width() - p.width());
    957     verticalScrollBar()->setRange(0, v.height() - p.height());
    958     horizontalScrollBar()->setPageStep(p.width());
    959     verticalScrollBar()->setPageStep(p.height());
     952    frameBufferSize = scaledForward(frameBufferSize);
     953
     954    /* If maximum viewport size can cover whole frame-buffer => no scroll-bars required: */
     955    if (maxViewportSize.expandedTo(frameBufferSize) == maxViewportSize)
     956        curViewportSize = maxViewportSize;
     957
     958    /* What length we want scroll-bars of? */
     959    int xRange = frameBufferSize.width()  - curViewportSize.width();
     960    int yRange = frameBufferSize.height() - curViewportSize.height();
     961
     962#ifdef Q_WS_MAC
     963    /* Due to Qt 4.x doesn't supports HiDPI directly
     964     * we should take the backing-scale-factor into account: */
     965    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     966    {
     967        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     968        if (dBackingScaleFactor > 1.0)
     969        {
     970            xRange *= dBackingScaleFactor;
     971            yRange *= dBackingScaleFactor;
     972        }
     973    }
     974#endif /* Q_WS_MAC */
     975
     976    /* Configure scroll-bars: */
     977    horizontalScrollBar()->setRange(0, xRange);
     978    verticalScrollBar()->setRange(0, yRange);
     979    horizontalScrollBar()->setPageStep(curViewportSize.width());
     980    verticalScrollBar()->setPageStep(curViewportSize.height());
    960981}
    961982
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