Changeset 82032 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 20, 2019 4:21:59 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134836
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r82030 r82032 17 17 18 18 /* Qt includes: */ 19 #include <QBitmap> 19 20 #include <QMainWindow> 20 21 #include <QPainter> … … 620 621 } 621 622 623 void UIMachineView::sltMousePointerShapeChange() 624 { 625 /* Fetch the shape and the mask: */ 626 QPixmap pixmapShape = uisession()->cursorShapePixmap(); 627 QPixmap pixmapMask = uisession()->cursorMaskPixmap(); 628 const QPoint hotspot = uisession()->cursorHotspot(); 629 uint uXHot = hotspot.x(); 630 uint uYHot = hotspot.y(); 631 632 /* If there is no mask: */ 633 if (pixmapMask.isNull()) 634 { 635 /* Scale the shape pixmap and 636 * compose the cursor on the basis of shape only: */ 637 updateMousePointerPixmapScaling(pixmapShape, uXHot, uYHot); 638 m_cursor = QCursor(pixmapShape, uXHot, uYHot); 639 } 640 /* Otherwise: */ 641 else 642 { 643 /* Scale the shape and the mask pixmaps and 644 * compose the cursor on the basis of shape and mask both: */ 645 updateMousePointerPixmapScaling(pixmapShape, uXHot, uYHot); 646 /// @todo updateMousePointerPixmapScaling(pixmapMask, uXHot, uYHot); 647 m_cursor = QCursor(pixmapShape, pixmapMask, uXHot, uYHot); 648 } 649 650 /* Let the listeners know: */ 651 emit sigMousePointerShapeChange(); 652 } 653 622 654 UIMachineView::UIMachineView( UIMachineWindow *pMachineWindow 623 655 , ulong uScreenId … … 837 869 connect(uisession(), &UISession::sigMachineStateChange, this, &UIMachineView::sltMachineStateChanged); 838 870 /* Mouse pointer shape updater: */ 839 connect(uisession(), &UISession::sigMousePointerShapeChange, this, &UIMachineView::s igMousePointerShapeChange);871 connect(uisession(), &UISession::sigMousePointerShapeChange, this, &UIMachineView::sltMousePointerShapeChange); 840 872 } 841 873 … … 1910 1942 return size; 1911 1943 } 1944 1945 void UIMachineView::updateMousePointerPixmapScaling(QPixmap &pixmap, uint &uXHot, uint &uYHot) 1946 { 1947 #if defined(VBOX_WS_MAC) 1948 1949 /* Take into account scale-factor if necessary: */ 1950 const double dScaleFactor = frameBuffer()->scaleFactor(); 1951 //printf("Scale-factor: %f\n", dScaleFactor); 1952 if (dScaleFactor > 1.0) 1953 { 1954 /* Scale the pixmap up: */ 1955 pixmap = pixmap.scaled(pixmap.width() * dScaleFactor, pixmap.height() * dScaleFactor, 1956 Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 1957 uXHot *= dScaleFactor; 1958 uYHot *= dScaleFactor; 1959 } 1960 1961 /* Take into account device-pixel-ratio if necessary: */ 1962 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1963 const bool fUseUnscaledHiDPIOutput = frameBuffer()->useUnscaledHiDPIOutput(); 1964 //printf("Device-pixel-ratio: %f, Unscaled HiDPI Output: %d\n", 1965 // dDevicePixelRatio, fUseUnscaledHiDPIOutput); 1966 if (dDevicePixelRatio > 1.0 && fUseUnscaledHiDPIOutput) 1967 { 1968 /* Scale the pixmap down: */ 1969 pixmap.setDevicePixelRatio(dDevicePixelRatio); 1970 uXHot /= dDevicePixelRatio; 1971 uYHot /= dDevicePixelRatio; 1972 } 1973 1974 #elif defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 1975 1976 /* We want to scale the pixmap just once, so let's prepare cumulative multiplier: */ 1977 double dScaleMultiplier = 1.0; 1978 1979 /* Take into account scale-factor if necessary: */ 1980 const double dScaleFactor = frameBuffer()->scaleFactor(); 1981 //printf("Scale-factor: %f\n", dScaleFactor); 1982 if (dScaleFactor > 1.0) 1983 dScaleMultiplier *= dScaleFactor; 1984 1985 /* Take into account device-pixel-ratio if necessary: */ 1986 # ifdef VBOX_WS_WIN 1987 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1988 # endif 1989 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual(); 1990 const bool fUseUnscaledHiDPIOutput = frameBuffer()->useUnscaledHiDPIOutput(); 1991 //printf("Device-pixel-ratio/actual: %f/%f, Unscaled HiDPI Output: %d\n", 1992 // dDevicePixelRatio, dDevicePixelRatioActual, fUseUnscaledHiDPIOutput); 1993 if (dDevicePixelRatioActual > 1.0 && !fUseUnscaledHiDPIOutput) 1994 dScaleMultiplier *= dDevicePixelRatioActual; 1995 1996 /* If scale multiplier was set: */ 1997 if (dScaleMultiplier > 1.0) 1998 { 1999 /* Scale the pixmap up: */ 2000 pixmap = pixmap.scaled(pixmap.width() * dScaleMultiplier, pixmap.height() * dScaleMultiplier, 2001 Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 2002 uXHot *= dScaleMultiplier; 2003 uYHot *= dScaleMultiplier; 2004 } 2005 2006 # ifdef VBOX_WS_WIN 2007 /* If device pixel ratio was set: */ 2008 if (dDevicePixelRatio > 1.0) 2009 { 2010 /* Scale the pixmap down: */ 2011 pixmap.setDevicePixelRatio(dDevicePixelRatio); 2012 uXHot /= dDevicePixelRatio; 2013 uYHot /= dDevicePixelRatio; 2014 } 2015 # endif 2016 2017 #else 2018 2019 Q_UNUSED(pixmap); 2020 Q_UNUSED(uXHot); 2021 Q_UNUSED(uYHot); 2022 2023 #endif 2024 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r82030 r82032 139 139 /* Console callback handlers: */ 140 140 virtual void sltMachineStateChanged(); 141 /** Handles guest request to change the mouse pointer shape. */ 142 void sltMousePointerShapeChange(); 141 143 142 144 protected: … … 234 236 void updateScaledPausePixmap(); 235 237 238 /** Returns cached mouse cursor. */ 239 QCursor cursor() const { return m_cursor; } 240 236 241 /** The available area on the current screen for application windows. */ 237 242 virtual QRect workingArea() const = 0; … … 340 345 QSize scaledBackward(QSize size) const; 341 346 347 /** Updates mouse pointer @a pixmap, @a uXHot and @a uYHot according to scaling attributes. */ 348 void updateMousePointerPixmapScaling(QPixmap &pixmap, uint &uXHot, uint &uYHot); 349 342 350 /* Protected members: */ 343 351 UIMachineWindow *m_pMachineWindow; … … 378 386 QPixmap m_pausePixmapScaled; 379 387 388 /** Holds cached mouse cursor. */ 389 QCursor m_cursor; 390 380 391 #ifdef VBOX_WITH_DRAG_AND_DROP 381 392 /** Pointer to drag and drop handler instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r82030 r82032 477 477 QList<ulong> screenIds = m_viewports.keys(); 478 478 for (int i = 0; i < screenIds.size(); ++i) 479 UICommon::setCursor(m_viewports[screenIds[i]], uisession()->cursor());479 UICommon::setCursor(m_viewports[screenIds[i]], m_views[screenIds[i]]->cursor()); 480 480 } 481 481 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r82029 r82032 1658 1658 /* Fetch incoming shape data: */ 1659 1659 const bool fHasAlpha = m_shapeData.hasAlpha(); 1660 uint uXHot = m_shapeData.hotSpot().x();1661 uint uYHot = m_shapeData.hotSpot().y();1662 1660 const uint uWidth = m_shapeData.shapeSize().width(); 1663 1661 const uint uHeight = m_shapeData.shapeSize().height(); … … 1674 1672 const uint uAndMaskSize = (uWidth + 7) / 8 * uHeight; 1675 1673 const uchar *pSrcShapePtr = pShapeData + ((uAndMaskSize + 3) & ~3); 1676 1677 /* Remember initial cursor hotspot: */1678 m_cursorHotspot = QPoint(uXHot, uYHot);1679 1674 1680 1675 #if defined (VBOX_WS_WIN) … … 1698 1693 1699 1694 m_cursorShapePixmap = QPixmap::fromImage(image); 1700 updateMousePointerPixmapScaling(m_cursorShapePixmap, uXHot, uYHot);1701 m_cursor = QCursor(m_cursorShapePixmap, uXHot, uYHot);1702 1695 } 1703 1696 else … … 1790 1783 m_cursorShapePixmap = QBitmap::fromImage(bitmap); 1791 1784 m_cursorMaskPixmap = QBitmap::fromImage(mask); 1792 updateMousePointerPixmapScaling(m_cursorShapePixmap, uXHot, uYHot);1793 updateMousePointerPixmapScaling(m_cursorMaskPixmap, uXHot, uYHot);1794 m_cursor = QCursor(m_cursorShapePixmap, m_cursorMaskPixmap, uXHot, uYHot);1795 1785 } 1796 1786 else … … 1823 1813 1824 1814 m_cursorShapePixmap = QPixmap::fromImage(image); 1825 updateMousePointerPixmapScaling(m_cursorShapePixmap, uXHot, uYHot);1826 m_cursor = QCursor(m_cursorShapePixmap, uXHot, uYHot);1827 1815 } 1828 1816 } … … 1849 1837 /* Create cursor-pixmap from the image: */ 1850 1838 m_cursorShapePixmap = QPixmap::fromImage(image); 1851 updateMousePointerPixmapScaling(m_cursorShapePixmap, uXHot, uYHot);1852 m_cursor = QCursor(m_cursorShapePixmap, uXHot, uYHot);1853 1839 1854 1840 /* Mark mouse pointer shape valid: */ … … 1861 1847 #endif 1862 1848 1863 /* Cache cursor pixmap size : */1849 /* Cache cursor pixmap size and hotspot: */ 1864 1850 m_cursorSize = m_cursorShapePixmap.size(); 1865 } 1866 1867 void UISession::updateMousePointerPixmapScaling(QPixmap &pixmap, uint &uXHot, uint &uYHot) 1868 { 1869 #if defined(VBOX_WS_MAC) 1870 1871 /* Get screen-id of active machine-window: */ 1872 /// @todo In case of multi-monitor setup check whether parameters are screen specific. 1873 const ulong uScreenID = activeMachineWindow()->screenId(); 1874 1875 /* Take into account scale-factor if necessary: */ 1876 const double dScaleFactor = frameBuffer(uScreenID)->scaleFactor(); 1877 //printf("Scale-factor: %f\n", dScaleFactor); 1878 if (dScaleFactor > 1.0) 1879 { 1880 /* Scale the pixmap up: */ 1881 pixmap = pixmap.scaled(pixmap.width() * dScaleFactor, pixmap.height() * dScaleFactor, 1882 Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 1883 uXHot *= dScaleFactor; 1884 uYHot *= dScaleFactor; 1885 } 1886 1887 /* Take into account device-pixel-ratio if necessary: */ 1888 const double dDevicePixelRatio = frameBuffer(uScreenID)->devicePixelRatio(); 1889 const bool fUseUnscaledHiDPIOutput = frameBuffer(uScreenID)->useUnscaledHiDPIOutput(); 1890 //printf("Device-pixel-ratio: %f, Unscaled HiDPI Output: %d\n", 1891 // dDevicePixelRatio, fUseUnscaledHiDPIOutput); 1892 if (dDevicePixelRatio > 1.0 && fUseUnscaledHiDPIOutput) 1893 { 1894 /* Scale the pixmap down: */ 1895 pixmap.setDevicePixelRatio(dDevicePixelRatio); 1896 uXHot /= dDevicePixelRatio; 1897 uYHot /= dDevicePixelRatio; 1898 } 1899 1900 #elif defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 1901 1902 /* Get screen-id of active machine-window: */ 1903 /// @todo In case of multi-monitor setup check whether parameters are screen specific. 1904 const ulong uScreenID = activeMachineWindow()->screenId(); 1905 1906 /* We want to scale the pixmap just once, so let's prepare cumulative multiplier: */ 1907 double dScaleMultiplier = 1.0; 1908 1909 /* Take into account scale-factor if necessary: */ 1910 const double dScaleFactor = frameBuffer(uScreenID)->scaleFactor(); 1911 //printf("Scale-factor: %f\n", dScaleFactor); 1912 if (dScaleFactor > 1.0) 1913 dScaleMultiplier *= dScaleFactor; 1914 1915 /* Take into account device-pixel-ratio if necessary: */ 1916 # ifdef VBOX_WS_WIN 1917 const double dDevicePixelRatio = frameBuffer(uScreenID)->devicePixelRatio(); 1918 # endif 1919 const double dDevicePixelRatioActual = frameBuffer(uScreenID)->devicePixelRatioActual(); 1920 const bool fUseUnscaledHiDPIOutput = frameBuffer(uScreenID)->useUnscaledHiDPIOutput(); 1921 //printf("Device-pixel-ratio/actual: %f/%f, Unscaled HiDPI Output: %d\n", 1922 // dDevicePixelRatio, dDevicePixelRatioActual, fUseUnscaledHiDPIOutput); 1923 if (dDevicePixelRatioActual > 1.0 && !fUseUnscaledHiDPIOutput) 1924 dScaleMultiplier *= dDevicePixelRatioActual; 1925 1926 /* If scale multiplier was set: */ 1927 if (dScaleMultiplier > 1.0) 1928 { 1929 /* Scale the pixmap up: */ 1930 pixmap = pixmap.scaled(pixmap.width() * dScaleMultiplier, pixmap.height() * dScaleMultiplier, 1931 Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 1932 uXHot *= dScaleMultiplier; 1933 uYHot *= dScaleMultiplier; 1934 } 1935 1936 # ifdef VBOX_WS_WIN 1937 /* If device pixel ratio was set: */ 1938 if (dDevicePixelRatio > 1.0) 1939 { 1940 /* Scale the pixmap down: */ 1941 pixmap.setDevicePixelRatio(dDevicePixelRatio); 1942 uXHot /= dDevicePixelRatio; 1943 uYHot /= dDevicePixelRatio; 1944 } 1945 # endif 1946 1947 #else 1948 1949 Q_UNUSED(pixmap); 1950 Q_UNUSED(uXHot); 1951 Q_UNUSED(uYHot); 1952 1953 #endif 1851 m_cursorHotspot = m_shapeData.hotSpot(); 1954 1852 } 1955 1853 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r82022 r82032 135 135 UIMachineWindow *activeMachineWindow() const; 136 136 137 /** Returns currently cached mouse cursor. */138 QCursor cursor() const { return m_cursor; }139 137 /** Returns currently cached mouse cursor shape pixmap. */ 140 138 QPixmap cursorShapePixmap() const { return m_cursorShapePixmap; } … … 448 446 /** Updates mouse pointer shape. */ 449 447 void updateMousePointerShape(); 450 /** Updates mouse pointer @a pixmap, @a uXHot and @a uYHot according to scaling attributes. */451 void updateMousePointerPixmapScaling(QPixmap &pixmap, uint &uXHot, uint &uYHot);452 448 453 449 /* Common helpers: */ … … 512 508 KMachineState m_machineState; 513 509 514 /** Holds cached mouse cursor. */515 QCursor m_cursor;516 510 /** Holds cached mouse cursor shape pixmap. */ 517 511 QPixmap m_cursorShapePixmap;
Note:
See TracChangeset
for help on using the changeset viewer.