VirtualBox

Changeset 69931 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 5, 2017 10:20:34 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119418
Message:

FE/Qt: bugref:8694: macOS: Moving HiDPI handling from cocoa to Qt rails.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
11 edited

Legend:

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

    r69500 r69931  
    3434/* GUI includes: */
    3535# include "VBoxFBOverlay.h"
     36# include "UIDesktopWidgetWatchdog.h"
    3637# include "UIMessageCenter.h"
    3738# include "UIPopupCenter.h"
     
    44474448
    44484449#ifdef VBOX_WS_MAC
    4449     /* Take the backing-scale-factor into account: */
     4450    /* Take the device-pixel-ratio into account: */
    44504451    if (mSizeInfo.useUnscaledHiDPIOutput())
    44514452    {
    4452         const double dBackingScaleFactor = darwinBackingScaleFactor(mpViewport->window());
    4453         if (dBackingScaleFactor > 1.0)
    4454         {
    4455             rect.moveTo((int)floor((double)rect.x() / dBackingScaleFactor) - 1,
    4456                         (int)floor((double)rect.y() / dBackingScaleFactor) - 1);
    4457             rect.setSize(QSize((int)ceil((double)rect.width()  / dBackingScaleFactor) + 2,
    4458                                (int)ceil((double)rect.height() / dBackingScaleFactor) + 2));
     4453        const double dDevicePixelRatio = gpDesktop->devicePixelRatio(mpViewport->window());
     4454        if (dDevicePixelRatio > 1.0)
     4455        {
     4456            rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatio) - 1,
     4457                        (int)floor((double)rect.y() / dDevicePixelRatio) - 1);
     4458            rect.setSize(QSize((int)ceil((double)rect.width()  / dDevicePixelRatio) + 2,
     4459                               (int)ceil((double)rect.height() / dDevicePixelRatio) + 2));
    44594460        }
    44604461    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp

    r69500 r69931  
    355355#endif /* VBOX_WS_X11 */
    356356
     357double UIDesktopWidgetWatchdog::devicePixelRatio(int iHostScreenIndex)
     358{
     359    /* First, we should check whether the screen is valid: */
     360    QScreen *pScreen = iHostScreenIndex == -1
     361                     ? QGuiApplication::primaryScreen()
     362                     : QGuiApplication::screens().value(iHostScreenIndex);
     363    AssertPtrReturn(pScreen, 1.0);
     364    /* Then acquire device-pixel-ratio: */
     365    return pScreen->devicePixelRatio();
     366}
     367
     368double UIDesktopWidgetWatchdog::devicePixelRatio(QWidget *pWidget)
     369{
     370    /* Redirect call to wrapper above: */
     371    return devicePixelRatio(screenNumber(pWidget));
     372}
     373
    357374void UIDesktopWidgetWatchdog::sltHostScreenAdded(QScreen *pHostScreen)
    358375{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.h

    r69500 r69931  
    106106#endif
    107107
     108    /** Returns device-pixel-ratio of the host-screen with @a iHostScreenIndex. */
     109    double devicePixelRatio(int iHostScreenIndex = -1);
     110    /** Returns device-pixel-ratio of the host-screen which contains @a pWidget. */
     111    double devicePixelRatio(QWidget *pWidget);
     112
    108113private slots:
    109114
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm

    r69824 r69931  
    263263    else
    264264        return false;
    265 }
    266 
    267 double darwinBackingScaleFactor(NativeNSWindowRef pWindow)
    268 {
    269     /* If host window responds to 'backingScaleFactor' selector: */
    270     if ([pWindow respondsToSelector :@selector(backingScaleFactor)])
    271     {
    272         /* Default scale-factor still '1': */
    273         CGFloat dScaleFactor = 1.0;
    274         /* Compose dynamical invocation: */
    275         SEL selector = @selector(backingScaleFactor);
    276         NSMethodSignature *signature = [pWindow methodSignatureForSelector :selector];
    277         NSInvocation *invocation = [NSInvocation invocationWithMethodSignature :signature];
    278         /* Configure invocation: */
    279         [invocation setTarget :pWindow];
    280         [invocation setSelector :selector];
    281         /* Call for invocation: */
    282         [invocation invoke];
    283         /* And acquire invocation result finally: */
    284         [invocation getReturnValue :&dScaleFactor];
    285         /* Return scale-factor we have: */
    286         return dScaleFactor;
    287     }
    288     /* Default scale-factor is '1': */
    289     return 1.0;
    290265}
    291266
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp

    r69500 r69931  
    176176{
    177177    return ::darwinOpenFile(darwinToNativeString(strFile.toUtf8().constData()));
    178 }
    179 
    180 double darwinBackingScaleFactor(QWidget *pWidget)
    181 {
    182     return ::darwinBackingScaleFactor(::darwinToNativeWindow(pWidget));
    183178}
    184179
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h

    r69500 r69931  
    102102
    103103bool darwinOpenFile(NativeNSStringRef pstrFile);
    104 
    105 double darwinBackingScaleFactor(NativeNSWindowRef pWindow);
    106104
    107105float darwinSmallFontSize();
     
    279277bool darwinOpenFile(const QString &strFile);
    280278
    281 double darwinBackingScaleFactor(QWidget *pWidget);
    282 
    283279QString darwinSystemLanguage(void);
    284280QPixmap darwinCreateDragPixmap(const QPixmap& aPixmap, const QString &aText);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r69824 r69931  
    153153    void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; }
    154154
    155     /** Returns backing-scale-factor used by HiDPI frame-buffer. */
    156     double backingScaleFactor() const { return m_dBackingScaleFactor; }
    157     /** Defines backing-scale-factor used by HiDPI frame-buffer. */
    158     void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }
     155    /** Returns device-pixel-ratio set for HiDPI frame-buffer. */
     156    double devicePixelRatio() const { return m_dDevicePixelRatio; }
     157    /** Defines device-pixel-ratio set for HiDPI frame-buffer. */
     158    void setDevicePixelRatio(double dDevicePixelRatio) { m_dDevicePixelRatio = dDevicePixelRatio; }
    159159
    160160    /** Returns whether frame-buffer should use unscaled HiDPI output. */
     
    301301                               bool fUseUnscaledHiDPIOutput,
    302302                               HiDPIOptimizationType hiDPIOptimizationType,
    303                                double dBackingScaleFactor);
     303                               double dDevicePixelRatio);
    304304    /** Draws corresponding @a rect of passed @a image with @a painter. */
    305305    static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
     
    307307                              bool fUseUnscaledHiDPIOutput,
    308308                              HiDPIOptimizationType hiDPIOptimizationType,
    309                               double dBackingScaleFactor);
     309                              double dDevicePixelRatio);
    310310
    311311    /** Holds the screen-id. */
     
    382382    /** @name HiDPI screens related variables.
    383383     * @{ */
    384     /** Holds backing-scale-factor used by HiDPI frame-buffer. */
    385     double m_dBackingScaleFactor;
     384    /** Holds device-pixel-ratio set for HiDPI frame-buffer. */
     385    double m_dDevicePixelRatio;
    386386    /** Holds whether frame-buffer should use unscaled HiDPI output. */
    387387    bool m_fUseUnscaledHiDPIOutput;
     
    536536    , m_dScaleFactor(1.0)
    537537    , m_enmScalingOptimizationType(ScalingOptimizationType_None)
    538     , m_dBackingScaleFactor(1.0)
     538    , m_dDevicePixelRatio(1.0)
    539539    , m_fUseUnscaledHiDPIOutput(false)
    540540    , m_hiDPIOptimizationType(HiDPIOptimizationType_None)
     
    980980    }
    981981    /* Tune according scale-factor: */
    982     if (scaleFactor() != 1.0 || backingScaleFactor() > 1.0)
     982    if (scaleFactor() != 1.0 || devicePixelRatio() > 1.0)
    983983        region = m_transform.map(region);
    984984
     
    13321332        m_transform = m_transform.scale(scaleFactor(), scaleFactor());
    13331333
    1334     /* Apply the backing-scale-factor if necessary: */
    1335     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    1336         m_transform = m_transform.scale(1.0 / backingScaleFactor(), 1.0 / backingScaleFactor());
     1334    /* Apply the device-pixel-ratio if necessary: */
     1335    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
     1336        m_transform = m_transform.scale(1.0 / devicePixelRatio(), 1.0 / devicePixelRatio());
    13371337}
    13381338
     
    13661366    QRect paintRect = pEvent->rect();
    13671367
    1368     /* Take the backing-scale-factor into account: */
    1369     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    1370     {
    1371         paintRect.moveTo(paintRect.topLeft() * backingScaleFactor());
    1372         paintRect.setSize(paintRect.size() * backingScaleFactor());
     1368    /* Take the device-pixel-ratio into account: */
     1369    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
     1370    {
     1371        paintRect.moveTo(paintRect.topLeft() * devicePixelRatio());
     1372        paintRect.setSize(paintRect.size() * devicePixelRatio());
    13731373    }
    13741374
     
    13841384    /* On OSX for Qt5 we need to erase backing store first: */
    13851385    QRect eraseRect = paintRect;
    1386     /* Take the backing-scale-factor into account: */
    1387     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    1388     {
    1389         eraseRect.moveTo(eraseRect.topLeft() / backingScaleFactor());
    1390         eraseRect.setSize(eraseRect.size() / backingScaleFactor());
     1386    /* Take the device-pixel-ratio into account: */
     1387    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
     1388    {
     1389        eraseRect.moveTo(eraseRect.topLeft() / devicePixelRatio());
     1390        eraseRect.setSize(eraseRect.size() / devicePixelRatio());
    13911391    }
    13921392    /* Replace translucent background with black one: */
     
    13991399    drawImageRect(painter, sourceImage, paintRect,
    14001400                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    1401                   useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
     1401                  useUnscaledHiDPIOutput(), hiDPIOptimizationType(), devicePixelRatio());
    14021402}
    14031403
     
    14371437    unlock();
    14381438
    1439     /* Take the backing-scale-factor into account: */
    1440     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    1441     {
    1442         paintRect.moveTo(paintRect.topLeft() * backingScaleFactor());
    1443         paintRect.setSize(paintRect.size() * backingScaleFactor());
     1439    /* Take the device-pixel-ratio into account: */
     1440    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
     1441    {
     1442        paintRect.moveTo(paintRect.topLeft() * devicePixelRatio());
     1443        paintRect.setSize(paintRect.size() * devicePixelRatio());
    14441444    }
    14451445
     
    14581458    /* Erase rectangle: */
    14591459    eraseImageRect(painter, paintRect,
    1460                    useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
     1460                   useUnscaledHiDPIOutput(), hiDPIOptimizationType(), devicePixelRatio());
    14611461
    14621462    /* Apply painter clipping for painting: */
     
    14681468    /* On OSX for Qt5 we need to erase backing store first: */
    14691469    QRect eraseRect = paintRect;
    1470     /* Take the backing-scale-factor into account: */
    1471     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    1472     {
    1473         eraseRect.moveTo(eraseRect.topLeft() / backingScaleFactor());
    1474         eraseRect.setSize(eraseRect.size() / backingScaleFactor());
     1470    /* Take the device-pixel-ratio into account: */
     1471    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
     1472    {
     1473        eraseRect.moveTo(eraseRect.topLeft() / devicePixelRatio());
     1474        eraseRect.setSize(eraseRect.size() / devicePixelRatio());
    14751475    }
    14761476    /* Replace translucent background with black one: */
     
    14831483    drawImageRect(painter, sourceImage, paintRect,
    14841484                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    1485                   useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
     1485                  useUnscaledHiDPIOutput(), hiDPIOptimizationType(), devicePixelRatio());
    14861486}
    14871487
     
    15031503                                          bool fUseUnscaledHiDPIOutput,
    15041504                                          HiDPIOptimizationType hiDPIOptimizationType,
    1505                                           double dBackingScaleFactor)
     1505                                          double dDevicePixelRatio)
    15061506{
    15071507    /* Prepare sub-pixmap: */
    15081508    QPixmap subPixmap = QPixmap(rect.width(), rect.height());
    15091509
    1510     /* If HiDPI 'backing-scale-factor' defined: */
    1511     if (dBackingScaleFactor > 1.0)
     1510    /* If HiDPI 'device-pixel-ratio' defined: */
     1511    if (dDevicePixelRatio > 1.0)
    15121512    {
    15131513        /* Should we
     
    15161516        {
    15171517            /* Adjust sub-pixmap: */
    1518             subPixmap = QPixmap((int)(rect.width() * dBackingScaleFactor),
    1519                                 (int)(rect.height() * dBackingScaleFactor));
     1518            subPixmap = QPixmap((int)(rect.width() * dDevicePixelRatio),
     1519                                (int)(rect.height() * dDevicePixelRatio));
    15201520        }
    15211521
     
    15271527        {
    15281528            /* Mark sub-pixmap as HiDPI: */
    1529             subPixmap.setDevicePixelRatio(dBackingScaleFactor);
     1529            subPixmap.setDevicePixelRatio(dDevicePixelRatio);
    15301530        }
    15311531#endif /* VBOX_WS_MAC */
     
    15351535    QPointF paintPoint = rect.topLeft();
    15361536
    1537     /* Take the backing-scale-factor into account: */
    1538     if (fUseUnscaledHiDPIOutput && dBackingScaleFactor > 1.0)
    1539         paintPoint /= dBackingScaleFactor;
     1537    /* Take the device-pixel-ratio into account: */
     1538    if (fUseUnscaledHiDPIOutput && dDevicePixelRatio > 1.0)
     1539        paintPoint /= dDevicePixelRatio;
    15401540
    15411541    /* Draw sub-pixmap: */
     
    15481548                                         bool fUseUnscaledHiDPIOutput,
    15491549                                         HiDPIOptimizationType hiDPIOptimizationType,
    1550                                          double dBackingScaleFactor)
     1550                                         double dDevicePixelRatio)
    15511551{
    15521552    /* Calculate offset: */
     
    15661566    QPixmap subPixmap = QPixmap::fromImage(subImage);
    15671567
    1568     /* If HiDPI 'backing-scale-factor' defined: */
    1569     if (dBackingScaleFactor > 1.0)
     1568    /* If HiDPI 'device-pixel-ratio' defined: */
     1569    if (dDevicePixelRatio > 1.0)
    15701570    {
    15711571        /* Should we
     
    15741574        {
    15751575            /* Fast scale sub-pixmap (2nd copy involved): */
    1576             subPixmap = subPixmap.scaled(subPixmap.size() * dBackingScaleFactor,
     1576            subPixmap = subPixmap.scaled(subPixmap.size() * dDevicePixelRatio,
    15771577                                         Qt::IgnoreAspectRatio, Qt::FastTransformation);
    15781578        }
     
    15851585        {
    15861586            /* Mark sub-pixmap as HiDPI: */
    1587             subPixmap.setDevicePixelRatio(dBackingScaleFactor);
     1587            subPixmap.setDevicePixelRatio(dDevicePixelRatio);
    15881588        }
    15891589#endif /* VBOX_WS_MAC */
     
    15931593    QPointF paintPoint = rect.topLeft();
    15941594
    1595     /* Take the backing-scale-factor into account: */
    1596     if (fUseUnscaledHiDPIOutput && dBackingScaleFactor > 1.0)
    1597         paintPoint /= dBackingScaleFactor;
     1595    /* Take the device-pixel-ratio into account: */
     1596    if (fUseUnscaledHiDPIOutput && dDevicePixelRatio > 1.0)
     1597        paintPoint /= dDevicePixelRatio;
    15981598
    15991599    /* Draw sub-pixmap: */
     
    17231723}
    17241724
    1725 double UIFrameBuffer::backingScaleFactor() const
    1726 {
    1727     return m_pFrameBuffer->backingScaleFactor();
    1728 }
    1729 
    1730 void UIFrameBuffer::setBackingScaleFactor(double dBackingScaleFactor)
    1731 {
    1732     m_pFrameBuffer->setBackingScaleFactor(dBackingScaleFactor);
     1725double UIFrameBuffer::devicePixelRatio() const
     1726{
     1727    return m_pFrameBuffer->devicePixelRatio();
     1728}
     1729
     1730void UIFrameBuffer::setDevicePixelRatio(double dDevicePixelRatio)
     1731{
     1732    m_pFrameBuffer->setDevicePixelRatio(dDevicePixelRatio);
    17331733}
    17341734
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r69500 r69931  
    106106    void setScaleFactor(double dScaleFactor);
    107107
    108     /** Returns backing-scale-factor used by HiDPI frame-buffer. */
    109     double backingScaleFactor() const;
    110     /** Defines backing-scale-factor used by HiDPI frame-buffer. */
    111     void setBackingScaleFactor(double dBackingScaleFactor);
     108    /** Returns device-pixel-ratio set for HiDPI frame-buffer. */
     109    double devicePixelRatio() const;
     110    /** Defines device-pixel-ratio set for HiDPI frame-buffer. */
     111    void setDevicePixelRatio(double dDevicePixelRatio);
    112112
    113113    /** Returns whether frame-buffer should use unscaled HiDPI output. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r69824 r69931  
    435435    }
    436436
    437     /* Shift has to be scaled by the backing-scale-factor
     437    /* Shift has to be scaled by the device-pixel-ratio
    438438     * but not scaled by the scale-factor. */
    439439    rect.translate(-contentsX(), -contentsY());
    440440
    441441#ifdef VBOX_WS_MAC
    442     /* Take the backing-scale-factor into account: */
     442    /* Take the device-pixel-ratio into account: */
    443443    if (frameBuffer()->useUnscaledHiDPIOutput())
    444444    {
    445         const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    446         if (dBackingScaleFactor > 1.0)
    447         {
    448             rect.moveTo((int)floor((double)rect.x() / dBackingScaleFactor) - 1,
    449                         (int)floor((double)rect.y() / dBackingScaleFactor) - 1);
    450             rect.setSize(QSize((int)ceil((double)rect.width()  / dBackingScaleFactor) + 2,
    451                                (int)ceil((double)rect.height() / dBackingScaleFactor) + 2));
     445        const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     446        if (dDevicePixelRatio > 1.0)
     447        {
     448            rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatio) - 1,
     449                        (int)floor((double)rect.y() / dDevicePixelRatio) - 1);
     450            rect.setSize(QSize((int)ceil((double)rect.width()  / dDevicePixelRatio) + 2,
     451                               (int)ceil((double)rect.height() / dDevicePixelRatio) + 2));
    452452        }
    453453    }
     
    706706
    707707#ifdef VBOX_WS_MAC
    708         /* Take backing scale-factor into account: */
    709         m_pFrameBuffer->setBackingScaleFactor(darwinBackingScaleFactor(machineWindow()));
     708        /* Take device-pixel-ratio into account: */
     709        m_pFrameBuffer->setDevicePixelRatio(gpDesktop->devicePixelRatio(machineWindow()));
    710710#endif /* VBOX_WS_MAC */
    711711
     
    11211121    m_pausePixmap = QPixmap::fromImage(screenShot);
    11221122#ifdef VBOX_WS_MAC
    1123     /* Adjust backing-scale-factor if necessary: */
    1124     const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1125     if (dBackingScaleFactor > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1126         m_pausePixmap.setDevicePixelRatio(dBackingScaleFactor);
     1123    /* Adjust device-pixel-ratio if necessary: */
     1124    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1125    if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
     1126        m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio);
    11271127#endif /* VBOX_WS_MAC */
    11281128
     
    11561156    m_pausePixmap = QPixmap::fromImage(screenShot);
    11571157#ifdef VBOX_WS_MAC
    1158     /* Adjust backing-scale-factor if necessary: */
    1159     const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1160     if (dBackingScaleFactor > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1161         m_pausePixmap.setDevicePixelRatio(dBackingScaleFactor);
     1158    /* Adjust device-pixel-ratio if necessary: */
     1159    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1160    if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
     1161        m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio);
    11621162#endif /* VBOX_WS_MAC */
    11631163
     
    11801180    m_pausePixmapScaled = pausePixmap().scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    11811181#ifdef VBOX_WS_MAC
    1182     /* Adjust backing-scale-factor if necessary: */
    1183     const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1184     if (dBackingScaleFactor > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1185         m_pausePixmapScaled.setDevicePixelRatio(dBackingScaleFactor);
     1182    /* Adjust device-pixel-ratio if necessary: */
     1183    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1184    if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
     1185        m_pausePixmapScaled.setDevicePixelRatio(dDevicePixelRatio);
    11861186#endif /* VBOX_WS_MAC */
    11871187}
     
    12091209#ifdef VBOX_WS_MAC
    12101210    /* Due to Qt 4.x doesn't supports HiDPI directly
    1211      * we should take the backing-scale-factor into account.
     1211     * we should take the device-pixel-ratio into account.
    12121212     * See also viewportToContents()... */
    12131213    if (frameBuffer()->useUnscaledHiDPIOutput())
    12141214    {
    1215         const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1216         if (dBackingScaleFactor > 1.0)
    1217         {
    1218             xRange *= dBackingScaleFactor;
    1219             yRange *= dBackingScaleFactor;
     1215        const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1216        if (dDevicePixelRatio > 1.0)
     1217        {
     1218            xRange *= dDevicePixelRatio;
     1219            yRange *= dDevicePixelRatio;
    12201220        }
    12211221    }
     
    12371237#ifdef VBOX_WS_MAC
    12381238    /* Due to Qt 4.x doesn't supports HiDPI directly
    1239      * we should take the backing-scale-factor into account.
     1239     * we should take the device-pixel-ratio into account.
    12401240     * See also updateSliders()... */
    12411241    if (frameBuffer()->useUnscaledHiDPIOutput())
    12421242    {
    1243         const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1244         if (dBackingScaleFactor > 1.0)
    1245         {
    1246             iContentsX /= dBackingScaleFactor;
    1247             iContentsY /= dBackingScaleFactor;
     1243        const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1244        if (dDevicePixelRatio > 1.0)
     1245        {
     1246            iContentsX /= dDevicePixelRatio;
     1247            iContentsY /= dDevicePixelRatio;
    12481248        }
    12491249    }
     
    14601460                    if (m_pFrameBuffer)
    14611461                    {
    1462                         /* Update backing-scale-factor for underlying frame-buffer: */
    1463                         m_pFrameBuffer->setBackingScaleFactor(darwinBackingScaleFactor(machineWindow()));
     1462                        /* Update device-pixel-ratio for underlying frame-buffer: */
     1463                        m_pFrameBuffer->setDevicePixelRatio(gpDesktop->devicePixelRatio(machineWindow()));
    14641464                        /* Perform frame-buffer rescaling: */
    14651465                        m_pFrameBuffer->performRescale();
     
    18691869
    18701870#ifdef VBOX_WS_MAC
    1871     /* Take the backing-scale-factor into account: */
     1871    /* Take the device-pixel-ratio into account: */
    18721872    if (frameBuffer()->useUnscaledHiDPIOutput())
    18731873    {
    1874         const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1875         if (dBackingScaleFactor > 1.0)
    1876             size = QSize(size.width() / dBackingScaleFactor, size.height() / dBackingScaleFactor);
     1874        const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1875        if (dDevicePixelRatio > 1.0)
     1876            size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio);
    18771877    }
    18781878#endif /* VBOX_WS_MAC */
     
    18851885{
    18861886#ifdef VBOX_WS_MAC
    1887     /* Take the backing-scale-factor into account: */
     1887    /* Take the device-pixel-ratio into account: */
    18881888    if (frameBuffer()->useUnscaledHiDPIOutput())
    18891889    {
    1890         const double dBackingScaleFactor = frameBuffer()->backingScaleFactor();
    1891         if (dBackingScaleFactor > 1.0)
    1892             size = QSize(size.width() * dBackingScaleFactor, size.height() * dBackingScaleFactor);
     1890        const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1891        if (dDevicePixelRatio > 1.0)
     1892            size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio);
    18931893    }
    18941894#endif /* VBOX_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r69500 r69931  
    10451045
    10461046#ifdef VBOX_WS_MAC
    1047             /* Take the backing-scale-factor into account: */
     1047            /* Take the device-pixel-ratio into account: */
    10481048            if (pFrameBuffer->useUnscaledHiDPIOutput())
    10491049            {
    1050                 const double dBackingScaleFactor = pFrameBuffer->backingScaleFactor();
    1051                 if (dBackingScaleFactor > 1.0)
    1052                 {
    1053                     cpnt.setX((int)(cpnt.x() * dBackingScaleFactor));
    1054                     cpnt.setY((int)(cpnt.y() * dBackingScaleFactor));
     1050                const double dDevicePixelRatio = pFrameBuffer->devicePixelRatio();
     1051                if (dDevicePixelRatio > 1.0)
     1052                {
     1053                    cpnt.setX((int)(cpnt.x() * dDevicePixelRatio));
     1054                    cpnt.setY((int)(cpnt.y() * dDevicePixelRatio));
    10551055                }
    10561056            }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r69858 r69931  
    17771777    QPixmap cursorPixmap = QPixmap::fromImage(image);
    17781778# ifdef VBOX_WS_MAC
    1779     /* Adjust backing-scale-factor: */
    1780     /// @todo In case of multi-monitor setup check whether backing-scale factor and cursor are screen specific.
     1779    /* Adjust device-pixel-ratio: */
     1780    /// @todo In case of multi-monitor setup check whether device-pixel-ratio and cursor are screen specific.
    17811781    /* Get screen-id of main-window: */
    17821782    const ulong uScreenID = machineLogic()->activeMachineWindow()->screenId();
    1783     /* Get backing-scale-factor: */
    1784     const double dBackingScaleFactor = frameBuffer(uScreenID)->backingScaleFactor();
    1785     /* Adjust backing-scale-factor if necessary: */
    1786     if (dBackingScaleFactor > 1.0 && frameBuffer(uScreenID)->useUnscaledHiDPIOutput())
    1787     {
    1788         uXHot /= dBackingScaleFactor;
    1789         uYHot /= dBackingScaleFactor;
    1790         cursorPixmap.setDevicePixelRatio(dBackingScaleFactor);
     1783    /* Get device-pixel-ratio: */
     1784    const double dDevicePixelRatio = frameBuffer(uScreenID)->devicePixelRatio();
     1785    /* Adjust device-pixel-ratio if necessary: */
     1786    if (dDevicePixelRatio > 1.0 && frameBuffer(uScreenID)->useUnscaledHiDPIOutput())
     1787    {
     1788        uXHot /= dDevicePixelRatio;
     1789        uYHot /= dDevicePixelRatio;
     1790        cursorPixmap.setDevicePixelRatio(dDevicePixelRatio);
    17911791    }
    17921792# endif /* VBOX_WS_MAC */
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