summaryrefslogtreecommitdiffstats
path: root/src/compositor/wayland_wrapper/qwltouch.cpp
diff options
context:
space:
mode:
authorJan Arne Petersen <jan.petersen@kdab.com>2013-08-01 14:14:04 +0200
committerJørgen Lind <jorgen.lind@digia.com>2013-11-22 15:45:25 +0100
commit52fcbe66e3d165754c0874250ab650fb7fc6a559 (patch)
tree3e289555968814319169ab46491473d6319ceee6 /src/compositor/wayland_wrapper/qwltouch.cpp
parente48e1d4f6e4f6ce8c9aef8f8baa24f588a65a1d1 (diff)
Add TouchGrabber
Change-Id: I1a06858688b0b6e90966d92da7f7a25e1203b4f1 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper/qwltouch.cpp')
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp66
1 files changed, 59 insertions, 7 deletions
diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp
index e595440d7..2a4070e5e 100644
--- a/src/compositor/wayland_wrapper/qwltouch.cpp
+++ b/src/compositor/wayland_wrapper/qwltouch.cpp
@@ -51,7 +51,9 @@ Touch::Touch(Compositor *compositor)
, m_compositor(compositor)
, m_focus()
, m_focusResource()
+ , m_grab(this)
{
+ m_grab->setTouch(this);
}
void Touch::setFocus(Surface *surface)
@@ -60,6 +62,17 @@ void Touch::setFocus(Surface *surface)
m_focusResource = surface ? resourceMap().value(surface->resource()->client()) : 0;
}
+void Touch::startGrab(TouchGrabber *grab)
+{
+ m_grab = grab;
+ grab->setTouch(this);
+}
+
+void Touch::endGrab()
+{
+ m_grab = this;
+}
+
void Touch::sendCancel()
{
if (m_focusResource)
@@ -74,32 +87,71 @@ void Touch::sendFrame()
void Touch::sendDown(int touch_id, const QPointF &position)
{
+ m_grab->down(m_compositor->currentTimeMsecs(), touch_id, position);
+}
+
+void Touch::sendMotion(int touch_id, const QPointF &position)
+{
+ m_grab->motion(m_compositor->currentTimeMsecs(), touch_id, position);
+}
+
+void Touch::sendUp(int touch_id)
+{
+ m_grab->up(m_compositor->currentTimeMsecs(), touch_id);
+}
+
+void Touch::down(uint32_t time, int touch_id, const QPointF &position)
+{
if (!m_focusResource || !m_focus)
return;
uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
- send_down(m_focusResource->handle, serial, Compositor::currentTimeMsecs(), m_focus->resource()->handle, touch_id,
+ send_down(m_focusResource->handle, serial, time, m_focus->resource()->handle, touch_id,
wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
}
-void Touch::sendMotion(int touch_id, const QPointF &position)
+void Touch::up(uint32_t time, int touch_id)
{
if (!m_focusResource)
return;
- send_motion(m_focusResource->handle, Compositor::currentTimeMsecs(), touch_id,
- wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
+ uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
+
+ send_up(m_focusResource->handle, serial, time, touch_id);
}
-void Touch::sendUp(int touch_id)
+void Touch::motion(uint32_t time, int touch_id, const QPointF &position)
{
if (!m_focusResource)
return;
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
+ send_motion(m_focusResource->handle, time, touch_id,
+ wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
+}
- send_up(m_focusResource->handle, serial, Compositor::currentTimeMsecs(), touch_id);
+TouchGrabber::TouchGrabber()
+ : m_touch(0)
+{
+}
+
+TouchGrabber::~TouchGrabber()
+{
+}
+
+const Touch *TouchGrabber::touch() const
+{
+ return m_touch;
+}
+
+Touch *TouchGrabber::touch()
+{
+ return m_touch;
+}
+
+void TouchGrabber::setTouch(Touch *touch)
+{
+ m_touch = touch;
}
} // namespace QtWayland