--- src/egl/eglut/eglut_wayland.c 2013-09-06 16:34:07.000000000 +0200 +++ src/egl/eglut/eglut_wayland.c 2013-09-09 11:28:17.000000000 +0200 @@ -6,7 +6,9 @@ struct display { struct wl_display *display; struct wl_compositor *compositor; + struct wl_registry *registry; struct wl_shell *shell; + struct wl_shm *shm; uint32_t mask; }; @@ -20,16 +22,18 @@ static struct window window = {0, }; static void -display_handle_global(struct wl_display *display, uint32_t id, - const char *interface, uint32_t version, void *data) +display_handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) { struct display *d = data; if (strcmp(interface, "wl_compositor") == 0) { d->compositor = - wl_display_bind(display, id, &wl_compositor_interface); + wl_registry_bind(registry, id, &wl_compositor_interface, 1); } else if (strcmp(interface, "wl_shell") == 0) { - d->shell = wl_display_bind(display, id, &wl_shell_interface); + d->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); + } else if (strcmp(interface, "wl_shm") == 0) { + d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); } } @@ -43,6 +47,32 @@ return 0; } + + +static void +display_handle_global_remove (void *data, struct wl_registry *registry, uint32_t name) +{ +} + +static const struct wl_registry_listener registry_listener = { + display_handle_global, + display_handle_global_remove +}; + + + +static void +handle_ping (void *data, struct wl_shell_surface *shell_surface, uint32_t serial) +{ + wl_shell_surface_pong (shell_surface, serial); +} + +static const struct wl_shell_surface_listener shell_surface_listener = { + handle_ping +}; + + + void _eglutNativeInitDisplay(void) { @@ -51,11 +81,10 @@ if (!_eglut->native_dpy) _eglutFatal("failed to initialize native display"); - wl_display_add_global_listener(_eglut->native_dpy, - display_handle_global, &display); + display.registry = wl_display_get_registry (_eglut->native_dpy); + wl_registry_add_listener (display.registry, ®istry_listener, &display); - wl_display_get_fd(_eglut->native_dpy, event_mask_update, &display); - wl_display_iterate(_eglut->native_dpy, WL_DISPLAY_READABLE); + wl_display_dispatch (_eglut->native_dpy); _eglut->surface_type = EGL_WINDOW_BIT; } @@ -76,6 +105,8 @@ window.surface = wl_compositor_create_surface(display.compositor); window.shell_surface = wl_shell_get_shell_surface(display.shell, window.surface); + wl_shell_surface_add_listener (window.shell_surface, &shell_surface_listener, &window); + native = wl_egl_window_create(window.surface, w, h); wl_shell_surface_set_toplevel(window.shell_surface); @@ -91,7 +122,7 @@ wl_egl_window_destroy(win->native.u.window); wl_shell_surface_destroy(window.shell_surface); - wl_surface_destroy(window.surface); + wl_surface_destroy(window.surface); if (window.callback) wl_callback_destroy(window.callback); @@ -103,7 +134,7 @@ static const struct wl_callback_listener frame_listener = { draw }; - + static void draw(void *data, struct wl_callback *callback, uint32_t time) { @@ -121,13 +152,14 @@ wl_callback_add_listener(window->callback, &frame_listener, window); } + void _eglutNativeEventLoop(void) { draw(&window, NULL, 0); while (1) { - wl_display_iterate(display.display, display.mask); + wl_display_dispatch (display.display); if (_eglut->idle_cb) _eglut->idle_cb();