xwayland: embed wlr_xwayland_server_options in server struct

As more options are added, more fields will be duplicated. Let's
just embed the struct in wlr_xwayland_server so that we don't need
to keep both in sync.
This commit is contained in:
Simon Ser 2021-06-25 11:46:57 +02:00 committed by Kenny Levinsen
parent 4b316a3823
commit 770a561bce
2 changed files with 12 additions and 14 deletions

View file

@ -19,6 +19,11 @@
struct wlr_xwm; struct wlr_xwm;
struct wlr_xwayland_cursor; struct wlr_xwayland_cursor;
struct wlr_xwayland_server_options {
bool lazy;
bool enable_wm;
};
struct wlr_xwayland_server { struct wlr_xwayland_server {
pid_t pid; pid_t pid;
struct wl_client *client; struct wl_client *client;
@ -33,8 +38,7 @@ struct wlr_xwayland_server {
char display_name[16]; char display_name[16];
int x_fd[2]; int x_fd[2];
struct wl_event_source *x_fd_read_event[2]; struct wl_event_source *x_fd_read_event[2];
bool lazy; struct wlr_xwayland_server_options options;
bool enable_wm;
struct wl_display *wl_display; struct wl_display *wl_display;
@ -49,11 +53,6 @@ struct wlr_xwayland_server {
void *data; void *data;
}; };
struct wlr_xwayland_server_options {
bool lazy;
bool enable_wm;
};
struct wlr_xwayland_server_ready_event { struct wlr_xwayland_server_ready_event {
struct wlr_xwayland_server *server; struct wlr_xwayland_server *server;
int wm_fd; int wm_fd;

View file

@ -32,7 +32,7 @@ noreturn static void exec_xwayland(struct wlr_xwayland_server *server) {
wlr_log(WLR_ERROR, "Failed to unset CLOEXEC on FD"); wlr_log(WLR_ERROR, "Failed to unset CLOEXEC on FD");
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
if (server->enable_wm && !set_cloexec(server->wm_fd[1], false)) { if (server->options.enable_wm && !set_cloexec(server->wm_fd[1], false)) {
wlr_log(WLR_ERROR, "Failed to unset CLOEXEC on FD"); wlr_log(WLR_ERROR, "Failed to unset CLOEXEC on FD");
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
@ -67,7 +67,7 @@ noreturn static void exec_xwayland(struct wlr_xwayland_server *server) {
#endif #endif
char wmfd[16]; char wmfd[16];
if (server->enable_wm) { if (server->options.enable_wm) {
snprintf(wmfd, sizeof(wmfd), "%d", server->wm_fd[1]); snprintf(wmfd, sizeof(wmfd), "%d", server->wm_fd[1]);
argv[i++] = "-wm"; argv[i++] = "-wm";
argv[i++] = wmfd; argv[i++] = wmfd;
@ -187,7 +187,7 @@ static void handle_client_destroy(struct wl_listener *listener, void *data) {
server_finish_process(server); server_finish_process(server);
if (time(NULL) - server->server_start > 5) { if (time(NULL) - server->server_start > 5) {
if (server->lazy) { if (server->options.lazy) {
wlr_log(WLR_INFO, "Restarting Xwayland (lazy)"); wlr_log(WLR_INFO, "Restarting Xwayland (lazy)");
server_start_lazy(server); server_start_lazy(server);
} else { } else {
@ -287,7 +287,7 @@ static bool server_start(struct wlr_xwayland_server *server) {
server_finish_process(server); server_finish_process(server);
return false; return false;
} }
if (server->enable_wm) { if (server->options.enable_wm) {
if (socketpair(AF_UNIX, SOCK_STREAM, 0, server->wm_fd) != 0) { if (socketpair(AF_UNIX, SOCK_STREAM, 0, server->wm_fd) != 0) {
wlr_log_errno(WLR_ERROR, "socketpair failed"); wlr_log_errno(WLR_ERROR, "socketpair failed");
server_finish_process(server); server_finish_process(server);
@ -443,8 +443,7 @@ struct wlr_xwayland_server *wlr_xwayland_server_create(
} }
server->wl_display = wl_display; server->wl_display = wl_display;
server->lazy = options->lazy; server->options = *options;
server->enable_wm = options->enable_wm;
server->x_fd[0] = server->x_fd[1] = -1; server->x_fd[0] = server->x_fd[1] = -1;
server->wl_fd[0] = server->wl_fd[1] = -1; server->wl_fd[0] = server->wl_fd[1] = -1;
@ -457,7 +456,7 @@ struct wlr_xwayland_server *wlr_xwayland_server_create(
goto error_alloc; goto error_alloc;
} }
if (server->lazy) { if (server->options.lazy) {
if (!server_start_lazy(server)) { if (!server_start_lazy(server)) {
goto error_display; goto error_display;
} }