Changeset 69931 in vbox for trunk/src/VBox
- Timestamp:
- Dec 5, 2017 10:20:34 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119418
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r69500 r69931 34 34 /* GUI includes: */ 35 35 # include "VBoxFBOverlay.h" 36 # include "UIDesktopWidgetWatchdog.h" 36 37 # include "UIMessageCenter.h" 37 38 # include "UIPopupCenter.h" … … 4447 4448 4448 4449 #ifdef VBOX_WS_MAC 4449 /* Take the backing-scale-factorinto account: */4450 /* Take the device-pixel-ratio into account: */ 4450 4451 if (mSizeInfo.useUnscaledHiDPIOutput()) 4451 4452 { 4452 const double d BackingScaleFactor = darwinBackingScaleFactor(mpViewport->window());4453 if (d BackingScaleFactor> 1.0)4454 { 4455 rect.moveTo((int)floor((double)rect.x() / d BackingScaleFactor) - 1,4456 (int)floor((double)rect.y() / d BackingScaleFactor) - 1);4457 rect.setSize(QSize((int)ceil((double)rect.width() / d BackingScaleFactor) + 2,4458 (int)ceil((double)rect.height() / d BackingScaleFactor) + 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)); 4459 4460 } 4460 4461 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp
r69500 r69931 355 355 #endif /* VBOX_WS_X11 */ 356 356 357 double 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 368 double UIDesktopWidgetWatchdog::devicePixelRatio(QWidget *pWidget) 369 { 370 /* Redirect call to wrapper above: */ 371 return devicePixelRatio(screenNumber(pWidget)); 372 } 373 357 374 void UIDesktopWidgetWatchdog::sltHostScreenAdded(QScreen *pHostScreen) 358 375 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.h
r69500 r69931 106 106 #endif 107 107 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 108 113 private slots: 109 114 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm
r69824 r69931 263 263 else 264 264 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;290 265 } 291 266 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp
r69500 r69931 176 176 { 177 177 return ::darwinOpenFile(darwinToNativeString(strFile.toUtf8().constData())); 178 }179 180 double darwinBackingScaleFactor(QWidget *pWidget)181 {182 return ::darwinBackingScaleFactor(::darwinToNativeWindow(pWidget));183 178 } 184 179 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h
r69500 r69931 102 102 103 103 bool darwinOpenFile(NativeNSStringRef pstrFile); 104 105 double darwinBackingScaleFactor(NativeNSWindowRef pWindow);106 104 107 105 float darwinSmallFontSize(); … … 279 277 bool darwinOpenFile(const QString &strFile); 280 278 281 double darwinBackingScaleFactor(QWidget *pWidget);282 283 279 QString darwinSystemLanguage(void); 284 280 QPixmap darwinCreateDragPixmap(const QPixmap& aPixmap, const QString &aText); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r69824 r69931 153 153 void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; } 154 154 155 /** Returns backing-scale-factor used byHiDPI frame-buffer. */156 double backingScaleFactor() const { return m_dBackingScaleFactor; }157 /** Defines backing-scale-factor used byHiDPI frame-buffer. */158 void set BackingScaleFactor(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; } 159 159 160 160 /** Returns whether frame-buffer should use unscaled HiDPI output. */ … … 301 301 bool fUseUnscaledHiDPIOutput, 302 302 HiDPIOptimizationType hiDPIOptimizationType, 303 double d BackingScaleFactor);303 double dDevicePixelRatio); 304 304 /** Draws corresponding @a rect of passed @a image with @a painter. */ 305 305 static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect, … … 307 307 bool fUseUnscaledHiDPIOutput, 308 308 HiDPIOptimizationType hiDPIOptimizationType, 309 double d BackingScaleFactor);309 double dDevicePixelRatio); 310 310 311 311 /** Holds the screen-id. */ … … 382 382 /** @name HiDPI screens related variables. 383 383 * @{ */ 384 /** Holds backing-scale-factor used byHiDPI frame-buffer. */385 double m_d BackingScaleFactor;384 /** Holds device-pixel-ratio set for HiDPI frame-buffer. */ 385 double m_dDevicePixelRatio; 386 386 /** Holds whether frame-buffer should use unscaled HiDPI output. */ 387 387 bool m_fUseUnscaledHiDPIOutput; … … 536 536 , m_dScaleFactor(1.0) 537 537 , m_enmScalingOptimizationType(ScalingOptimizationType_None) 538 , m_d BackingScaleFactor(1.0)538 , m_dDevicePixelRatio(1.0) 539 539 , m_fUseUnscaledHiDPIOutput(false) 540 540 , m_hiDPIOptimizationType(HiDPIOptimizationType_None) … … 980 980 } 981 981 /* Tune according scale-factor: */ 982 if (scaleFactor() != 1.0 || backingScaleFactor() > 1.0)982 if (scaleFactor() != 1.0 || devicePixelRatio() > 1.0) 983 983 region = m_transform.map(region); 984 984 … … 1332 1332 m_transform = m_transform.scale(scaleFactor(), scaleFactor()); 1333 1333 1334 /* Apply the backing-scale-factorif 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()); 1337 1337 } 1338 1338 … … 1366 1366 QRect paintRect = pEvent->rect(); 1367 1367 1368 /* Take the backing-scale-factorinto 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()); 1373 1373 } 1374 1374 … … 1384 1384 /* On OSX for Qt5 we need to erase backing store first: */ 1385 1385 QRect eraseRect = paintRect; 1386 /* Take the backing-scale-factorinto 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()); 1391 1391 } 1392 1392 /* Replace translucent background with black one: */ … … 1399 1399 drawImageRect(painter, sourceImage, paintRect, 1400 1400 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 1401 useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());1401 useUnscaledHiDPIOutput(), hiDPIOptimizationType(), devicePixelRatio()); 1402 1402 } 1403 1403 … … 1437 1437 unlock(); 1438 1438 1439 /* Take the backing-scale-factorinto 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()); 1444 1444 } 1445 1445 … … 1458 1458 /* Erase rectangle: */ 1459 1459 eraseImageRect(painter, paintRect, 1460 useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());1460 useUnscaledHiDPIOutput(), hiDPIOptimizationType(), devicePixelRatio()); 1461 1461 1462 1462 /* Apply painter clipping for painting: */ … … 1468 1468 /* On OSX for Qt5 we need to erase backing store first: */ 1469 1469 QRect eraseRect = paintRect; 1470 /* Take the backing-scale-factorinto 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()); 1475 1475 } 1476 1476 /* Replace translucent background with black one: */ … … 1483 1483 drawImageRect(painter, sourceImage, paintRect, 1484 1484 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 1485 useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());1485 useUnscaledHiDPIOutput(), hiDPIOptimizationType(), devicePixelRatio()); 1486 1486 } 1487 1487 … … 1503 1503 bool fUseUnscaledHiDPIOutput, 1504 1504 HiDPIOptimizationType hiDPIOptimizationType, 1505 double d BackingScaleFactor)1505 double dDevicePixelRatio) 1506 1506 { 1507 1507 /* Prepare sub-pixmap: */ 1508 1508 QPixmap subPixmap = QPixmap(rect.width(), rect.height()); 1509 1509 1510 /* If HiDPI ' backing-scale-factor' defined: */1511 if (d BackingScaleFactor> 1.0)1510 /* If HiDPI 'device-pixel-ratio' defined: */ 1511 if (dDevicePixelRatio > 1.0) 1512 1512 { 1513 1513 /* Should we … … 1516 1516 { 1517 1517 /* Adjust sub-pixmap: */ 1518 subPixmap = QPixmap((int)(rect.width() * d BackingScaleFactor),1519 (int)(rect.height() * d BackingScaleFactor));1518 subPixmap = QPixmap((int)(rect.width() * dDevicePixelRatio), 1519 (int)(rect.height() * dDevicePixelRatio)); 1520 1520 } 1521 1521 … … 1527 1527 { 1528 1528 /* Mark sub-pixmap as HiDPI: */ 1529 subPixmap.setDevicePixelRatio(d BackingScaleFactor);1529 subPixmap.setDevicePixelRatio(dDevicePixelRatio); 1530 1530 } 1531 1531 #endif /* VBOX_WS_MAC */ … … 1535 1535 QPointF paintPoint = rect.topLeft(); 1536 1536 1537 /* Take the backing-scale-factorinto account: */1538 if (fUseUnscaledHiDPIOutput && d BackingScaleFactor> 1.0)1539 paintPoint /= d BackingScaleFactor;1537 /* Take the device-pixel-ratio into account: */ 1538 if (fUseUnscaledHiDPIOutput && dDevicePixelRatio > 1.0) 1539 paintPoint /= dDevicePixelRatio; 1540 1540 1541 1541 /* Draw sub-pixmap: */ … … 1548 1548 bool fUseUnscaledHiDPIOutput, 1549 1549 HiDPIOptimizationType hiDPIOptimizationType, 1550 double d BackingScaleFactor)1550 double dDevicePixelRatio) 1551 1551 { 1552 1552 /* Calculate offset: */ … … 1566 1566 QPixmap subPixmap = QPixmap::fromImage(subImage); 1567 1567 1568 /* If HiDPI ' backing-scale-factor' defined: */1569 if (d BackingScaleFactor> 1.0)1568 /* If HiDPI 'device-pixel-ratio' defined: */ 1569 if (dDevicePixelRatio > 1.0) 1570 1570 { 1571 1571 /* Should we … … 1574 1574 { 1575 1575 /* Fast scale sub-pixmap (2nd copy involved): */ 1576 subPixmap = subPixmap.scaled(subPixmap.size() * d BackingScaleFactor,1576 subPixmap = subPixmap.scaled(subPixmap.size() * dDevicePixelRatio, 1577 1577 Qt::IgnoreAspectRatio, Qt::FastTransformation); 1578 1578 } … … 1585 1585 { 1586 1586 /* Mark sub-pixmap as HiDPI: */ 1587 subPixmap.setDevicePixelRatio(d BackingScaleFactor);1587 subPixmap.setDevicePixelRatio(dDevicePixelRatio); 1588 1588 } 1589 1589 #endif /* VBOX_WS_MAC */ … … 1593 1593 QPointF paintPoint = rect.topLeft(); 1594 1594 1595 /* Take the backing-scale-factorinto account: */1596 if (fUseUnscaledHiDPIOutput && d BackingScaleFactor> 1.0)1597 paintPoint /= d BackingScaleFactor;1595 /* Take the device-pixel-ratio into account: */ 1596 if (fUseUnscaledHiDPIOutput && dDevicePixelRatio > 1.0) 1597 paintPoint /= dDevicePixelRatio; 1598 1598 1599 1599 /* Draw sub-pixmap: */ … … 1723 1723 } 1724 1724 1725 double UIFrameBuffer:: backingScaleFactor() const1726 { 1727 return m_pFrameBuffer-> backingScaleFactor();1728 } 1729 1730 void UIFrameBuffer::set BackingScaleFactor(double dBackingScaleFactor)1731 { 1732 m_pFrameBuffer->set BackingScaleFactor(dBackingScaleFactor);1725 double UIFrameBuffer::devicePixelRatio() const 1726 { 1727 return m_pFrameBuffer->devicePixelRatio(); 1728 } 1729 1730 void UIFrameBuffer::setDevicePixelRatio(double dDevicePixelRatio) 1731 { 1732 m_pFrameBuffer->setDevicePixelRatio(dDevicePixelRatio); 1733 1733 } 1734 1734 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h
r69500 r69931 106 106 void setScaleFactor(double dScaleFactor); 107 107 108 /** Returns backing-scale-factor used byHiDPI frame-buffer. */109 double backingScaleFactor() const;110 /** Defines backing-scale-factor used byHiDPI frame-buffer. */111 void set BackingScaleFactor(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); 112 112 113 113 /** Returns whether frame-buffer should use unscaled HiDPI output. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r69824 r69931 435 435 } 436 436 437 /* Shift has to be scaled by the backing-scale-factor437 /* Shift has to be scaled by the device-pixel-ratio 438 438 * but not scaled by the scale-factor. */ 439 439 rect.translate(-contentsX(), -contentsY()); 440 440 441 441 #ifdef VBOX_WS_MAC 442 /* Take the backing-scale-factorinto account: */442 /* Take the device-pixel-ratio into account: */ 443 443 if (frameBuffer()->useUnscaledHiDPIOutput()) 444 444 { 445 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();446 if (d BackingScaleFactor> 1.0)447 { 448 rect.moveTo((int)floor((double)rect.x() / d BackingScaleFactor) - 1,449 (int)floor((double)rect.y() / d BackingScaleFactor) - 1);450 rect.setSize(QSize((int)ceil((double)rect.width() / d BackingScaleFactor) + 2,451 (int)ceil((double)rect.height() / d BackingScaleFactor) + 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)); 452 452 } 453 453 } … … 706 706 707 707 #ifdef VBOX_WS_MAC 708 /* Take backing scale-factorinto account: */709 m_pFrameBuffer->set BackingScaleFactor(darwinBackingScaleFactor(machineWindow()));708 /* Take device-pixel-ratio into account: */ 709 m_pFrameBuffer->setDevicePixelRatio(gpDesktop->devicePixelRatio(machineWindow())); 710 710 #endif /* VBOX_WS_MAC */ 711 711 … … 1121 1121 m_pausePixmap = QPixmap::fromImage(screenShot); 1122 1122 #ifdef VBOX_WS_MAC 1123 /* Adjust backing-scale-factorif necessary: */1124 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1125 if (d BackingScaleFactor> 1.0 && frameBuffer()->useUnscaledHiDPIOutput())1126 m_pausePixmap.setDevicePixelRatio(d BackingScaleFactor);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); 1127 1127 #endif /* VBOX_WS_MAC */ 1128 1128 … … 1156 1156 m_pausePixmap = QPixmap::fromImage(screenShot); 1157 1157 #ifdef VBOX_WS_MAC 1158 /* Adjust backing-scale-factorif necessary: */1159 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1160 if (d BackingScaleFactor> 1.0 && frameBuffer()->useUnscaledHiDPIOutput())1161 m_pausePixmap.setDevicePixelRatio(d BackingScaleFactor);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); 1162 1162 #endif /* VBOX_WS_MAC */ 1163 1163 … … 1180 1180 m_pausePixmapScaled = pausePixmap().scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 1181 1181 #ifdef VBOX_WS_MAC 1182 /* Adjust backing-scale-factorif necessary: */1183 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1184 if (d BackingScaleFactor> 1.0 && frameBuffer()->useUnscaledHiDPIOutput())1185 m_pausePixmapScaled.setDevicePixelRatio(d BackingScaleFactor);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); 1186 1186 #endif /* VBOX_WS_MAC */ 1187 1187 } … … 1209 1209 #ifdef VBOX_WS_MAC 1210 1210 /* Due to Qt 4.x doesn't supports HiDPI directly 1211 * we should take the backing-scale-factorinto account.1211 * we should take the device-pixel-ratio into account. 1212 1212 * See also viewportToContents()... */ 1213 1213 if (frameBuffer()->useUnscaledHiDPIOutput()) 1214 1214 { 1215 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1216 if (d BackingScaleFactor> 1.0)1217 { 1218 xRange *= d BackingScaleFactor;1219 yRange *= d BackingScaleFactor;1215 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1216 if (dDevicePixelRatio > 1.0) 1217 { 1218 xRange *= dDevicePixelRatio; 1219 yRange *= dDevicePixelRatio; 1220 1220 } 1221 1221 } … … 1237 1237 #ifdef VBOX_WS_MAC 1238 1238 /* Due to Qt 4.x doesn't supports HiDPI directly 1239 * we should take the backing-scale-factorinto account.1239 * we should take the device-pixel-ratio into account. 1240 1240 * See also updateSliders()... */ 1241 1241 if (frameBuffer()->useUnscaledHiDPIOutput()) 1242 1242 { 1243 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1244 if (d BackingScaleFactor> 1.0)1245 { 1246 iContentsX /= d BackingScaleFactor;1247 iContentsY /= d BackingScaleFactor;1243 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1244 if (dDevicePixelRatio > 1.0) 1245 { 1246 iContentsX /= dDevicePixelRatio; 1247 iContentsY /= dDevicePixelRatio; 1248 1248 } 1249 1249 } … … 1460 1460 if (m_pFrameBuffer) 1461 1461 { 1462 /* Update backing-scale-factorfor underlying frame-buffer: */1463 m_pFrameBuffer->set BackingScaleFactor(darwinBackingScaleFactor(machineWindow()));1462 /* Update device-pixel-ratio for underlying frame-buffer: */ 1463 m_pFrameBuffer->setDevicePixelRatio(gpDesktop->devicePixelRatio(machineWindow())); 1464 1464 /* Perform frame-buffer rescaling: */ 1465 1465 m_pFrameBuffer->performRescale(); … … 1869 1869 1870 1870 #ifdef VBOX_WS_MAC 1871 /* Take the backing-scale-factorinto account: */1871 /* Take the device-pixel-ratio into account: */ 1872 1872 if (frameBuffer()->useUnscaledHiDPIOutput()) 1873 1873 { 1874 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1875 if (d BackingScaleFactor> 1.0)1876 size = QSize(size.width() / d BackingScaleFactor, size.height() / dBackingScaleFactor);1874 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1875 if (dDevicePixelRatio > 1.0) 1876 size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio); 1877 1877 } 1878 1878 #endif /* VBOX_WS_MAC */ … … 1885 1885 { 1886 1886 #ifdef VBOX_WS_MAC 1887 /* Take the backing-scale-factorinto account: */1887 /* Take the device-pixel-ratio into account: */ 1888 1888 if (frameBuffer()->useUnscaledHiDPIOutput()) 1889 1889 { 1890 const double d BackingScaleFactor = frameBuffer()->backingScaleFactor();1891 if (d BackingScaleFactor> 1.0)1892 size = QSize(size.width() * d BackingScaleFactor, size.height() * dBackingScaleFactor);1890 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1891 if (dDevicePixelRatio > 1.0) 1892 size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio); 1893 1893 } 1894 1894 #endif /* VBOX_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r69500 r69931 1045 1045 1046 1046 #ifdef VBOX_WS_MAC 1047 /* Take the backing-scale-factorinto account: */1047 /* Take the device-pixel-ratio into account: */ 1048 1048 if (pFrameBuffer->useUnscaledHiDPIOutput()) 1049 1049 { 1050 const double d BackingScaleFactor = pFrameBuffer->backingScaleFactor();1051 if (d BackingScaleFactor> 1.0)1052 { 1053 cpnt.setX((int)(cpnt.x() * d BackingScaleFactor));1054 cpnt.setY((int)(cpnt.y() * d BackingScaleFactor));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)); 1055 1055 } 1056 1056 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r69858 r69931 1777 1777 QPixmap cursorPixmap = QPixmap::fromImage(image); 1778 1778 # ifdef VBOX_WS_MAC 1779 /* Adjust backing-scale-factor: */1780 /// @todo In case of multi-monitor setup check whether backing-scale factorand 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. 1781 1781 /* Get screen-id of main-window: */ 1782 1782 const ulong uScreenID = machineLogic()->activeMachineWindow()->screenId(); 1783 /* Get backing-scale-factor: */1784 const double d BackingScaleFactor = frameBuffer(uScreenID)->backingScaleFactor();1785 /* Adjust backing-scale-factorif necessary: */1786 if (d BackingScaleFactor> 1.0 && frameBuffer(uScreenID)->useUnscaledHiDPIOutput())1787 { 1788 uXHot /= d BackingScaleFactor;1789 uYHot /= d BackingScaleFactor;1790 cursorPixmap.setDevicePixelRatio(d BackingScaleFactor);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); 1791 1791 } 1792 1792 # endif /* VBOX_WS_MAC */
Note:
See TracChangeset
for help on using the changeset viewer.