xwayland: Add client destroy listener
Make sure that we consistently mark the client as NULL when it's destroyed, and destroy it on process exit as well, so we have a consistent state. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
506901d918
commit
eff5e7e0f3
|
@ -41,6 +41,15 @@
|
|||
#include "shared/helpers.h"
|
||||
#include "shared/string-helpers.h"
|
||||
|
||||
static void
|
||||
weston_xserver_client_destroyed(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct weston_xserver *wxs =
|
||||
container_of(listener, struct weston_xserver, client_destroy_listener);
|
||||
|
||||
wxs->client = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
|
||||
{
|
||||
|
@ -54,6 +63,9 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
|
|||
weston_log("Failed to spawn the Xwayland server\n");
|
||||
return 1;
|
||||
}
|
||||
wxs->client_destroy_listener.notify = weston_xserver_client_destroyed;
|
||||
wl_client_add_destroy_late_listener(wxs->client,
|
||||
&wxs->client_destroy_listener);
|
||||
|
||||
wl_event_source_remove(wxs->abstract_source);
|
||||
wl_event_source_remove(wxs->unix_source);
|
||||
|
@ -70,7 +82,10 @@ weston_xserver_shutdown(struct weston_xserver *wxs)
|
|||
unlink(path);
|
||||
snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display);
|
||||
unlink(path);
|
||||
if (wxs->client == NULL) {
|
||||
if (wxs->client) {
|
||||
wl_client_destroy(wxs->client);
|
||||
wxs->client = NULL;
|
||||
} else {
|
||||
wl_event_source_remove(wxs->abstract_source);
|
||||
wl_event_source_remove(wxs->unix_source);
|
||||
}
|
||||
|
@ -315,6 +330,8 @@ weston_xwayland_xserver_exited(struct weston_xwayland *xwayland)
|
|||
{
|
||||
struct weston_xserver *wxs = (struct weston_xserver *)xwayland;
|
||||
|
||||
if (wxs->client)
|
||||
wl_client_destroy(wxs->client);
|
||||
wxs->client = NULL;
|
||||
|
||||
wxs->abstract_source =
|
||||
|
|
|
@ -44,9 +44,10 @@ struct weston_xserver {
|
|||
struct wl_event_source *unix_source;
|
||||
int display;
|
||||
struct wl_client *client;
|
||||
struct wl_listener client_destroy_listener;
|
||||
struct weston_compositor *compositor;
|
||||
struct weston_wm *wm;
|
||||
struct wl_listener compositor_destroy_listener;
|
||||
struct weston_wm *wm;
|
||||
weston_xwayland_spawn_xserver_func_t spawn_func;
|
||||
void *user_data;
|
||||
|
||||
|
|
Loading…
Reference in New Issue