xwayland: Only pass Xwayland wl_client to libweston
Remove all handling of process/PID internals from libweston's Xwayland launcher, and keep this only in the frontend. libweston now only sees the wl_client and nothing else. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
d5bcc26078
commit
e64232a808
@ -52,7 +52,6 @@ struct wet_xwayland {
|
|||||||
const struct weston_xwayland_api *api;
|
const struct weston_xwayland_api *api;
|
||||||
struct weston_xwayland *xwayland;
|
struct weston_xwayland *xwayland;
|
||||||
struct wl_event_source *display_fd_source;
|
struct wl_event_source *display_fd_source;
|
||||||
struct wl_client *client;
|
|
||||||
int wm_fd;
|
int wm_fd;
|
||||||
struct wet_process *process;
|
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'))
|
if (n <= 0 || (n > 0 && buf[n - 1] != '\n'))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
wxw->api->xserver_loaded(wxw->xwayland, wxw->client, wxw->wm_fd);
|
wxw->api->xserver_loaded(wxw->xwayland, wxw->wm_fd);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
wl_event_source_remove(wxw->display_fd_source);
|
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);
|
assert(process == wxw->process);
|
||||||
|
|
||||||
wxw->api->xserver_exited(wxw->xwayland, status);
|
wxw->api->xserver_exited(wxw->xwayland, status);
|
||||||
wxw->client = NULL;
|
|
||||||
wxw->process = 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)
|
spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd)
|
||||||
{
|
{
|
||||||
struct wet_xwayland *wxw = user_data;
|
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;
|
char *xserver = NULL;
|
||||||
struct weston_config *config = wet_get_config(wxw->compositor);
|
struct weston_config *config = wet_get_config(wxw->compositor);
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
|
struct wl_client *client;
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
struct custom_env child_env;
|
struct custom_env child_env;
|
||||||
int no_cloexec_fds[5];
|
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;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxw->client = wl_client_create(wxw->compositor->wl_display,
|
client = wl_client_create(wxw->compositor->wl_display,
|
||||||
wayland_socket.fds[0]);
|
wayland_socket.fds[0]);
|
||||||
if (!wxw->client) {
|
if (!client) {
|
||||||
weston_log("Couldn't create client for Xwayland\n");
|
weston_log("Couldn't create client for Xwayland\n");
|
||||||
goto err_proc;
|
goto err_proc;
|
||||||
}
|
}
|
||||||
@ -206,7 +205,7 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd
|
|||||||
|
|
||||||
free(xserver);
|
free(xserver);
|
||||||
|
|
||||||
return wxw->process->pid;
|
return client;
|
||||||
|
|
||||||
|
|
||||||
err_proc:
|
err_proc:
|
||||||
@ -217,7 +216,7 @@ err:
|
|||||||
fdstr_close_all(&x11_wm_socket);
|
fdstr_close_all(&x11_wm_socket);
|
||||||
fdstr_close_all(&wayland_socket);
|
fdstr_close_all(&wayland_socket);
|
||||||
free(wxw->process);
|
free(wxw->process);
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -37,10 +37,10 @@ extern "C" {
|
|||||||
struct weston_compositor;
|
struct weston_compositor;
|
||||||
struct weston_xwayland;
|
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"
|
#define WESTON_XWAYLAND_SURFACE_API_NAME "weston_xwayland_surface_v1"
|
||||||
|
|
||||||
typedef pid_t
|
typedef struct wl_client *
|
||||||
(*weston_xwayland_spawn_xserver_func_t)(
|
(*weston_xwayland_spawn_xserver_func_t)(
|
||||||
void *user_data, const char *display, int abstract_fd, int unix_fd);
|
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.
|
/** Notify the Xwayland module that the Xwayland server is loaded.
|
||||||
*
|
*
|
||||||
* After the Xwayland server process has been spawned it will notify
|
* After the Xwayland server process has been spawned it will notify
|
||||||
* the parent that is has finished the initialization by sending a
|
* the parent that it has finished the initialization by writing to
|
||||||
* SIGUSR1 signal.
|
* the displayfd passed.
|
||||||
* The caller should listen for that signal and call this function
|
* The caller should listen for that write and call this function
|
||||||
* when it is received.
|
* when it is received.
|
||||||
*
|
*
|
||||||
* \param xwayland The Xwayland context object.
|
* \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.
|
* \param wm_fd The file descriptor for the wm.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(*xserver_loaded)(struct weston_xwayland *xwayland,
|
(*xserver_loaded)(struct weston_xwayland *xwayland, int wm_fd);
|
||||||
struct wl_client *client, int wm_fd);
|
|
||||||
|
|
||||||
/** Notify the Xwayland module that the Xwayland server has exited.
|
/** Notify the Xwayland module that the Xwayland server has exited.
|
||||||
*
|
*
|
||||||
|
@ -49,13 +49,12 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
|
|||||||
|
|
||||||
snprintf(display, sizeof display, ":%d", wxs->display);
|
snprintf(display, sizeof display, ":%d", wxs->display);
|
||||||
|
|
||||||
wxs->pid = wxs->spawn_func(wxs->user_data, display, wxs->abstract_fd, wxs->unix_fd);
|
wxs->client = wxs->spawn_func(wxs->user_data, display, wxs->abstract_fd, wxs->unix_fd);
|
||||||
if (wxs->pid == -1) {
|
if (wxs->client == NULL) {
|
||||||
weston_log("Failed to spawn the Xwayland server\n");
|
weston_log("Failed to spawn the Xwayland server\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
weston_log("Spawned Xwayland server, pid %d\n", wxs->pid);
|
|
||||||
wl_event_source_remove(wxs->abstract_source);
|
wl_event_source_remove(wxs->abstract_source);
|
||||||
wl_event_source_remove(wxs->unix_source);
|
wl_event_source_remove(wxs->unix_source);
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ weston_xserver_shutdown(struct weston_xserver *wxs)
|
|||||||
unlink(path);
|
unlink(path);
|
||||||
snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display);
|
snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display);
|
||||||
unlink(path);
|
unlink(path);
|
||||||
if (wxs->pid == 0) {
|
if (wxs->client == NULL) {
|
||||||
wl_event_source_remove(wxs->abstract_source);
|
wl_event_source_remove(wxs->abstract_source);
|
||||||
wl_event_source_remove(wxs->unix_source);
|
wl_event_source_remove(wxs->unix_source);
|
||||||
}
|
}
|
||||||
@ -305,12 +304,10 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
weston_xwayland_xserver_loaded(struct weston_xwayland *xwayland,
|
weston_xwayland_xserver_loaded(struct weston_xwayland *xwayland, int wm_fd)
|
||||||
struct wl_client *client, int wm_fd)
|
|
||||||
{
|
{
|
||||||
struct weston_xserver *wxs = (struct weston_xserver *)xwayland;
|
struct weston_xserver *wxs = (struct weston_xserver *)xwayland;
|
||||||
wxs->wm = weston_wm_create(wxs, wm_fd);
|
wxs->wm = weston_wm_create(wxs, wm_fd);
|
||||||
wxs->client = client;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -319,7 +316,6 @@ weston_xwayland_xserver_exited(struct weston_xwayland *xwayland,
|
|||||||
{
|
{
|
||||||
struct weston_xserver *wxs = (struct weston_xserver *)xwayland;
|
struct weston_xserver *wxs = (struct weston_xserver *)xwayland;
|
||||||
|
|
||||||
wxs->pid = 0;
|
|
||||||
wxs->client = NULL;
|
wxs->client = NULL;
|
||||||
|
|
||||||
wxs->abstract_source =
|
wxs->abstract_source =
|
||||||
|
@ -43,7 +43,6 @@ struct weston_xserver {
|
|||||||
int unix_fd;
|
int unix_fd;
|
||||||
struct wl_event_source *unix_source;
|
struct wl_event_source *unix_source;
|
||||||
int display;
|
int display;
|
||||||
pid_t pid;
|
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
struct weston_compositor *compositor;
|
struct weston_compositor *compositor;
|
||||||
struct weston_wm *wm;
|
struct weston_wm *wm;
|
||||||
|
Loading…
Reference in New Issue
Block a user