compositor: Parse config file in main(), only keep weston config object

Now that all backends and modules have been converted to the new
config parser API, we don't have to keep the fd around.
This commit is contained in:
Kristian Høgsberg 2013-05-26 21:48:14 -04:00
parent 115b0f729c
commit 14e438c8a2
10 changed files with 54 additions and 57 deletions

View file

@ -2442,7 +2442,8 @@ planes_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data
static struct weston_compositor *
drm_compositor_create(struct wl_display *display,
int connector, const char *seat, int tty, int pixman,
int *argc, char *argv[], int config_fd)
int *argc, char *argv[],
struct weston_config *config)
{
struct drm_compositor *ec;
struct udev_device *drm_device;
@ -2465,7 +2466,7 @@ drm_compositor_create(struct wl_display *display,
ec->use_pixman = pixman;
if (weston_compositor_init(&ec->base, display, argc, argv,
config_fd) < 0) {
config) < 0) {
weston_log("%s failed\n", __func__);
goto err_base;
}
@ -2602,7 +2603,7 @@ err_base:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
int connector = 0, tty = 0, use_pixman = 0;
const char *seat = default_seat;
@ -2618,5 +2619,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
parse_options(drm_options, ARRAY_LENGTH(drm_options), argc, argv);
return drm_compositor_create(display, connector, seat, tty, use_pixman,
argc, argv, config_fd);
argc, argv, config);
}

View file

@ -836,7 +836,8 @@ switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *d
static struct weston_compositor *
fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
int config_fd, struct fbdev_parameters *param)
struct weston_config *config,
struct fbdev_parameters *param)
{
struct fbdev_compositor *compositor;
const char *seat = default_seat;
@ -849,7 +850,7 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
return NULL;
if (weston_compositor_init(&compositor->base, display, argc, argv,
config_fd) < 0)
config) < 0)
goto out_free;
compositor->udev = udev_new();
@ -907,7 +908,7 @@ out_free:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
/* TODO: Ideally, available frame buffers should be enumerated using
* udev, rather than passing a device node in as a parameter. */
@ -923,6 +924,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
return fbdev_compositor_create(display, argc, argv, config_fd,
&param);
return fbdev_compositor_create(display, argc, argv, config, &param);
}

View file

@ -157,8 +157,9 @@ headless_destroy(struct weston_compositor *ec)
static struct weston_compositor *
headless_compositor_create(struct wl_display *display,
int width, int height, const char *display_name,
int *argc, char *argv[], int config_fd)
int width, int height, const char *display_name,
int *argc, char *argv[],
struct weston_config *config)
{
struct headless_compositor *c;
@ -168,8 +169,7 @@ headless_compositor_create(struct wl_display *display,
memset(c, 0, sizeof *c);
if (weston_compositor_init(&c->base, display, argc, argv,
config_fd) < 0)
if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
goto err_free;
weston_seat_init(&c->fake_seat, &c->base);
@ -194,7 +194,7 @@ err_free:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
int width = 1024, height = 640;
char *display_name = NULL;
@ -208,5 +208,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
ARRAY_LENGTH(headless_options), argc, argv);
return headless_compositor_create(display, width, height, display_name,
argc, argv, config_fd);
argc, argv, config);
}

View file

@ -965,7 +965,7 @@ rdp_incoming_peer(freerdp_listener *instance, freerdp_peer *client)
static struct weston_compositor *
rdp_compositor_create(struct wl_display *display,
struct rdp_compositor_config *config,
int *argc, char *argv[], int config_fd)
int *argc, char *argv[], struct weston_config *config)
{
struct rdp_compositor *c;
char *fd_str;
@ -977,8 +977,7 @@ rdp_compositor_create(struct wl_display *display,
memset(c, 0, sizeof *c);
if (weston_compositor_init(&c->base, display, argc, argv,
config_fd) < 0)
if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
goto err_free;
c->base.destroy = rdp_destroy;
@ -1047,7 +1046,7 @@ err_free:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
struct rdp_compositor_config config;
rdp_compositor_config_init(&config);
@ -1070,5 +1069,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
};
parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
return rdp_compositor_create(display, &config, argc, argv, config_fd);
return rdp_compositor_create(display, &config, argc, argv, config);
}

View file

@ -734,7 +734,8 @@ struct rpi_parameters {
static struct weston_compositor *
rpi_compositor_create(struct wl_display *display, int *argc, char *argv[],
int config_fd, struct rpi_parameters *param)
struct weston_config *config,
struct rpi_parameters *param)
{
struct rpi_compositor *compositor;
const char *seat = default_seat;
@ -747,7 +748,7 @@ rpi_compositor_create(struct wl_display *display, int *argc, char *argv[],
return NULL;
if (weston_compositor_init(&compositor->base, display, argc, argv,
config_fd) < 0)
config) < 0)
goto out_free;
compositor->udev = udev_new();
@ -817,7 +818,7 @@ out_free:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
const char *transform = "normal";
int ret;
@ -843,5 +844,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
else
param.output_transform = ret;
return rpi_compositor_create(display, argc, argv, config_fd, &param);
return rpi_compositor_create(display, argc, argv, config, &param);
}

View file

@ -721,7 +721,8 @@ wayland_destroy(struct weston_compositor *ec)
static struct weston_compositor *
wayland_compositor_create(struct wl_display *display,
int width, int height, const char *display_name,
int *argc, char *argv[], int config_fd)
int *argc, char *argv[],
struct weston_config *config)
{
struct wayland_compositor *c;
struct wl_event_loop *loop;
@ -734,7 +735,7 @@ wayland_compositor_create(struct wl_display *display,
memset(c, 0, sizeof *c);
if (weston_compositor_init(&c->base, display, argc, argv,
config_fd) < 0)
config) < 0)
goto err_free;
c->parent.wl_display = wl_display_connect(display_name);
@ -797,7 +798,7 @@ err_free:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
int width = 1024, height = 640;
char *display_name = NULL;
@ -812,5 +813,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
ARRAY_LENGTH(wayland_options), argc, argv);
return wayland_compositor_create(display, width, height, display_name,
argc, argv, config_fd);
argc, argv, config);
}

View file

@ -1508,7 +1508,8 @@ x11_compositor_create(struct wl_display *display,
int fullscreen,
int no_input,
int use_pixman,
int *argc, char *argv[], int config_fd)
int *argc, char *argv[],
struct weston_config *config)
{
struct x11_compositor *c;
struct x11_output *output;
@ -1528,8 +1529,7 @@ x11_compositor_create(struct wl_display *display,
memset(c, 0, sizeof *c);
if (weston_compositor_init(&c->base, display, argc, argv,
config_fd) < 0)
if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
goto err_free;
c->dpy = XOpenDisplay(NULL);
@ -1654,7 +1654,7 @@ err_free:
WL_EXPORT struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
int fullscreen = 0;
int no_input = 0;
@ -1675,5 +1675,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
fullscreen,
no_input,
use_pixman,
argc, argv, config_fd);
argc, argv, config);
}

View file

@ -2771,15 +2771,13 @@ WL_EXPORT int
weston_compositor_init(struct weston_compositor *ec,
struct wl_display *display,
int *argc, char *argv[],
int config_fd)
struct weston_config *config)
{
struct wl_event_loop *loop;
struct xkb_rule_names xkb_names;
struct weston_config_section *s;
ec->config_fd = config_fd;
ec->config = weston_config_parse(config_fd);
ec->config = config;
ec->wl_display = display;
wl_signal_init(&ec->destroy_signal);
wl_signal_init(&ec->activate_signal);
@ -2876,7 +2874,7 @@ weston_compositor_shutdown(struct weston_compositor *ec)
wl_event_loop_destroy(ec->input_loop);
close(ec->config_fd);
weston_config_destroy(ec->config);
}
WL_EXPORT void
@ -3208,24 +3206,18 @@ int main(int argc, char *argv[])
struct wl_event_loop *loop;
struct weston_compositor
*(*backend_init)(struct wl_display *display,
int *argc, char *argv[], int config_fd);
int *argc, char *argv[],
struct weston_config *config);
int i, config_fd;
char *backend = NULL;
const char *modules = "desktop-shell.so", *option_modules = NULL;
char *modules, *option_modules = NULL;
char *log = NULL;
int32_t idle_time = 300;
int32_t help = 0;
char *socket_name = "wayland-0";
int32_t version = 0;
const struct config_key core_config_keys[] = {
{ "modules", CONFIG_KEY_STRING, &modules },
};
const struct config_section cs[] = {
{ "core",
core_config_keys, ARRAY_LENGTH(core_config_keys) },
};
struct weston_config *config;
struct weston_config_section *section;
const struct weston_option core_options[] = {
{ WESTON_OPTION_STRING, "backend", 'B', &backend },
@ -3283,13 +3275,18 @@ int main(int argc, char *argv[])
}
config_fd = open_config_file("weston.ini");
parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), NULL);
config = weston_config_parse(config_fd);
close(config_fd);
section = weston_config_get_section(config, "core", NULL, NULL);
weston_config_section_get_string(section, "modules",
&modules, "desktop-shell.so");
backend_init = load_module(backend, "backend_init");
if (!backend_init)
exit(EXIT_FAILURE);
ec = backend_init(display, &argc, argv, config_fd);
ec = backend_init(display, &argc, argv, config);
if (ec == NULL) {
weston_log("fatal: failed to create compositor\n");
exit(EXIT_FAILURE);

View file

@ -556,8 +556,6 @@ struct weston_compositor {
struct xkb_rule_names xkb_names;
struct xkb_context *xkb_context;
struct weston_xkb_info xkb_info;
int config_fd;
};
struct weston_buffer_reference {
@ -1011,7 +1009,7 @@ weston_compositor_get_time(void);
int
weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
int *argc, char *argv[], int config_fd);
int *argc, char *argv[], struct weston_config *config);
void
weston_compositor_shutdown(struct weston_compositor *ec);
void
@ -1149,7 +1147,7 @@ noop_renderer_init(struct weston_compositor *ec);
struct weston_compositor *
backend_init(struct wl_display *display, int *argc, char *argv[],
int config_fd);
struct weston_config *config);
int
module_init(struct weston_compositor *compositor,

View file

@ -379,7 +379,7 @@ get_animation_type(char *animation)
}
static void
shell_configuration(struct desktop_shell *shell, int config_fd)
shell_configuration(struct desktop_shell *shell)
{
struct weston_config_section *section;
int duration;
@ -4418,7 +4418,7 @@ module_init(struct weston_compositor *ec,
wl_array_init(&shell->workspaces.array);
wl_list_init(&shell->workspaces.client_list);
shell_configuration(shell, ec->config_fd);
shell_configuration(shell);
for (i = 0; i < shell->workspaces.num; i++) {
pws = wl_array_add(&shell->workspaces.array, sizeof *pws);