<div dir="ltr"><div>Looks mostly the same as Ander's patch here:<br><br><a href="http://lists.freedesktop.org/archives/wayland-devel/2014-May/014658.html">http://lists.freedesktop.org/archives/wayland-devel/2014-May/014658.html</a><br>
<br></div>Same review applies :)<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 7, 2014 at 10:00 AM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Previously simple-touch would only handle one seat. If there were<br>
multiple seats it would lose track of whether there is a touch device<br>
available depending on what order the capability events arrive in.<br>
This makes it keep a linked list of seats and to track a separate<br>
touch device for each seat so that it doesn't matter what order they<br>
arrive in.<br>
<br>
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=78365" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=78365</a><br>
---<br>
clients/simple-touch.c | 77 +++++++++++++++++++++++++++++++++++++++-----------<br>
1 file changed, 60 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/clients/simple-touch.c b/clients/simple-touch.c<br>
index b5a84d7..a45de46 100644<br>
--- a/clients/simple-touch.c<br>
+++ b/clients/simple-touch.c<br>
@@ -42,18 +42,25 @@ struct touch {<br>
struct wl_compositor *compositor;<br>
struct wl_shell *shell;<br>
struct wl_shm *shm;<br>
- struct wl_seat *seat;<br>
- struct wl_touch *wl_touch;<br>
struct wl_pointer *pointer;<br>
struct wl_keyboard *keyboard;<br>
struct wl_surface *surface;<br>
struct wl_shell_surface *shell_surface;<br>
struct wl_buffer *buffer;<br>
+ struct wl_list seats;<br>
int has_argb;<br>
int width, height;<br>
void *data;<br>
};<br>
<br>
+struct touch_seat {<br>
+ struct touch *touch;<br>
+ struct wl_touch *wl_touch;<br>
+ struct wl_seat *wl_seat;<br>
+ struct wl_list link;<br>
+ uint32_t name;<br>
+};<br>
+<br>
static void<br>
create_shm_buffer(struct touch *touch)<br>
{<br>
@@ -156,7 +163,8 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,<br>
uint32_t serial, uint32_t time, struct wl_surface *surface,<br>
int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)<br>
{<br>
- struct touch *touch = data;<br>
+ struct touch_seat *seat = data;<br>
+ struct touch *touch = seat->touch;<br>
float x = wl_fixed_to_double(x_w);<br>
float y = wl_fixed_to_double(y_w);<br>
<br>
@@ -173,7 +181,8 @@ static void<br>
touch_handle_motion(void *data, struct wl_touch *wl_touch,<br>
uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)<br>
{<br>
- struct touch *touch = data;<br>
+ struct touch_seat *seat = data;<br>
+ struct touch *touch = seat->touch;<br>
float x = wl_fixed_to_double(x_w);<br>
float y = wl_fixed_to_double(y_w);<br>
<br>
@@ -199,18 +208,18 @@ static const struct wl_touch_listener touch_listener = {<br>
};<br>
<br>
static void<br>
-seat_handle_capabilities(void *data, struct wl_seat *seat,<br>
+seat_handle_capabilities(void *data, struct wl_seat *wl_seat,<br>
enum wl_seat_capability caps)<br>
{<br>
- struct touch *touch = data;<br>
-<br>
- if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !touch->wl_touch) {<br>
- touch->wl_touch = wl_seat_get_touch(seat);<br>
- wl_touch_set_user_data(touch->wl_touch, touch);<br>
- wl_touch_add_listener(touch->wl_touch, &touch_listener, touch);<br>
- } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && touch->wl_touch) {<br>
- wl_touch_destroy(touch->wl_touch);<br>
- touch->wl_touch = NULL;<br>
+ struct touch_seat *seat = data;<br>
+<br>
+ if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->wl_touch) {<br>
+ seat->wl_touch = wl_seat_get_touch(wl_seat);<br>
+ wl_touch_set_user_data(seat->wl_touch, seat);<br>
+ wl_touch_add_listener(seat->wl_touch, &touch_listener, seat);<br>
+ } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch) {<br>
+ wl_touch_destroy(seat->wl_touch);<br>
+ seat->wl_touch = NULL;<br>
}<br>
}<br>
<br>
@@ -243,6 +252,31 @@ static const struct wl_shell_surface_listener shell_surface_listener = {<br>
};<br>
<br>
static void<br>
+add_seat(struct touch *touch, uint32_t name)<br>
+{<br>
+ struct touch_seat *seat;<br>
+<br>
+ seat = malloc(sizeof *seat);<br>
+ seat->touch = touch;<br>
+ seat->wl_seat = wl_registry_bind(touch->registry, name,<br>
+ &wl_seat_interface, 1);<br>
+ seat->name = name;<br>
+ seat->wl_touch = NULL;<br>
+ wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);<br>
+ wl_list_insert(&touch->seats, &seat->link);<br>
+}<br>
+<br>
+static void<br>
+remove_seat(struct touch_seat *seat)<br>
+{<br>
+ if (seat->wl_touch)<br>
+ wl_touch_destroy(seat->wl_touch);<br>
+ wl_seat_destroy(seat->wl_seat);<br>
+ wl_list_remove(&seat->link);<br>
+ free(seat);<br>
+}<br>
+<br>
+static void<br>
handle_global(void *data, struct wl_registry *registry,<br>
uint32_t name, const char *interface, uint32_t version)<br>
{<br>
@@ -261,15 +295,22 @@ handle_global(void *data, struct wl_registry *registry,<br>
&wl_shm_interface, 1);<br>
wl_shm_add_listener(touch->shm, &shm_listener, touch);<br>
} else if (strcmp(interface, "wl_seat") == 0) {<br>
- touch->seat = wl_registry_bind(registry, name,<br>
- &wl_seat_interface, 1);<br>
- wl_seat_add_listener(touch->seat, &seat_listener, touch);<br>
+ add_seat(touch, name);<br>
}<br>
}<br>
<br>
static void<br>
handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)<br>
{<br>
+ struct touch *touch = data;<br>
+ struct touch_seat *seat;<br>
+<br>
+ wl_list_for_each(seat, &touch->seats, link) {<br>
+ if (seat->name == name) {<br>
+ remove_seat(seat);<br>
+ break;<br>
+ }<br>
+ }<br>
}<br>
<br>
static const struct wl_registry_listener registry_listener = {<br>
@@ -290,6 +331,8 @@ touch_create(int width, int height)<br>
touch->display = wl_display_connect(NULL);<br>
assert(touch->display);<br>
<br>
+ wl_list_init(&touch->seats);<br>
+<br>
touch->has_argb = 0;<br>
touch->registry = wl_display_get_registry(touch->display);<br>
wl_registry_add_listener(touch->registry, ®istry_listener, touch);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.0<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><br clear="all"><br>-- <br> Jasper<br>
</div>