diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-04-08 23:44:15 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-04-08 23:44:15 +0200 |
commit | a292671f0842211ca60e51cf34b6fb47d8bae655 (patch) | |
tree | 9eb75c6b218533e5136b23d6b43e3f782e6c885f /src/x11extras/qx11info_x11.cpp | |
parent | b35074ec6cf0da49ce153948aff45c42950cab9a (diff) | |
parent | b414120c60ef8c3cc2aad7dca41092647d741a36 (diff) | |
download | qtx11extras-a292671f0842211ca60e51cf34b6fb47d8bae655.tar.gz |
Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: I98ab3d1c372f68a7a24f831be30bae939c6a62ba
Diffstat (limited to 'src/x11extras/qx11info_x11.cpp')
-rw-r--r-- | src/x11extras/qx11info_x11.cpp | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp index c5914e4..0473fda 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))); } /*! @@ -365,4 +376,29 @@ xcb_connection_t *QX11Info::connection() return reinterpret_cast<xcb_connection_t *>(connection); } +/*! + \since 5.7 + + Returns true if there is a compositing manager running for the connection + attached to \a screen. + + If \a screen equals -1, the application's primary screen is used. +*/ +bool QX11Info::isCompositingManagerRunning(int screen) +{ + if (!qApp) + return false; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + if (!native) + return false; + + QScreen *scr = screen == -1 ? QGuiApplication::primaryScreen() : findScreenForVirtualDesktop(screen); + if (!scr) { + qWarning() << "isCompositingManagerRunning: Could not find screen number" << screen; + return false; + } + + return native->nativeResourceForScreen(QByteArray("compositingEnabled"), scr); +} + QT_END_NAMESPACE |