diff --git a/wayland_backend.cpp b/wayland_backend.cpp index b184d3b0ae..a4106586d2 100644 --- a/wayland_backend.cpp +++ b/wayland_backend.cpp @@ -86,9 +86,8 @@ bool CursorData::init() return true; } -X11CursorTracker::X11CursorTracker(WaylandSeat *seat, WaylandBackend *backend, QObject* parent) +X11CursorTracker::X11CursorTracker(WaylandBackend *backend, QObject* parent) : QObject(parent) - , m_seat(seat) , m_backend(backend) , m_lastX11Cursor(0) { @@ -131,11 +130,11 @@ void X11CursorTracker::cursorChanged(uint32_t serial) void X11CursorTracker::installCursor(const CursorData& cursor) { const QImage &cursorImage = cursor.cursor(); - auto buffer = m_backend->shmPool()->createBuffer(cursorImage).toStrongRef(); + auto buffer = m_backend->shmPool()->createBuffer(cursorImage); if (!buffer) { return; } - m_seat->installCursorImage(buffer->buffer(), cursorImage.size(), cursor.hotSpot()); + emit cursorImageChanged(buffer, cursorImage.size(), cursor.hotSpot()); } void X11CursorTracker::resetCursor() @@ -234,7 +233,15 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend) input()->processPointerAxis(toAxis(), delta, time); } ); - m_cursorTracker.reset(new X11CursorTracker(this, m_backend)); + m_cursorTracker.reset(new X11CursorTracker(m_backend)); + connect(m_cursorTracker.data(), &X11CursorTracker::cursorImageChanged, this, + [this](Buffer::Ptr image, const QSize &size, const QPoint &hotspot) { + if (image.isNull()) { + return; + } + installCursorImage(image.toStrongRef()->buffer(), size, hotspot); + } + ); } else { destroyPointer(); } diff --git a/wayland_backend.h b/wayland_backend.h index be10291419..7fb413e1ee 100644 --- a/wayland_backend.h +++ b/wayland_backend.h @@ -39,6 +39,7 @@ namespace KWayland { namespace Client { +class Buffer; class ShmPool; class Compositor; class ConnectionThread; @@ -83,14 +84,17 @@ class X11CursorTracker : public QObject { Q_OBJECT public: - explicit X11CursorTracker(WaylandSeat *seat, WaylandBackend *backend, QObject* parent = 0); + explicit X11CursorTracker(WaylandBackend *backend, QObject* parent = 0); virtual ~X11CursorTracker(); void resetCursor(); + +Q_SIGNALS: + void cursorImageChanged(QWeakPointer image, const QSize &size, const QPoint &hotSpot); + private Q_SLOTS: void cursorChanged(uint32_t serial); private: void installCursor(const CursorData &cursor); - WaylandSeat *m_seat; QHash m_cursors; WaylandBackend *m_backend; uint32_t m_installedCursor;