clients: Add an optional roundtrip for visual lookup
This commit is contained in:
+21
-1
@@ -188,12 +188,31 @@ init_gl(struct window *window)
|
|||||||
glGetUniformLocation(window->gl.program, "rotation");
|
glGetUniformLocation(window->gl.program, "rotation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sync_callback(void *data)
|
||||||
|
{
|
||||||
|
int *done = data;
|
||||||
|
|
||||||
|
*done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_surface(struct window *window)
|
create_surface(struct window *window)
|
||||||
{
|
{
|
||||||
struct display *display = window->display;
|
struct display *display = window->display;
|
||||||
struct wl_visual *visual;
|
struct wl_visual *visual;
|
||||||
EGLBoolean ret;
|
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);
|
window->surface = wl_compositor_create_surface(display->compositor);
|
||||||
visual = display->premultiplied_argb_visual;
|
visual = display->premultiplied_argb_visual;
|
||||||
@@ -333,6 +352,8 @@ main(int argc, char **argv)
|
|||||||
wl_display_add_global_listener(display.display,
|
wl_display_add_global_listener(display.display,
|
||||||
display_handle_global, &display);
|
display_handle_global, &display);
|
||||||
|
|
||||||
|
wl_display_get_fd(display.display, event_mask_update, &display);
|
||||||
|
|
||||||
init_egl(&display);
|
init_egl(&display);
|
||||||
create_surface(&window);
|
create_surface(&window);
|
||||||
init_gl(&window);
|
init_gl(&window);
|
||||||
@@ -340,7 +361,6 @@ main(int argc, char **argv)
|
|||||||
wl_display_frame_callback(display.display, window.surface,
|
wl_display_frame_callback(display.display, window.surface,
|
||||||
redraw, &window);
|
redraw, &window);
|
||||||
|
|
||||||
wl_display_get_fd(display.display, event_mask_update, &display);
|
|
||||||
while (true)
|
while (true)
|
||||||
wl_display_iterate(display.display, display.mask);
|
wl_display_iterate(display.display, display.mask);
|
||||||
|
|
||||||
|
|||||||
+27
-1
@@ -1849,6 +1849,25 @@ init_egl(struct display *d)
|
|||||||
return 0;
|
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 *
|
struct display *
|
||||||
display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
|
display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
|
||||||
display_global_handler_t handler)
|
display_global_handler_t handler)
|
||||||
@@ -1900,7 +1919,6 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
|
|||||||
|
|
||||||
/* Process connection events. */
|
/* Process connection events. */
|
||||||
wl_display_iterate(d->display, WL_DISPLAY_READABLE);
|
wl_display_iterate(d->display, WL_DISPLAY_READABLE);
|
||||||
|
|
||||||
if (init_egl(d) < 0)
|
if (init_egl(d) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1909,6 +1927,14 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
|
|||||||
d->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
|
d->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
|
||||||
d->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
|
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);
|
create_pointer_surfaces(d);
|
||||||
|
|
||||||
display_render_frame(d);
|
display_render_frame(d);
|
||||||
|
|||||||
Reference in New Issue
Block a user