Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.15.0
-
None
-
UOS(Deepin)
Description
When there are two screens, the calculation of virtualGeometry comes from screen->geometry(), while screen->geometry() comes from the function deviceIndependentGeometry(). This function does not calculate the zoom when calculating topleft (for example, the zoom ratio is 1.25). This leads to an increase in the calculation of virtualGeometry.
or example: the first small screen is on the left, and the size is 1920*1080. The second large screen is on the right, and the size is 3840*2160. In the absence of scaling, the geometry of the two screens is (0,0,1920 + 0,1080 + 0) (1920,0,3840 1920 ,2160 + 0) Their virtualGeometry is (0,0,5760,2160) when the zoom factor is 1.25. Because topleft is not scaled in the deviceIndependentGeometry function, the scaled coordinates of the two screens are (0,0,1536 + 0,864 0) (1920,0,3072 1920,1728 0), and the calculated virtualGeometry (0 ,0,4992,1728).
The virtualGeometry here is because topleft is not scaled, and the calculated size has exceeded the size of the screen. The correct size should be (0,0,4800(3072+1536),1728). So when zooming, we should consider geometry->topleft
QRect QPlatformScreen::deviceIndependentGeometry() const { qreal scaleFactor = QHighDpiScaling::factor(this); QRect nativeGeometry = geometry(); return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor)); }
example:
#include <QApplication> #include <QDebug> #include <QScreen> int main(int argc, char *argv[]) { qputenv("QT_SCALE_FACTOR", "1.25"); QApplication a(argc, argv); QWidget w; qDebug() << "MyMainWindow" <<qApp->screens().at(0)->geometry() << qApp->screens().at(1)->geometry() ; qDebug() << "MyMainWindow" <<qApp->screens().at(0)->virtualGeometry() << qApp->screens().at(1)->virtualGeometry() ; qDebug() << "MyMainWindow" <<qApp->screens().at(0)->availableGeometry() << qApp->screens().at(1)->availableGeometry() ; w.showFullScreen(); return a.exec(); }
Attachments
For Gerrit Dashboard: QTBUG-86565 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
313553,4 | Fix QScreen::virtualGeometry() in high-DPI scenarios | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |