[PATCH weston 03/15] compositor: remove the weston_config field from weston_compositor
Giulio Camuffo
giuliocamuffo at gmail.com
Thu Nov 6 12:41:22 PST 2014
Instead of the central weston_config pointer we now store it in some
module-specific pointers. This way we can remove them one by one.
---
desktop-shell/shell.c | 8 +++++---
desktop-shell/shell.h | 1 +
fullscreen-shell/fullscreen-shell.c | 3 ++-
src/cms-colord.c | 3 ++-
src/cms-static.c | 7 +++++--
src/compositor-drm.c | 10 ++++++++++
src/compositor-fbdev.c | 14 ++++++++++++++
src/compositor-rpi.c | 15 +++++++++++++++
src/compositor.c | 21 ++++++++++-----------
src/compositor.h | 7 ++++---
src/libinput-device.c | 29 +----------------------------
src/libinput-device.h | 2 ++
src/libinput-seat.c | 29 +++++++++++++++++++++++++++--
src/libinput-seat.h | 8 ++++++++
src/text-backend.c | 10 ++++++----
tests/surface-global-test.c | 3 ++-
tests/surface-test.c | 3 ++-
tests/weston-test.c | 3 ++-
xwayland/launcher.c | 6 ++++--
xwayland/xwayland.h | 1 +
20 files changed, 123 insertions(+), 60 deletions(-)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 844a322..dfc7b65 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -577,14 +577,14 @@ shell_configuration(struct desktop_shell *shell)
char *s, *client;
int ret;
- section = weston_config_get_section(shell->compositor->config,
+ section = weston_config_get_section(shell->config,
"screensaver", NULL, NULL);
weston_config_section_get_string(section,
"path", &shell->screensaver.path, NULL);
weston_config_section_get_int(section, "duration", &duration, 60);
shell->screensaver.duration = duration * 1000;
- section = weston_config_get_section(shell->compositor->config,
+ section = weston_config_get_section(shell->config,
"shell", NULL, NULL);
ret = asprintf(&client, "%s/%s", weston_config_get_libexec_dir(),
WESTON_SHELL_CLIENT);
@@ -6488,7 +6488,8 @@ handle_seat_created(struct wl_listener *listener, void *data)
WL_EXPORT int
module_init(struct weston_compositor *ec,
- int *argc, char *argv[])
+ int *argc, char *argv[],
+ struct weston_config *config)
{
struct weston_seat *seat;
struct desktop_shell *shell;
@@ -6501,6 +6502,7 @@ module_init(struct weston_compositor *ec,
return -1;
shell->compositor = ec;
+ shell->config = config;
shell->destroy_listener.notify = shell_destroy;
wl_signal_add(&ec->destroy_signal, &shell->destroy_listener);
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index 2cfd1d6..101a960 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -117,6 +117,7 @@ struct shell_output {
struct desktop_shell {
struct weston_compositor *compositor;
+ struct weston_config *config;
struct wl_listener idle_listener;
struct wl_listener wake_listener;
diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index 35e6d8f..679cfd1 100644
--- a/fullscreen-shell/fullscreen-shell.c
+++ b/fullscreen-shell/fullscreen-shell.c
@@ -787,7 +787,8 @@ bind_fullscreen_shell(struct wl_client *client, void *data, uint32_t version,
WL_EXPORT int
module_init(struct weston_compositor *compositor,
- int *argc, char *argv[])
+ int *argc, char *argv[],
+ struct weston_config *config)
{
struct fullscreen_shell *shell;
struct weston_seat *seat;
diff --git a/src/cms-colord.c b/src/cms-colord.c
index c541a34..6510c15 100644
--- a/src/cms-colord.c
+++ b/src/cms-colord.c
@@ -483,7 +483,8 @@ colord_cms_output_destroy(gpointer data)
WL_EXPORT int
module_init(struct weston_compositor *ec,
- int *argc, char *argv[])
+ int *argc, char *argv[],
+ struct weston_config *config)
{
gboolean ret;
GError *error = NULL;
diff --git a/src/cms-static.c b/src/cms-static.c
index ad54fd1..cc66a2e 100644
--- a/src/cms-static.c
+++ b/src/cms-static.c
@@ -32,6 +32,7 @@ struct cms_static {
struct weston_compositor *ec;
struct wl_listener destroy_listener;
struct wl_listener output_created_listener;
+ struct weston_config *config;
};
static void
@@ -45,7 +46,7 @@ cms_output_created(struct cms_static *cms, struct weston_output *o)
if (o->name == NULL)
return;
- s = weston_config_get_section(cms->ec->config,
+ s = weston_config_get_section(cms->config,
"output", "name", o->name);
if (s == NULL)
return;
@@ -86,7 +87,8 @@ cms_notifier_destroy(struct wl_listener *listener, void *data)
WL_EXPORT int
module_init(struct weston_compositor *ec,
- int *argc, char *argv[])
+ int *argc, char *argv[],
+ struct weston_config *config)
{
struct cms_static *cms;
struct weston_output *output;
@@ -99,6 +101,7 @@ module_init(struct weston_compositor *ec,
return -1;
cms->ec = ec;
+ cms->config = config;
cms->destroy_listener.notify = cms_notifier_destroy;
wl_signal_add(&ec->destroy_signal, &cms->destroy_listener);
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index b858b93..643bb2b 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -235,6 +235,8 @@ struct drm_parameters {
uint32_t format;
void (*get_output_parameters)(const char *name,
struct drm_output_parameters *parameters);
+ void (*configure_device)(struct weston_compositor *compositor,
+ struct evdev_device *device);
};
static struct gl_renderer_interface *gl_renderer;
@@ -2731,6 +2733,7 @@ drm_backend_create(struct weston_compositor *compositor,
wl_list_init(&b->sprite_list);
create_sprites(b);
+ b->input.configure_device = param->configure_device;
if (udev_input_init(&b->input,
compositor, b->udev, param->seat_id) < 0) {
weston_log("failed to create input devices\n");
@@ -2942,6 +2945,12 @@ output_parameters(const char *name, struct drm_output_parameters *params)
weston_config_section_get_string(section, "seat", ¶ms->seat, "");
}
+static void
+configure_device(struct weston_compositor *c, struct evdev_device *device)
+{
+ evdev_device_configure(device, wconfig);
+}
+
WL_EXPORT int
backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
struct weston_config *config)
@@ -2964,6 +2973,7 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
param.seat_id = default_seat;
param.get_output_parameters = output_parameters;
+ param.configure_device = configure_device;
parse_options(drm_options, ARRAY_LENGTH(drm_options), argc, argv);
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 28cd55e..7b6b23c 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -94,6 +94,8 @@ struct fbdev_parameters {
int tty;
char *device;
int use_gl;
+ void (*configure_device)(struct weston_compositor *compositor,
+ struct evdev_device *device);
};
struct gl_renderer_interface *gl_renderer;
@@ -934,6 +936,7 @@ fbdev_backend_create(struct weston_compositor *compositor,
if (fbdev_output_create(backend, param->device) < 0)
goto out_pixman;
+ backend->input.configure_device = param->configure_device;
udev_input_init(&backend->input, compositor, backend->udev, seat_id);
compositor->backend = &backend->base;
@@ -956,6 +959,14 @@ out_compositor:
return NULL;
}
+static struct weston_config *wconfig;
+
+static void
+configure_device(struct weston_compositor *c, struct evdev_device *device)
+{
+ evdev_device_configure(device, wconfig);
+}
+
WL_EXPORT int
backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
struct weston_config *config)
@@ -969,6 +980,8 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
.use_gl = 0,
};
+ wconfig = config;
+
const struct weston_option fbdev_options[] = {
{ WESTON_OPTION_INTEGER, "tty", 0, ¶m.tty },
{ WESTON_OPTION_STRING, "device", 0, ¶m.device },
@@ -976,6 +989,7 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
};
parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
+ param.configure_device = configure_device;
b = fbdev_backend_create(compositor, ¶m);
if (b == NULL)
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 0fa2a86..f3b3772 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -480,6 +480,8 @@ struct rpi_parameters {
int tty;
struct rpi_renderer_parameters renderer;
uint32_t output_transform;
+ void (*configure_device)(struct weston_compositor *compositor,
+ struct evdev_device *device);
};
static struct rpi_backend *
@@ -544,6 +546,7 @@ rpi_backend_create(struct weston_compositor *compositor,
if (rpi_output_create(backend, param->output_transform) < 0)
goto out_renderer;
+ backend->input.configure_device = param->configure_device;
if (udev_input_init(&backend->input,
compositor,
backend->udev, "seat0") != 0) {
@@ -571,6 +574,14 @@ out_compositor:
return NULL;
}
+static struct weston_config *wconfig;
+
+static void
+configure_device(struct weston_compositor *c, struct evdev_device *device)
+{
+ evdev_device_configure(device, wconfig);
+}
+
WL_EXPORT int
backend_init(struct weston_compositor *compositor,
int *argc, char *argv[],
@@ -580,6 +591,8 @@ backend_init(struct weston_compositor *compositor,
int ret;
struct rpi_backend *b;
+ wconfig = config;
+
struct rpi_parameters param = {
.tty = 0, /* default to current tty */
.renderer.single_buffer = 0,
@@ -598,6 +611,8 @@ backend_init(struct weston_compositor *compositor,
parse_options(rpi_options, ARRAY_LENGTH(rpi_options), argc, argv);
+ param.configure_device = configure_device;
+
ret = str2transform(transform);
if (ret < 0)
weston_log("invalid transform \"%s\"\n", transform);
diff --git a/src/compositor.c b/src/compositor.c
index 6a94565..2243509 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4023,7 +4023,6 @@ weston_compositor_init(struct weston_compositor *ec,
struct xkb_rule_names xkb_names;
struct weston_config_section *s;
- ec->config = config;
wl_signal_init(&ec->destroy_signal);
wl_signal_init(&ec->create_surface_signal);
wl_signal_init(&ec->activate_signal);
@@ -4074,7 +4073,7 @@ weston_compositor_init(struct weston_compositor *ec,
weston_plane_init(&ec->primary_plane, ec, 0, 0);
weston_compositor_stack_plane(ec, &ec->primary_plane, NULL);
- s = weston_config_get_section(ec->config, "keyboard", NULL, NULL);
+ s = weston_config_get_section(config, "keyboard", NULL, NULL);
weston_config_section_get_string(s, "keymap_rules",
(char **) &xkb_names.rules, NULL);
weston_config_section_get_string(s, "keymap_model",
@@ -4094,7 +4093,7 @@ weston_compositor_init(struct weston_compositor *ec,
weston_config_section_get_int(s, "repeat-delay",
&ec->kb_repeat_delay, 400);
- text_backend_init(ec);
+ text_backend_init(ec, config);
wl_data_device_manager_init(ec->wl_display);
@@ -4139,8 +4138,6 @@ weston_compositor_shutdown(struct weston_compositor *ec)
weston_plane_release(&ec->primary_plane);
wl_event_loop_destroy(ec->input_loop);
-
- weston_config_destroy(ec->config);
}
WL_EXPORT void
@@ -4402,12 +4399,13 @@ weston_load_module(const char *name, const char *entrypoint)
static int
load_modules(struct weston_compositor *ec, const char *modules,
- int *argc, char *argv[])
+ int *argc, char *argv[], struct weston_config *config)
{
const char *p, *end;
char buffer[256];
int (*module_init)(struct weston_compositor *ec,
- int *argc, char *argv[]);
+ int *argc, char *argv[],
+ struct weston_config *config);
if (modules == NULL)
return 0;
@@ -4418,7 +4416,7 @@ load_modules(struct weston_compositor *ec, const char *modules,
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
module_init = weston_load_module(buffer, "module_init");
if (module_init)
- module_init(ec, argc, argv);
+ module_init(ec, argc, argv, config);
p = end;
while (*p == ',')
p++;
@@ -4783,14 +4781,14 @@ int main(int argc, char *argv[])
weston_config_section_get_string(section, "shell", &shell,
"desktop-shell.so");
- if (load_modules(ec, shell, &argc, argv) < 0)
+ if (load_modules(ec, shell, &argc, argv, config) < 0)
goto out;
weston_config_section_get_string(section, "modules", &modules, "");
- if (load_modules(ec, modules, &argc, argv) < 0)
+ if (load_modules(ec, modules, &argc, argv, config) < 0)
goto out;
- if (load_modules(ec, option_modules, &argc, argv) < 0)
+ if (load_modules(ec, option_modules, &argc, argv, config) < 0)
goto out;
section = weston_config_get_section(config, "keyboard", NULL, NULL);
@@ -4827,6 +4825,7 @@ out_signals:
wl_display_destroy(display);
weston_log_file_close();
+ weston_config_destroy(config);
free(backend);
free(shell);
diff --git a/src/compositor.h b/src/compositor.h
index dd11124..75e3961 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -593,7 +593,6 @@ struct weston_compositor {
struct wl_display *wl_display;
struct weston_shell_interface shell_interface;
- struct weston_config *config;
/* surface signals */
struct wl_signal create_surface_signal;
@@ -1367,7 +1366,8 @@ struct clipboard *
clipboard_create(struct weston_seat *seat);
int
-text_backend_init(struct weston_compositor *ec);
+text_backend_init(struct weston_compositor *ec,
+ struct weston_config *config);
struct weston_process;
typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
@@ -1450,7 +1450,8 @@ backend_init(struct weston_compositor *c,
struct weston_config *config);
int
module_init(struct weston_compositor *compositor,
- int *argc, char *argv[]);
+ int *argc, char *argv[],
+ struct weston_config *config);
void
weston_transformed_coord(int width, int height,
diff --git a/src/libinput-device.c b/src/libinput-device.c
index 0e3f46d..192a752 100644
--- a/src/libinput-device.c
+++ b/src/libinput-device.c
@@ -288,7 +288,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
* can't do that, so we need to convert the calibration to the normalized
* format libinput expects.
*/
-static void
+void
evdev_device_set_calibration(struct evdev_device *device)
{
struct udev *udev;
@@ -382,31 +382,6 @@ evdev_device_set_output(struct evdev_device *device,
evdev_device_set_calibration(device);
}
-static void
-configure_device(struct evdev_device *device)
-{
- struct weston_compositor *compositor = device->seat->compositor;
- struct weston_config_section *s;
- int enable_tap;
- int enable_tap_default;
-
- s = weston_config_get_section(compositor->config,
- "libinput", NULL, NULL);
-
- if (libinput_device_config_tap_get_finger_count(device->device) > 0) {
- enable_tap_default =
- libinput_device_config_tap_get_default_enabled(
- device->device);
- weston_config_section_get_bool(s, "enable_tap",
- &enable_tap,
- enable_tap_default);
- libinput_device_config_tap_set_enabled(device->device,
- enable_tap);
- }
-
- evdev_device_set_calibration(device);
-}
-
struct evdev_device *
evdev_device_create(struct libinput_device *libinput_device,
struct weston_seat *seat)
@@ -440,8 +415,6 @@ evdev_device_create(struct libinput_device *libinput_device,
libinput_device_set_user_data(libinput_device, device);
libinput_device_ref(libinput_device);
- configure_device(device);
-
return device;
}
diff --git a/src/libinput-device.h b/src/libinput-device.h
index 0775743..e14e1dd 100644
--- a/src/libinput-device.h
+++ b/src/libinput-device.h
@@ -63,6 +63,8 @@ void
evdev_device_set_output(struct evdev_device *device,
struct weston_output *output);
void
+evdev_device_set_calibration(struct evdev_device *device);
+void
evdev_device_destroy(struct evdev_device *device);
void
diff --git a/src/libinput-seat.c b/src/libinput-seat.c
index ef2d804..dd61cf7 100644
--- a/src/libinput-seat.c
+++ b/src/libinput-seat.c
@@ -70,6 +70,9 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
if (device == NULL)
return;
+ if (input->configure_device != NULL)
+ input->configure_device(c, device);
+ evdev_device_set_calibration(device);
udev_seat = (struct udev_seat *) seat;
wl_list_insert(udev_seat->devices_list.prev, &device->link);
@@ -266,9 +269,9 @@ udev_input_init(struct udev_input *input, struct weston_compositor *c,
enum libinput_log_priority priority = LIBINPUT_LOG_PRIORITY_INFO;
const char *log_priority = NULL;
- memset(input, 0, sizeof *input);
-
input->compositor = c;
+ input->libinput_source = NULL;
+ input->suspended = 0;
log_priority = getenv("WESTON_LIBINPUT_LOG_PRIORITY");
@@ -387,3 +390,25 @@ udev_seat_get_named(struct udev_input *input, const char *seat_name)
return udev_seat_create(input, seat_name);
}
+
+void
+evdev_device_configure(struct evdev_device *device, struct weston_config *config)
+{
+ struct weston_config_section *s;
+ int enable_tap;
+ int enable_tap_default;
+
+ s = weston_config_get_section(config,
+ "libinput", NULL, NULL);
+
+ if (libinput_device_config_tap_get_finger_count(device->device) > 0) {
+ enable_tap_default =
+ libinput_device_config_tap_get_default_enabled(
+ device->device);
+ weston_config_section_get_bool(s, "enable_tap",
+ &enable_tap,
+ enable_tap_default);
+ libinput_device_config_tap_set_enabled(device->device,
+ enable_tap);
+ }
+}
diff --git a/src/libinput-seat.h b/src/libinput-seat.h
index c448da0..4d1f2eb 100644
--- a/src/libinput-seat.h
+++ b/src/libinput-seat.h
@@ -36,11 +36,15 @@ struct udev_seat {
struct wl_listener output_create_listener;
};
+struct evdev_device;
+
struct udev_input {
struct libinput *libinput;
struct wl_event_source *libinput_source;
struct weston_compositor *compositor;
int suspended;
+ void (*configure_device)(struct weston_compositor *compositor,
+ struct evdev_device *device);
};
int
@@ -59,4 +63,8 @@ struct udev_seat *
udev_seat_get_named(struct udev_input *u,
const char *seat_name);
+void
+evdev_device_configure(struct evdev_device *device,
+ struct weston_config *config);
+
#endif
diff --git a/src/text-backend.c b/src/text-backend.c
index e9578a4..0b674ee 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -934,13 +934,14 @@ handle_seat_created(struct wl_listener *listener,
}
static void
-text_backend_configuration(struct text_backend *text_backend)
+text_backend_configuration(struct text_backend *text_backend,
+ struct weston_config *config)
{
struct weston_config_section *section;
char *client;
int ret;
- section = weston_config_get_section(text_backend->compositor->config,
+ section = weston_config_get_section(config,
"input-method", NULL, NULL);
ret = asprintf(&client, "%s/weston-keyboard",
weston_config_get_libexec_dir());
@@ -968,7 +969,8 @@ text_backend_notifier_destroy(struct wl_listener *listener, void *data)
WL_EXPORT int
-text_backend_init(struct weston_compositor *ec)
+text_backend_init(struct weston_compositor *ec,
+ struct weston_config *config)
{
struct text_backend *text_backend;
@@ -983,7 +985,7 @@ text_backend_init(struct weston_compositor *ec)
text_backend->destroy_listener.notify = text_backend_notifier_destroy;
wl_signal_add(&ec->destroy_signal, &text_backend->destroy_listener);
- text_backend_configuration(text_backend);
+ text_backend_configuration(text_backend, config);
text_input_manager_create(ec);
diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c
index edc5d9f..3e30900 100644
--- a/tests/surface-global-test.c
+++ b/tests/surface-global-test.c
@@ -75,7 +75,8 @@ surface_to_from_global(void *data)
}
WL_EXPORT int
-module_init(struct weston_compositor *compositor, int *argc, char *argv[])
+module_init(struct weston_compositor *compositor, int *argc, char *argv[],
+ struct weston_config *config)
{
struct wl_event_loop *loop;
diff --git a/tests/surface-test.c b/tests/surface-test.c
index 80dce81..46aff1e 100644
--- a/tests/surface-test.c
+++ b/tests/surface-test.c
@@ -56,7 +56,8 @@ surface_transform(void *data)
}
WL_EXPORT int
-module_init(struct weston_compositor *compositor, int *argc, char *argv[])
+module_init(struct weston_compositor *compositor, int *argc, char *argv[],
+ struct weston_config *config)
{
struct wl_event_loop *loop;
diff --git a/tests/weston-test.c b/tests/weston-test.c
index f1e45c1..b2fa5fd 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -291,7 +291,8 @@ idle_launch_client(void *data)
WL_EXPORT int
module_init(struct weston_compositor *ec,
- int *argc, char *argv[])
+ int *argc, char *argv[],
+ struct weston_config *config)
{
struct weston_test *test;
struct wl_event_loop *loop;
diff --git a/xwayland/launcher.c b/xwayland/launcher.c
index df2efd2..2a76ee3 100644
--- a/xwayland/launcher.c
+++ b/xwayland/launcher.c
@@ -94,7 +94,7 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
goto fail;
snprintf(wm_fd, sizeof wm_fd, "%d", fd);
- section = weston_config_get_section(wxs->compositor->config,
+ section = weston_config_get_section(wxs->config,
"xwayland", NULL, NULL);
weston_config_section_get_string(section, "path",
&xserver, XSERVER_PATH);
@@ -346,7 +346,8 @@ weston_xserver_destroy(struct wl_listener *l, void *data)
WL_EXPORT int
module_init(struct weston_compositor *compositor,
- int *argc, char *argv[])
+ int *argc, char *argv[],
+ struct weston_config *config)
{
struct wl_display *display = compositor->wl_display;
@@ -394,6 +395,7 @@ module_init(struct weston_compositor *compositor,
weston_log("xserver listening on display %s\n", display_name);
setenv("DISPLAY", display_name, 1);
+ wxs->config = config;
wxs->loop = wl_display_get_event_loop(display);
wxs->abstract_source =
wl_event_loop_add_fd(wxs->loop, wxs->abstract_fd,
diff --git a/xwayland/xwayland.h b/xwayland/xwayland.h
index 312c9b2..161615f 100644
--- a/xwayland/xwayland.h
+++ b/xwayland/xwayland.h
@@ -47,6 +47,7 @@ struct weston_xserver {
struct wl_client *client;
struct weston_compositor *compositor;
struct weston_wm *wm;
+ struct weston_config *config;
struct wl_listener destroy_listener;
};
--
2.1.3
More information about the wayland-devel
mailing list