diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-10-11 10:07:31 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-10-11 10:07:31 -0400 |
commit | d1ecb284ba086ff108de08e649f86d501b7e2d6b (patch) | |
tree | f390762ed7b4e80b2abb0a6d91e3e57e705c36b2 /tests | |
parent | 5fd5580c88ca21ab8642961ecf04a493f06a17bc (diff) |
tests: Update tests to new APIsnext
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-client.c | 30 | ||||
-rw-r--r-- | tests/test-text-client.c | 45 |
2 files changed, 45 insertions, 30 deletions
diff --git a/tests/test-client.c b/tests/test-client.c index fb9d5c0a..f7c9f234 100644 --- a/tests/test-client.c +++ b/tests/test-client.c @@ -31,6 +31,7 @@ struct display { struct wl_display *display; + struct wl_registry *registry; struct wl_compositor *compositor; struct input *input; struct output *output; @@ -262,8 +263,8 @@ static const struct wl_output_listener output_listener = { }; static void -handle_global(struct wl_display *_display, uint32_t id, - const char *interface, uint32_t version, void *data) +handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) { struct display *display = data; struct input *input; @@ -271,12 +272,12 @@ handle_global(struct wl_display *_display, uint32_t id, if (strcmp(interface, "wl_compositor") == 0) { display->compositor = - wl_display_bind(display->display, - id, &wl_compositor_interface); + wl_registry_bind(display->registry, + id, &wl_compositor_interface, 1); } else if (strcmp(interface, "wl_seat") == 0) { input = calloc(1, sizeof *input); - input->seat = wl_display_bind(display->display, id, - &wl_seat_interface); + input->seat = wl_registry_bind(display->registry, id, + &wl_seat_interface, 1); input->pointer_focus = NULL; input->keyboard_focus = NULL; @@ -284,8 +285,8 @@ handle_global(struct wl_display *_display, uint32_t id, display->input = input; } else if (strcmp(interface, "wl_output") == 0) { output = malloc(sizeof *output); - output->output = wl_display_bind(display->display, - id, &wl_output_interface); + output->output = wl_registry_bind(display->registry, + id, &wl_output_interface, 1); wl_output_add_listener(output->output, &output_listener, output); display->output = output; @@ -295,6 +296,10 @@ handle_global(struct wl_display *_display, uint32_t id, } } +static const struct wl_registry_listener registry_listener = { + handle_global +}; + static void surface_enter(void *data, struct wl_surface *wl_surface, struct wl_output *output) @@ -422,10 +427,11 @@ int main(int argc, char *argv[]) display->display = wl_display_connect(NULL); assert(display->display); - wl_display_add_global_listener(display->display, - handle_global, display); - wl_display_iterate(display->display, WL_DISPLAY_READABLE); - wl_display_roundtrip(display->display); + display->registry = wl_display_get_registry(display->display); + wl_registry_add_listener(display->registry, + ®istry_listener, display); + wl_display_dispatch(display->display); + wl_display_dispatch(display->display); fd = 0; p = getenv("TEST_SOCKET"); diff --git a/tests/test-text-client.c b/tests/test-text-client.c index 897909af..73423811 100644 --- a/tests/test-text-client.c +++ b/tests/test-text-client.c @@ -31,6 +31,7 @@ struct display { struct wl_display *display; + struct wl_registry *registry; struct wl_compositor *compositor; struct wl_surface *surface; @@ -100,8 +101,10 @@ text_model_locale(void *data, } static void -text_model_activated(void *data, - struct text_model *text_model) +text_model_enter(void *data, + struct text_model *text_model, + struct wl_surface *surface) + { struct display *display = data; @@ -111,8 +114,8 @@ text_model_activated(void *data, } static void -text_model_deactivated(void *data, - struct text_model *text_model) +text_model_leave(void *data, + struct text_model *text_model) { struct display *display = data; @@ -128,29 +131,34 @@ static const struct text_model_listener text_model_listener = { text_model_selection_replacement, text_model_direction, text_model_locale, - text_model_activated, - text_model_deactivated + text_model_enter, + text_model_leave }; static void -handle_global(struct wl_display *_display, uint32_t id, - const char *interface, uint32_t version, void *data) +handle_global(void *data, + struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) { struct display *display = data; if (strcmp(interface, "wl_compositor") == 0) { display->compositor = - wl_display_bind(display->display, - id, &wl_compositor_interface); + wl_registry_bind(display->registry, + id, &wl_compositor_interface, 1); } else if (strcmp(interface, "wl_seat") == 0) { - display->seat = wl_display_bind(display->display, id, - &wl_seat_interface); + display->seat = wl_registry_bind(display->registry, id, + &wl_seat_interface, 1); } else if (strcmp(interface, "text_model_factory") == 0) { - display->factory = wl_display_bind(display->display, id, - &text_model_factory_interface); + display->factory = wl_registry_bind(display->registry, id, + &text_model_factory_interface, 1); } } +static const struct wl_registry_listener registry_listener = { + handle_global +}; + static void create_surface(int fd, struct display *display) { @@ -230,10 +238,11 @@ int main(int argc, char *argv[]) display->activated = 0; display->deactivated = 0; - wl_display_add_global_listener(display->display, - handle_global, display); - wl_display_iterate(display->display, WL_DISPLAY_READABLE); - wl_display_roundtrip(display->display); + display->registry = wl_display_get_registry(display->display); + wl_registry_add_listener(display->registry, + ®istry_listener, display); + wl_display_dispatch(display->display); + wl_display_dispatch(display->display); fd = 0; p = getenv("TEST_SOCKET"); |