[wayland] Make Wayland::Cursor a proper optional build dep

Only needed in the Wayland backend and can easily be ifdefed there.
This commit is contained in:
Martin Gräßlin 2015-03-23 10:07:59 +01:00
parent 3c6fd0190b
commit 75d60d4f85
4 changed files with 27 additions and 1 deletions

View file

@ -129,6 +129,7 @@ set_package_properties(Wayland PROPERTIES
PURPOSE "Required for building KWin with Wayland support" 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-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") add_feature_info("Wayland-EGL" Wayland_Egl_FOUND "Required for building the Wayland EGL compositing backend in KWin")
find_package(XKB 0.4.1) 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_WAYLAND ${Wayland_Client_FOUND})
set(HAVE_XKB ${XKB_FOUND}) set(HAVE_XKB ${XKB_FOUND})
set(HAVE_WAYLAND_EGL ${Wayland_Egl_FOUND}) set(HAVE_WAYLAND_EGL ${Wayland_Egl_FOUND})
set(HAVE_WAYLAND_CURSOR ${Wayland_Cursor_FOUND})
set(HAVE_X11_XCB ${X11_XCB_FOUND}) set(HAVE_X11_XCB ${X11_XCB_FOUND})
else() else()
set(HAVE_WAYLAND FALSE) set(HAVE_WAYLAND FALSE)
set(HAVE_XKB FALSE) set(HAVE_XKB FALSE)
set(HAVE_WAYLAND_EGL FALSE) set(HAVE_WAYLAND_EGL FALSE)
set(HAVE_WAYLAND_CURSOR FALSE)
set(HAVE_X11_XCB FALSE) set(HAVE_X11_XCB FALSE)
endif() endif()
@ -506,7 +509,6 @@ set(kwin_XCB_LIBS
) )
set(kwin_WAYLAND_LIBS set(kwin_WAYLAND_LIBS
Wayland::Cursor
XKB::XKB XKB::XKB
KF5::WaylandClient KF5::WaylandClient
KF5::WaylandServer KF5::WaylandServer
@ -520,6 +522,10 @@ if(X11_XCB_FOUND)
set(kwin_WAYLAND_LIBS ${kwin_WAYLAND_LIBS} X11::XCB) set(kwin_WAYLAND_LIBS ${kwin_WAYLAND_LIBS} X11::XCB)
endif() endif()
if(Wayland_Cursor_FOUND)
set(kwin_WAYLAND_LIBS ${kwin_WAYLAND_LIBS} Wayland::Cursor)
endif()
if(KWIN_BUILD_ACTIVITIES) if(KWIN_BUILD_ACTIVITIES)
set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities) set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities)
endif() endif()

View file

@ -11,6 +11,7 @@
#define KWIN_KILLER_BIN "${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}/kwin_killer_helper" #define KWIN_KILLER_BIN "${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}/kwin_killer_helper"
#cmakedefine01 HAVE_WAYLAND #cmakedefine01 HAVE_WAYLAND
#cmakedefine01 HAVE_WAYLAND_EGL #cmakedefine01 HAVE_WAYLAND_EGL
#cmakedefine01 HAVE_WAYLAND_CURSOR
#cmakedefine01 HAVE_XKB #cmakedefine01 HAVE_XKB
#cmakedefine01 HAVE_INPUT #cmakedefine01 HAVE_INPUT
#cmakedefine01 HAVE_XCB_CURSOR #cmakedefine01 HAVE_XCB_CURSOR

View file

@ -51,7 +51,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QMetaMethod> #include <QMetaMethod>
#include <QThread> #include <QThread>
// Wayland // Wayland
#if HAVE_WAYLAND_CURSOR
#include <wayland-cursor.h> #include <wayland-cursor.h>
#endif
namespace KWin namespace KWin
{ {
@ -66,7 +68,9 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
, m_pointer(NULL) , m_pointer(NULL)
, m_keyboard(NULL) , m_keyboard(NULL)
, m_cursor(NULL) , m_cursor(NULL)
#if HAVE_WAYLAND_CURSOR
, m_theme(new WaylandCursorTheme(backend, this)) , m_theme(new WaylandCursorTheme(backend, this))
#endif
, m_enteredSerial(0) , m_enteredSerial(0)
, m_backend(backend) , m_backend(backend)
, m_installCursor(false) , m_installCursor(false)
@ -208,6 +212,7 @@ void WaylandSeat::installCursorImage(wl_buffer *image, const QSize &size, const
void WaylandSeat::installCursorImage(Qt::CursorShape shape) void WaylandSeat::installCursorImage(Qt::CursorShape shape)
{ {
#if HAVE_WAYLAND_CURSOR
wl_cursor_image *image = m_theme->get(shape); wl_cursor_image *image = m_theme->get(shape);
if (!image) { if (!image) {
return; return;
@ -215,6 +220,7 @@ void WaylandSeat::installCursorImage(Qt::CursorShape shape)
installCursorImage(wl_cursor_image_get_buffer(image), installCursorImage(wl_cursor_image_get_buffer(image),
QSize(image->width, image->height), QSize(image->width, image->height),
QPoint(image->hotspot_x, image->hotspot_y)); QPoint(image->hotspot_x, image->hotspot_y));
#endif
} }
void WaylandSeat::installCursorImage(const QImage &image, const QPoint &hotSpot) void WaylandSeat::installCursorImage(const QImage &image, const QPoint &hotSpot)
@ -228,6 +234,7 @@ void WaylandSeat::setInstallCursor(bool install)
m_installCursor = install; m_installCursor = install;
} }
#if HAVE_WAYLAND_CURSOR
WaylandCursorTheme::WaylandCursorTheme(WaylandBackend *backend, QObject *parent) WaylandCursorTheme::WaylandCursorTheme(WaylandBackend *backend, QObject *parent)
: QObject(parent) : QObject(parent)
, m_theme(nullptr) , m_theme(nullptr)
@ -277,11 +284,14 @@ wl_cursor_image *WaylandCursorTheme::get(Qt::CursorShape shape)
} }
return c->images[0]; return c->images[0];
} }
#endif
WaylandCursor::WaylandCursor(Surface *parentSurface, WaylandBackend *backend) WaylandCursor::WaylandCursor(Surface *parentSurface, WaylandBackend *backend)
: QObject(backend) : QObject(backend)
, m_backend(backend) , m_backend(backend)
#if HAVE_WAYLAND_CURSOR
, m_theme(new WaylandCursorTheme(backend, this)) , m_theme(new WaylandCursorTheme(backend, this))
#endif
{ {
auto surface = backend->compositor()->createSurface(this); auto surface = backend->compositor()->createSurface(this);
m_subSurface = backend->subCompositor()->createSubSurface(QPointer<Surface>(surface), QPointer<Surface>(parentSurface), this); m_subSurface = backend->subCompositor()->createSubSurface(QPointer<Surface>(surface), QPointer<Surface>(parentSurface), this);
@ -336,6 +346,7 @@ void WaylandCursor::setCursorImage(const QImage &image, const QPoint &hotspot)
void WaylandCursor::setCursorImage(Qt::CursorShape shape) void WaylandCursor::setCursorImage(Qt::CursorShape shape)
{ {
#if HAVE_WAYLAND_CURSOR
wl_cursor_image *image = m_theme->get(shape); wl_cursor_image *image = m_theme->get(shape);
if (!image) { if (!image) {
return; return;
@ -343,6 +354,7 @@ void WaylandCursor::setCursorImage(Qt::CursorShape shape)
setCursorImage(wl_cursor_image_get_buffer(image), setCursorImage(wl_cursor_image_get_buffer(image),
QSize(image->width, image->height), QSize(image->width, image->height),
QPoint(image->hotspot_x, image->hotspot_y)); QPoint(image->hotspot_x, image->hotspot_y));
#endif
} }
WaylandBackend *WaylandBackend::s_self = 0; WaylandBackend *WaylandBackend::s_self = 0;

View file

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_WAYLAND_BACKEND_H #define KWIN_WAYLAND_BACKEND_H
// KWin // KWin
#include "abstract_backend.h" #include "abstract_backend.h"
#include <config-kwin.h>
#include <kwinglobals.h> #include <kwinglobals.h>
// Qt // Qt
#include <QHash> #include <QHash>
@ -69,6 +70,7 @@ namespace Wayland
class WaylandBackend; class WaylandBackend;
class WaylandSeat; class WaylandSeat;
#if HAVE_WAYLAND_CURSOR
class WaylandCursorTheme : public QObject class WaylandCursorTheme : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -84,6 +86,7 @@ private:
wl_cursor_theme *m_theme; wl_cursor_theme *m_theme;
WaylandBackend *m_backend; WaylandBackend *m_backend;
}; };
#endif
class WaylandSeat : public QObject class WaylandSeat : public QObject
{ {
@ -106,7 +109,9 @@ private:
KWayland::Client::Pointer *m_pointer; KWayland::Client::Pointer *m_pointer;
KWayland::Client::Keyboard *m_keyboard; KWayland::Client::Keyboard *m_keyboard;
KWayland::Client::Surface *m_cursor; KWayland::Client::Surface *m_cursor;
#if HAVE_WAYLAND_CURSOR
WaylandCursorTheme *m_theme; WaylandCursorTheme *m_theme;
#endif
uint32_t m_enteredSerial; uint32_t m_enteredSerial;
WaylandBackend *m_backend; WaylandBackend *m_backend;
bool m_installCursor; bool m_installCursor;
@ -133,7 +138,9 @@ private:
WaylandBackend *m_backend; WaylandBackend *m_backend;
QPoint m_hotSpot; QPoint m_hotSpot;
KWayland::Client::SubSurface *m_subSurface; KWayland::Client::SubSurface *m_subSurface;
#if HAVE_WAYLAND_CURSOR
WaylandCursorTheme *m_theme; WaylandCursorTheme *m_theme;
#endif
}; };
/** /**