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. Pick-to: 6.1 Change-Id: I1044e43a1e24a25359db95988c9956f4f1b5d35f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
9227c5d18d
commit
51b6fa425e
@ -329,8 +329,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
|||||||
if (interface == QStringLiteral("wl_output")) {
|
if (interface == QStringLiteral("wl_output")) {
|
||||||
mWaitingScreens << mWaylandIntegration->createPlatformScreen(this, version, id);
|
mWaitingScreens << mWaylandIntegration->createPlatformScreen(this, version, id);
|
||||||
} else if (interface == QStringLiteral("wl_compositor")) {
|
} else if (interface == QStringLiteral("wl_compositor")) {
|
||||||
mCompositorVersion = qMin((int)version, 4);
|
mCompositor.init(registry, id, qMin((int)version, 4));
|
||||||
mCompositor.init(registry, id, mCompositorVersion);
|
|
||||||
} else if (interface == QStringLiteral("wl_shm")) {
|
} else if (interface == QStringLiteral("wl_shm")) {
|
||||||
mShm.reset(new QWaylandShm(this, version, id));
|
mShm.reset(new QWaylandShm(this, version, id));
|
||||||
} else if (interface == QStringLiteral("wl_seat")) {
|
} else if (interface == QStringLiteral("wl_seat")) {
|
||||||
|
@ -158,7 +158,6 @@ public:
|
|||||||
|
|
||||||
const struct wl_compositor *wl_compositor() const { return mCompositor.object(); }
|
const struct wl_compositor *wl_compositor() const { return mCompositor.object(); }
|
||||||
QtWayland::wl_compositor *compositor() { return &mCompositor; }
|
QtWayland::wl_compositor *compositor() { return &mCompositor; }
|
||||||
int compositorVersion() const { return mCompositorVersion; }
|
|
||||||
|
|
||||||
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
|
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
|
||||||
QWaylandInputDevice *defaultInputDevice() const;
|
QWaylandInputDevice *defaultInputDevice() const;
|
||||||
@ -287,7 +286,6 @@ private:
|
|||||||
int mFd = -1;
|
int mFd = -1;
|
||||||
int mWritableNotificationFd = -1;
|
int mWritableNotificationFd = -1;
|
||||||
QList<RegistryGlobal> mGlobals;
|
QList<RegistryGlobal> mGlobals;
|
||||||
int mCompositorVersion = -1;
|
|
||||||
uint32_t mLastInputSerial = 0;
|
uint32_t mLastInputSerial = 0;
|
||||||
QWaylandInputDevice *mLastInputDevice = nullptr;
|
QWaylandInputDevice *mLastInputDevice = nullptr;
|
||||||
QPointer<QWaylandWindow> mLastInputWindow;
|
QPointer<QWaylandWindow> mLastInputWindow;
|
||||||
|
@ -132,7 +132,7 @@ QWaylandInputDevice::Keyboard::~Keyboard()
|
|||||||
{
|
{
|
||||||
if (mFocus)
|
if (mFocus)
|
||||||
QWindowSystemInterface::handleWindowActivated(nullptr);
|
QWindowSystemInterface::handleWindowActivated(nullptr);
|
||||||
if (mParent->mVersion >= 3)
|
if (version() >= 3)
|
||||||
wl_keyboard_release(object());
|
wl_keyboard_release(object());
|
||||||
else
|
else
|
||||||
wl_keyboard_destroy(object());
|
wl_keyboard_destroy(object());
|
||||||
@ -156,7 +156,7 @@ QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *seat)
|
|||||||
|
|
||||||
QWaylandInputDevice::Pointer::~Pointer()
|
QWaylandInputDevice::Pointer::~Pointer()
|
||||||
{
|
{
|
||||||
if (mParent->mVersion >= 3)
|
if (version() >= 3)
|
||||||
wl_pointer_release(object());
|
wl_pointer_release(object());
|
||||||
else
|
else
|
||||||
wl_pointer_destroy(object());
|
wl_pointer_destroy(object());
|
||||||
@ -197,8 +197,6 @@ public:
|
|||||||
: QWaylandSurface(display)
|
: QWaylandSurface(display)
|
||||||
, m_pointer(pointer)
|
, 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,
|
connect(this, &QWaylandSurface::screensChanged,
|
||||||
m_pointer, &QWaylandInputDevice::Pointer::updateCursor);
|
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)
|
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
|
// 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;
|
auto enterSerial = m_pointer->mEnterSerial;
|
||||||
if (m_setSerial < enterSerial || m_hotspot != hotspot) {
|
if (m_setSerial < enterSerial || m_hotspot != hotspot) {
|
||||||
@ -224,7 +222,7 @@ public:
|
|||||||
m_hotspot = hotspot;
|
m_hotspot = hotspot;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_version >= 3)
|
if (version() >= 3)
|
||||||
set_buffer_scale(bufferScale);
|
set_buffer_scale(bufferScale);
|
||||||
|
|
||||||
attach(buffer, 0, 0);
|
attach(buffer, 0, 0);
|
||||||
@ -250,7 +248,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
QScopedPointer<WlCallback> m_frameCallback;
|
QScopedPointer<WlCallback> m_frameCallback;
|
||||||
QWaylandInputDevice::Pointer *m_pointer = nullptr;
|
QWaylandInputDevice::Pointer *m_pointer = nullptr;
|
||||||
uint m_version = 0;
|
|
||||||
uint m_setSerial = 0;
|
uint m_setSerial = 0;
|
||||||
QPoint m_hotspot;
|
QPoint m_hotspot;
|
||||||
};
|
};
|
||||||
@ -270,9 +267,9 @@ int QWaylandInputDevice::Pointer::cursorSize() const
|
|||||||
|
|
||||||
int QWaylandInputDevice::Pointer::idealCursorScale() const
|
int QWaylandInputDevice::Pointer::idealCursorScale() const
|
||||||
{
|
{
|
||||||
// set_buffer_scale is not supported on earlier versions
|
if (seat()->mQDisplay->compositor()->version() < 3) {
|
||||||
if (seat()->mQDisplay->compositorVersion() < 3)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (auto *s = mCursor.surface.data()) {
|
if (auto *s = mCursor.surface.data()) {
|
||||||
if (s->outputScale() > 0)
|
if (s->outputScale() > 0)
|
||||||
@ -394,7 +391,7 @@ QWaylandInputDevice::Touch::Touch(QWaylandInputDevice *p)
|
|||||||
|
|
||||||
QWaylandInputDevice::Touch::~Touch()
|
QWaylandInputDevice::Touch::~Touch()
|
||||||
{
|
{
|
||||||
if (mParent->mVersion >= 3)
|
if (version() >= 3)
|
||||||
wl_touch_release(object());
|
wl_touch_release(object());
|
||||||
else
|
else
|
||||||
wl_touch_destroy(object());
|
wl_touch_destroy(object());
|
||||||
@ -404,7 +401,6 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version,
|
|||||||
: QtWayland::wl_seat(display->wl_registry(), id, qMin(version, 5))
|
: QtWayland::wl_seat(display->wl_registry(), id, qMin(version, 5))
|
||||||
, mQDisplay(display)
|
, mQDisplay(display)
|
||||||
, mDisplay(display->wl_display())
|
, mDisplay(display->wl_display())
|
||||||
, mVersion(qMin(version, 5))
|
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(wayland_datadevice)
|
#if QT_CONFIG(wayland_datadevice)
|
||||||
if (mQDisplay->dndSelectionHandler()) {
|
if (mQDisplay->dndSelectionHandler()) {
|
||||||
@ -901,7 +897,7 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in
|
|||||||
|
|
||||||
mParent->mTime = time;
|
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";
|
qCDebug(lcQpaWaylandInput) << "Flushing new event; no frame event in this version";
|
||||||
flushFrameEvent();
|
flushFrameEvent();
|
||||||
}
|
}
|
||||||
@ -1000,7 +996,7 @@ void QWaylandInputDevice::Pointer::setFrameEvent(QWaylandPointerEvent *event)
|
|||||||
|
|
||||||
mFrameData.event = 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";
|
qCDebug(lcQpaWaylandInput) << "Flushing new event; no frame event in this version";
|
||||||
flushFrameEvent();
|
flushFrameEvent();
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,6 @@ protected:
|
|||||||
QWaylandDisplay *mQDisplay = nullptr;
|
QWaylandDisplay *mQDisplay = nullptr;
|
||||||
struct wl_display *mDisplay = nullptr;
|
struct wl_display *mDisplay = nullptr;
|
||||||
|
|
||||||
int mVersion;
|
|
||||||
uint32_t mCaps = 0;
|
uint32_t mCaps = 0;
|
||||||
|
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
|
@ -55,7 +55,6 @@ namespace QtWaylandClient {
|
|||||||
|
|
||||||
QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display, uint id, uint version)
|
QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display, uint id, uint version)
|
||||||
: QtWayland::zxdg_output_manager_v1(display->wl_registry(), id, qMin(3u, version))
|
: QtWayland::zxdg_output_manager_v1(display->wl_registry(), id, qMin(3u, version))
|
||||||
, m_version(qMin(3u, version))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,6 @@ class QWaylandCursor;
|
|||||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgOutputManagerV1 : public QtWayland::zxdg_output_manager_v1 {
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgOutputManagerV1 : public QtWayland::zxdg_output_manager_v1 {
|
||||||
public:
|
public:
|
||||||
QWaylandXdgOutputManagerV1(QWaylandDisplay *display, uint id, uint version);
|
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
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output, QtWayland::zxdg_output_v1
|
||||||
|
@ -188,7 +188,7 @@ void QWaylandWindow::initWindow()
|
|||||||
// Enable high-dpi rendering. Scale() returns the screen scale factor and will
|
// 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()
|
// 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.
|
// to inform the compositor that high-resolution buffers will be provided.
|
||||||
if (mDisplay->compositorVersion() >= 3)
|
if (mSurface->version() >= 3)
|
||||||
mSurface->set_buffer_scale(scale());
|
mSurface->set_buffer_scale(scale());
|
||||||
|
|
||||||
setWindowFlags(window()->flags());
|
setWindowFlags(window()->flags());
|
||||||
@ -567,7 +567,7 @@ void QWaylandWindow::attachOffset(QWaylandBuffer *buffer)
|
|||||||
void QWaylandWindow::damage(const QRect &rect)
|
void QWaylandWindow::damage(const QRect &rect)
|
||||||
{
|
{
|
||||||
const int s = scale();
|
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());
|
mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
|
||||||
else
|
else
|
||||||
mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
|
mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
@ -604,7 +604,7 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
attachOffset(buffer);
|
attachOffset(buffer);
|
||||||
if (mDisplay->compositorVersion() >= 4) {
|
if (mSurface->version() >= 4) {
|
||||||
const int s = scale();
|
const int s = scale();
|
||||||
for (const QRect &rect: damage)
|
for (const QRect &rect: damage)
|
||||||
mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
|
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)
|
void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
|
||||||
{
|
{
|
||||||
if (mDisplay->compositorVersion() < 2)
|
if (mSurface->version() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wl_output_transform transform;
|
wl_output_transform transform;
|
||||||
@ -1014,7 +1014,7 @@ void QWaylandWindow::handleScreensChanged()
|
|||||||
int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
|
int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
|
||||||
if (scale != mScale) {
|
if (scale != mScale) {
|
||||||
mScale = scale;
|
mScale = scale;
|
||||||
if (mSurface && mDisplay->compositorVersion() >= 3)
|
if (mSurface && mSurface->version() >= 3)
|
||||||
mSurface->set_buffer_scale(mScale);
|
mSurface->set_buffer_scale(mScale);
|
||||||
ensureSize();
|
ensureSize();
|
||||||
}
|
}
|
||||||
|
@ -1045,6 +1045,8 @@ bool Scanner::process()
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" bool isInitialized() const;\n");
|
printf(" bool isInitialized() const;\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
printf(" uint32_t version() const;");
|
||||||
|
printf("\n");
|
||||||
printf(" static const struct ::wl_interface *interface();\n");
|
printf(" static const struct ::wl_interface *interface();\n");
|
||||||
|
|
||||||
printEnums(interface.enums);
|
printEnums(interface.enums);
|
||||||
@ -1198,6 +1200,12 @@ bool Scanner::process()
|
|||||||
printf(" }\n");
|
printf(" }\n");
|
||||||
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(" const struct wl_interface *%s::interface()\n", interfaceName);
|
||||||
printf(" {\n");
|
printf(" {\n");
|
||||||
printf(" return &::%s_interface;\n", interfaceName);
|
printf(" return &::%s_interface;\n", interfaceName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user