diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-05-31 11:36:31 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-05-31 15:05:32 +0200 |
commit | 65e5051bc768a7ee834815bc851bd1f4d77b86b1 (patch) | |
tree | 3cf097e1f123228afbbbf3e1a7667bbafa4d1e58 | |
parent | ff073a6a6bc3bfb4acf05cfe8c07a02572325158 (diff) |
clients: Add an optional roundtrip for visual lookup
-rw-r--r-- | clients/simple-client.c | 22 | ||||
-rw-r--r-- | clients/window.c | 28 |
2 files changed, 48 insertions, 2 deletions
diff --git a/clients/simple-client.c b/clients/simple-client.c index f2252ea..0a97be0 100644 --- a/clients/simple-client.c +++ b/clients/simple-client.c @@ -189,11 +189,30 @@ init_gl(struct window *window) } static void +sync_callback(void *data) +{ + int *done = data; + + *done = 1; +} + +static void create_surface(struct window *window) { struct display *display = window->display; struct wl_visual *visual; EGLBoolean ret; + int done = 0; + + if (!display->premultiplied_argb_visual) { + wl_display_sync_callback(display->display, sync_callback, &done); + while (!done) + wl_display_iterate(display->display, display->mask); + if (!display->premultiplied_argb_visual) { + fprintf(stderr, "premultiplied argb visual missing\n"); + exit(1); + } + } window->surface = wl_compositor_create_surface(display->compositor); visual = display->premultiplied_argb_visual; @@ -333,6 +352,8 @@ main(int argc, char **argv) wl_display_add_global_listener(display.display, display_handle_global, &display); + wl_display_get_fd(display.display, event_mask_update, &display); + init_egl(&display); create_surface(&window); init_gl(&window); @@ -340,7 +361,6 @@ main(int argc, char **argv) wl_display_frame_callback(display.display, window.surface, redraw, &window); - wl_display_get_fd(display.display, event_mask_update, &display); while (true) wl_display_iterate(display.display, display.mask); diff --git a/clients/window.c b/clients/window.c index 758a536..944981c 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1849,6 +1849,25 @@ init_egl(struct display *d) return 0; } +static void +sync_callback(void *data) +{ + int *done = data; + + *done = 1; +} + +static void +force_roundtrip(struct display *d) +{ + int done = 0; + + wl_display_sync_callback(d->display, sync_callback, &done); + wl_display_iterate(d->display, WL_DISPLAY_WRITABLE); + while (!done) + wl_display_iterate(d->display, WL_DISPLAY_READABLE); +} + struct display * display_create(int *argc, char **argv[], const GOptionEntry *option_entries, display_global_handler_t handler) @@ -1900,7 +1919,6 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries, /* Process connection events. */ wl_display_iterate(d->display, WL_DISPLAY_READABLE); - if (init_egl(d) < 0) return NULL; @@ -1909,6 +1927,14 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries, d->create_image = (void *) eglGetProcAddress("eglCreateImageKHR"); d->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR"); + if (!d->premultiplied_argb_visual || !d->rgb_visual) { + force_roundtrip(d); + if (!d->premultiplied_argb_visual || !d->rgb_visual) { + fprintf(stderr, "failed to retreive visuals\n"); + return NULL; + } + } + create_pointer_surfaces(d); display_render_frame(d); |