diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-03-21 16:25:45 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-03-21 16:27:14 -0700 |
commit | 2bc54e9a5b7464a2839b408c79f190bf54011a97 (patch) | |
tree | bbd5d8824041564a4c06406d970133fbc394f874 | |
parent | 5df6e708b64e22f98a053145011b6da917257174 (diff) | |
parent | f27489d66cc6d8263130451c26c7e4ae40acc6b4 (diff) | |
download | qtx11extras-2bc54e9a5b7464a2839b408c79f190bf54011a97.tar.gz |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I406ef8471dca716daf694a0bb88dc7295c6d0a5e
-rw-r--r-- | src/x11extras/qx11info_x11.cpp | 27 | ||||
-rw-r--r-- | src/x11extras/x11extras.pro | 6 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp index c5914e4..e5aa678 100644 --- a/src/x11extras/qx11info_x11.cpp +++ b/src/x11extras/qx11info_x11.cpp @@ -49,6 +49,7 @@ #include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformwindow.h> +#include <QtPlatformHeaders/qxcbscreenfunctions.h> #include <qscreen.h> #include <qwindow.h> #include <qguiapplication.h> @@ -56,6 +57,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 @@ -109,11 +118,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(); } /*! @@ -136,11 +145,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(); } /*! @@ -157,11 +166,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))); } /*! diff --git a/src/x11extras/x11extras.pro b/src/x11extras/x11extras.pro index 730a145..a400276 100644 --- a/src/x11extras/x11extras.pro +++ b/src/x11extras/x11extras.pro @@ -4,9 +4,9 @@ DEFINES += QT_NO_USING_NAMESPACE QMAKE_DOCS = $$PWD/doc/qtx11extras.qdocconf -load(qt_module) - -QT += gui-private +QT_PRIVATE += gui-private HEADERS += qx11info_x11.h SOURCES += qx11info_x11.cpp + +load(qt_module) |