Move X11CursorTracker from WaylandSeat to WaylandBackend

Allows it to be easily re-used in case we don't have a Seat.
This commit is contained in:
Martin Gräßlin 2014-10-15 14:55:31 +02:00
parent fd0d966652
commit 2fec4d55fc
2 changed files with 13 additions and 20 deletions

View file

@ -153,7 +153,6 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
, m_cursor(NULL) , m_cursor(NULL)
, m_theme(NULL) , m_theme(NULL)
, m_enteredSerial(0) , m_enteredSerial(0)
, m_cursorTracker()
, m_backend(backend) , m_backend(backend)
{ {
m_seat->setup(seat); m_seat->setup(seat);
@ -233,8 +232,7 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
input()->processPointerAxis(toAxis(), delta, time); input()->processPointerAxis(toAxis(), delta, time);
} }
); );
m_cursorTracker.reset(new X11CursorTracker(m_backend)); connect(m_backend->cursorTracker(), &X11CursorTracker::cursorImageChanged, this,
connect(m_cursorTracker.data(), &X11CursorTracker::cursorImageChanged, this,
[this](Buffer::Ptr image, const QSize &size, const QPoint &hotspot) { [this](Buffer::Ptr image, const QSize &size, const QPoint &hotspot) {
if (image.isNull()) { if (image.isNull()) {
return; return;
@ -260,7 +258,6 @@ void WaylandSeat::destroyPointer()
{ {
delete m_pointer; delete m_pointer;
m_pointer = nullptr; m_pointer = nullptr;
m_cursorTracker.reset();
} }
void WaylandSeat::destroyKeyboard() void WaylandSeat::destroyKeyboard()
@ -269,13 +266,6 @@ void WaylandSeat::destroyKeyboard()
m_keyboard = nullptr; m_keyboard = nullptr;
} }
void WaylandSeat::resetCursor()
{
if (!m_cursorTracker.isNull()) {
m_cursorTracker->resetCursor();
}
}
void WaylandSeat::installCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotSpot) void WaylandSeat::installCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotSpot)
{ {
if (!m_pointer || !m_pointer->isValid()) { if (!m_pointer || !m_pointer->isValid()) {
@ -352,6 +342,7 @@ WaylandBackend::WaylandBackend(QObject *parent)
, m_shellSurface(NULL) , m_shellSurface(NULL)
, m_seat() , m_seat()
, m_shm(new ShmPool(this)) , m_shm(new ShmPool(this))
, m_cursorTracker()
, m_connectionThreadObject(nullptr) , m_connectionThreadObject(nullptr)
, m_connectionThread(nullptr) , m_connectionThread(nullptr)
, m_fullscreenShell(new FullscreenShell(this)) , m_fullscreenShell(new FullscreenShell(this))
@ -437,11 +428,13 @@ void WaylandBackend::initConnection()
// setup registry // setup registry
m_registry->create(m_display); m_registry->create(m_display);
m_registry->setup(); m_registry->setup();
m_cursorTracker.reset(new X11CursorTracker(this, this));
}, },
Qt::QueuedConnection); Qt::QueuedConnection);
connect(m_connectionThreadObject, &ConnectionThread::connectionDied, this, connect(m_connectionThreadObject, &ConnectionThread::connectionDied, this,
[this]() { [this]() {
emit systemCompositorDied(); emit systemCompositorDied();
m_cursorTracker.reset();
m_seat.reset(); m_seat.reset();
m_shm->destroy(); m_shm->destroy();
destroyOutputs(); destroyOutputs();
@ -508,13 +501,7 @@ void WaylandBackend::createSurface()
// map the surface as fullscreen // map the surface as fullscreen
m_shellSurface = m_shell->createSurface(m_surface, this); m_shellSurface = m_shell->createSurface(m_surface, this);
m_shellSurface->setFullscreen(); m_shellSurface->setFullscreen();
connect(m_shellSurface, &ShellSurface::pinged, this, connect(m_shellSurface, &ShellSurface::pinged, m_cursorTracker.data(), &X11CursorTracker::resetCursor);
[this]() {
if (!m_seat.isNull()) {
m_seat->resetCursor();
}
}
);
connect(m_shellSurface, &ShellSurface::sizeChanged, this, &WaylandBackend::shellSurfaceSizeChanged); connect(m_shellSurface, &ShellSurface::sizeChanged, this, &WaylandBackend::shellSurfaceSizeChanged);
} }
} }

View file

@ -108,7 +108,6 @@ public:
WaylandSeat(wl_seat *seat, WaylandBackend *backend); WaylandSeat(wl_seat *seat, WaylandBackend *backend);
virtual ~WaylandSeat(); virtual ~WaylandSeat();
void resetCursor();
void installCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotspot); void installCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotspot);
void installCursorImage(Qt::CursorShape shape); void installCursorImage(Qt::CursorShape shape);
private Q_SLOTS: private Q_SLOTS:
@ -123,7 +122,6 @@ private:
KWayland::Client::Surface *m_cursor; KWayland::Client::Surface *m_cursor;
wl_cursor_theme *m_theme; wl_cursor_theme *m_theme;
uint32_t m_enteredSerial; uint32_t m_enteredSerial;
QScopedPointer<X11CursorTracker> m_cursorTracker;
WaylandBackend *m_backend; WaylandBackend *m_backend;
}; };
@ -142,6 +140,7 @@ public:
KWayland::Client::Compositor *compositor(); KWayland::Client::Compositor *compositor();
const QList<KWayland::Client::Output*> &outputs() const; const QList<KWayland::Client::Output*> &outputs() const;
KWayland::Client::ShmPool *shmPool(); KWayland::Client::ShmPool *shmPool();
X11CursorTracker *cursorTracker();
KWayland::Client::Surface *surface() const; KWayland::Client::Surface *surface() const;
QSize shellSurfaceSize() const; QSize shellSurfaceSize() const;
@ -166,6 +165,7 @@ private:
KWayland::Client::ShellSurface *m_shellSurface; KWayland::Client::ShellSurface *m_shellSurface;
QScopedPointer<WaylandSeat> m_seat; QScopedPointer<WaylandSeat> m_seat;
KWayland::Client::ShmPool *m_shm; KWayland::Client::ShmPool *m_shm;
QScopedPointer<X11CursorTracker> m_cursorTracker;
QList<KWayland::Client::Output*> m_outputs; QList<KWayland::Client::Output*> m_outputs;
KWayland::Client::ConnectionThread *m_connectionThreadObject; KWayland::Client::ConnectionThread *m_connectionThreadObject;
QThread *m_connectionThread; QThread *m_connectionThread;
@ -210,6 +210,12 @@ KWayland::Client::ShmPool* WaylandBackend::shmPool()
return m_shm; return m_shm;
} }
inline
X11CursorTracker *WaylandBackend::cursorTracker()
{
return m_cursorTracker.data();
}
inline inline
KWayland::Client::Surface *WaylandBackend::surface() const KWayland::Client::Surface *WaylandBackend::surface() const
{ {