static int init_wscreensaver(struct wscreensaver *wscr, struct display *display) { int size; const char prefix[] = "wscreensaver::"; char *str; display_set_user_data(display, wscr); wscr->display = display; wscr->plugin = plugins[0]; size = sizeof(prefix) + strlen(wscr->plugin->name); str = malloc(size); if (!str) { fprintf(stderr, "init: out of memory\n"); return -1; } snprintf(str, size, "%s%s", prefix, wscr->plugin->name); progname = str; wscr->egl.display = display_get_egl_display(wscr->display); if (!wscr->egl.display) { fprintf(stderr, "init: no EGL display\n"); return -1; } eglBindAPI(EGL_OPENGL_API); wscr->egl.config = display_get_argb_egl_config(wscr->display); if (demo_mode) { struct wl_output *o = output_get_wl_output(display_get_output(display)); /* only one instance */ wscr->demomode = create_wscreensaver_instance(wscr, o, 400, 300); return 0; } display_set_output_configure_handler(display, handle_output_configure); return 0; }
int main(int argc, char *argv[]) { struct virtual_keyboard virtual_keyboard; struct output *output; memset(&virtual_keyboard, 0, sizeof virtual_keyboard); virtual_keyboard.display = display_create(&argc, argv); if (virtual_keyboard.display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; } display_set_user_data(virtual_keyboard.display, &virtual_keyboard); display_set_global_handler(virtual_keyboard.display, global_handler); output = display_get_output(virtual_keyboard.display); keyboard_create(output, &virtual_keyboard); display_run(virtual_keyboard.display); return 0; }