[wayland] WaylandCursorTheme takes ShmPool instead of WaylandBackend

Allows to use the WaylandCursorTheme without needing a WaylandBackend.
WaylandBackend was only used for getting the ShmPool.
This commit is contained in:
Martin Gräßlin 2015-04-02 14:25:51 +02:00
parent bb404f7d67
commit 265af8e7ed
2 changed files with 10 additions and 7 deletions

View file

@ -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);

View file

@ -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