diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-01-14 15:31:58 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2012-01-16 08:03:19 +0100 |
commit | 147c0f0cf373bf94c30dcd032248c9bbfa592f14 (patch) | |
tree | 3b1b18608a1f216d2bd2b2ffd940d000588bf030 /src/compositor/wayland_wrapper | |
parent | b4348fc574c93417010ef1b7a5d77166b9f75fa7 (diff) |
Send the contents of the rawScreenPositions() list too.
Change-Id: If43c4e07ae919b77050aaf5dcffea3b8d48ac460
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')
-rw-r--r-- | src/compositor/wayland_wrapper/wltouch.cpp | 29 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wltouch.h | 4 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/compositor/wayland_wrapper/wltouch.cpp b/src/compositor/wayland_wrapper/wltouch.cpp index b260bcb43..8bca8755d 100644 --- a/src/compositor/wayland_wrapper/wltouch.cpp +++ b/src/compositor/wayland_wrapper/wltouch.cpp @@ -53,15 +53,25 @@ const struct wl_touch_extension_interface TouchExtensionGlobal::touch_interface dummy }; +static const int maxRawPos = 24; + TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor) : m_compositor(compositor) { + wl_array_init(&m_rawdata_array); + m_rawdata_ptr = static_cast<float *>(wl_array_add(&m_rawdata_array, maxRawPos * sizeof(float) * 2)); + wl_display_add_global(compositor->wl_display(), &wl_touch_extension_interface, this, TouchExtensionGlobal::bind_func); } +TouchExtensionGlobal::~TouchExtensionGlobal() +{ + wl_array_release(&m_rawdata_array); +} + void TouchExtensionGlobal::destroy_resource(wl_resource *resource) { TouchExtensionGlobal *self = static_cast<TouchExtensionGlobal *>(resource->data); @@ -105,6 +115,7 @@ void TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface) uint32_t id = tp.id(); uint32_t state = tp.state(); uint32_t flags = tp.flags(); + QPointF p = tp.pos() - surfacePos; // surface-relative int x = toFixed(p.x()); int y = toFixed(p.y()); @@ -115,7 +126,25 @@ void TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface) int vx = toFixed(tp.velocity().x()); int vy = toFixed(tp.velocity().y()); uint32_t pressure = uint32_t(tp.pressure() * 255); + wl_array *rawData = 0; + QList<QPointF> rawPosList = tp.rawScreenPositions(); + int rawPosCount = rawPosList.count(); + if (rawPosCount) { + rawPosCount = qMin(maxRawPos, rawPosCount); + rawData = &m_rawdata_array; + rawData->size = rawPosCount * sizeof(float) * 2; + float *p = m_rawdata_ptr; + for (int rpi = 0; rpi < rawPosCount; ++rpi) { + const QPointF &rawPos(rawPosList.at(rpi)); + // This will stay in screen coordinates for performance + // reasons, clients using this data will presumably know + // what they are doing. + *p++ = float(rawPos.x()); + *p++ = float(rawPos.y()); + } + } + wl_resource_post_event(target, WL_TOUCH_EXTENSION_TOUCH, time, id, state, x, y, nx, ny, w, h, diff --git a/src/compositor/wayland_wrapper/wltouch.h b/src/compositor/wayland_wrapper/wltouch.h index fbd1cd0c1..600dd9020 100644 --- a/src/compositor/wayland_wrapper/wltouch.h +++ b/src/compositor/wayland_wrapper/wltouch.h @@ -43,6 +43,7 @@ #include "wlcompositor.h" #include "wayland-touch-extension-server-protocol.h" +#include "wayland-util.h" class Compositor; class Surface; @@ -54,6 +55,7 @@ class TouchExtensionGlobal { public: TouchExtensionGlobal(Compositor *compositor); + ~TouchExtensionGlobal(); void postTouchEvent(QTouchEvent *event, Surface *surface); @@ -68,6 +70,8 @@ private: static const struct wl_touch_extension_interface touch_interface; QList<wl_resource *> m_resources; + wl_array m_rawdata_array; + float *m_rawdata_ptr; }; } |