[PATCH weston] compositor: Use libwayland to find a good default display for us
Jasper St. Pierre
jstpierre at mecheye.net
Thu Jul 17 10:55:44 PDT 2014
---
src/compositor.c | 67 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 38 insertions(+), 29 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 17fce8d..5eb8ac8 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4153,7 +4153,7 @@ int main(int argc, char *argv[])
char *server_socket = NULL, *end;
int32_t idle_time = 300;
int32_t help = 0;
- char *socket_name = "wayland-0";
+ const char *socket_name = NULL;
int32_t version = 0;
int32_t noconfig = 0;
struct weston_config *config = NULL;
@@ -4259,30 +4259,6 @@ int main(int argc, char *argv[])
ec->idle_time = idle_time;
ec->default_pointer_grab = NULL;
- setenv("WAYLAND_DISPLAY", socket_name, 1);
-
- if (option_shell)
- shell = strdup(option_shell);
- else
- weston_config_section_get_string(section, "shell", &shell,
- "desktop-shell.so");
-
- if (load_modules(ec, shell, &argc, argv) < 0) {
- free(shell);
- goto out;
- }
- free(shell);
-
- weston_config_section_get_string(section, "modules", &modules, "");
- if (load_modules(ec, modules, &argc, argv) < 0) {
- free(modules);
- goto out;
- }
- free(modules);
-
- if (load_modules(ec, option_modules, &argc, argv) < 0)
- goto out;
-
for (i = 1; i < argc; i++)
weston_log("fatal: unhandled option: %s\n", argv[i]);
if (argc > 1) {
@@ -4314,13 +4290,46 @@ int main(int argc, char *argv[])
wl_client_add_destroy_listener(primary_client,
&primary_client_destroyed);
} else {
- if (wl_display_add_socket(display, socket_name)) {
- weston_log("fatal: failed to add socket: %m\n");
- ret = EXIT_FAILURE;
- goto out;
+ if (socket_name) {
+ if (wl_display_add_socket(display, socket_name)) {
+ weston_log("fatal: failed to add socket: %m\n");
+ ret = EXIT_FAILURE;
+ goto out;
+ }
+ } else {
+ socket_name = wl_display_add_socket_auto(display);
+ if (!socket_name) {
+ weston_log("fatal: failed to add socket: %m\n");
+ ret = EXIT_FAILURE;
+ goto out;
+ }
}
+
+ setenv("WAYLAND_DISPLAY", socket_name, 1);
}
+ if (option_shell)
+ shell = strdup(option_shell);
+ else
+ weston_config_section_get_string(section, "shell", &shell,
+ "desktop-shell.so");
+
+ if (load_modules(ec, shell, &argc, argv) < 0) {
+ free(shell);
+ goto out;
+ }
+ free(shell);
+
+ weston_config_section_get_string(section, "modules", &modules, "");
+ if (load_modules(ec, modules, &argc, argv) < 0) {
+ free(modules);
+ goto out;
+ }
+ free(modules);
+
+ if (load_modules(ec, option_modules, &argc, argv) < 0)
+ goto out;
+
weston_compositor_wake(ec);
wl_display_run(display);
--
2.0.1
More information about the wayland-devel
mailing list