summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@nokia.com>2011-01-20 13:47:37 (GMT)
committerRobert Griebl <robert.griebl@nokia.com>2011-01-24 13:12:48 (GMT)
commit4810b587a65d81f8f90646efd09cadeb1276a756 (patch)
treebd39bad9b570d074d5046f9c18a7c36cb99fb5cf
parent4f9a318d639c4e7e09e56751d31608fb39d472af (diff)
downloadQt-4810b587a65d81f8f90646efd09cadeb1276a756.zip
Qt-4810b587a65d81f8f90646efd09cadeb1276a756.tar.gz
Qt-4810b587a65d81f8f90646efd09cadeb1276a756.tar.bz2
Fix Xrandr DPI calculation for NVidia TwinView.
The problem is that a Xinerama 'screen' (as used by QDesktopWidget) does NOT correspond to a Xrandr 'screen', so we have to convert via the root windows. Reviewed-by: Ralf Engels
-rw-r--r--src/gui/util/qscroller.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp
index ae66cd4..2eb6d2f 100644
--- a/src/gui/util/qscroller.cpp
+++ b/src/gui/util/qscroller.cpp
@@ -1006,9 +1006,18 @@ QPointF QScrollerPrivate::realDpi(int screen)
return QPointF(260, 260);
# elif defined(Q_WS_X11) && !defined(QT_NO_XRANDR)
- if (X11->use_xrandr && X11->ptrXRRSizes) {
+ if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) {
int nsizes = 0;
- XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, screen == -1 ? X11->defaultScreen : screen, &nsizes);
+ // QDesktopWidget is based on Xinerama screens, which do not always
+ // correspond to RandR screens: NVidia's TwinView e.g. will show up
+ // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen.
+ // (although with the combined size of the Xinerama screens).
+ // Additionally, libXrandr will simply crash when calling XRRSizes
+ // for (the non-existant) screen 1 in this scenario.
+ Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen);
+ int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1;
+
+ XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes);
if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) {
qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));