[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:
parent
bb404f7d67
commit
265af8e7ed
2 changed files with 10 additions and 7 deletions
|
@ -74,7 +74,7 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
|
||||||
, m_touch(nullptr)
|
, m_touch(nullptr)
|
||||||
, m_cursor(NULL)
|
, m_cursor(NULL)
|
||||||
#if HAVE_WAYLAND_CURSOR
|
#if HAVE_WAYLAND_CURSOR
|
||||||
, m_theme(new WaylandCursorTheme(backend, this))
|
, m_theme(new WaylandCursorTheme(backend->shmPool(), this))
|
||||||
#endif
|
#endif
|
||||||
, m_enteredSerial(0)
|
, m_enteredSerial(0)
|
||||||
, m_backend(backend)
|
, m_backend(backend)
|
||||||
|
@ -278,10 +278,10 @@ void WaylandSeat::setInstallCursor(bool install)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_WAYLAND_CURSOR
|
#if HAVE_WAYLAND_CURSOR
|
||||||
WaylandCursorTheme::WaylandCursorTheme(WaylandBackend *backend, QObject *parent)
|
WaylandCursorTheme::WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_theme(nullptr)
|
, m_theme(nullptr)
|
||||||
, m_backend(backend)
|
, m_shm(shm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +292,9 @@ WaylandCursorTheme::~WaylandCursorTheme()
|
||||||
|
|
||||||
void WaylandCursorTheme::loadTheme()
|
void WaylandCursorTheme::loadTheme()
|
||||||
{
|
{
|
||||||
|
if (!m_shm->isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Cursor *c = Cursor::self();
|
Cursor *c = Cursor::self();
|
||||||
if (!m_theme) {
|
if (!m_theme) {
|
||||||
// so far the theme had not been created, this means we need to start tracking theme changes
|
// 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();
|
destroyTheme();
|
||||||
}
|
}
|
||||||
m_theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(),
|
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()
|
void WaylandCursorTheme::destroyTheme()
|
||||||
|
@ -333,7 +336,7 @@ WaylandCursor::WaylandCursor(Surface *parentSurface, WaylandBackend *backend)
|
||||||
: QObject(backend)
|
: QObject(backend)
|
||||||
, m_backend(backend)
|
, m_backend(backend)
|
||||||
#if HAVE_WAYLAND_CURSOR
|
#if HAVE_WAYLAND_CURSOR
|
||||||
, m_theme(new WaylandCursorTheme(backend, this))
|
, m_theme(new WaylandCursorTheme(backend->shmPool(), this))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
auto surface = backend->compositor()->createSurface(this);
|
auto surface = backend->compositor()->createSurface(this);
|
||||||
|
|
|
@ -76,7 +76,7 @@ class WaylandCursorTheme : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit WaylandCursorTheme(WaylandBackend *backend, QObject *parent = nullptr);
|
explicit WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent = nullptr);
|
||||||
virtual ~WaylandCursorTheme();
|
virtual ~WaylandCursorTheme();
|
||||||
|
|
||||||
wl_cursor_image *get(Qt::CursorShape shape);
|
wl_cursor_image *get(Qt::CursorShape shape);
|
||||||
|
@ -85,7 +85,7 @@ private:
|
||||||
void loadTheme();
|
void loadTheme();
|
||||||
void destroyTheme();
|
void destroyTheme();
|
||||||
wl_cursor_theme *m_theme;
|
wl_cursor_theme *m_theme;
|
||||||
WaylandBackend *m_backend;
|
KWayland::Client::ShmPool *m_shm = nullptr;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue