aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-11-17 12:29:59 +0100
committeremersion <contact@emersion.fr>2018-11-19 17:38:37 +0100
commit311c7db7e300bc9e749a582a56805150180138e0 (patch)
treea695f7af6143e47c8b7bb8afe32e2e8f59c39958 /sway
parent67d24e8fc54b9e091533500de22f02302a4c79fc (diff)
downloadsway-311c7db7e300bc9e749a582a56805150180138e0.tar.xz
Add xwayland command
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/xwayland.c21
-rw-r--r--sway/config.c1
-rw-r--r--sway/main.c2
-rw-r--r--sway/meson.build1
-rw-r--r--sway/server.c73
-rw-r--r--sway/sway.5.scd6
7 files changed, 68 insertions, 37 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 4b86c2fa..a68c724a 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -113,6 +113,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 c1320acf..6f65d0c2 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -212,6 +212,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;
// floating view
config->floating_maximum_width = 0;
diff --git a/sway/main.c b/sway/main.c
index 920cea11..86374163 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -382,7 +382,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 d9bc08f3..4524bac9 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -94,6 +94,7 @@ sway_sources = files(
'commands/workspace.c',
'commands/workspace_layout.c',
'commands/ws_auto_back_and_forth.c',
+ 'commands/xwayland.c',
'commands/bar/activate_button.c',
'commands/bar/binding_mode_indicator.c',
diff --git a/sway/server.c b/sway/server.c
index cd3fcdf6..68142e87 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -83,40 +83,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(
@@ -173,7 +139,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 1a11015f..95376ccc 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).
@@ -421,7 +425,7 @@ The default colors are:
*focus\_follows\_mouse* yes|no|always
If set to _yes_, moving your mouse over a window will focus that window. If
- set to _always_, the window under the cursor will always be focused, even
+ set to _always_, the window under the cursor will always be focused, even
after switching between workspaces.
*focus\_wrapping* yes|no|force