X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=clients%2Fsimple-touch.c;h=d8439acaf5124fc946ed7ca9253b6795daeb54ca;hb=22e16b656f67ee577e32a7af91f443840fc3aee1;hp=69e460c730a85b2510fd3942ec7740d74cc27058;hpb=c7d2c4c14727780a1d38644ebde3e22f65c64649;p=platform%2Fupstream%2Fweston.git diff --git a/clients/simple-touch.c b/clients/simple-touch.c index 69e460c..d8439ac 100644 --- a/clients/simple-touch.c +++ b/clients/simple-touch.c @@ -36,14 +36,18 @@ #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) +struct seat { + struct touch *touch; + struct wl_seat *seat; + struct wl_touch *wl_touch; +}; + struct touch { struct wl_display *display; struct wl_registry *registry; struct wl_compositor *compositor; struct wl_shell *shell; struct wl_shm *shm; - struct wl_seat *seat; - struct wl_touch *wl_touch; struct wl_pointer *pointer; struct wl_keyboard *keyboard; struct wl_surface *surface; @@ -199,18 +203,19 @@ static const struct wl_touch_listener touch_listener = { }; static void -seat_handle_capabilities(void *data, struct wl_seat *seat, +seat_handle_capabilities(void *data, struct wl_seat *wl_seat, enum wl_seat_capability caps) { - struct touch *touch = data; - - if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !touch->wl_touch) { - touch->wl_touch = wl_seat_get_touch(seat); - wl_touch_set_user_data(touch->wl_touch, touch); - wl_touch_add_listener(touch->wl_touch, &touch_listener, touch); - } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && touch->wl_touch) { - wl_touch_destroy(touch->wl_touch); - touch->wl_touch = NULL; + struct seat *seat = data; + struct touch *touch = seat->touch; + + if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->wl_touch) { + seat->wl_touch = wl_seat_get_touch(wl_seat); + wl_touch_set_user_data(seat->wl_touch, touch); + wl_touch_add_listener(seat->wl_touch, &touch_listener, touch); + } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch) { + wl_touch_destroy(seat->wl_touch); + seat->wl_touch = NULL; } } @@ -219,6 +224,21 @@ static const struct wl_seat_listener seat_listener = { }; static void +add_seat(struct touch *touch, uint32_t name, uint32_t version) +{ + struct seat *seat; + + seat = malloc(sizeof *seat); + assert(seat); + + seat->touch = touch; + seat->wl_touch = NULL; + seat->seat = wl_registry_bind(touch->registry, name, + &wl_seat_interface, 1); + wl_seat_add_listener(seat->seat, &seat_listener, seat); +} + +static void handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial) { @@ -261,9 +281,7 @@ handle_global(void *data, struct wl_registry *registry, &wl_shm_interface, 1); wl_shm_add_listener(touch->shm, &shm_listener, touch); } else if (strcmp(interface, "wl_seat") == 0) { - touch->seat = wl_registry_bind(registry, name, - &wl_seat_interface, 1); - wl_seat_add_listener(touch->seat, &seat_listener, touch); + add_seat(touch, name, version); } } @@ -301,8 +319,6 @@ touch_create(int width, int height) exit(1); } - wl_display_get_fd(touch->display); - touch->width = width; touch->height = height; touch->surface = wl_compositor_create_surface(touch->compositor);