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")) {
|
||||
mWaitingScreens << mWaylandIntegration->createPlatformScreen(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")) {
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -164,7 +164,6 @@ protected:
|
||||
QWaylandDisplay *mQDisplay = nullptr;
|
||||
struct wl_display *mDisplay = nullptr;
|
||||
|
||||
int mVersion;
|
||||
uint32_t mCaps = 0;
|
||||
|
||||
#if QT_CONFIG(cursor)
|
||||
|
@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user