mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-26 11:39:47 +01:00
xwayland: add option to disable WM
This commit is contained in:
parent
27609ba0d9
commit
2176c63856
3 changed files with 48 additions and 13 deletions
|
@ -34,6 +34,7 @@ struct wlr_xwayland_server {
|
|||
int x_fd[2];
|
||||
struct wl_event_source *x_fd_read_event[2];
|
||||
bool lazy;
|
||||
bool enable_wm;
|
||||
|
||||
struct wl_display *wl_display;
|
||||
|
||||
|
@ -48,6 +49,11 @@ struct wlr_xwayland_server {
|
|||
void *data;
|
||||
};
|
||||
|
||||
struct wlr_xwayland_server_options {
|
||||
bool lazy;
|
||||
bool enable_wm;
|
||||
};
|
||||
|
||||
struct wlr_xwayland_server_ready_event {
|
||||
struct wlr_xwayland_server *server;
|
||||
int wm_fd;
|
||||
|
@ -216,7 +222,7 @@ struct wlr_xwayland_resize_event {
|
|||
};
|
||||
|
||||
struct wlr_xwayland_server *wlr_xwayland_server_create(
|
||||
struct wl_display *display, bool lazy);
|
||||
struct wl_display *display, struct wlr_xwayland_server_options *options);
|
||||
void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server);
|
||||
|
||||
/** Create an Xwayland server and XWM.
|
||||
|
|
|
@ -47,8 +47,12 @@ static int fill_arg(char ***argv, const char *fmt, ...) {
|
|||
noreturn static void exec_xwayland(struct wlr_xwayland_server *server) {
|
||||
if (!set_cloexec(server->x_fd[0], false) ||
|
||||
!set_cloexec(server->x_fd[1], false) ||
|
||||
!set_cloexec(server->wm_fd[1], false) ||
|
||||
!set_cloexec(server->wl_fd[1], false)) {
|
||||
wlr_log(WLR_ERROR, "Failed to unset CLOEXEC on FD");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (server->enable_wm && !set_cloexec(server->wm_fd[1], false)) {
|
||||
wlr_log(WLR_ERROR, "Failed to unset CLOEXEC on FD");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -67,11 +71,19 @@ noreturn static void exec_xwayland(struct wlr_xwayland_server *server) {
|
|||
|
||||
if (fill_arg(&cur_arg, ":%d", server->display) < 0 ||
|
||||
fill_arg(&cur_arg, "%d", server->x_fd[0]) < 0 ||
|
||||
fill_arg(&cur_arg, "%d", server->x_fd[1]) < 0 ||
|
||||
fill_arg(&cur_arg, "%d", server->wm_fd[1]) < 0) {
|
||||
fill_arg(&cur_arg, "%d", server->x_fd[1]) < 0) {
|
||||
wlr_log_errno(WLR_ERROR, "alloc/print failure");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (server->enable_wm) {
|
||||
if (fill_arg(&cur_arg, "%d", server->wm_fd[1]) < 0) {
|
||||
wlr_log_errno(WLR_ERROR, "alloc/print failure");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
cur_arg++;
|
||||
*cur_arg = NULL;
|
||||
}
|
||||
|
||||
char wayland_socket_str[16];
|
||||
snprintf(wayland_socket_str, sizeof(wayland_socket_str), "%d", server->wl_fd[1]);
|
||||
|
@ -249,19 +261,30 @@ static bool server_start_display(struct wlr_xwayland_server *server,
|
|||
}
|
||||
|
||||
static bool server_start(struct wlr_xwayland_server *server) {
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, server->wl_fd) != 0 ||
|
||||
socketpair(AF_UNIX, SOCK_STREAM, 0, server->wm_fd) != 0) {
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, server->wl_fd) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "socketpair failed");
|
||||
server_finish_process(server);
|
||||
return false;
|
||||
}
|
||||
if (!set_cloexec(server->wl_fd[0], true) ||
|
||||
!set_cloexec(server->wl_fd[1], true) ||
|
||||
!set_cloexec(server->wm_fd[0], true) ||
|
||||
!set_cloexec(server->wm_fd[1], true)) {
|
||||
!set_cloexec(server->wl_fd[1], true)) {
|
||||
wlr_log(WLR_ERROR, "Failed to set O_CLOEXEC on socket");
|
||||
server_finish_process(server);
|
||||
return false;
|
||||
}
|
||||
if (server->enable_wm) {
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, server->wm_fd) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "socketpair failed");
|
||||
server_finish_process(server);
|
||||
return false;
|
||||
}
|
||||
if (!set_cloexec(server->wm_fd[0], true) ||
|
||||
!set_cloexec(server->wm_fd[1], true)) {
|
||||
wlr_log(WLR_ERROR, "Failed to set O_CLOEXEC on socket");
|
||||
server_finish_process(server);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
server->server_start = time(NULL);
|
||||
|
||||
|
@ -319,7 +342,7 @@ static bool server_start(struct wlr_xwayland_server *server) {
|
|||
/* close child fds */
|
||||
/* remain managing x sockets for lazy start */
|
||||
close(server->wl_fd[1]);
|
||||
close(server->wm_fd[1]);
|
||||
safe_close(server->wm_fd[1]);
|
||||
server->wl_fd[1] = server->wm_fd[1] = -1;
|
||||
|
||||
return true;
|
||||
|
@ -359,7 +382,8 @@ void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server) {
|
|||
}
|
||||
|
||||
struct wlr_xwayland_server *wlr_xwayland_server_create(
|
||||
struct wl_display *wl_display, bool lazy) {
|
||||
struct wl_display *wl_display,
|
||||
struct wlr_xwayland_server_options *options) {
|
||||
struct wlr_xwayland_server *server =
|
||||
calloc(1, sizeof(struct wlr_xwayland_server));
|
||||
if (!server) {
|
||||
|
@ -367,7 +391,8 @@ struct wlr_xwayland_server *wlr_xwayland_server_create(
|
|||
}
|
||||
|
||||
server->wl_display = wl_display;
|
||||
server->lazy = lazy;
|
||||
server->lazy = options->lazy;
|
||||
server->enable_wm = options->enable_wm;
|
||||
|
||||
server->x_fd[0] = server->x_fd[1] = -1;
|
||||
server->wl_fd[0] = server->wl_fd[1] = -1;
|
||||
|
|
|
@ -85,7 +85,11 @@ struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
|
|||
wl_signal_init(&xwayland->events.new_surface);
|
||||
wl_signal_init(&xwayland->events.ready);
|
||||
|
||||
xwayland->server = wlr_xwayland_server_create(wl_display, lazy);
|
||||
struct wlr_xwayland_server_options options = {
|
||||
.lazy = lazy,
|
||||
.enable_wm = true,
|
||||
};
|
||||
xwayland->server = wlr_xwayland_server_create(wl_display, &options);
|
||||
if (xwayland->server == NULL) {
|
||||
free(xwayland->server);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue