Re: [PATCH 2/2] compositor-wayland: Add touch support

2014-05-09 Thread Boyan Ding
At 2014-05-08 09:55:23, Jason Ekstrand ja...@jlekstrand.net wrote:

Boyan,
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.


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.





On Tue, May 6, 2014 at 9:46 PM, Boyan Ding stu_...@126.com wrote:
Adding touch support to weston's nested wayland backend to make testing
easier.

https://bugs.freedesktop.org/show_bug.cgi?id=77769
---
 src/compositor-wayland.c | 95 
 1 file changed, 95 insertions(+)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index a08b71a..45040d4 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1582,6 +1582,91 @@ static const struct wl_keyboard_listener 
keyboard_listener = {
 };

 static void
+input_handle_touch_down(void *data, struct wl_touch *touch, uint32_t serial,
+   uint32_t time, struct wl_surface *surface, int32_t id,
+   wl_fixed_t x, wl_fixed_t y)
+{
+   struct wayland_input *input = data;
+   int32_t fx, fy;
+
+   if (input-output-frame) {
+   frame_touch_down(input-output-frame, input, id,
+wl_fixed_to_int(x), wl_fixed_to_int(y));
+   frame_interior(input-output-frame, fx, fy, NULL, NULL);
+   x -= wl_fixed_from_int(fx);
+   y -= wl_fixed_from_int(fy);



You probably want to handle FRAME_STATUS_MOVE here.  See also 
input_handle_button.



I saw the code handling FRAME_STATUS_MOVE in input_handle_button returned after 
handling that. Do we need to return here?
Also, I saw the pointer code notify the event only if the location is 
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 theme_location in [2] 
but that patch hasn't been applied.
 
+
+   if (frame_status(input-output-frame)  FRAME_STATUS_REPAINT)
+   weston_output_schedule_repaint(input-output-base);
+   }
+
+   weston_output_transform_coordinate(input-output-base, x, y, x, y);
+
+   notify_touch(input-base, time, id, x, y, WL_TOUCH_DOWN);
+}
+
+static void
+input_handle_touch_up(void *data, struct wl_touch *touch, uint32_t serial,
+ uint32_t time, int32_t id)
+{
+   struct wayland_input *input = data;
+
+   if (input-output-frame) {
+   frame_touch_up(input-output-frame, input, id);
+



You need to handle FRAME_STATUS_CLOSE here.  See also input_handle_button.

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.

 
+   if (frame_status(input-output-frame)  FRAME_STATUS_REPAINT)
+   weston_output_schedule_repaint(input-output-base);
+   }
+
+   notify_touch(input-base, time, id, 0, 0, WL_TOUCH_UP);
+}
+
+static void
+input_handle_touch_motion(void *data, struct wl_touch *touch, uint32_t time,
+ int32_t id, wl_fixed_t x, wl_fixed_t y)
+{
+   struct wayland_input *input = data;
+   int32_t fx, fy;
+
+   if (input-output-frame) {
+   frame_touch_motion(input-output-frame, input, id,
+wl_fixed_to_int(x), wl_fixed_to_int(y));
+
+   frame_interior(input-output-frame, fx, fy, NULL, NULL);
+   x -= wl_fixed_from_int(fx);
+   y -= wl_fixed_from_int(fy);
+
+   if (frame_status(input-output-frame)  FRAME_STATUS_REPAINT)
+   weston_output_schedule_repaint(input-output-base);
+   }
+
+   weston_output_transform_coordinate(input-output-base, x, y, x, y);
+
+   notify_touch(input-base, time, id, x, y, WL_TOUCH_MOTION);
+}
+
+static void
+input_handle_touch_frame(void *data, struct wl_touch *touch)
+{
+   struct wayland_input *input = data;
+
+   notify_touch_frame(input-base);
+}
+
+static void
+input_handle_touch_cancel(void *data, struct wl_touch *touch)
+{



We should add a frame_touch_cancel function to frame.c and call it here.


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.

 
+}
+
+static const struct wl_touch_listener touch_listener = {
+   input_handle_touch_down,
+   input_handle_touch_up,
+   input_handle_touch_motion,
+   input_handle_touch_frame,
+   input_handle_touch_cancel
+};
+

Re: [PATCH 2/2] compositor-wayland: Add touch support

2014-05-09 Thread Jason Ekstrand
On Fri, May 9, 2014 at 1:09 AM, Boyan Ding stu_...@126.com wrote:

 At 2014-05-08 09:55:23, Jason Ekstrand ja...@jlekstrand.net wrote:

 Boyan,
 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.


 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.


I'll be curious to see how well that works.  I don't have a touch screen
either and it would be nice to be able to test things anyway.



 On Tue, May 6, 2014 at 9:46 PM, Boyan Ding stu_...@126.com wrote:

 Adding touch support to weston's nested wayland backend to make testing
 easier.

 https://bugs.freedesktop.org/show_bug.cgi?id=77769
 ---
  src/compositor-wayland.c | 95
 
  1 file changed, 95 insertions(+)

 diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
 index a08b71a..45040d4 100644
 --- a/src/compositor-wayland.c
 +++ b/src/compositor-wayland.c
 @@ -1582,6 +1582,91 @@ static const struct wl_keyboard_listener
 keyboard_listener = {
  };

  static void
 +input_handle_touch_down(void *data, struct wl_touch *touch, uint32_t
 serial,
 +   uint32_t time, struct wl_surface *surface,
 int32_t id,
 +   wl_fixed_t x, wl_fixed_t y)
 +{
 +   struct wayland_input *input = data;
 +   int32_t fx, fy;
 +
 +   if (input-output-frame) {
 +   frame_touch_down(input-output-frame, input, id,
 +wl_fixed_to_int(x), wl_fixed_to_int(y));
 +   frame_interior(input-output-frame, fx, fy, NULL,
 NULL);
 +   x -= wl_fixed_from_int(fx);
 +   y -= wl_fixed_from_int(fy);


 You probably want to handle FRAME_STATUS_MOVE here.  See also
 input_handle_button.


 I saw the code handling FRAME_STATUS_MOVE in input_handle_button returned
 after handling that. Do we need to return here?
 Also, I saw the pointer code notify the event only if the location is 
 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 theme_location in [2] but that patch hasn't
 been applied.


Actually, the return probably shouldn't be there in the pointer code.  None
of the frame states preempt any of the others.  Regarding notfying, that's
a more delicate question.  We probably want to do one of two things: a)
only call weston_touc_notify if the first touch point went down inside the
client area, otherwise only pass touch points to the frame or b) track
which touch points went down inside the client area and only notify for
those.  I think a) would be the simplest to implement and would probably
provide the best user experience.




 +
 +   if (frame_status(input-output-frame) 
 FRAME_STATUS_REPAINT)
 +
 weston_output_schedule_repaint(input-output-base);
 +   }
 +
 +   weston_output_transform_coordinate(input-output-base, x, y,
 x, y);
 +
 +   notify_touch(input-base, time, id, x, y, WL_TOUCH_DOWN);
 +}
 +
 +static void
 +input_handle_touch_up(void *data, struct wl_touch *touch, uint32_t
 serial,
 + uint32_t time, int32_t id)
 +{
 +   struct wayland_input *input = data;
 +
 +   if (input-output-frame) {
 +   frame_touch_up(input-output-frame, input, id);
 +


 You need to handle FRAME_STATUS_CLOSE here.  See also input_handle_button.

 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.


 +   if (frame_status(input-output-frame) 
 FRAME_STATUS_REPAINT)
 +
 weston_output_schedule_repaint(input-output-base);
 +   }
 +
 +   notify_touch(input-base, time, id, 0, 0, WL_TOUCH_UP);
 +}
 +
 +static void
 +input_handle_touch_motion(void *data, struct wl_touch *touch, uint32_t
 time,
 + int32_t id, wl_fixed_t x, wl_fixed_t y)
 +{
 +   struct wayland_input *input = data;
 +   int32_t fx, fy;
 +
 +   if (input-output-frame) {
 +   frame_touch_motion(input-output-frame, input, id,
 +wl_fixed_to_int(x), wl_fixed_to_int(y));
 +
 +   frame_interior(input-output-frame, fx, fy, NULL,
 NULL);
 +   x -= wl_fixed_from_int(fx);
 +   y -= wl_fixed_from_int(fy);
 +
 +   if (frame_status(input-output-frame) 
 FRAME_STATUS_REPAINT)
 +
 weston_output_schedule_repaint(input-output-base);
 +   }
 +
 +   weston_output_transform_coordinate(input-output-base, x, y,
 x, y);
 +
 +   notify_touch(input-base, time, id, x, y, WL_TOUCH_MOTION);
 +}
 +
 +static void
 +input_handle_touch_frame(void *data, struct wl_touch *touch)
 +{
 +   struct wayland_input *input = 

Re: [PATCH 2/2] compositor-wayland: Add touch support

2014-05-07 Thread Jason Ekstrand
Boyan,
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.


On Tue, May 6, 2014 at 9:46 PM, Boyan Ding stu_...@126.com wrote:

 Adding touch support to weston's nested wayland backend to make testing
 easier.

 https://bugs.freedesktop.org/show_bug.cgi?id=77769
 ---
  src/compositor-wayland.c | 95
 
  1 file changed, 95 insertions(+)

 diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
 index a08b71a..45040d4 100644
 --- a/src/compositor-wayland.c
 +++ b/src/compositor-wayland.c
 @@ -1582,6 +1582,91 @@ static const struct wl_keyboard_listener
 keyboard_listener = {
  };

  static void
 +input_handle_touch_down(void *data, struct wl_touch *touch, uint32_t
 serial,
 +   uint32_t time, struct wl_surface *surface, int32_t
 id,
 +   wl_fixed_t x, wl_fixed_t y)
 +{
 +   struct wayland_input *input = data;
 +   int32_t fx, fy;
 +
 +   if (input-output-frame) {
 +   frame_touch_down(input-output-frame, input, id,
 +wl_fixed_to_int(x), wl_fixed_to_int(y));
 +   frame_interior(input-output-frame, fx, fy, NULL, NULL);
 +   x -= wl_fixed_from_int(fx);
 +   y -= wl_fixed_from_int(fy);


You probably want to handle FRAME_STATUS_MOVE here.  See also
input_handle_button.


 +
 +   if (frame_status(input-output-frame) 
 FRAME_STATUS_REPAINT)
 +
 weston_output_schedule_repaint(input-output-base);
 +   }
 +
 +   weston_output_transform_coordinate(input-output-base, x, y, x,
 y);
 +
 +   notify_touch(input-base, time, id, x, y, WL_TOUCH_DOWN);
 +}
 +
 +static void
 +input_handle_touch_up(void *data, struct wl_touch *touch, uint32_t serial,
 + uint32_t time, int32_t id)
 +{
 +   struct wayland_input *input = data;
 +
 +   if (input-output-frame) {
 +   frame_touch_up(input-output-frame, input, id);
 +


You need to handle FRAME_STATUS_CLOSE here.  See also input_handle_button.

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.


 +   if (frame_status(input-output-frame) 
 FRAME_STATUS_REPAINT)
 +
 weston_output_schedule_repaint(input-output-base);
 +   }
 +
 +   notify_touch(input-base, time, id, 0, 0, WL_TOUCH_UP);
 +}
 +
 +static void
 +input_handle_touch_motion(void *data, struct wl_touch *touch, uint32_t
 time,
 + int32_t id, wl_fixed_t x, wl_fixed_t y)
 +{
 +   struct wayland_input *input = data;
 +   int32_t fx, fy;
 +
 +   if (input-output-frame) {
 +   frame_touch_motion(input-output-frame, input, id,
 +wl_fixed_to_int(x), wl_fixed_to_int(y));
 +
 +   frame_interior(input-output-frame, fx, fy, NULL, NULL);
 +   x -= wl_fixed_from_int(fx);
 +   y -= wl_fixed_from_int(fy);
 +
 +   if (frame_status(input-output-frame) 
 FRAME_STATUS_REPAINT)
 +
 weston_output_schedule_repaint(input-output-base);
 +   }
 +
 +   weston_output_transform_coordinate(input-output-base, x, y, x,
 y);
 +
 +   notify_touch(input-base, time, id, x, y, WL_TOUCH_MOTION);
 +}
 +
 +static void
 +input_handle_touch_frame(void *data, struct wl_touch *touch)
 +{
 +   struct wayland_input *input = data;
 +
 +   notify_touch_frame(input-base);
 +}
 +
 +static void
 +input_handle_touch_cancel(void *data, struct wl_touch *touch)
 +{


We should add a frame_touch_cancel function to frame.c and call it here.

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.


 +}
 +
 +static const struct wl_touch_listener touch_listener = {
 +   input_handle_touch_down,
 +   input_handle_touch_up,
 +   input_handle_touch_motion,
 +   input_handle_touch_frame,
 +   input_handle_touch_cancel
 +};
 +
 +static void
  input_handle_capabilities(void *data, struct wl_seat *seat,
   enum wl_seat_capability caps)
  {
 @@ -1607,6 +1692,16 @@ input_handle_capabilities(void *data, struct
 wl_seat *seat,
 wl_keyboard_destroy(input-parent.keyboard);
 input-parent.keyboard = NULL;
 }
 +
 +   if ((caps  WL_SEAT_CAPABILITY_TOUCH)  !input-parent.touch) {
 +   input-parent.touch = wl_seat_get_touch(seat);
 +   wl_touch_set_user_data(input-parent.touch, input);
 +   

[PATCH 2/2] compositor-wayland: Add touch support

2014-05-06 Thread Boyan Ding
Adding touch support to weston's nested wayland backend to make testing
easier.

https://bugs.freedesktop.org/show_bug.cgi?id=77769
---
 src/compositor-wayland.c | 95 
 1 file changed, 95 insertions(+)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index a08b71a..45040d4 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1582,6 +1582,91 @@ static const struct wl_keyboard_listener 
keyboard_listener = {
 };
 
 static void
+input_handle_touch_down(void *data, struct wl_touch *touch, uint32_t serial,
+   uint32_t time, struct wl_surface *surface, int32_t id,
+   wl_fixed_t x, wl_fixed_t y)
+{
+   struct wayland_input *input = data;
+   int32_t fx, fy;
+
+   if (input-output-frame) {
+   frame_touch_down(input-output-frame, input, id,
+wl_fixed_to_int(x), wl_fixed_to_int(y));
+   frame_interior(input-output-frame, fx, fy, NULL, NULL);
+   x -= wl_fixed_from_int(fx);
+   y -= wl_fixed_from_int(fy);
+
+   if (frame_status(input-output-frame)  FRAME_STATUS_REPAINT)
+   weston_output_schedule_repaint(input-output-base);
+   }
+
+   weston_output_transform_coordinate(input-output-base, x, y, x, y);
+
+   notify_touch(input-base, time, id, x, y, WL_TOUCH_DOWN);
+}
+
+static void
+input_handle_touch_up(void *data, struct wl_touch *touch, uint32_t serial,
+ uint32_t time, int32_t id)
+{
+   struct wayland_input *input = data;
+
+   if (input-output-frame) {
+   frame_touch_up(input-output-frame, input, id);
+
+   if (frame_status(input-output-frame)  FRAME_STATUS_REPAINT)
+   weston_output_schedule_repaint(input-output-base);
+   }
+
+   notify_touch(input-base, time, id, 0, 0, WL_TOUCH_UP);
+}
+
+static void
+input_handle_touch_motion(void *data, struct wl_touch *touch, uint32_t time,
+ int32_t id, wl_fixed_t x, wl_fixed_t y)
+{
+   struct wayland_input *input = data;
+   int32_t fx, fy;
+
+   if (input-output-frame) {
+   frame_touch_motion(input-output-frame, input, id,
+wl_fixed_to_int(x), wl_fixed_to_int(y));
+
+   frame_interior(input-output-frame, fx, fy, NULL, NULL);
+   x -= wl_fixed_from_int(fx);
+   y -= wl_fixed_from_int(fy);
+
+   if (frame_status(input-output-frame)  FRAME_STATUS_REPAINT)
+   weston_output_schedule_repaint(input-output-base);
+   }
+
+   weston_output_transform_coordinate(input-output-base, x, y, x, y);
+
+   notify_touch(input-base, time, id, x, y, WL_TOUCH_MOTION);
+}
+
+static void
+input_handle_touch_frame(void *data, struct wl_touch *touch)
+{
+   struct wayland_input *input = data;
+
+   notify_touch_frame(input-base);
+}
+
+static void
+input_handle_touch_cancel(void *data, struct wl_touch *touch)
+{
+}
+
+static const struct wl_touch_listener touch_listener = {
+   input_handle_touch_down,
+   input_handle_touch_up,
+   input_handle_touch_motion,
+   input_handle_touch_frame,
+   input_handle_touch_cancel
+};
+
+static void
 input_handle_capabilities(void *data, struct wl_seat *seat,
  enum wl_seat_capability caps)
 {
@@ -1607,6 +1692,16 @@ input_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_keyboard_destroy(input-parent.keyboard);
input-parent.keyboard = NULL;
}
+
+   if ((caps  WL_SEAT_CAPABILITY_TOUCH)  !input-parent.touch) {
+   input-parent.touch = wl_seat_get_touch(seat);
+   wl_touch_set_user_data(input-parent.touch, input);
+   wl_touch_add_listener(input-parent.touch,
+touch_listener, input);
+   } else if (!(caps  WL_SEAT_CAPABILITY_TOUCH)  input-parent.touch) {
+   wl_touch_destroy(input-parent.touch);
+   input-parent.touch = NULL;
+   }
 }
 
 static const struct wl_seat_listener seat_listener = {
-- 
1.9.2


___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel