struct display {
struct wl_display *display;
+ struct wl_registry *registry;
struct wl_compositor *compositor;
struct input *input;
struct output *output;
};
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;
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;
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;
}
}
+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)
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");
struct display {
struct wl_display *display;
+ struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_surface *surface;
}
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;
}
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;
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)
{
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");