diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a4c45373d..a7789437f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,6 +129,7 @@ set_package_properties(Wayland PROPERTIES PURPOSE "Required for building KWin with Wayland support" ) add_feature_info("Wayland-Client" Wayland_Client_FOUND "Required for building the Wayland backend in KWin") +add_feature_info("Wayland-Cursor" Wayland_Cursor_FOUND "Required for cursor support in Wayland backend of kwin_wayland") add_feature_info("Wayland-EGL" Wayland_Egl_FOUND "Required for building the Wayland EGL compositing backend in KWin") find_package(XKB 0.4.1) @@ -266,11 +267,13 @@ if(Wayland_Client_FOUND AND XKB_FOUND AND KF5Wayland_FOUND) set(HAVE_WAYLAND ${Wayland_Client_FOUND}) set(HAVE_XKB ${XKB_FOUND}) set(HAVE_WAYLAND_EGL ${Wayland_Egl_FOUND}) + set(HAVE_WAYLAND_CURSOR ${Wayland_Cursor_FOUND}) set(HAVE_X11_XCB ${X11_XCB_FOUND}) else() set(HAVE_WAYLAND FALSE) set(HAVE_XKB FALSE) set(HAVE_WAYLAND_EGL FALSE) + set(HAVE_WAYLAND_CURSOR FALSE) set(HAVE_X11_XCB FALSE) endif() @@ -506,7 +509,6 @@ set(kwin_XCB_LIBS ) set(kwin_WAYLAND_LIBS - Wayland::Cursor XKB::XKB KF5::WaylandClient KF5::WaylandServer @@ -520,6 +522,10 @@ if(X11_XCB_FOUND) set(kwin_WAYLAND_LIBS ${kwin_WAYLAND_LIBS} X11::XCB) endif() +if(Wayland_Cursor_FOUND) + set(kwin_WAYLAND_LIBS ${kwin_WAYLAND_LIBS} Wayland::Cursor) +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 1c91b5128d..8b98ae3b1b 100644 --- a/config-kwin.h.cmake +++ b/config-kwin.h.cmake @@ -11,6 +11,7 @@ #define KWIN_KILLER_BIN "${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}/kwin_killer_helper" #cmakedefine01 HAVE_WAYLAND #cmakedefine01 HAVE_WAYLAND_EGL +#cmakedefine01 HAVE_WAYLAND_CURSOR #cmakedefine01 HAVE_XKB #cmakedefine01 HAVE_INPUT #cmakedefine01 HAVE_XCB_CURSOR diff --git a/wayland_backend.cpp b/wayland_backend.cpp index b6cbbad8e2..55884224f9 100644 --- a/wayland_backend.cpp +++ b/wayland_backend.cpp @@ -51,7 +51,9 @@ along with this program. If not, see . #include #include // Wayland +#if HAVE_WAYLAND_CURSOR #include +#endif namespace KWin { @@ -66,7 +68,9 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend) , m_pointer(NULL) , m_keyboard(NULL) , m_cursor(NULL) +#if HAVE_WAYLAND_CURSOR , m_theme(new WaylandCursorTheme(backend, this)) +#endif , m_enteredSerial(0) , m_backend(backend) , m_installCursor(false) @@ -208,6 +212,7 @@ void WaylandSeat::installCursorImage(wl_buffer *image, const QSize &size, const void WaylandSeat::installCursorImage(Qt::CursorShape shape) { +#if HAVE_WAYLAND_CURSOR wl_cursor_image *image = m_theme->get(shape); if (!image) { return; @@ -215,6 +220,7 @@ void WaylandSeat::installCursorImage(Qt::CursorShape shape) installCursorImage(wl_cursor_image_get_buffer(image), QSize(image->width, image->height), QPoint(image->hotspot_x, image->hotspot_y)); +#endif } void WaylandSeat::installCursorImage(const QImage &image, const QPoint &hotSpot) @@ -228,6 +234,7 @@ void WaylandSeat::setInstallCursor(bool install) m_installCursor = install; } +#if HAVE_WAYLAND_CURSOR WaylandCursorTheme::WaylandCursorTheme(WaylandBackend *backend, QObject *parent) : QObject(parent) , m_theme(nullptr) @@ -277,11 +284,14 @@ wl_cursor_image *WaylandCursorTheme::get(Qt::CursorShape shape) } return c->images[0]; } +#endif WaylandCursor::WaylandCursor(Surface *parentSurface, WaylandBackend *backend) : QObject(backend) , m_backend(backend) +#if HAVE_WAYLAND_CURSOR , m_theme(new WaylandCursorTheme(backend, this)) +#endif { auto surface = backend->compositor()->createSurface(this); m_subSurface = backend->subCompositor()->createSubSurface(QPointer(surface), QPointer(parentSurface), this); @@ -336,6 +346,7 @@ void WaylandCursor::setCursorImage(const QImage &image, const QPoint &hotspot) void WaylandCursor::setCursorImage(Qt::CursorShape shape) { +#if HAVE_WAYLAND_CURSOR wl_cursor_image *image = m_theme->get(shape); if (!image) { return; @@ -343,6 +354,7 @@ void WaylandCursor::setCursorImage(Qt::CursorShape shape) setCursorImage(wl_cursor_image_get_buffer(image), QSize(image->width, image->height), QPoint(image->hotspot_x, image->hotspot_y)); +#endif } WaylandBackend *WaylandBackend::s_self = 0; diff --git a/wayland_backend.h b/wayland_backend.h index 8a9bfaadc4..ef86b529c5 100644 --- a/wayland_backend.h +++ b/wayland_backend.h @@ -21,6 +21,7 @@ along with this program. If not, see . #define KWIN_WAYLAND_BACKEND_H // KWin #include "abstract_backend.h" +#include #include // Qt #include @@ -69,6 +70,7 @@ namespace Wayland class WaylandBackend; class WaylandSeat; +#if HAVE_WAYLAND_CURSOR class WaylandCursorTheme : public QObject { Q_OBJECT @@ -84,6 +86,7 @@ private: wl_cursor_theme *m_theme; WaylandBackend *m_backend; }; +#endif class WaylandSeat : public QObject { @@ -106,7 +109,9 @@ private: KWayland::Client::Pointer *m_pointer; KWayland::Client::Keyboard *m_keyboard; KWayland::Client::Surface *m_cursor; +#if HAVE_WAYLAND_CURSOR WaylandCursorTheme *m_theme; +#endif uint32_t m_enteredSerial; WaylandBackend *m_backend; bool m_installCursor; @@ -133,7 +138,9 @@ private: WaylandBackend *m_backend; QPoint m_hotSpot; KWayland::Client::SubSurface *m_subSurface; +#if HAVE_WAYLAND_CURSOR WaylandCursorTheme *m_theme; +#endif }; /**