diff --git a/include/FramelessHelper/Core/framelesshelper_linux.h b/include/FramelessHelper/Core/framelesshelper_linux.h index d1829d2..143a595 100644 --- a/include/FramelessHelper/Core/framelesshelper_linux.h +++ b/include/FramelessHelper/Core/framelesshelper_linux.h @@ -56,6 +56,18 @@ // This one is not included in any public headers. using Display = struct _XDisplay; +#ifndef FRAMELESSHELPER_HAS_XLIB +extern "C" +{ + +FRAMELESSHELPER_CORE_API int +XInitThreads( + void +); + +} // extern "C" +#endif // FRAMELESSHELPER_HAS_XLIB + #if __has_include() # include # define FRAMELESSHELPER_HAS_XCB diff --git a/include/FramelessHelper/Core/private/sysapiloader_p.h b/include/FramelessHelper/Core/private/sysapiloader_p.h index 90112a7..aae6ebb 100644 --- a/include/FramelessHelper/Core/private/sysapiloader_p.h +++ b/include/FramelessHelper/Core/private/sysapiloader_p.h @@ -85,6 +85,7 @@ Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)) #endif // Q_OS_WINDOWS #ifdef Q_OS_LINUX +# define API_XLIB_AVAILABLE(func) API_AVAILABLE(libX11, func) # define API_XCB_AVAILABLE(func) API_AVAILABLE(libxcb, func) # define API_GTK_AVAILABLE(func) API_AVAILABLE(libgtk, func) #endif // Q_OS_LINUX diff --git a/src/core/framelesshelpercore_global.cpp b/src/core/framelesshelpercore_global.cpp index d52a6d7..e3b5ab4 100644 --- a/src/core/framelesshelpercore_global.cpp +++ b/src/core/framelesshelpercore_global.cpp @@ -174,6 +174,7 @@ void initialize() // enough, that is, before the construction of any Q(Gui)Application // instances. QCoreApplication won't instantiate the platform plugin. qputenv(QT_QPA_ENV_VAR, kxcb); + XInitThreads(); gtk_init(nullptr, nullptr); #endif diff --git a/src/core/platformsupport_linux.cpp b/src/core/platformsupport_linux.cpp index a149541..a6b7e77 100644 --- a/src/core/platformsupport_linux.cpp +++ b/src/core/platformsupport_linux.cpp @@ -25,6 +25,28 @@ #include "framelesshelper_linux.h" #include "sysapiloader_p.h" +////////////////////////////////////////////// +// Xlib + +#ifndef FRAMELESSHELPER_HAS_XLIB + +FRAMELESSHELPER_STRING_CONSTANT(libX11) + +FRAMELESSHELPER_STRING_CONSTANT(XInitThreads) + +extern "C" int +XInitThreads( + void +) +{ + if (!API_XLIB_AVAILABLE(XInitThreads)) { + return 0; + } + return API_CALL_FUNCTION(XInitThreads); +} + +#endif // FRAMELESSHELPER_HAS_XLIB + ////////////////////////////////////////////// // XCB