Client: Make CursorSurface inherit from QWaylandSurface
QWaylandSurface has now been decoupled from QWaylandWindow so we can share some implementation with it and get rid of a lot of duplication. Task-number: QTBUG-74373 Change-Id: Ieb9aa3a5cf11abe381b7cf407122d3ca7a9251fc Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
This commit is contained in:
parent
24be607d50
commit
b384628f8b
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "qwaylandintegration_p.h"
|
#include "qwaylandintegration_p.h"
|
||||||
#include "qwaylandwindow_p.h"
|
#include "qwaylandwindow_p.h"
|
||||||
|
#include "qwaylandsurface_p.h"
|
||||||
#include "qwaylandbuffer_p.h"
|
#include "qwaylandbuffer_p.h"
|
||||||
#if QT_CONFIG(wayland_datadevice)
|
#if QT_CONFIG(wayland_datadevice)
|
||||||
#include "qwaylanddatadevice_p.h"
|
#include "qwaylanddatadevice_p.h"
|
||||||
@ -190,23 +191,17 @@ QWaylandInputDevice::Pointer::~Pointer()
|
|||||||
|
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
|
|
||||||
class CursorSurface : public QObject, public QtWayland::wl_surface
|
class CursorSurface : public QWaylandSurface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CursorSurface(QWaylandInputDevice::Pointer *pointer, QWaylandDisplay *display)
|
explicit CursorSurface(QWaylandInputDevice::Pointer *pointer, QWaylandDisplay *display)
|
||||||
: m_pointer(pointer)
|
: QWaylandSurface(display)
|
||||||
|
, m_pointer(pointer)
|
||||||
{
|
{
|
||||||
init(display->createSurface(this));
|
|
||||||
//TODO: When we upgrade to libwayland 1.10, use wl_surface_get_version instead.
|
//TODO: When we upgrade to libwayland 1.10, use wl_surface_get_version instead.
|
||||||
m_version = display->compositorVersion();
|
m_version = display->compositorVersion();
|
||||||
connect(qApp, &QGuiApplication::screenRemoved, this, [this](QScreen *screen) {
|
connect(this, &QWaylandSurface::screensChanged,
|
||||||
int oldScale = outputScale();
|
m_pointer, &QWaylandInputDevice::Pointer::updateCursor);
|
||||||
if (!m_screens.removeOne(static_cast<QWaylandScreen *>(screen->handle())))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (outputScale() != oldScale)
|
|
||||||
m_pointer->updateCursor();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hide()
|
void hide()
|
||||||
@ -246,38 +241,11 @@ public:
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
void surface_enter(struct ::wl_output *output) override
|
|
||||||
{
|
|
||||||
int oldScale = outputScale();
|
|
||||||
auto *screen = QWaylandScreen::fromWlOutput(output);
|
|
||||||
if (m_screens.contains(screen))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_screens.append(screen);
|
|
||||||
|
|
||||||
if (outputScale() != oldScale)
|
|
||||||
m_pointer->updateCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void surface_leave(struct ::wl_output *output) override
|
|
||||||
{
|
|
||||||
int oldScale = outputScale();
|
|
||||||
auto *screen = QWaylandScreen::fromWlOutput(output);
|
|
||||||
|
|
||||||
if (!m_screens.removeOne(screen))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (outputScale() != oldScale)
|
|
||||||
m_pointer->updateCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWaylandInputDevice::Pointer *m_pointer = nullptr;
|
QWaylandInputDevice::Pointer *m_pointer = nullptr;
|
||||||
uint m_version = 0;
|
uint m_version = 0;
|
||||||
uint m_setSerial = 0;
|
uint m_setSerial = 0;
|
||||||
QPoint m_hotspot;
|
QPoint m_hotspot;
|
||||||
QVector<QWaylandScreen *> m_screens;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QString QWaylandInputDevice::Pointer::cursorThemeName() const
|
QString QWaylandInputDevice::Pointer::cursorThemeName() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user