summaryrefslogtreecommitdiffstats
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
parente48e1d4f6e4f6ce8c9aef8f8baa24f588a65a1d1 (diff)
Add TouchGrabber
Change-Id: I1a06858688b0b6e90966d92da7f7a25e1203b4f1 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp66
-rw-r--r--src/compositor/wayland_wrapper/qwltouch_p.h29
2 files changed, 87 insertions, 8 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
diff --git a/src/compositor/wayland_wrapper/qwltouch_p.h b/src/compositor/wayland_wrapper/qwltouch_p.h
index f7fdd7113..d967b714d 100644
--- a/src/compositor/wayland_wrapper/qwltouch_p.h
+++ b/src/compositor/wayland_wrapper/qwltouch_p.h
@@ -54,14 +54,35 @@ namespace QtWayland {
class Compositor;
class Surface;
+class Touch;
-class Q_COMPOSITOR_EXPORT Touch : public QtWaylandServer::wl_touch
+class Q_COMPOSITOR_EXPORT TouchGrabber {
+public:
+ TouchGrabber();
+ virtual ~TouchGrabber();
+
+ virtual void down(uint32_t time, int touch_id, const QPointF &position) = 0;
+ virtual void up(uint32_t time, int touch_id) = 0;
+ virtual void motion(uint32_t time, int touch_id, const QPointF &position) = 0;
+
+ const Touch *touch() const;
+ Touch *touch();
+ void setTouch(Touch *touch);
+
+private:
+ Touch *m_touch;
+};
+
+class Q_COMPOSITOR_EXPORT Touch : public QtWaylandServer::wl_touch, public TouchGrabber
{
public:
explicit Touch(Compositor *compositor);
void setFocus(Surface *surface);
+ void startGrab(TouchGrabber *grab);
+ void endGrab();
+
void sendCancel();
void sendFrame();
@@ -69,11 +90,17 @@ public:
void sendMotion(int touch_id, const QPointF &position);
void sendUp(int touch_id);
+ void down(uint32_t time, int touch_id, const QPointF &position);
+ void up(uint32_t time, int touch_id);
+ void motion(uint32_t time, int touch_id, const QPointF &position);
+
private:
Compositor *m_compositor;
Surface *m_focus;
Resource *m_focusResource;
+
+ TouchGrabber *m_grab;
};
} // namespace QtWayland