From: Laszlo Agocs Date: Thu, 17 May 2012 09:25:13 +0000 (+0300) Subject: Store the input device in the touch extension X-Git-Tag: TIZEN~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98d6e198f896875d3cdb06c357d5bfdfd71ca394;p=profile%2Fivi%2Fqtwayland.git Store the input device in the touch extension Implicit sharing is nice but not doing anything is better Change-Id: I2ae753e749c1b7d7e1dce78dd59a084ce8e4e836 Reviewed-by: Samuel Rødal --- diff --git a/src/plugins/platforms/wayland/qwaylandtouch.cpp b/src/plugins/platforms/wayland/qwaylandtouch.cpp index f4de44c..3387f9f 100644 --- a/src/plugins/platforms/wayland/qwaylandtouch.cpp +++ b/src/plugins/platforms/wayland/qwaylandtouch.cpp @@ -49,7 +49,8 @@ QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_ mTouchDevice(0), mPointsLeft(0), mFlags(0), - mMouseSourceId(-1) + mMouseSourceId(-1), + mInputDevice(0) { mTouch = static_cast(wl_display_bind(display->wl_display(), id, &wl_touch_extension_interface)); wl_touch_extension_add_listener(mTouch, &touch_listener, this); @@ -77,17 +78,20 @@ void QWaylandTouchExtension::handle_touch(void *data, wl_touch_extension *ext, u { Q_UNUSED(ext); QWaylandTouchExtension *self = static_cast(data); - QList inputDevices = self->mDisplay->inputDevices(); - if (inputDevices.isEmpty()) { - qWarning("wl_touch_extension: handle_touch: No input device"); - return; + + if (!self->mInputDevice) { + QList inputDevices = self->mDisplay->inputDevices(); + if (inputDevices.isEmpty()) { + qWarning("wl_touch_extension: handle_touch: No input devices"); + return; + } + self->mInputDevice = inputDevices.first(); } - QWaylandInputDevice *dev = inputDevices.first(); - QWaylandWindow *win = dev->mTouchFocus; + QWaylandWindow *win = self->mInputDevice->mTouchFocus; if (!win) - win = dev->mPointerFocus; + win = self->mInputDevice->mPointerFocus; if (!win) - win = dev->mKeyboardFocus; + win = self->mInputDevice->mKeyboardFocus; if (!win || !win->window()) { qWarning("wl_touch_extension: handle_touch: No pointer focus"); return; diff --git a/src/plugins/platforms/wayland/qwaylandtouch.h b/src/plugins/platforms/wayland/qwaylandtouch.h index 7739642..226c658 100644 --- a/src/plugins/platforms/wayland/qwaylandtouch.h +++ b/src/plugins/platforms/wayland/qwaylandtouch.h @@ -93,6 +93,7 @@ private: QPointF mLastMouseLocal; QPointF mLastMouseGlobal; QWindow *mTargetWindow; + QWaylandInputDevice *mInputDevice; }; #endif // QWAYLANDTOUCH_H