[wayland] Create xcb_connection through XLib in windowed mode

Adds optional dependency to X11_XCB and gets used in X11WindowedBackend
to create an XLib Display if dependency is present.

This allows to create an EGL backend for the X11WindowedBackend.
master
Martin Gräßlin 10 years ago
parent 6bf44b7db4
commit 3cc1032839

@ -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()

@ -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 <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1

@ -34,6 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/surface_interface.h>
// system
#include <linux/input.h>
#if HAVE_X11_XCB
#include <X11/Xlib-xcb.h>
#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)) {

@ -27,6 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <xcb/xcb.h>
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;
};

Loading…
Cancel
Save