diff --git a/src/main.c b/src/main.c index 892607c0..292f8e0a 100644 --- a/src/main.c +++ b/src/main.c @@ -631,6 +631,64 @@ handle_exit(struct weston_compositor *c) wl_display_terminate(c->wl_display); } +/* Temporary function to be removed when all backends are converted. */ +static int +load_backend_old(struct weston_compositor *compositor, const char *backend, + int *argc, char **argv, struct weston_config *wc) +{ + int (*backend_init)(struct weston_compositor *c, + int *argc, char *argv[], + struct weston_config *config, + struct weston_backend_config *config_base); + + backend_init = weston_load_module(backend, "backend_init"); + if (!backend_init) + return -1; + + return backend_init(compositor, argc, argv, wc, NULL); +} + +/* Temporary function to be replaced by weston_compositor_load_backend(). */ +static int +load_backend_new(struct weston_compositor *compositor, const char *backend, + struct weston_backend_config *config_base) +{ + int (*backend_init)(struct weston_compositor *c, + int *argc, char *argv[], + struct weston_config *config, + struct weston_backend_config *config_base); + + backend_init = weston_load_module(backend, "backend_init"); + if (!backend_init) + return -1; + + return backend_init(compositor, NULL, NULL, NULL, config_base); +} + +static int +load_backend(struct weston_compositor *compositor, const char *backend, + int *argc, char **argv, struct weston_config *config) +{ +#if 0 + if (strstr(backend, "drm-backend.so")) + return load_drm_backend(compositor, backend, argc, argv, config); + else if (strstr(backend, "wayland-backend.so")) + return load_wayland_backend(compositor, backend, argc, argv, config); + else if (strstr(backend, "x11-backend.so")) + return load_x11_backend(compositor, backend, argc, argv, config); + else if (strstr(backend, "fbdev-backend.so")) + return load_fbdev_backend(compositor, backend, argc, argv, config); + else if (strstr(backend, "headless-backend.so")) + return load_headless_backend(compositor, backend, argc, argv, config); + else if (strstr(backend, "rpi-backend.so")) + return load_rpi_backend(compositor, backend, argc, argv, config); + else if (strstr(backend, "rdp-backend.so")) + return load_rdp_backend(compositor, backend, argc, argv, config); +#endif + + return load_backend_old(compositor, backend, argc, argv, config); +} + int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; @@ -638,10 +696,6 @@ int main(int argc, char *argv[]) struct weston_compositor *ec; struct wl_event_source *signals[4]; struct wl_event_loop *loop; - int (*backend_init)(struct weston_compositor *c, - int *argc, char *argv[], - struct weston_config *config, - struct weston_backend_config *config_base); int i, fd; char *backend = NULL; char *shell = NULL; @@ -726,10 +780,6 @@ int main(int argc, char *argv[]) backend = weston_choose_default_backend(); } - backend_init = weston_load_module(backend, "backend_init"); - if (!backend_init) - goto out_signals; - ec = weston_compositor_create(display, NULL); if (ec == NULL) { weston_log("fatal: failed to create compositor\n"); @@ -740,7 +790,7 @@ int main(int argc, char *argv[]) if (weston_compositor_init_config(ec, config) < 0) goto out; - if (backend_init(ec, &argc, argv, config, NULL) < 0) { + if (load_backend(ec, backend, &argc, argv, config) < 0) { weston_log("fatal: failed to create compositor backend\n"); goto out; }