diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-02-29 14:30:14 -0800 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-03-22 15:05:34 +0000 |
commit | fbf5e9403e15655bd479e4cc6b26bf1451e5b8c5 (patch) | |
tree | 6f4130cff9c5b948809d7e4ab5985c657aff5e57 | |
parent | 2bc54e9a5b7464a2839b408c79f190bf54011a97 (diff) | |
download | qtx11extras-fbf5e9403e15655bd479e4cc6b26bf1451e5b8c5.tar.gz |
Add QX11Info::isCompositingManagerRunning() function
Task-number: QTBUG-41195
Change-Id: Id4b385478dad85dd02c484fe9c44666bae46268b
Reviewed-by: Błażej Szczygieł <spaz16@wp.pl>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
-rw-r--r-- | src/x11extras/qx11info_x11.cpp | 25 | ||||
-rw-r--r-- | src/x11extras/qx11info_x11.h | 2 | ||||
-rw-r--r-- | tests/auto/qx11info/tst_qx11info.cpp | 2 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp index e5aa678..a201547 100644 --- a/src/x11extras/qx11info_x11.cpp +++ b/src/x11extras/qx11info_x11.cpp @@ -376,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 \l -1, the application 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 diff --git a/src/x11extras/qx11info_x11.h b/src/x11extras/qx11info_x11.h index 620428d..ab72686 100644 --- a/src/x11extras/qx11info_x11.h +++ b/src/x11extras/qx11info_x11.h @@ -73,6 +73,8 @@ public: static Display *display(); static xcb_connection_t *connection(); + static bool isCompositingManagerRunning(int screen = -1); + private: QX11Info(); }; diff --git a/tests/auto/qx11info/tst_qx11info.cpp b/tests/auto/qx11info/tst_qx11info.cpp index 0a19d7f..a27f443 100644 --- a/tests/auto/qx11info/tst_qx11info.cpp +++ b/tests/auto/qx11info/tst_qx11info.cpp @@ -96,6 +96,8 @@ void tst_QX11Info::staticFunctionsBeforeQApplication() appUserTime = QX11Info::appUserTime(); QCOMPARE(appTime, 0ul); QCOMPARE(appTime, 0ul); + + QX11Info::isCompositingManagerRunning(); } static const char idFromEnv[] = "startupid_TIME123456"; |