diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/xwayland.c | 21 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/main.c | 2 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/server.c | 73 | ||||
-rw-r--r-- | sway/sway.5.scd | 4 |
7 files changed, 67 insertions, 36 deletions
diff --git a/sway/commands.c b/sway/commands.c index 4e524a88..1d190e0b 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -101,6 +101,7 @@ static struct cmd_handler config_handlers[] = { { "swaybg_command", cmd_swaybg_command }, { "swaynag_command", cmd_swaynag_command }, { "workspace_layout", cmd_workspace_layout }, + { "xwayland", cmd_xwayland }, }; /* Runtime-only commands. Keep alphabetized */ diff --git a/sway/commands/xwayland.c b/sway/commands/xwayland.c new file mode 100644 index 00000000..03a0121b --- /dev/null +++ b/sway/commands/xwayland.c @@ -0,0 +1,21 @@ +#include "sway/config.h" +#include "log.h" +#include "sway/commands.h" +#include "sway/server.h" +#include "util.h" + +struct cmd_results *cmd_xwayland(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "xwayland", EXPECTED_EQUAL_TO, 1))) { + return error; + } + +#ifdef HAVE_XWAYLAND + config->xwayland = parse_boolean(argv[0], config->xwayland); +#else + wlr_log(WLR_INFO, "Ignoring `xwayland` command, " + "sway hasn't been built with Xwayland support"); +#endif + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/config.c b/sway/config.c index 5ca4806c..18fee404 100644 --- a/sway/config.c +++ b/sway/config.c @@ -204,6 +204,7 @@ static void config_defaults(struct sway_config *config) { config->font_height = 17; // height of monospace 10 config->urgent_timeout = 500; config->popup_during_fullscreen = POPUP_SMART; + config->xwayland = true; config->titlebar_border_thickness = 1; config->titlebar_h_padding = 5; diff --git a/sway/main.c b/sway/main.c index d08c0457..6e3f6b67 100644 --- a/sway/main.c +++ b/sway/main.c @@ -369,7 +369,7 @@ int main(int argc, char **argv) { } if (!terminate_request) { - if (!server_start_backend(&server)) { + if (!server_start(&server)) { sway_terminate(EXIT_FAILURE); } } diff --git a/sway/meson.build b/sway/meson.build index 93858336..c2ed6298 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -104,6 +104,7 @@ sway_sources = files( 'commands/workspace.c', 'commands/workspace_layout.c', 'commands/ws_auto_back_and_forth.c', + 'commands/xwayland.c', 'commands/bar/bind.c', 'commands/bar/binding_mode_indicator.c', diff --git a/sway/server.c b/sway/server.c index 13264a2c..0529cab1 100644 --- a/sway/server.c +++ b/sway/server.c @@ -84,40 +84,6 @@ bool server_init(struct sway_server *server) { &server->xdg_shell_surface); server->xdg_shell_surface.notify = handle_xdg_shell_surface; - // TODO: configurable cursor theme and size - int cursor_size = 24; - const char *cursor_theme = NULL; - - char cursor_size_fmt[16]; - snprintf(cursor_size_fmt, sizeof(cursor_size_fmt), "%d", cursor_size); - setenv("XCURSOR_SIZE", cursor_size_fmt, 1); - if (cursor_theme != NULL) { - setenv("XCURSOR_THEME", cursor_theme, 1); - } - -#if HAVE_XWAYLAND - server->xwayland.wlr_xwayland = - wlr_xwayland_create(server->wl_display, server->compositor, true); - wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface, - &server->xwayland_surface); - server->xwayland_surface.notify = handle_xwayland_surface; - wl_signal_add(&server->xwayland.wlr_xwayland->events.ready, - &server->xwayland_ready); - server->xwayland_ready.notify = handle_xwayland_ready; - - server->xwayland.xcursor_manager = - wlr_xcursor_manager_create(cursor_theme, cursor_size); - wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1); - struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( - server->xwayland.xcursor_manager, "left_ptr", 1); - if (xcursor != NULL) { - struct wlr_xcursor_image *image = xcursor->images[0]; - wlr_xwayland_set_cursor(server->xwayland.wlr_xwayland, image->buffer, - image->width * 4, image->width, image->height, image->hotspot_x, - image->hotspot_y); - } -#endif - server->server_decoration_manager = wlr_server_decoration_manager_create(server->wl_display); wlr_server_decoration_manager_set_default_mode( @@ -175,7 +141,44 @@ void server_fini(struct sway_server *server) { list_free(server->transactions); } -bool server_start_backend(struct sway_server *server) { +bool server_start(struct sway_server *server) { + // TODO: configurable cursor theme and size + int cursor_size = 24; + const char *cursor_theme = NULL; + + char cursor_size_fmt[16]; + snprintf(cursor_size_fmt, sizeof(cursor_size_fmt), "%d", cursor_size); + setenv("XCURSOR_SIZE", cursor_size_fmt, 1); + if (cursor_theme != NULL) { + setenv("XCURSOR_THEME", cursor_theme, 1); + } + +#if HAVE_XWAYLAND + if (config->xwayland) { + wlr_log(WLR_DEBUG, "Initializing Xwayland"); + server->xwayland.wlr_xwayland = + wlr_xwayland_create(server->wl_display, server->compositor, true); + wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface, + &server->xwayland_surface); + server->xwayland_surface.notify = handle_xwayland_surface; + wl_signal_add(&server->xwayland.wlr_xwayland->events.ready, + &server->xwayland_ready); + server->xwayland_ready.notify = handle_xwayland_ready; + + server->xwayland.xcursor_manager = + wlr_xcursor_manager_create(cursor_theme, cursor_size); + wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1); + struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( + server->xwayland.xcursor_manager, "left_ptr", 1); + if (xcursor != NULL) { + struct wlr_xcursor_image *image = xcursor->images[0]; + wlr_xwayland_set_cursor(server->xwayland.wlr_xwayland, image->buffer, + image->width * 4, image->width, image->height, image->hotspot_x, + image->hotspot_y); + } + } +#endif + wlr_log(WLR_INFO, "Starting backend on wayland display '%s'", server->socket); if (!wlr_backend_start(server->backend)) { diff --git a/sway/sway.5.scd b/sway/sway.5.scd index a9f60c1b..06bc0dbf 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -84,6 +84,10 @@ The following commands may only be used in the configuration file. It can be disabled by setting the command to a single dash: _swaynag\_command -_ +*xwayland* enable|disable + Enables or disables Xwayland support, which allows X11 applications to be + used. + The following commands cannot be used directly in the configuration file. They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). |