summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2015-04-22 19:28:24 +0300
committerShawn Rutledge <shawn.rutledge@theqtcompany.com>2016-03-05 21:08:05 +0000
commitf27489d66cc6d8263130451c26c7e4ae40acc6b4 (patch)
tree735b851278d154fe58ec77cc5e1d7fa23d0b0941
parentf43b5d926e5940299230e7ea50cc7d07ae93d6ba (diff)
downloadqtx11extras-5.6.1.tar.gz
Properly get appDpiX, appDpiY and appRootWindow for X screenv5.6.1-1v5.6.15.6.1
X screen is a virtual desktop in Qt terminology. So find the first QScreen which belongs to the requested virtual desktop and use it to get the values. Change-Id: If5c08ff6c3e19e1d49d17ae8e1c54e09ffeb97cf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/x11extras/qx11info_x11.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp
index 8d8f337..2d4c5d2 100644
--- a/src/x11extras/qx11info_x11.cpp
+++ b/src/x11extras/qx11info_x11.cpp
@@ -43,6 +43,7 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformwindow.h>
+#include <QtPlatformHeaders/qxcbscreenfunctions.h>
#include <qscreen.h>
#include <qwindow.h>
#include <qguiapplication.h>
@@ -50,6 +51,14 @@
QT_BEGIN_NAMESPACE
+static QScreen *findScreenForVirtualDesktop(int virtualDesktopNumber)
+{
+ foreach (QScreen *screen, QGuiApplication::screens()) {
+ if (QXcbScreenFunctions::virtualDesktopNumber(screen) == virtualDesktopNumber)
+ return screen;
+ }
+ return Q_NULLPTR;
+}
/*!
\class QX11Info
@@ -103,11 +112,11 @@ int QX11Info::appDpiX(int screen)
return qRound(scr->logicalDotsPerInchX());
}
- QList<QScreen *> screens = QGuiApplication::screens();
- if (screen >= screens.size())
+ QScreen *scr = findScreenForVirtualDesktop(screen);
+ if (!scr)
return 0;
- return screens[screen]->logicalDotsPerInchX();
+ return scr->logicalDotsPerInchX();
}
/*!
@@ -130,11 +139,11 @@ int QX11Info::appDpiY(int screen)
return qRound(scr->logicalDotsPerInchY());
}
- QList<QScreen *> screens = QGuiApplication::screens();
- if (screen > screens.size())
+ QScreen *scr = findScreenForVirtualDesktop(screen);
+ if (!scr)
return 0;
- return screens[screen]->logicalDotsPerInchY();
+ return scr->logicalDotsPerInchY();
}
/*!
@@ -151,11 +160,13 @@ unsigned long QX11Info::appRootWindow(int screen)
{
if (!qApp)
return 0;
- Q_UNUSED(screen);
QPlatformNativeInterface *native = qApp->platformNativeInterface();
if (!native)
return 0;
- return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForIntegration(QByteArrayLiteral("rootwindow"))));
+ QScreen *scr = screen == -1 ? QGuiApplication::primaryScreen() : findScreenForVirtualDesktop(screen);
+ if (!scr)
+ return 0;
+ return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen(QByteArrayLiteral("rootwindow"), scr)));
}
/*!