diff options
author | David Edmundson <davidedmundson@kde.org> | 2021-02-09 22:05:30 +0000 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-24 16:39:32 +0000 |
commit | 3ac797ea5809d69bff83ceacef13ee3a04c2df03 (patch) | |
tree | 4995b296e9401142681c574bd024d3111ff4216c | |
parent | 740e5ba7e25a5112888af8cc74f075f344a9c42b (diff) | |
download | qtwayland-3ac797ea5809d69bff83ceacef13ee3a04c2df03.tar.gz |
Client: Generate method to expose used version of a given proxy
Relying on the compositor version only works for the core protocols.
Using the version of our relevant object is more extensible and relies
on less caching.
Change-Id: I1044e43a1e24a25359db95988c9956f4f1b5d35f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit e735be5d52f08004bc3d8f246240d7c2c8418a17)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 3 | ||||
-rw-r--r-- | src/client/qwaylanddisplay_p.h | 2 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 22 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 1 | ||||
-rw-r--r-- | src/client/qwaylandscreen.cpp | 1 | ||||
-rw-r--r-- | src/client/qwaylandscreen_p.h | 3 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 10 | ||||
-rw-r--r-- | src/qtwaylandscanner/qtwaylandscanner.cpp | 8 |
8 files changed, 23 insertions, 27 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 82dcc63e..64b524aa 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -329,8 +329,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin if (interface == QStringLiteral("wl_output")) { mWaitingScreens << new QWaylandScreen(this, version, id); } else if (interface == QStringLiteral("wl_compositor")) { - mCompositorVersion = qMin((int)version, 4); - mCompositor.init(registry, id, mCompositorVersion); + mCompositor.init(registry, id, qMin((int)version, 4)); } else if (interface == QStringLiteral("wl_shm")) { mShm.reset(new QWaylandShm(this, version, id)); } else if (interface == QStringLiteral("wl_seat")) { diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index e5cdbee9..38bc35ff 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -158,7 +158,6 @@ public: const struct wl_compositor *wl_compositor() const { return mCompositor.object(); } QtWayland::wl_compositor *compositor() { return &mCompositor; } - int compositorVersion() const { return mCompositorVersion; } QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; } QWaylandInputDevice *defaultInputDevice() const; @@ -287,7 +286,6 @@ private: int mFd = -1; int mWritableNotificationFd = -1; QList<RegistryGlobal> mGlobals; - int mCompositorVersion = -1; uint32_t mLastInputSerial = 0; QWaylandInputDevice *mLastInputDevice = nullptr; QPointer<QWaylandWindow> mLastInputWindow; diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 5be49993..fb9c63d8 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -132,7 +132,7 @@ QWaylandInputDevice::Keyboard::~Keyboard() { if (mFocus) QWindowSystemInterface::handleWindowActivated(nullptr); - if (mParent->mVersion >= 3) + if (version() >= 3) wl_keyboard_release(object()); else wl_keyboard_destroy(object()); @@ -156,7 +156,7 @@ QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *seat) QWaylandInputDevice::Pointer::~Pointer() { - if (mParent->mVersion >= 3) + if (version() >= 3) wl_pointer_release(object()); else wl_pointer_destroy(object()); @@ -197,8 +197,6 @@ public: : QWaylandSurface(display) , m_pointer(pointer) { - //TODO: When we upgrade to libwayland 1.10, use wl_surface_get_version instead. - m_version = display->compositorVersion(); connect(this, &QWaylandSurface::screensChanged, m_pointer, &QWaylandInputDevice::Pointer::updateCursor); } @@ -215,7 +213,7 @@ public: void update(wl_buffer *buffer, const QPoint &hotspot, const QSize &size, int bufferScale, bool animated = false) { // Calling code needs to ensure buffer scale is supported if != 1 - Q_ASSERT(bufferScale == 1 || m_version >= 3); + Q_ASSERT(bufferScale == 1 || version() >= 3); auto enterSerial = m_pointer->mEnterSerial; if (m_setSerial < enterSerial || m_hotspot != hotspot) { @@ -224,7 +222,7 @@ public: m_hotspot = hotspot; } - if (m_version >= 3) + if (version() >= 3) set_buffer_scale(bufferScale); attach(buffer, 0, 0); @@ -250,7 +248,6 @@ public: private: QScopedPointer<WlCallback> m_frameCallback; QWaylandInputDevice::Pointer *m_pointer = nullptr; - uint m_version = 0; uint m_setSerial = 0; QPoint m_hotspot; }; @@ -270,9 +267,9 @@ int QWaylandInputDevice::Pointer::cursorSize() const int QWaylandInputDevice::Pointer::idealCursorScale() const { - // set_buffer_scale is not supported on earlier versions - if (seat()->mQDisplay->compositorVersion() < 3) + if (seat()->mQDisplay->compositor()->version() < 3) { return 1; + } if (auto *s = mCursor.surface.data()) { if (s->outputScale() > 0) @@ -394,7 +391,7 @@ QWaylandInputDevice::Touch::Touch(QWaylandInputDevice *p) QWaylandInputDevice::Touch::~Touch() { - if (mParent->mVersion >= 3) + if (version() >= 3) wl_touch_release(object()); else wl_touch_destroy(object()); @@ -404,7 +401,6 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version, : QtWayland::wl_seat(display->wl_registry(), id, qMin(version, 5)) , mQDisplay(display) , mDisplay(display->wl_display()) - , mVersion(qMin(version, 5)) { #if QT_CONFIG(wayland_datadevice) if (mQDisplay->dndSelectionHandler()) { @@ -901,7 +897,7 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in mParent->mTime = time; - if (mParent->mVersion < WL_POINTER_FRAME_SINCE_VERSION) { + if (version() < WL_POINTER_FRAME_SINCE_VERSION) { qCDebug(lcQpaWaylandInput) << "Flushing new event; no frame event in this version"; flushFrameEvent(); } @@ -1000,7 +996,7 @@ void QWaylandInputDevice::Pointer::setFrameEvent(QWaylandPointerEvent *event) mFrameData.event = event; - if (mParent->mVersion < WL_POINTER_FRAME_SINCE_VERSION) { + if (version() < WL_POINTER_FRAME_SINCE_VERSION) { qCDebug(lcQpaWaylandInput) << "Flushing new event; no frame event in this version"; flushFrameEvent(); } diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 53691e68..7c39e50c 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -164,7 +164,6 @@ private: QWaylandDisplay *mQDisplay = nullptr; struct wl_display *mDisplay = nullptr; - int mVersion; uint32_t mCaps = 0; #if QT_CONFIG(cursor) diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 854f3b08..40a49d88 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -55,7 +55,6 @@ namespace QtWaylandClient { QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display, uint id, uint version) : QtWayland::zxdg_output_manager_v1(display->wl_registry(), id, qMin(3u, version)) - , m_version(qMin(3u, version)) { } diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index 404d0f1e..de03e944 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -67,9 +67,6 @@ class QWaylandCursor; class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgOutputManagerV1 : public QtWayland::zxdg_output_manager_v1 { public: QWaylandXdgOutputManagerV1(QWaylandDisplay *display, uint id, uint version); - uint version() const { return m_version; } -private: - uint m_version = 1; // TODO: remove when we upgrade minimum libwayland requriement to 1.10 }; class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output, QtWayland::zxdg_output_v1 diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index b19c518d..243f16a7 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -188,7 +188,7 @@ void QWaylandWindow::initWindow() // Enable high-dpi rendering. Scale() returns the screen scale factor and will // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale() // to inform the compositor that high-resolution buffers will be provided. - if (mDisplay->compositorVersion() >= 3) + if (mSurface->version() >= 3) mSurface->set_buffer_scale(scale()); setWindowFlags(window()->flags()); @@ -567,7 +567,7 @@ void QWaylandWindow::attachOffset(QWaylandBuffer *buffer) void QWaylandWindow::damage(const QRect &rect) { const int s = scale(); - if (mDisplay->compositorVersion() >= 4) + if (mSurface->version() >= 4) mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height()); else mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height()); @@ -604,7 +604,7 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage) return; attachOffset(buffer); - if (mDisplay->compositorVersion() >= 4) { + if (mSurface->version() >= 4) { const int s = scale(); for (const QRect &rect: damage) mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height()); @@ -734,7 +734,7 @@ QWaylandScreen *QWaylandWindow::waylandScreen() const void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) { - if (mDisplay->compositorVersion() < 2) + if (mSurface->version() < 2) return; wl_output_transform transform; @@ -1014,7 +1014,7 @@ void QWaylandWindow::handleScreensChanged() int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale(); if (scale != mScale) { mScale = scale; - if (mSurface && mDisplay->compositorVersion() >= 3) + if (mSurface && mSurface->version() >= 3) mSurface->set_buffer_scale(mScale); ensureSize(); } diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 450ef519..6da02152 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -1045,6 +1045,8 @@ bool Scanner::process() printf("\n"); printf(" bool isInitialized() const;\n"); printf("\n"); + printf(" uint32_t version() const;"); + printf("\n"); printf(" static const struct ::wl_interface *interface();\n"); printEnums(interface.enums); @@ -1198,6 +1200,12 @@ bool Scanner::process() printf(" }\n"); printf("\n"); + printf(" uint32_t %s::version() const\n", interfaceName); + printf(" {\n"); + printf(" return wl_proxy_get_version(reinterpret_cast<wl_proxy*>(m_%s));\n", interfaceName); + printf(" }\n"); + printf("\n"); + printf(" const struct wl_interface *%s::interface()\n", interfaceName); printf(" {\n"); printf(" return &::%s_interface;\n", interfaceName); |