From 265af8e7ed50303d78b348cc19885bbb5b8f13d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 2 Apr 2015 14:25:51 +0200 Subject: [PATCH] [wayland] WaylandCursorTheme takes ShmPool instead of WaylandBackend Allows to use the WaylandCursorTheme without needing a WaylandBackend. WaylandBackend was only used for getting the ShmPool. --- wayland_backend.cpp | 13 ++++++++----- wayland_backend.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/wayland_backend.cpp b/wayland_backend.cpp index ea9ebeff37..1dbd096e2b 100644 --- a/wayland_backend.cpp +++ b/wayland_backend.cpp @@ -74,7 +74,7 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend) , m_touch(nullptr) , m_cursor(NULL) #if HAVE_WAYLAND_CURSOR - , m_theme(new WaylandCursorTheme(backend, this)) + , m_theme(new WaylandCursorTheme(backend->shmPool(), this)) #endif , m_enteredSerial(0) , m_backend(backend) @@ -278,10 +278,10 @@ void WaylandSeat::setInstallCursor(bool install) } #if HAVE_WAYLAND_CURSOR -WaylandCursorTheme::WaylandCursorTheme(WaylandBackend *backend, QObject *parent) +WaylandCursorTheme::WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent) : QObject(parent) , m_theme(nullptr) - , m_backend(backend) + , m_shm(shm) { } @@ -292,6 +292,9 @@ WaylandCursorTheme::~WaylandCursorTheme() void WaylandCursorTheme::loadTheme() { + if (!m_shm->isValid()) { + return; + } Cursor *c = Cursor::self(); if (!m_theme) { // so far the theme had not been created, this means we need to start tracking theme changes @@ -300,7 +303,7 @@ void WaylandCursorTheme::loadTheme() destroyTheme(); } m_theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(), - c->themeSize() ? c->themeSize() : -1, m_backend->shmPool()->shm()); + c->themeSize() ? c->themeSize() : -1, m_shm->shm()); } void WaylandCursorTheme::destroyTheme() @@ -333,7 +336,7 @@ WaylandCursor::WaylandCursor(Surface *parentSurface, WaylandBackend *backend) : QObject(backend) , m_backend(backend) #if HAVE_WAYLAND_CURSOR - , m_theme(new WaylandCursorTheme(backend, this)) + , m_theme(new WaylandCursorTheme(backend->shmPool(), this)) #endif { auto surface = backend->compositor()->createSurface(this); diff --git a/wayland_backend.h b/wayland_backend.h index c2c22d50d7..650186214a 100644 --- a/wayland_backend.h +++ b/wayland_backend.h @@ -76,7 +76,7 @@ class WaylandCursorTheme : public QObject { Q_OBJECT public: - explicit WaylandCursorTheme(WaylandBackend *backend, QObject *parent = nullptr); + explicit WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent = nullptr); virtual ~WaylandCursorTheme(); wl_cursor_image *get(Qt::CursorShape shape); @@ -85,7 +85,7 @@ private: void loadTheme(); void destroyTheme(); wl_cursor_theme *m_theme; - WaylandBackend *m_backend; + KWayland::Client::ShmPool *m_shm = nullptr; }; #endif