Pass argc and argv to modules
This lets modules parse options from the command line.
This commit is contained in:
+14
-13
@@ -3211,11 +3211,13 @@ load_module(const char *name, const char *entrypoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
load_modules(struct weston_compositor *ec, const char *modules)
|
load_modules(struct weston_compositor *ec, const char *modules,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
{
|
{
|
||||||
const char *p, *end;
|
const char *p, *end;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int (*module_init)(struct weston_compositor *ec);
|
int (*module_init)(struct weston_compositor *ec,
|
||||||
|
int *argc, char *argv[], const char *config_file);
|
||||||
|
|
||||||
if (modules == NULL)
|
if (modules == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3226,7 +3228,7 @@ load_modules(struct weston_compositor *ec, const char *modules)
|
|||||||
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
|
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
|
||||||
module_init = load_module(buffer, "module_init");
|
module_init = load_module(buffer, "module_init");
|
||||||
if (module_init)
|
if (module_init)
|
||||||
module_init(ec);
|
module_init(ec, argc, argv, config_file);
|
||||||
p = end;
|
p = end;
|
||||||
while (*p == ',')
|
while (*p == ',')
|
||||||
p++;
|
p++;
|
||||||
@@ -3429,14 +3431,6 @@ int main(int argc, char *argv[])
|
|||||||
sigaction(SIGSEGV, &segv_action, NULL);
|
sigaction(SIGSEGV, &segv_action, NULL);
|
||||||
segv_compositor = ec;
|
segv_compositor = ec;
|
||||||
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
weston_log("fatal: unhandled option: %s\n", argv[i]);
|
|
||||||
if (argc > 1) {
|
|
||||||
ret = EXIT_FAILURE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(config_file);
|
free(config_file);
|
||||||
|
|
||||||
ec->option_idle_time = idle_time;
|
ec->option_idle_time = idle_time;
|
||||||
@@ -3444,11 +3438,18 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
setenv("WAYLAND_DISPLAY", socket_name, 1);
|
setenv("WAYLAND_DISPLAY", socket_name, 1);
|
||||||
|
|
||||||
if (load_modules(ec, modules) < 0)
|
if (load_modules(ec, modules, &argc, argv, config_file) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
if (load_modules(ec, option_modules) < 0)
|
if (load_modules(ec, option_modules, &argc, argv, config_file) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
weston_log("fatal: unhandled option: %s\n", argv[i]);
|
||||||
|
if (argc > 1) {
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (wl_display_add_socket(display, socket_name)) {
|
if (wl_display_add_socket(display, socket_name)) {
|
||||||
weston_log("fatal: failed to add socket: %m\n");
|
weston_log("fatal: failed to add socket: %m\n");
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
|
|||||||
+2
-1
@@ -843,7 +843,8 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
|
|||||||
const char *config_file);
|
const char *config_file);
|
||||||
|
|
||||||
int
|
int
|
||||||
module_init(struct weston_compositor *compositor);
|
module_init(struct weston_compositor *compositor,
|
||||||
|
int *argc, char *argv[], const char *config_file);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_transformed_coord(int width, int height,
|
weston_transformed_coord(int width, int height,
|
||||||
|
|||||||
+4
-6
@@ -345,9 +345,8 @@ get_animation_type(char *animation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shell_configuration(struct desktop_shell *shell)
|
shell_configuration(struct desktop_shell *shell, const char *config_file)
|
||||||
{
|
{
|
||||||
char *config_file;
|
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
int duration = 60;
|
int duration = 60;
|
||||||
unsigned int num_workspaces = DEFAULT_NUM_WORKSPACES;
|
unsigned int num_workspaces = DEFAULT_NUM_WORKSPACES;
|
||||||
@@ -371,9 +370,7 @@ shell_configuration(struct desktop_shell *shell)
|
|||||||
{ "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },
|
{ "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
config_file = config_file_path("weston.ini");
|
|
||||||
parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
|
parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
|
||||||
free(config_file);
|
|
||||||
|
|
||||||
shell->screensaver.path = path;
|
shell->screensaver.path = path;
|
||||||
shell->screensaver.duration = duration;
|
shell->screensaver.duration = duration;
|
||||||
@@ -3957,7 +3954,8 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
module_init(struct weston_compositor *ec)
|
module_init(struct weston_compositor *ec,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
{
|
{
|
||||||
struct weston_seat *seat;
|
struct weston_seat *seat;
|
||||||
struct desktop_shell *shell;
|
struct desktop_shell *shell;
|
||||||
@@ -4002,7 +4000,7 @@ module_init(struct weston_compositor *ec)
|
|||||||
wl_array_init(&shell->workspaces.array);
|
wl_array_init(&shell->workspaces.array);
|
||||||
wl_list_init(&shell->workspaces.client_list);
|
wl_list_init(&shell->workspaces.client_list);
|
||||||
|
|
||||||
shell_configuration(shell);
|
shell_configuration(shell, config_file);
|
||||||
|
|
||||||
for (i = 0; i < shell->workspaces.num; i++) {
|
for (i = 0; i < shell->workspaces.num; i++) {
|
||||||
pws = wl_array_add(&shell->workspaces.array, sizeof *pws);
|
pws = wl_array_add(&shell->workspaces.array, sizeof *pws);
|
||||||
|
|||||||
+2
-1
@@ -531,7 +531,8 @@ tablet_shell_destroy(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
module_init(struct weston_compositor *compositor)
|
module_init(struct weston_compositor *compositor,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
{
|
{
|
||||||
struct tablet_shell *shell;
|
struct tablet_shell *shell;
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
|
|||||||
@@ -315,7 +315,9 @@ weston_xserver_destroy(struct wl_listener *l, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
module_init(struct weston_compositor *compositor)
|
module_init(struct weston_compositor *compositor,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct wl_display *display = compositor->wl_display;
|
struct wl_display *display = compositor->wl_display;
|
||||||
struct weston_xserver *wxs;
|
struct weston_xserver *wxs;
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ surface_to_from_global(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
module_init(struct weston_compositor *compositor)
|
module_init(struct weston_compositor *compositor,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
{
|
{
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ surface_transform(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
module_init(struct weston_compositor *compositor)
|
module_init(struct weston_compositor *compositor,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
{
|
{
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -224,7 +224,8 @@ idle_launch_client(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
module_init(struct weston_compositor *ec)
|
module_init(struct weston_compositor *ec,
|
||||||
|
int *argc, char *argv[], const char *config_file)
|
||||||
{
|
{
|
||||||
struct weston_test *test;
|
struct weston_test *test;
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
|
|||||||
Reference in New Issue
Block a user