diff --git a/compositor/xwayland.c b/compositor/xwayland.c index 1aacff92..5a1e19e1 100644 --- a/compositor/xwayland.c +++ b/compositor/xwayland.c @@ -52,7 +52,6 @@ struct wet_xwayland { const struct weston_xwayland_api *api; struct weston_xwayland *xwayland; struct wl_event_source *display_fd_source; - struct wl_client *client; int wm_fd; struct wet_process *process; }; @@ -82,7 +81,7 @@ handle_display_fd(int fd, uint32_t mask, void *data) if (n <= 0 || (n > 0 && buf[n - 1] != '\n')) return 1; - wxw->api->xserver_loaded(wxw->xwayland, wxw->client, wxw->wm_fd); + wxw->api->xserver_loaded(wxw->xwayland, wxw->wm_fd); out: wl_event_source_remove(wxw->display_fd_source); @@ -101,11 +100,10 @@ xserver_cleanup(struct wet_process *process, int status, void *data) assert(process == wxw->process); wxw->api->xserver_exited(wxw->xwayland, status); - wxw->client = NULL; wxw->process = NULL; } -static pid_t +static struct wl_client * spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd) { struct wet_xwayland *wxw = user_data; @@ -117,6 +115,7 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd char *xserver = NULL; struct weston_config *config = wet_get_config(wxw->compositor); struct weston_config_section *section; + struct wl_client *client; struct wl_event_loop *loop; struct custom_env child_env; int no_cloexec_fds[5]; @@ -180,9 +179,9 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd goto err; } - wxw->client = wl_client_create(wxw->compositor->wl_display, - wayland_socket.fds[0]); - if (!wxw->client) { + client = wl_client_create(wxw->compositor->wl_display, + wayland_socket.fds[0]); + if (!client) { weston_log("Couldn't create client for Xwayland\n"); goto err_proc; } @@ -206,7 +205,7 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd free(xserver); - return wxw->process->pid; + return client; err_proc: @@ -217,7 +216,7 @@ err: fdstr_close_all(&x11_wm_socket); fdstr_close_all(&wayland_socket); free(wxw->process); - return -1; + return NULL; } static void diff --git a/include/libweston/xwayland-api.h b/include/libweston/xwayland-api.h index ff71fddd..0fcfc149 100644 --- a/include/libweston/xwayland-api.h +++ b/include/libweston/xwayland-api.h @@ -37,10 +37,10 @@ extern "C" { struct weston_compositor; struct weston_xwayland; -#define WESTON_XWAYLAND_API_NAME "weston_xwayland_v1" +#define WESTON_XWAYLAND_API_NAME "weston_xwayland_v2" #define WESTON_XWAYLAND_SURFACE_API_NAME "weston_xwayland_surface_v1" -typedef pid_t +typedef struct wl_client * (*weston_xwayland_spawn_xserver_func_t)( void *user_data, const char *display, int abstract_fd, int unix_fd); @@ -83,19 +83,16 @@ struct weston_xwayland_api { /** Notify the Xwayland module that the Xwayland server is loaded. * * After the Xwayland server process has been spawned it will notify - * the parent that is has finished the initialization by sending a - * SIGUSR1 signal. - * The caller should listen for that signal and call this function + * the parent that it has finished the initialization by writing to + * the displayfd passed. + * The caller should listen for that write and call this function * when it is received. * * \param xwayland The Xwayland context object. - * \param client The wl_client object representing the connection of - * the Xwayland server process. * \param wm_fd The file descriptor for the wm. */ void - (*xserver_loaded)(struct weston_xwayland *xwayland, - struct wl_client *client, int wm_fd); + (*xserver_loaded)(struct weston_xwayland *xwayland, int wm_fd); /** Notify the Xwayland module that the Xwayland server has exited. * diff --git a/xwayland/launcher.c b/xwayland/launcher.c index 7702b4fb..c14c313e 100644 --- a/xwayland/launcher.c +++ b/xwayland/launcher.c @@ -49,13 +49,12 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data) snprintf(display, sizeof display, ":%d", wxs->display); - wxs->pid = wxs->spawn_func(wxs->user_data, display, wxs->abstract_fd, wxs->unix_fd); - if (wxs->pid == -1) { + wxs->client = wxs->spawn_func(wxs->user_data, display, wxs->abstract_fd, wxs->unix_fd); + if (wxs->client == NULL) { weston_log("Failed to spawn the Xwayland server\n"); return 1; } - weston_log("Spawned Xwayland server, pid %d\n", wxs->pid); wl_event_source_remove(wxs->abstract_source); wl_event_source_remove(wxs->unix_source); @@ -71,7 +70,7 @@ weston_xserver_shutdown(struct weston_xserver *wxs) unlink(path); snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display); unlink(path); - if (wxs->pid == 0) { + if (wxs->client == NULL) { wl_event_source_remove(wxs->abstract_source); wl_event_source_remove(wxs->unix_source); } @@ -305,12 +304,10 @@ retry: } static void -weston_xwayland_xserver_loaded(struct weston_xwayland *xwayland, - struct wl_client *client, int wm_fd) +weston_xwayland_xserver_loaded(struct weston_xwayland *xwayland, int wm_fd) { struct weston_xserver *wxs = (struct weston_xserver *)xwayland; wxs->wm = weston_wm_create(wxs, wm_fd); - wxs->client = client; } static void @@ -319,7 +316,6 @@ weston_xwayland_xserver_exited(struct weston_xwayland *xwayland, { struct weston_xserver *wxs = (struct weston_xserver *)xwayland; - wxs->pid = 0; wxs->client = NULL; wxs->abstract_source = diff --git a/xwayland/xwayland.h b/xwayland/xwayland.h index 270dc99b..59c5b652 100644 --- a/xwayland/xwayland.h +++ b/xwayland/xwayland.h @@ -43,7 +43,6 @@ struct weston_xserver { int unix_fd; struct wl_event_source *unix_source; int display; - pid_t pid; struct wl_client *client; struct weston_compositor *compositor; struct weston_wm *wm;