[PATCH 1/2] cairo-util: Add frame_touch_motion support

Boyan Ding stu_dby at 126.com
Tue May 6 19:46:29 PDT 2014


---
 shared/cairo-util.h |  3 +++
 shared/frame.c      | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index 4493b0d..7aebb65 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -211,6 +211,9 @@ void
 frame_touch_up(struct frame *frame, void *data, int32_t id);
 
 void
+frame_touch_motion(struct frame *frame, void *data, int32_t id, int x, int y);
+
+void
 frame_repaint(struct frame *frame, cairo_t *cr);
 
 #endif
diff --git a/shared/frame.c b/shared/frame.c
index 35e6b65..df51eca 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -837,6 +837,30 @@ frame_touch_up(struct frame *frame, void *data, int32_t id)
 }
 
 void
+frame_touch_motion(struct frame *frame, void *data, int32_t id, int x, int y)
+{
+	struct frame_touch *touch = frame_touch_get(frame, data);
+	struct frame_button *button = frame_find_button(frame, x, y);
+
+	if (id > 0 || !touch)
+		return;
+
+	touch->x = x;
+	touch->y = y;
+
+	if (touch->button == button)
+		return ;
+
+	if (touch->button)
+		frame_button_release(touch->button);
+
+	touch->button = button;
+
+	if (touch->button)
+		frame_button_press(touch->button);
+}
+
+void
 frame_repaint(struct frame *frame, cairo_t *cr)
 {
 	struct frame_button *button;
-- 
1.9.2




More information about the wayland-devel mailing list