diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-04-05 14:36:57 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-04-10 07:25:42 +0000 |
commit | 0dee89272cbd05454ed3c527b5e50e5acee1ba39 (patch) | |
tree | 36894f4f4ba63e6108896625ebcd034d2e4971bd /src/client/qwaylandinputdevice.cpp | |
parent | 8b4ce01eaa5354352101d8e726cd2fb4db5ea909 (diff) |
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>
Diffstat (limited to 'src/client/qwaylandinputdevice.cpp')
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 711f5b422..daad6f15c 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -41,6 +41,7 @@ #include "qwaylandintegration_p.h" #include "qwaylandwindow_p.h" +#include "qwaylandsurface_p.h" #include "qwaylandbuffer_p.h" #if QT_CONFIG(wayland_datadevice) #include "qwaylanddatadevice_p.h" @@ -190,23 +191,17 @@ QWaylandInputDevice::Pointer::~Pointer() #if QT_CONFIG(cursor) -class CursorSurface : public QObject, public QtWayland::wl_surface +class CursorSurface : public QWaylandSurface { public: 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. m_version = display->compositorVersion(); - connect(qApp, &QGuiApplication::screenRemoved, this, [this](QScreen *screen) { - int oldScale = outputScale(); - if (!m_screens.removeOne(static_cast<QWaylandScreen *>(screen->handle()))) - return; - - if (outputScale() != oldScale) - m_pointer->updateCursor(); - }); + connect(this, &QWaylandSurface::screensChanged, + m_pointer, &QWaylandInputDevice::Pointer::updateCursor); } void hide() @@ -246,38 +241,11 @@ public: 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: QWaylandInputDevice::Pointer *m_pointer = nullptr; uint m_version = 0; uint m_setSerial = 0; QPoint m_hotspot; - QVector<QWaylandScreen *> m_screens; }; QString QWaylandInputDevice::Pointer::cursorThemeName() const |