diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-03 17:38:42 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-03 17:42:52 +0100 |
commit | aedde6a37e915d9e712ca8e85f8870870ab3fb63 (patch) | |
tree | 1316ffe7d6fcc7fe5bff4e33bdb127d82d1d8a92 | |
parent | b17de9816b0d3cee463706cd0560959bb982756c (diff) |
egl-wayland-window-legacy: Update to wayland changes
-rw-r--r-- | egl-wayland-window-legacy.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/egl-wayland-window-legacy.c b/egl-wayland-window-legacy.c index 2385854..8bb7eff 100644 --- a/egl-wayland-window-legacy.c +++ b/egl-wayland-window-legacy.c @@ -13,7 +13,6 @@ struct display { struct wl_display *display; - struct wl_egl_display *egl_display; struct { struct wl_compositor *compositor; struct wl_shell *shell; @@ -55,7 +54,7 @@ init_egl(struct display *display) EGL_NONE }; - display->egl.dpy = eglGetDisplay(display->egl_display); + display->egl.dpy = eglGetDisplay(display->display); assert(display->egl.dpy); assert(eglInitialize(display->egl.dpy, &major, &minor)); @@ -73,14 +72,9 @@ init_egl(struct display *display) static void create_egl_window(struct display *display, struct window *window) { - struct wl_visual *visual; - - visual = wl_display_get_premultiplied_argb_visual(display->display); - window->egl_window = wl_egl_window_create(display->egl_display, - window->surface, + window->egl_window = wl_egl_window_create(window->surface, window->width, - window->height, - visual); + window->height); window->egl.surf = eglCreateWindowSurface(display->egl.dpy, display->egl.conf, @@ -129,6 +123,8 @@ redraw(void *data, uint32_t time) if (start_time == 0) start_time = time; + if (last_time == 0) + last_time = time; ++frames; if ((time - last_time) >= 5000) { @@ -214,10 +210,12 @@ display_handle_global(struct wl_display *display, uint32_t id, { struct display *d = data; - if (strcmp(interface, "compositor") == 0) { - d->interface.compositor = wl_compositor_create(display, id); - } else if (strcmp(interface, "shell") == 0) { - d->interface.shell = wl_shell_create(display, id); + if (strcmp(interface, "wl_compositor") == 0) { + d->interface.compositor = wl_display_bind(display, id, + &wl_compositor_interface); + } else if (strcmp(interface, "wl_shell") == 0) { + d->interface.shell = wl_display_bind(display, id, + &wl_shell_interface); wl_shell_add_listener(d->interface.shell, &wayland_shell_listener, d); } } @@ -237,6 +235,7 @@ main(int argc, char **argv) { struct display display = { 0 }; struct window window = { 0 }; + int fd; window.display = &display; window.width = 250; @@ -245,9 +244,6 @@ main(int argc, char **argv) display.display = wl_display_connect(NULL); assert(display.display); - display.egl_display = wl_egl_display_create(display.display); - assert(display.egl_display); - wl_display_add_global_listener(display.display, display_handle_global, &display); /* process connection events */ @@ -261,18 +257,28 @@ main(int argc, char **argv) init_gl(&window); - wl_surface_map_toplevel(window.surface); + wl_shell_set_toplevel(display.interface.shell, window.surface); - wl_display_get_fd(display.display, event_mask_update, &display); - + fd = wl_display_get_fd(display.display, event_mask_update, &display); while (true) { struct timeval tv; uint32_t msec; + uint32_t mask; + fd_set rfds; gettimeofday(&tv, NULL); redraw(&window, tv.tv_sec * 1000 + tv.tv_usec / 1000); - wl_display_iterate(display.display, display.mask); + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + + tv.tv_sec = 0; + tv.tv_usec = 0; + mask = display.mask; + if (select(fd + 1, &rfds, NULL, NULL, &tv) != 1) + mask &= ~WL_DISPLAY_READABLE; + if (mask) + wl_display_iterate(display.display, mask); } return 0; |