compositor: Extend compositor user data

This patch makes the compositor user data a structure
which can be expanded with new fields when necessary.

v2:

Don't export to_wet_compositor

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Armin Krezović 8 years ago committed by Pekka Paalanen
parent 649bbce607
commit 78a36373f6
  1. 20
      compositor/main.c

@ -65,6 +65,10 @@
#define WINDOW_TITLE "Weston Compositor" #define WINDOW_TITLE "Weston Compositor"
struct wet_compositor {
struct weston_config *config;
};
static FILE *weston_logfile = NULL; static FILE *weston_logfile = NULL;
static int cached_tm_mday = -1; static int cached_tm_mday = -1;
@ -414,12 +418,20 @@ log_uname(void)
usys.version, usys.machine); usys.version, usys.machine);
} }
WL_EXPORT struct weston_config * static struct wet_compositor *
wet_get_config(struct weston_compositor *compositor) to_wet_compositor(struct weston_compositor *compositor)
{ {
return weston_compositor_get_user_data(compositor); return weston_compositor_get_user_data(compositor);
} }
WL_EXPORT struct weston_config *
wet_get_config(struct weston_compositor *ec)
{
struct wet_compositor *compositor = to_wet_compositor(ec);
return compositor->config;
}
static const char xdg_error_message[] = static const char xdg_error_message[] =
"fatal: environment variable XDG_RUNTIME_DIR is not set.\n"; "fatal: environment variable XDG_RUNTIME_DIR is not set.\n";
@ -1581,6 +1593,7 @@ int main(int argc, char *argv[])
struct wl_client *primary_client; struct wl_client *primary_client;
struct wl_listener primary_client_destroyed; struct wl_listener primary_client_destroyed;
struct weston_seat *seat; struct weston_seat *seat;
struct wet_compositor user_data;
const struct weston_option core_options[] = { const struct weston_option core_options[] = {
{ WESTON_OPTION_STRING, "backend", 'B', &backend }, { WESTON_OPTION_STRING, "backend", 'B', &backend },
@ -1644,6 +1657,7 @@ int main(int argc, char *argv[])
if (load_configuration(&config, noconfig, config_file) < 0) if (load_configuration(&config, noconfig, config_file) < 0)
goto out_signals; goto out_signals;
user_data.config = config;
section = weston_config_get_section(config, "core", NULL, NULL); section = weston_config_get_section(config, "core", NULL, NULL);
@ -1654,7 +1668,7 @@ int main(int argc, char *argv[])
backend = weston_choose_default_backend(); backend = weston_choose_default_backend();
} }
ec = weston_compositor_create(display, config); ec = weston_compositor_create(display, &user_data);
if (ec == NULL) { if (ec == NULL) {
weston_log("fatal: failed to create compositor\n"); weston_log("fatal: failed to create compositor\n");
goto out; goto out;

Loading…
Cancel
Save