Skip to content

Commit

Permalink
backport Qt 5.7 change to 5.6.1
Browse files Browse the repository at this point in the history
Add QX11Info::isCompositingManagerRunning() function

Task-number: QTBUG-41195
  • Loading branch information
wayne-arnold-adsk committed Jun 28, 2016
1 parent f27489d commit d86b590
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/x11extras/qx11info_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,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
2 changes: 2 additions & 0 deletions src/x11extras/qx11info_x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Q_X11EXTRAS_EXPORT QX11Info
static Display *display();
static xcb_connection_t *connection();

static bool isCompositingManagerRunning(int screen = -1);

private:
QX11Info();
};
Expand Down
2 changes: 2 additions & 0 deletions tests/auto/qx11info/tst_qx11info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ void tst_QX11Info::staticFunctionsBeforeQApplication()
appUserTime = QX11Info::appUserTime();
QCOMPARE(appTime, 0ul);
QCOMPARE(appTime, 0ul);

QX11Info::isCompositingManagerRunning();
}

static const char idFromEnv[] = "startupid_TIME123456";
Expand Down

0 comments on commit d86b590

Please sign in to comment.