X11CursorTracker emits signal when a new cursor image needs to be installed
This means the X11CursorTracker is no longer bound to the WaylandSeat. Instead the WaylandSeat just connects to the signal emitted by the X11CursorTracker. This allows to use the X11CursorTracker also in cases where we don't use a Seat for setting the cursor image.
This commit is contained in:
parent
752de2d888
commit
fd0d966652
2 changed files with 18 additions and 7 deletions
|
@ -86,9 +86,8 @@ bool CursorData::init()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
X11CursorTracker::X11CursorTracker(WaylandSeat *seat, WaylandBackend *backend, QObject* parent)
|
X11CursorTracker::X11CursorTracker(WaylandBackend *backend, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_seat(seat)
|
|
||||||
, m_backend(backend)
|
, m_backend(backend)
|
||||||
, m_lastX11Cursor(0)
|
, m_lastX11Cursor(0)
|
||||||
{
|
{
|
||||||
|
@ -131,11 +130,11 @@ void X11CursorTracker::cursorChanged(uint32_t serial)
|
||||||
void X11CursorTracker::installCursor(const CursorData& cursor)
|
void X11CursorTracker::installCursor(const CursorData& cursor)
|
||||||
{
|
{
|
||||||
const QImage &cursorImage = cursor.cursor();
|
const QImage &cursorImage = cursor.cursor();
|
||||||
auto buffer = m_backend->shmPool()->createBuffer(cursorImage).toStrongRef();
|
auto buffer = m_backend->shmPool()->createBuffer(cursorImage);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_seat->installCursorImage(buffer->buffer(), cursorImage.size(), cursor.hotSpot());
|
emit cursorImageChanged(buffer, cursorImage.size(), cursor.hotSpot());
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11CursorTracker::resetCursor()
|
void X11CursorTracker::resetCursor()
|
||||||
|
@ -234,7 +233,15 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
|
||||||
input()->processPointerAxis(toAxis(), delta, time);
|
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 {
|
} else {
|
||||||
destroyPointer();
|
destroyPointer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace KWayland
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
{
|
{
|
||||||
|
class Buffer;
|
||||||
class ShmPool;
|
class ShmPool;
|
||||||
class Compositor;
|
class Compositor;
|
||||||
class ConnectionThread;
|
class ConnectionThread;
|
||||||
|
@ -83,14 +84,17 @@ class X11CursorTracker : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit X11CursorTracker(WaylandSeat *seat, WaylandBackend *backend, QObject* parent = 0);
|
explicit X11CursorTracker(WaylandBackend *backend, QObject* parent = 0);
|
||||||
virtual ~X11CursorTracker();
|
virtual ~X11CursorTracker();
|
||||||
void resetCursor();
|
void resetCursor();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void cursorImageChanged(QWeakPointer<KWayland::Client::Buffer> image, const QSize &size, const QPoint &hotSpot);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void cursorChanged(uint32_t serial);
|
void cursorChanged(uint32_t serial);
|
||||||
private:
|
private:
|
||||||
void installCursor(const CursorData &cursor);
|
void installCursor(const CursorData &cursor);
|
||||||
WaylandSeat *m_seat;
|
|
||||||
QHash<uint32_t, CursorData> m_cursors;
|
QHash<uint32_t, CursorData> m_cursors;
|
||||||
WaylandBackend *m_backend;
|
WaylandBackend *m_backend;
|
||||||
uint32_t m_installedCursor;
|
uint32_t m_installedCursor;
|
||||||
|
|
Loading…
Reference in a new issue