<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">At 2014-05-08 09:55:23, "Jason Ekstrand" <jason@jlekstrand.net> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr">Boyan,<br>By and large, this looks really good!  I have just a few comments below.  As I said in another e-mail, I don't have any touch hardware I can test this on, so I wasn't able to actually test it.</div></blockquote><div><span style="line-height: 1.7;"><br></span></div><div><span style="line-height: 1.7;">Unfortunately, I don't have touch hardware either. However I found a interesting project [1] on github, though I'm still figuring out how to use it.</span></div><div><span style="line-height: 1.7;"><br></span></div><blockquote style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr">
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 6, 2014 at 9:46 PM, Boyan Ding <span dir="ltr"><<a href="mailto:stu_dby@126.com" target="_blank">stu_dby@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Adding touch support to weston's nested wayland backend to make testing<br>
easier.<br>
<br>
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=77769" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=77769</a><br>
---<br>
 src/compositor-wayland.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++<br>
 1 file changed, 95 insertions(+)<br>
<br>
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c<br>
index a08b71a..45040d4 100644<br>
--- a/src/compositor-wayland.c<br>
+++ b/src/compositor-wayland.c<br>
@@ -1582,6 +1582,91 @@ static const struct wl_keyboard_listener keyboard_listener = {<br>
 };<br>
<br>
 static void<br>
+input_handle_touch_down(void *data, struct wl_touch *touch, uint32_t serial,<br>
+                       uint32_t time, struct wl_surface *surface, int32_t id,<br>
+                       wl_fixed_t x, wl_fixed_t y)<br>
+{<br>
+       struct wayland_input *input = data;<br>
+       int32_t fx, fy;<br>
+<br>
+       if (input->output->frame) {<br>
+               frame_touch_down(input->output->frame, input, id,<br>
+                                wl_fixed_to_int(x), wl_fixed_to_int(y));<br>
+               frame_interior(input->output->frame, &fx, &fy, NULL, NULL);<br>
+               x -= wl_fixed_from_int(fx);<br>
+               y -= wl_fixed_from_int(fy);<br></blockquote><div><br></div><div>You probably want to handle FRAME_STATUS_MOVE here.  See also input_handle_button.<br></div></div></div></div></blockquote><div><br></div><div><span style="line-height: 1.7;">I saw the code handling FRAME_STATUS_MOVE in input_handle_button returned after handling that. Do we need to return here?</span></div><div><span style="line-height: 1.7;">Also, I saw the pointer code notify the event only if the location is </span>THEME_LOCATION_CLIENT_AREA. Do we need to do the same thing? (I noticed the change of return type of frame_touch_down from void to <span style="font-family: arial; white-space: pre-wrap; line-height: normal;">theme_location in [2]</span><font face="arial"><span style="line-height: normal; white-space: pre-wrap;"> but that patch hasn't been applied.</span></font></div><blockquote style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+<br>
+               if (frame_status(input->output->frame) & FRAME_STATUS_REPAINT)<br>
+                       weston_output_schedule_repaint(&input->output->base);<br>
+       }<br>
+<br>
+       weston_output_transform_coordinate(&input->output->base, x, y, &x, &y);<br>
+<br>
+       notify_touch(&input->base, time, id, x, y, WL_TOUCH_DOWN);<br>
+}<br>
+<br>
+static void<br>
+input_handle_touch_up(void *data, struct wl_touch *touch, uint32_t serial,<br>
+                     uint32_t time, int32_t id)<br>
+{<br>
+       struct wayland_input *input = data;<br>
+<br>
+       if (input->output->frame) {<br>
+               frame_touch_up(input->output->frame, input, id);<br>
+<br></blockquote><div><br></div><div>You need to handle FRAME_STATUS_CLOSE here.  See also input_handle_button.<br><br>Perhaps, we want to add a wayland_output_handle_frame_status function to handle all of these so they can all be put in one place.  If we want to do that, then it should probably be in it's own patch.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+               if (frame_status(input->output->frame) & FRAME_STATUS_REPAINT)<br>
+                       weston_output_schedule_repaint(&input->output->base);<br>
+       }<br>
+<br>
+       notify_touch(&input->base, time, id, 0, 0, WL_TOUCH_UP);<br>
+}<br>
+<br>
+static void<br>
+input_handle_touch_motion(void *data, struct wl_touch *touch, uint32_t time,<br>
+                         int32_t id, wl_fixed_t x, wl_fixed_t y)<br>
+{<br>
+       struct wayland_input *input = data;<br>
+       int32_t fx, fy;<br>
+<br>
+       if (input->output->frame) {<br>
+               frame_touch_motion(input->output->frame, input, id,<br>
+                                wl_fixed_to_int(x), wl_fixed_to_int(y));<br>
+<br>
+               frame_interior(input->output->frame, &fx, &fy, NULL, NULL);<br>
+               x -= wl_fixed_from_int(fx);<br>
+               y -= wl_fixed_from_int(fy);<br>
+<br>
+               if (frame_status(input->output->frame) & FRAME_STATUS_REPAINT)<br>
+                       weston_output_schedule_repaint(&input->output->base);<br>
+       }<br>
+<br>
+       weston_output_transform_coordinate(&input->output->base, x, y, &x, &y);<br>
+<br>
+       notify_touch(&input->base, time, id, x, y, WL_TOUCH_MOTION);<br>
+}<br>
+<br>
+static void<br>
+input_handle_touch_frame(void *data, struct wl_touch *touch)<br>
+{<br>
+       struct wayland_input *input = data;<br>
+<br>
+       notify_touch_frame(&input->base);<br>
+}<br>
+<br>
+static void<br>
+input_handle_touch_cancel(void *data, struct wl_touch *touch)<br>
+{<br></blockquote><div><br></div><div>We should add a frame_touch_cancel function to frame.c and call it here.<br><br></div><div>Also, we should probably add support for WL_TOUCH_CANCEL in notify_touch in input.c and call it here.  If that's a little too involved for now, that's ok.  Just call notify_touch(&input->base, 0, -1, 0, 0, WL_TOUCH_CANCEL) here and we can implement it in notify_touch later.  It's just a big switch statement, so this won't hurt anything.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
+static const struct wl_touch_listener touch_listener = {<br>
+       input_handle_touch_down,<br>
+       input_handle_touch_up,<br>
+       input_handle_touch_motion,<br>
+       input_handle_touch_frame,<br>
+       input_handle_touch_cancel<br>
+};<br>
+<br>
+static void<br>
 input_handle_capabilities(void *data, struct wl_seat *seat,<br>
                          enum wl_seat_capability caps)<br>
 {<br>
@@ -1607,6 +1692,16 @@ input_handle_capabilities(void *data, struct wl_seat *seat,<br>
                wl_keyboard_destroy(input->parent.keyboard);<br>
                input->parent.keyboard = NULL;<br>
        }<br>
+<br>
+       if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->parent.touch) {<br>
+               input->parent.touch = wl_seat_get_touch(seat);<br>
+               wl_touch_set_user_data(input->parent.touch, input);<br>
+               wl_touch_add_listener(input->parent.touch,<br>
+                                        &touch_listener, input);<br>
+       } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->parent.touch) {<br>
+               wl_touch_destroy(input->parent.touch);<br>
+               input->parent.touch = NULL;<br>
+       }<br>
 }<br>
<br>
 static const struct wl_seat_listener seat_listener = {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.2<br>
<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div></div></blockquote><div><span style="line-height: 1.7;">Regards,</span></div><div><span style="line-height: 1.7;">Boyan Ding</span></div><div><span style="line-height: 1.7;"><br></span></div><div><span style="line-height: 1.7;">[1] </span><a href="https://github.com/vi/virtual_touchscreen" _src="https://github.com/vi/virtual_touchscreen">https://github.com/vi/virtual_touchscreen</a></div><div>[2] <a href="http://lists.freedesktop.org/archives/wayland-devel/2014-April/014385.html," _src="http://lists.freedesktop.org/archives/wayland-devel/2014-April/014385.html," style="font-family: arial; line-height: normal; white-space: pre-wrap;">http://lists.freedesktop.org/archives/wayland-devel/2014-April/014385.html</a></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>