Changeset View
Changeset View
Standalone View
Standalone View
src/platformtheme/main.cpp
Show All 16 Lines | |||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include <qpa/qplatformthemeplugin.h> | 21 | #include <qpa/qplatformthemeplugin.h> | ||
22 | 22 | | |||
23 | #include "kdeplatformtheme.h" | 23 | #include "kdeplatformtheme.h" | ||
24 | 24 | | |||
25 | #include <config-platformtheme.h> | | |||
26 | #if (QT_VERSION < QT_VERSION_CHECK(5, 3, 1)) | | |||
27 | #if HAVE_X11 | | |||
28 | #include <QCoreApplication> | | |||
29 | #include <QAbstractEventDispatcher> | | |||
30 | #include <QX11Info> | | |||
31 | #include <xcb/xcb.h> | | |||
32 | #endif | | |||
33 | #endif | | |||
34 | | ||||
35 | class KdePlatformThemePlugin : public QPlatformThemePlugin | 25 | class KdePlatformThemePlugin : public QPlatformThemePlugin | ||
36 | { | 26 | { | ||
37 | Q_OBJECT | 27 | Q_OBJECT | ||
38 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "kdeplatformtheme.json") | 28 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "kdeplatformtheme.json") | ||
39 | public: | 29 | public: | ||
40 | KdePlatformThemePlugin(QObject *parent = 0) | 30 | KdePlatformThemePlugin(QObject *parent = 0) | ||
41 | : QPlatformThemePlugin(parent) {} | 31 | : QPlatformThemePlugin(parent) {} | ||
42 | 32 | | |||
43 | QPlatformTheme *create(const QString &key, const QStringList ¶mList) Q_DECL_OVERRIDE | 33 | QPlatformTheme *create(const QString &key, const QStringList ¶mList) Q_DECL_OVERRIDE | ||
44 | { | 34 | { | ||
45 | Q_UNUSED(key) | 35 | Q_UNUSED(key) | ||
46 | Q_UNUSED(paramList) | 36 | Q_UNUSED(paramList) | ||
47 | #if (QT_VERSION < QT_VERSION_CHECK(5, 3, 1)) | | |||
48 | // Must be done after we have an event-dispatcher. By posting a method invocation | | |||
49 | // we are sure that by the time the method is called we have an event-dispatcher. | | |||
50 | QMetaObject::invokeMethod(this, "setupXcbFlush", Qt::QueuedConnection); | | |||
51 | #endif | | |||
52 | return new KdePlatformTheme; | 37 | return new KdePlatformTheme; | ||
53 | } | 38 | } | ||
54 | | ||||
55 | public Q_SLOTS: | | |||
56 | void setupXcbFlush(); | | |||
57 | }; | 39 | }; | ||
58 | 40 | | |||
59 | void KdePlatformThemePlugin::setupXcbFlush() | | |||
60 | { | | |||
61 | #if (QT_VERSION < QT_VERSION_CHECK(5, 3, 1)) | | |||
62 | #if HAVE_X11 | | |||
63 | // this is a workaround for BUG 334858 | | |||
64 | // it ensures that the xcb connection gets flushed before the EventDispatcher | | |||
65 | // is going to block. Qt does not guarantee this in all cases. | | |||
66 | // For Qt this issue is addressed in https://codereview.qt-project.org/85654 | | |||
67 | // TODO: remove again once we depend on a Qt version with the patch. | | |||
68 | if (!QX11Info::isPlatformX11() || qstrcmp(qVersion(), "5.3.1") >= 0) { | | |||
69 | return; | | |||
70 | } | | |||
71 | connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, | | |||
72 | []() { | | |||
73 | xcb_flush(QX11Info::connection()); | | |||
74 | } | | |||
75 | ); | | |||
76 | #endif | | |||
77 | #endif | | |||
78 | } | | |||
79 | | ||||
80 | #include "main.moc" | 41 | #include "main.moc" |