VirtualBox

Changeset 53931 in vbox


Ignore:
Timestamp:
Jan 22, 2015 5:24:21 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: 6278: Support for unscaled HiDPI (Retina) video-output: Fix absolute mouse positioning for contents shifted with scroll-bars.

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

Legend:

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

    r53921 r53931  
    962962#ifdef Q_WS_MAC
    963963    /* Due to Qt 4.x doesn't supports HiDPI directly
    964      * we should take the backing-scale-factor into account: */
     964     * we should take the backing-scale-factor into account.
     965     * See also viewportToContents()... */
    965966    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    966967    {
     
    983984QPoint UIMachineView::viewportToContents(const QPoint &vp) const
    984985{
    985     return QPoint(vp.x() + contentsX(), vp.y() + contentsY());
     986    /* Get physical contents shifts of scroll-bars: */
     987    int iContentsX = contentsX();
     988    int iContentsY = contentsY();
     989
     990#ifdef Q_WS_MAC
     991    /* Due to Qt 4.x doesn't supports HiDPI directly
     992     * we should take the backing-scale-factor into account.
     993     * See also updateSliders()... */
     994    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     995    {
     996        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     997        if (dBackingScaleFactor > 1.0)
     998        {
     999            iContentsX /= dBackingScaleFactor;
     1000            iContentsY /= dBackingScaleFactor;
     1001        }
     1002    }
     1003#endif /* Q_WS_MAC */
     1004
     1005    /* Return point shifted according scroll-bars: */
     1006    return QPoint(vp.x() + iContentsX, vp.y() + iContentsY);
    9861007}
    9871008
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r53447 r53931  
    928928            QPoint cpnt = m_views[uScreenId]->viewportToContents(relativePos);
    929929
    930             /* Determine scaling: */
    931             UIFrameBuffer *pFrameBuffer = m_views[uScreenId]->frameBuffer();
    932             QSize scaledSize = pFrameBuffer->scaledSize();
    933             double xRatio = scaledSize.isValid() ? (double)pFrameBuffer->width() / (double)scaledSize.width() : 1;
    934             double yRatio = scaledSize.isValid() ? (double)pFrameBuffer->height() / (double)scaledSize.height() : 1;
    935             /* Set scaling if scale-factor is present: */
    936             cpnt.setX((int)(cpnt.x() * xRatio));
    937             cpnt.setY((int)(cpnt.y() * yRatio));
     930            /* Take the scale-factor(s) into account: */
     931            const UIFrameBuffer *pFrameBuffer = m_views[uScreenId]->frameBuffer();
     932            if (pFrameBuffer)
     933            {
     934                const QSize scaledSize = pFrameBuffer->scaledSize();
     935                if (scaledSize.isValid())
     936                {
     937                    const double xScaleFactor = (double)scaledSize.width()  / pFrameBuffer->width();
     938                    const double yScaleFactor = (double)scaledSize.height() / pFrameBuffer->height();
     939                    cpnt.setX(cpnt.x() / xScaleFactor);
     940                    cpnt.setY(cpnt.y() / yScaleFactor);
     941                }
     942            }
     943
     944#ifdef Q_WS_MAC
     945            /* Take the backing-scale-factor into account: */
     946            if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     947            {
     948                const double dBackingScaleFactor = darwinBackingScaleFactor(m_windows.value(uScreenId));
     949                if (dBackingScaleFactor > 1.0)
     950                {
     951                    cpnt.setX(cpnt.x() * dBackingScaleFactor);
     952                    cpnt.setY(cpnt.y() * dBackingScaleFactor);
     953                }
     954            }
     955#endif /* Q_WS_MAC */
    938956
    939957#ifdef VBOX_WITH_DRAG_AND_DROP
     
    969987            cpnt.setX(cpnt.x() + xShift);
    970988            cpnt.setY(cpnt.y() + yShift);
    971 
    972 #ifdef Q_WS_MAC
    973             /* Take the backing-scale-factor into account: */
    974             if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    975             {
    976                 const double dBackingScaleFactor = darwinBackingScaleFactor(m_windows.value(uScreenId));
    977                 if (dBackingScaleFactor > 1.0)
    978                     cpnt *= dBackingScaleFactor;
    979             }
    980 #endif /* Q_WS_MAC */
    981989
    982990            /* Post absolute mouse-event into guest: */
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