|
|
@ -1,4 +1,5 @@
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <signal.h>
|
|
|
@ -37,15 +38,14 @@ static void handle_server_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
static void handle_server_start(struct wl_listener *listener, void *data) {
|
|
|
|
static void handle_server_start(struct wl_listener *listener, void *data) {
|
|
|
|
struct wlr_xwayland *xwayland =
|
|
|
|
struct wlr_xwayland *xwayland =
|
|
|
|
wl_container_of(listener, xwayland, server_start);
|
|
|
|
wl_container_of(listener, xwayland, server_start);
|
|
|
|
|
|
|
|
if (xwayland->shell_v1 != NULL) {
|
|
|
|
wlr_xwayland_shell_v1_set_client(xwayland->shell_v1, xwayland->server->client);
|
|
|
|
wlr_xwayland_shell_v1_set_client(xwayland->shell_v1, xwayland->server->client);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_server_ready(struct wl_listener *listener, void *data) {
|
|
|
|
static void xwayland_mark_ready(struct wlr_xwayland *xwayland) {
|
|
|
|
struct wlr_xwayland *xwayland =
|
|
|
|
assert(xwayland->server->wm_fd[0] >= 0);
|
|
|
|
wl_container_of(listener, xwayland, server_ready);
|
|
|
|
xwayland->xwm = xwm_create(xwayland, xwayland->server->wm_fd[0]);
|
|
|
|
struct wlr_xwayland_server_ready_event *event = data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->xwm = xwm_create(xwayland, event->wm_fd);
|
|
|
|
|
|
|
|
if (!xwayland->xwm) {
|
|
|
|
if (!xwayland->xwm) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -63,6 +63,12 @@ static void handle_server_ready(struct wl_listener *listener, void *data) {
|
|
|
|
wl_signal_emit_mutable(&xwayland->events.ready, NULL);
|
|
|
|
wl_signal_emit_mutable(&xwayland->events.ready, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_server_ready(struct wl_listener *listener, void *data) {
|
|
|
|
|
|
|
|
struct wlr_xwayland *xwayland =
|
|
|
|
|
|
|
|
wl_container_of(listener, xwayland, server_ready);
|
|
|
|
|
|
|
|
xwayland_mark_ready(xwayland);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_shell_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
static void handle_shell_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
struct wlr_xwayland *xwayland =
|
|
|
|
struct wlr_xwayland *xwayland =
|
|
|
|
wl_container_of(listener, xwayland, shell_destroy);
|
|
|
|
wl_container_of(listener, xwayland, shell_destroy);
|
|
|
@ -81,14 +87,16 @@ void wlr_xwayland_destroy(struct wlr_xwayland *xwayland) {
|
|
|
|
free(xwayland->cursor);
|
|
|
|
free(xwayland->cursor);
|
|
|
|
|
|
|
|
|
|
|
|
wlr_xwayland_set_seat(xwayland, NULL);
|
|
|
|
wlr_xwayland_set_seat(xwayland, NULL);
|
|
|
|
|
|
|
|
if (xwayland->own_server) {
|
|
|
|
wlr_xwayland_server_destroy(xwayland->server);
|
|
|
|
wlr_xwayland_server_destroy(xwayland->server);
|
|
|
|
|
|
|
|
}
|
|
|
|
xwayland->server = NULL;
|
|
|
|
xwayland->server = NULL;
|
|
|
|
wlr_xwayland_shell_v1_destroy(xwayland->shell_v1);
|
|
|
|
wlr_xwayland_shell_v1_destroy(xwayland->shell_v1);
|
|
|
|
free(xwayland);
|
|
|
|
free(xwayland);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
|
|
|
|
struct wlr_xwayland *wlr_xwayland_create_with_server(struct wl_display *wl_display,
|
|
|
|
struct wlr_compositor *compositor, bool lazy) {
|
|
|
|
struct wlr_compositor *compositor, struct wlr_xwayland_server *server) {
|
|
|
|
struct wlr_xwayland *xwayland = calloc(1, sizeof(*xwayland));
|
|
|
|
struct wlr_xwayland *xwayland = calloc(1, sizeof(*xwayland));
|
|
|
|
if (!xwayland) {
|
|
|
|
if (!xwayland) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
@ -101,9 +109,31 @@ struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
|
|
|
|
wl_signal_init(&xwayland->events.ready);
|
|
|
|
wl_signal_init(&xwayland->events.ready);
|
|
|
|
wl_signal_init(&xwayland->events.remove_startup_info);
|
|
|
|
wl_signal_init(&xwayland->events.remove_startup_info);
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->shell_v1 = wlr_xwayland_shell_v1_create(wl_display, 1);
|
|
|
|
xwayland->server = server;
|
|
|
|
if (xwayland->shell_v1 == NULL) {
|
|
|
|
xwayland->display_name = xwayland->server->display_name;
|
|
|
|
free(xwayland);
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->server_destroy.notify = handle_server_destroy;
|
|
|
|
|
|
|
|
wl_signal_add(&xwayland->server->events.destroy, &xwayland->server_destroy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->server_start.notify = handle_server_start;
|
|
|
|
|
|
|
|
wl_signal_add(&xwayland->server->events.start, &xwayland->server_start);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->server_ready.notify = handle_server_ready;
|
|
|
|
|
|
|
|
wl_signal_add(&xwayland->server->events.ready, &xwayland->server_ready);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_init(&xwayland->shell_destroy.link);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (server->ready) {
|
|
|
|
|
|
|
|
xwayland_mark_ready(xwayland);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return xwayland;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
|
|
|
|
|
|
|
|
struct wlr_compositor *compositor, bool lazy) {
|
|
|
|
|
|
|
|
struct wlr_xwayland_shell_v1 *shell_v1 = wlr_xwayland_shell_v1_create(wl_display, 1);
|
|
|
|
|
|
|
|
if (shell_v1 == NULL) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -114,28 +144,29 @@ struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
|
|
|
|
.terminate_delay = lazy ? 10 : 0,
|
|
|
|
.terminate_delay = lazy ? 10 : 0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
};
|
|
|
|
xwayland->server = wlr_xwayland_server_create(wl_display, &options);
|
|
|
|
struct wlr_xwayland_server *server = wlr_xwayland_server_create(wl_display, &options);
|
|
|
|
if (xwayland->server == NULL) {
|
|
|
|
if (server == NULL) {
|
|
|
|
wlr_xwayland_shell_v1_destroy(xwayland->shell_v1);
|
|
|
|
goto error_shell_v1;
|
|
|
|
free(xwayland);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->display_name = xwayland->server->display_name;
|
|
|
|
struct wlr_xwayland *xwayland = wlr_xwayland_create_with_server(wl_display, compositor, server);
|
|
|
|
|
|
|
|
if (xwayland == NULL) {
|
|
|
|
xwayland->server_destroy.notify = handle_server_destroy;
|
|
|
|
goto error_server;
|
|
|
|
wl_signal_add(&xwayland->server->events.destroy, &xwayland->server_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->server_start.notify = handle_server_start;
|
|
|
|
|
|
|
|
wl_signal_add(&xwayland->server->events.start, &xwayland->server_start);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->server_ready.notify = handle_server_ready;
|
|
|
|
xwayland->shell_v1 = shell_v1;
|
|
|
|
wl_signal_add(&xwayland->server->events.ready, &xwayland->server_ready);
|
|
|
|
xwayland->own_server = true;
|
|
|
|
|
|
|
|
|
|
|
|
xwayland->shell_destroy.notify = handle_shell_destroy;
|
|
|
|
xwayland->shell_destroy.notify = handle_shell_destroy;
|
|
|
|
wl_signal_add(&xwayland->shell_v1->events.destroy, &xwayland->shell_destroy);
|
|
|
|
wl_signal_add(&xwayland->shell_v1->events.destroy, &xwayland->shell_destroy);
|
|
|
|
|
|
|
|
|
|
|
|
return xwayland;
|
|
|
|
return xwayland;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error_server:
|
|
|
|
|
|
|
|
wlr_xwayland_server_destroy(server);
|
|
|
|
|
|
|
|
error_shell_v1:
|
|
|
|
|
|
|
|
wlr_xwayland_shell_v1_destroy(shell_v1);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_xwayland_set_cursor(struct wlr_xwayland *xwayland,
|
|
|
|
void wlr_xwayland_set_cursor(struct wlr_xwayland *xwayland,
|
|
|
|