diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-01-11 16:01:30 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2012-01-11 20:38:52 +0100 |
commit | 86cb4cbcfc375d4e9c764694c02eb82c3c7aa64b (patch) | |
tree | 07edccec5bb447ef8b048e1888837cebddc98730 /src/compositor/wayland_wrapper/wlinputdevice.cpp | |
parent | 3ff93ce7368ca577b775cbca0668fedb9373a04e (diff) |
Make touch event sending more robust in the InputDevice.
At least it won't crash and proper warnings are shown when the
slightly obscure pointer focus is not used properly in the compositor.
Change-Id: I2c970d197176b588f38a750e3cc805aae4d6c049
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper/wlinputdevice.cpp')
-rw-r--r-- | src/compositor/wayland_wrapper/wlinputdevice.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp index 70c0560f8..dfd2c6342 100644 --- a/src/compositor/wayland_wrapper/wlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp @@ -129,6 +129,8 @@ void InputDevice::sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState { uint32_t time = m_compositor->currentTimeMsecs(); struct wl_resource *resource = base()->pointer_focus_resource; + if (!resource) + return; switch (state) { case Qt::TouchPointPressed: wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_DOWN, time, base()->pointer_focus, id, x, y); @@ -150,15 +152,19 @@ void InputDevice::sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState void InputDevice::sendTouchFrameEvent() { struct wl_resource *resource = base()->pointer_focus_resource; - wl_resource_post_event(resource, - WL_INPUT_DEVICE_TOUCH_FRAME); + if (resource) { + wl_resource_post_event(resource, + WL_INPUT_DEVICE_TOUCH_FRAME); + } } void InputDevice::sendTouchCancelEvent() { struct wl_resource *resource = base()->pointer_focus_resource; - wl_resource_post_event(resource, - WL_INPUT_DEVICE_TOUCH_CANCEL); + if (resource) { + wl_resource_post_event(resource, + WL_INPUT_DEVICE_TOUCH_CANCEL); + } } void InputDevice::sendFullTouchEvent(QTouchEvent *event) @@ -166,8 +172,12 @@ void InputDevice::sendFullTouchEvent(QTouchEvent *event) const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); if (points.isEmpty()) return; + if (!mouseFocus()) { + qWarning("Cannot send touch event, no pointer focus, fix the compositor"); + return; + } const int pointCount = points.count(); - QPointF pos = mouseFocus()? mouseFocus()->pos():QPointF(0,0); + QPointF pos = mouseFocus()->pos(); for (int i = 0; i < pointCount; ++i) { const QTouchEvent::TouchPoint &tp(points.at(i)); // Convert the local pos in the compositor window to surface-relative. |