From 6d1b95ac8ba2dcea8e1819614a5503f3ff339958 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 11 May 2023 10:55:47 +0300 Subject: [PATCH] client: Move device initialization to device constructor The typical pattern throughout QtWayland is for wrapping clients to be entirely responsible for the lifespan of underlying proxy objects. InputDevices previously had a subtly different pattern with proxy object initialization being called externally. Change-Id: I2e018bff38628b636d0f485d810521f8e00291f3 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index b307fb43bdb..24c86a0cf70 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -63,6 +63,7 @@ static const int MaxTouchPoints = 10; QWaylandInputDevice::Keyboard::Keyboard(QWaylandInputDevice *p) : mParent(p) { + init(p->get_keyboard()); mRepeatTimer.callOnTimeout([&]() { if (!focusWindow()) { // We destroyed the keyboard focus surface, but the server didn't get the message yet... @@ -124,6 +125,7 @@ QWaylandWindow *QWaylandInputDevice::Keyboard::focusWindow() const QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *seat) : mParent(seat) { + init(seat->get_pointer()); #if QT_CONFIG(cursor) mCursor.frameTimer.setSingleShot(true); mCursor.frameTimer.callOnTimeout([&]() { @@ -364,6 +366,7 @@ void QWaylandInputDevice::Pointer::cursorFrameCallback() QWaylandInputDevice::Touch::Touch(QWaylandInputDevice *p) : mParent(p) { + init(p->get_touch()); } QWaylandInputDevice::Touch::~Touch() @@ -423,14 +426,12 @@ void QWaylandInputDevice::seat_capabilities(uint32_t caps) if (caps & WL_SEAT_CAPABILITY_KEYBOARD && !mKeyboard) { mKeyboard.reset(createKeyboard(this)); - mKeyboard->init(get_keyboard()); } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && mKeyboard) { mKeyboard.reset(); } if (caps & WL_SEAT_CAPABILITY_POINTER && !mPointer) { mPointer.reset(createPointer(this)); - mPointer->init(get_pointer()); auto *pointerGestures = mQDisplay->pointerGestures(); if (pointerGestures) { @@ -453,7 +454,6 @@ void QWaylandInputDevice::seat_capabilities(uint32_t caps) if (caps & WL_SEAT_CAPABILITY_TOUCH && !mTouch) { mTouch.reset(createTouch(this)); - mTouch->init(get_touch()); if (!mTouchDevice) { // TODO number of touchpoints, actual name and ID