From 27249024b553215d0c7e297bfdc3c9367d625f47 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 19 May 2012 11:01:02 +0300 Subject: [PATCH] Register QTouchDevice only when the seat is touch-capable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ibddfaa2f07b9cd2eae2e133b01d4e5669ced2af8 Reviewed-by: Samuel Rødal --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 56496ff..cbb922b 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -70,6 +70,7 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id) , mKeyboardFocus(0) , mTouchFocus(0) , mButtons(0) + , mTouchDevice(0) #ifndef QT_NO_WAYLAND_XKB , mXkbContext(0) , mXkbMap(0) @@ -103,11 +104,6 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id) if (mQDisplay->dndSelectionHandler()) { mTransferDevice = mQDisplay->dndSelectionHandler()->getDataDevice(this); } - - mTouchDevice = new QTouchDevice; - mTouchDevice->setType(QTouchDevice::TouchScreen); - mTouchDevice->setCapabilities(QTouchDevice::Position); - QWindowSystemInterface::registerTouchDevice(mTouchDevice); } QWaylandInputDevice::~QWaylandInputDevice() @@ -166,6 +162,13 @@ void QWaylandInputDevice::seat_capabilities(void *data, struct wl_seat *seat, ui if (caps & WL_SEAT_CAPABILITY_TOUCH) { self->mDeviceInterfaces.touch = wl_seat_get_touch(seat); wl_touch_add_listener(self->mDeviceInterfaces.touch, &touchListener, self); + + if (!self->mTouchDevice) { + self->mTouchDevice = new QTouchDevice; + self->mTouchDevice->setType(QTouchDevice::TouchScreen); + self->mTouchDevice->setCapabilities(QTouchDevice::Position); + QWindowSystemInterface::registerTouchDevice(self->mTouchDevice); + } } } -- 2.7.4