diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 2974d96648..25c059de90 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -134,6 +134,7 @@ add_executable( testBuiltInEffectLoader ${testBuiltInEffectLoader_SRCS}) target_link_libraries(testBuiltInEffectLoader Qt5::Concurrent Qt5::Test + Qt5::X11Extras KF5::Package kwineffects kwin4_effect_builtins @@ -160,6 +161,7 @@ target_link_libraries(testScriptedEffectLoader Qt5::Concurrent Qt5::Script Qt5::Test + Qt5::X11Extras KF5::ConfigGui KF5::GlobalAccel KF5::I18n @@ -184,6 +186,7 @@ add_executable( testPluginEffectLoader ${testPluginEffectLoader_SRCS}) target_link_libraries(testPluginEffectLoader Qt5::Concurrent Qt5::Test + Qt5::X11Extras KF5::Package kwineffects kwin4_effect_builtins diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h index 38558928bd..86b259d983 100644 --- a/autotests/mock_effectshandler.h +++ b/autotests/mock_effectshandler.h @@ -21,6 +21,8 @@ along with this program. If not, see . #define MOCK_EFFECTS_HANDLER_H #include +#include + class MockEffectsHandler : public KWin::EffectsHandler { Q_OBJECT diff --git a/autotests/test_client_machine.cpp b/autotests/test_client_machine.cpp index e862473701..1d97f6d972 100644 --- a/autotests/test_client_machine.cpp +++ b/autotests/test_client_machine.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . // Qt #include #include +#include // xcb #include // system diff --git a/autotests/test_screen_edges.cpp b/autotests/test_screen_edges.cpp index 87017bd717..0595f53c9a 100644 --- a/autotests/test_screen_edges.cpp +++ b/autotests/test_screen_edges.cpp @@ -35,6 +35,7 @@ along with this program. If not, see . #include // Qt #include +#include // xcb #include Q_DECLARE_METATYPE(KWin::ElectricBorder) diff --git a/autotests/test_xcb_size_hints.cpp b/autotests/test_xcb_size_hints.cpp index e759943a57..59b6bfc6cc 100644 --- a/autotests/test_xcb_size_hints.cpp +++ b/autotests/test_xcb_size_hints.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . // Qt #include #include +#include #include // xcb #include diff --git a/autotests/test_xcb_window.cpp b/autotests/test_xcb_window.cpp index 339be675a4..ee703f3a89 100644 --- a/autotests/test_xcb_window.cpp +++ b/autotests/test_xcb_window.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . // Qt #include #include +#include // xcb #include diff --git a/autotests/test_xcb_wrapper.cpp b/autotests/test_xcb_wrapper.cpp index a1e312c3fe..4a428c90f1 100644 --- a/autotests/test_xcb_wrapper.cpp +++ b/autotests/test_xcb_wrapper.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . // Qt #include #include +#include #include // xcb #include diff --git a/kcmkwin/kwinrules/main.cpp b/kcmkwin/kwinrules/main.cpp index 885e7ab36d..ae66a0372b 100644 --- a/kcmkwin/kwinrules/main.cpp +++ b/kcmkwin/kwinrules/main.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt index 306e380a0e..165abc50ff 100644 --- a/libkwineffects/CMakeLists.txt +++ b/libkwineffects/CMakeLists.txt @@ -45,7 +45,6 @@ set(kwin_EFFECTSLIB_SRCS set(kwineffects_QT_LIBS Qt5::DBus Qt5::Widgets - Qt5::X11Extras ) set(kwineffects_KDE_LIBS @@ -91,7 +90,7 @@ macro( KWIN4_ADD_GLUTILS_BACKEND name glinclude ) include_directories(${glinclude}) add_library(${name} SHARED ${kwin_GLUTILSLIB_SRCS}) generate_export_header(${name} BASE_NAME kwinglutils EXPORT_FILE_NAME kwinglutils_export.h) - target_link_libraries(${name} PUBLIC Qt5::DBus Qt5::X11Extras XCB::XCB KF5::CoreAddons KF5::WindowSystem) + target_link_libraries(${name} PUBLIC Qt5::DBus XCB::XCB KF5::CoreAddons KF5::WindowSystem) set_target_properties(${name} PROPERTIES VERSION ${KWINEFFECTS_VERSION_STRING} SOVERSION ${KWINEFFECTS_SOVERSION} diff --git a/libkwineffects/kwinglobals.h b/libkwineffects/kwinglobals.h index e755da1e9c..ba57d2790e 100644 --- a/libkwineffects/kwinglobals.h +++ b/libkwineffects/kwinglobals.h @@ -25,7 +25,6 @@ along with this program. If not, see . #include #include #include -#include #include #include @@ -130,16 +129,6 @@ enum PointerAxisDirection { PointerAxisRight }; -inline -KWIN_EXPORT Display* display() -{ - static Display *s_display = nullptr; - if (!s_display && QX11Info::isPlatformX11()) { - s_display = QX11Info::display(); - } - return s_display; -} - inline KWIN_EXPORT xcb_connection_t *connection() { diff --git a/main_x11.cpp b/main_x11.cpp index e4db348bf6..da3c0452e7 100644 --- a/main_x11.cpp +++ b/main_x11.cpp @@ -43,6 +43,7 @@ along with this program. If not, see . #include #include #include +#include // system #ifdef HAVE_UNISTD_H @@ -439,7 +440,7 @@ KWIN_EXPORT int kdemain(int argc, char * argv[]) argv[0], qPrintable(a.platformName())); exit(1); } - if (!KWin::display()) { + if (!QX11Info::display()) { fprintf(stderr, "%s: FATAL ERROR KWin requires Xlib support in the xcb plugin. Do not configure Qt with -no-xcb-xlib\n", argv[0]); exit(1); diff --git a/plugins/platforms/x11/common/eglonxbackend.cpp b/plugins/platforms/x11/common/eglonxbackend.cpp index 78e0ce4de0..077d9b8310 100644 --- a/plugins/platforms/x11/common/eglonxbackend.cpp +++ b/plugins/platforms/x11/common/eglonxbackend.cpp @@ -38,14 +38,14 @@ Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtCriticalMsg) namespace KWin { -EglOnXBackend::EglOnXBackend() +EglOnXBackend::EglOnXBackend(Display *display) : AbstractEglBackend() , m_overlayWindow(new OverlayWindow()) , surfaceHasSubPost(0) , m_bufferAge(0) , m_usesOverlayWindow(true) , m_connection(connection()) - , m_x11Display(display()) + , m_x11Display(display) , m_rootWindow(rootWindow()) , m_x11ScreenNumber(kwinApp()->x11ScreenNumber()) { diff --git a/plugins/platforms/x11/common/eglonxbackend.h b/plugins/platforms/x11/common/eglonxbackend.h index d123fee190..941f660d60 100644 --- a/plugins/platforms/x11/common/eglonxbackend.h +++ b/plugins/platforms/x11/common/eglonxbackend.h @@ -31,7 +31,7 @@ namespace KWin class KWIN_EXPORT EglOnXBackend : public AbstractEglBackend { public: - EglOnXBackend(); + EglOnXBackend(Display *display); explicit EglOnXBackend(xcb_connection_t *connection, Display *display, xcb_window_t rootWindow, int screenNumber, xcb_window_t renderingWindow); virtual ~EglOnXBackend(); virtual void screenGeometryChanged(const QSize &size); diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index d2dbada885..59599acd64 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -37,6 +37,7 @@ along with this program. If not, see . // Qt #include #include +#include // system #include @@ -105,7 +106,7 @@ bool SwapEventFilter::event(xcb_generic_event_t *event) -GlxBackend::GlxBackend() +GlxBackend::GlxBackend(Display *display) : OpenGLBackend() , m_overlayWindow(new OverlayWindow()) , window(None) @@ -114,6 +115,7 @@ GlxBackend::GlxBackend() , ctx(nullptr) , m_bufferAge(0) , haveSwapInterval(false) + , m_x11Display(display) { } diff --git a/plugins/platforms/x11/standalone/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h index 1f801df7b9..59787419e0 100644 --- a/plugins/platforms/x11/standalone/glxbackend.h +++ b/plugins/platforms/x11/standalone/glxbackend.h @@ -65,7 +65,7 @@ private: class GlxBackend : public OpenGLBackend { public: - GlxBackend(); + GlxBackend(Display *display); virtual ~GlxBackend(); virtual void screenGeometryChanged(const QSize &size); virtual SceneOpenGL::TexturePrivate *createBackendTexture(SceneOpenGL::Texture *texture); @@ -89,6 +89,9 @@ private: bool initFbConfig(); void initVisualDepthHashTable(); void setSwapInterval(int interval); + Display *display() const { + return m_x11Display; + } int visualDepth(xcb_visualid_t visual) const; FBConfigInfo *infoForVisual(xcb_visualid_t visual); @@ -112,6 +115,7 @@ private: bool m_haveINTELSwapEvent = false; bool haveSwapInterval = false; bool haveWaitSync = false; + Display *m_x11Display; friend class GlxTexture; }; @@ -130,6 +134,9 @@ private: friend class GlxBackend; GlxTexture(SceneOpenGL::Texture *texture, GlxBackend *backend); bool loadTexture(xcb_pixmap_t pix, const QSize &size, xcb_visualid_t visual); + Display *display() const { + return m_backend->m_x11Display; + } SceneOpenGL::Texture *q; GlxBackend *m_backend; GLXPixmap m_glxpixmap; // the glx pixmap the texture is bound to diff --git a/plugins/platforms/x11/standalone/x11_platform.cpp b/plugins/platforms/x11/standalone/x11_platform.cpp index 0c1dc19454..73db0921f7 100644 --- a/plugins/platforms/x11/standalone/x11_platform.cpp +++ b/plugins/platforms/x11/standalone/x11_platform.cpp @@ -46,10 +46,11 @@ namespace KWin X11StandalonePlatform::X11StandalonePlatform(QObject *parent) : Platform(parent) + , m_x11Display(QX11Info::display()) { #if HAVE_X11_XINPUT if (!qEnvironmentVariableIsSet("KWIN_NO_XI2")) { - m_xinputIntegration = new XInputIntegration(this); + m_xinputIntegration = new XInputIntegration(m_x11Display, this); m_xinputIntegration->init(); if (!m_xinputIntegration->hasXinput()) { delete m_xinputIntegration; @@ -84,14 +85,14 @@ OpenGLBackend *X11StandalonePlatform::createOpenGLBackend() #if HAVE_EPOXY_GLX case GlxPlatformInterface: if (hasGlx()) { - return new GlxBackend(); + return new GlxBackend(m_x11Display); } else { qCWarning(KWIN_X11STANDALONE) << "Glx not available, trying EGL instead."; // no break, needs fall-through } #endif case EglPlatformInterface: - return new EglOnXBackend(); + return new EglOnXBackend(m_x11Display); default: // no backend available return nullptr; diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h index 4a17f881f4..e4811f1ae1 100644 --- a/plugins/platforms/x11/standalone/x11_platform.h +++ b/plugins/platforms/x11/standalone/x11_platform.h @@ -70,6 +70,7 @@ private: XInputIntegration *m_xinputIntegration = nullptr; QThread *m_openGLFreezeProtectionThread = nullptr; QTimer *m_openGLFreezeProtection = nullptr; + Display *m_x11Display; }; diff --git a/plugins/platforms/x11/standalone/xinputintegration.cpp b/plugins/platforms/x11/standalone/xinputintegration.cpp index 490f150814..a944a55c17 100644 --- a/plugins/platforms/x11/standalone/xinputintegration.cpp +++ b/plugins/platforms/x11/standalone/xinputintegration.cpp @@ -162,8 +162,9 @@ private: Xkb *m_xkb = nullptr; }; -XInputIntegration::XInputIntegration(QObject *parent) +XInputIntegration::XInputIntegration(Display *display, QObject *parent) : QObject(parent) + , m_x11Display(display) { } diff --git a/plugins/platforms/x11/standalone/xinputintegration.h b/plugins/platforms/x11/standalone/xinputintegration.h index a818569172..ba1ff4b384 100644 --- a/plugins/platforms/x11/standalone/xinputintegration.h +++ b/plugins/platforms/x11/standalone/xinputintegration.h @@ -23,6 +23,7 @@ along with this program. If not, see . #include #include #include +typedef struct _XDisplay Display; namespace KWin { @@ -36,7 +37,7 @@ class XInputIntegration : public QObject { Q_OBJECT public: - explicit XInputIntegration(QObject *parent); + explicit XInputIntegration(Display *display, QObject *parent); virtual ~XInputIntegration(); void init(); @@ -49,6 +50,9 @@ public: void setXkb(Xkb *xkb); private: + Display *display() const { + return m_x11Display; + } bool m_hasXInput = false; int m_xiOpcode = 0; @@ -57,6 +61,7 @@ private: QPointer m_x11Cursor; // TODO: QPointer Xkb *m_xkb = nullptr; + Display *m_x11Display; QScopedPointer m_xiEventFilter; QScopedPointer m_keyPressFilter; diff --git a/tests/screenedgeshowtest.cpp b/tests/screenedgeshowtest.cpp index ec3f2de8fc..804fd366d1 100644 --- a/tests/screenedgeshowtest.cpp +++ b/tests/screenedgeshowtest.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "../xcbutils.h" #include diff --git a/utils.cpp b/utils.cpp index ad45406e56..afa631c09d 100644 --- a/utils.cpp +++ b/utils.cpp @@ -35,6 +35,7 @@ along with this program. If not, see . #include #include +#include #include #include