frontend: Return user-data pointer from Xwayland init

Return a void * from wet_load_xwayland, so we can later pass it back to
explicitly call the cleanup.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-05-01 19:15:52 +01:00
parent eff5e7e0f3
commit 10f6b99ac0
3 changed files with 13 additions and 11 deletions

View File

@ -3740,10 +3740,10 @@ copy_command_line(int argc, char * const argv[])
} }
#if !defined(BUILD_XWAYLAND) #if !defined(BUILD_XWAYLAND)
int void *
wet_load_xwayland(struct weston_compositor *comp) wet_load_xwayland(struct weston_compositor *comp)
{ {
return -1; return NULL;
} }
#endif #endif
@ -3882,6 +3882,7 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
struct weston_log_context *log_ctx = NULL; struct weston_log_context *log_ctx = NULL;
struct weston_log_subscriber *logger = NULL; struct weston_log_subscriber *logger = NULL;
struct weston_log_subscriber *flight_rec = NULL; struct weston_log_subscriber *flight_rec = NULL;
void *wet_xwl = NULL;
sigset_t mask; sigset_t mask;
struct sigaction action; struct sigaction action;
@ -4136,7 +4137,8 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
false); false);
} }
if (xwayland) { if (xwayland) {
if (wet_load_xwayland(wet.compositor) < 0) wet_xwl = wet_load_xwayland(wet.compositor);
if (!wet_xwl)
goto out; goto out;
} }

View File

@ -88,7 +88,7 @@ wet_get_libexec_path(const char *name);
char * char *
wet_get_bindir_path(const char *name); wet_get_bindir_path(const char *name);
int void *
wet_load_xwayland(struct weston_compositor *comp); wet_load_xwayland(struct weston_compositor *comp);
struct text_backend; struct text_backend;

View File

@ -238,7 +238,7 @@ wxw_compositor_destroy(struct wl_listener *listener, void *data)
free(wxw); free(wxw);
} }
int void *
wet_load_xwayland(struct weston_compositor *comp) wet_load_xwayland(struct weston_compositor *comp)
{ {
const struct weston_xwayland_api *api; const struct weston_xwayland_api *api;
@ -246,32 +246,32 @@ wet_load_xwayland(struct weston_compositor *comp)
struct wet_xwayland *wxw; struct wet_xwayland *wxw;
if (weston_compositor_load_xwayland(comp) < 0) if (weston_compositor_load_xwayland(comp) < 0)
return -1; return NULL;
api = weston_xwayland_get_api(comp); api = weston_xwayland_get_api(comp);
if (!api) { if (!api) {
weston_log("Failed to get the xwayland module API.\n"); weston_log("Failed to get the xwayland module API.\n");
return -1; return NULL;
} }
xwayland = api->get(comp); xwayland = api->get(comp);
if (!xwayland) { if (!xwayland) {
weston_log("Failed to get the xwayland object.\n"); weston_log("Failed to get the xwayland object.\n");
return -1; return NULL;
} }
wxw = zalloc(sizeof *wxw); wxw = zalloc(sizeof *wxw);
if (!wxw) if (!wxw)
return -1; return NULL;
wxw->compositor = comp; wxw->compositor = comp;
wxw->api = api; wxw->api = api;
wxw->xwayland = xwayland; wxw->xwayland = xwayland;
wxw->compositor_destroy_listener.notify = wxw_compositor_destroy; wxw->compositor_destroy_listener.notify = wxw_compositor_destroy;
if (api->listen(xwayland, wxw, spawn_xserver) < 0) if (api->listen(xwayland, wxw, spawn_xserver) < 0)
return -1; return NULL;
wl_signal_add(&comp->destroy_signal, &wxw->compositor_destroy_listener); wl_signal_add(&comp->destroy_signal, &wxw->compositor_destroy_listener);
return 0; return wxw;
} }