diff options
author | Josh Rahm <rahm@google.com> | 2024-02-15 22:59:32 -0700 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2024-02-15 22:59:32 -0700 |
commit | f4ed2dd61b53ea45b05f3e8f4ebcce24188d32bd (patch) | |
tree | 1537f0b4883eab358a8506af8c5143530bf6cef1 | |
parent | 46999e5c69e9e46d78f5c284a7dcc250a964274a (diff) | |
download | wetterhorn-f4ed2dd61b53ea45b05f3e8f4ebcce24188d32bd.tar.gz wetterhorn-f4ed2dd61b53ea45b05f3e8f4ebcce24188d32bd.tar.bz2 wetterhorn-f4ed2dd61b53ea45b05f3e8f4ebcce24188d32bd.zip |
Add some support for xwayland
-rw-r--r-- | harness/src/wl.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/harness/src/wl.c b/harness/src/wl.c index 474123a..d01797c 100644 --- a/harness/src/wl.c +++ b/harness/src/wl.c @@ -253,7 +253,7 @@ static void server_new_keyboard(struct tinywl_server *server, /* We need to prepare an XKB keymap and assign it to the keyboard. This * assumes the defaults (e.g. layout = "us"). */ struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - struct xkb_rule_names names = (struct xkb_rule_names) { 0 }; + struct xkb_rule_names names = (struct xkb_rule_names){0}; names.layout = "jr"; names.variant = "jdvprk"; names.options = "numpad:mac"; @@ -907,7 +907,7 @@ int main(int argc, char *argv[]) return 0; } - struct tinywl_server server; + struct tinywl_server server = {0}; if (load_plugin_from_file(argc, argv, plugin, &server.plugin)) { fprintf(stderr, "Failed to read plugin from file.\n"); @@ -938,7 +938,7 @@ int main(int argc, char *argv[]) * to dig your fingers in and play with their behavior if you want. Note that * the clients cannot set the selection directly without compositor approval, * see the handling of the request_set_selection event below.*/ - struct wlr_compositor* compositor; + struct wlr_compositor *compositor; compositor = wlr_compositor_create(server.wl_display, server.renderer); wlr_data_device_manager_create(server.wl_display); @@ -1032,6 +1032,20 @@ int main(int argc, char *argv[]) wl_display_destroy(server.wl_display); return 1; } + /* Run the Wayland event loop. This does not return until you exit the + * compositor. Starting the backend rigged up all of the necessary event + * loop configuration to listen to libinput events, DRM events, generate + * frame events at the refresh rate, and so on. */ + wlr_log(WLR_INFO, "Running Wayland compositor on WAYLAND_DISPLAY=%s", socket); + struct wlr_xwayland *xwayland; + if ((xwayland = wlr_xwayland_create(server.wl_display, compositor, false))) { + printf("======= DISPLAY=%s\n", xwayland->display_name); + setenv("DISPLAY", xwayland->display_name, 1); + } + else { + fprintf(stderr, + "======= failed to setup XWayland X server. Continuing without it.\n"); + } /* Set the WAYLAND_DISPLAY environment variable to our socket and run the * startup command if requested. */ @@ -1041,12 +1055,7 @@ int main(int argc, char *argv[]) execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void *)NULL); } } - /* Run the Wayland event loop. This does not return until you exit the - * compositor. Starting the backend rigged up all of the necessary event - * loop configuration to listen to libinput events, DRM events, generate - * frame events at the refresh rate, and so on. */ - wlr_log(WLR_INFO, "Running Wayland compositor on WAYLAND_DISPLAY=%s", socket); - wlr_xwayland_create(server.wl_display, compositor, false); + wl_display_run(server.wl_display); /* Once wl_display_run returns, we shut down the server. */ |