diff --git a/CMakeLists.txt b/CMakeLists.txt index f64e9a2ebc..cf8ecb07fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,6 +191,11 @@ if (XCB_VERSION VERSION_LESS "1.10") endif() add_feature_info("XCB-SYNC" HAVE_XCB_SYNC "XCB Sync version >= 1.10 required for synced window resizing") +find_package(X11_XCB) +set_package_properties(X11_XCB PROPERTIES + PURPOSE "Required for OpenGL support in X11 windowed backend of kwin_wayland" + TYPE OPTIONAL) + feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) ########### configure tests ############### @@ -275,6 +280,8 @@ else() set(HAVE_XCB_CURSOR FALSE) endif() +set(HAVE_X11_XCB ${X11_XCB_FOUND}) + include(CheckIncludeFiles) check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(malloc.h HAVE_MALLOC_H) @@ -510,6 +517,10 @@ set(kwin_WAYLAND_EGL_LIBS Wayland::Egl ) +if(X11_XCB_FOUND) + set(kwin_WAYLAND_LIBS ${kwin_WAYLAND_LIBS} X11::XCB) +endif() + if(KWIN_BUILD_ACTIVITIES) set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities) endif() diff --git a/config-kwin.h.cmake b/config-kwin.h.cmake index 8e8a805891..1c91b5128d 100644 --- a/config-kwin.h.cmake +++ b/config-kwin.h.cmake @@ -15,6 +15,7 @@ #cmakedefine01 HAVE_INPUT #cmakedefine01 HAVE_XCB_CURSOR #cmakedefine01 HAVE_XCB_SYNC +#cmakedefine01 HAVE_X11_XCB /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H 1 diff --git a/x11windowed_backend.cpp b/x11windowed_backend.cpp index 3616b5992a..b21cdbf3c5 100644 --- a/x11windowed_backend.cpp +++ b/x11windowed_backend.cpp @@ -34,6 +34,9 @@ along with this program. If not, see . #include // system #include +#if HAVE_X11_XCB +#include +#endif namespace KWin { @@ -52,10 +55,23 @@ X11WindowedBackend::X11WindowedBackend(const QString &display, const QSize &size , m_size(size) { int screen = 0; - auto c = xcb_connect(display.toUtf8().constData(), &screen); - if (!xcb_connection_has_error(c)) { + xcb_connection_t *c = nullptr; +#if HAVE_X11_XCB + Display *xDisplay = XOpenDisplay(display.toUtf8().constData()); + if (xDisplay) { + c = XGetXCBConnection(xDisplay); + XSetEventQueueOwner(xDisplay, XCBOwnsEventQueue); + screen = XDefaultScreen(xDisplay); + } +#else + c = xcb_connect(display.toUtf8().constData(), &screen); +#endif + if (c && !xcb_connection_has_error(c)) { m_connection = c; m_screenNumber = screen; +#if HAVE_X11_XCB + m_display = xDisplay; +#endif for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(m_connection)); it.rem; --screen, xcb_screen_next(&it)) { diff --git a/x11windowed_backend.h b/x11windowed_backend.h index fc005b8ebf..dcf07000a0 100644 --- a/x11windowed_backend.h +++ b/x11windowed_backend.h @@ -27,6 +27,9 @@ along with this program. If not, see . #include +struct _XDisplay; +typedef struct _XDisplay Display; + namespace KWin { @@ -46,6 +49,9 @@ public: xcb_window_t window() const { return m_window; } + Display *display() const { + return m_display; + } bool isValid() const { return m_connection != nullptr && m_window != XCB_WINDOW_NONE; @@ -81,6 +87,7 @@ private: xcb_atom_t m_protocols = XCB_ATOM_NONE; xcb_atom_t m_deleteWindowProtocol = XCB_ATOM_NONE; xcb_cursor_t m_cursor = XCB_CURSOR_NONE; + Display *m_display = nullptr; static X11WindowedBackend *s_self; };