aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2019-01-13 20:42:39 -0500
committerLibravatar GitHub <noreply@github.com>2019-01-13 20:42:39 -0500
commit4879d40695047a4c493bd8871d810c543978a869 (patch)
treeb043a9c62a8baeec8d62d06ece8c2f56d65b044a /sway
parentMerge pull request #3344 from RedSoxFan/bar-mouse-bindings-improved (diff)
parentAdd xwayland command (diff)
downloadsway-4879d40695047a4c493bd8871d810c543978a869.tar.gz
sway-4879d40695047a4c493bd8871d810c543978a869.tar.zst
sway-4879d40695047a4c493bd8871d810c543978a869.zip
Merge pull request #3144 from emersion/cmd-xwayland
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.scd4
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[] = {
101 { "swaybg_command", cmd_swaybg_command }, 101 { "swaybg_command", cmd_swaybg_command },
102 { "swaynag_command", cmd_swaynag_command }, 102 { "swaynag_command", cmd_swaynag_command },
103 { "workspace_layout", cmd_workspace_layout }, 103 { "workspace_layout", cmd_workspace_layout },
104 { "xwayland", cmd_xwayland },
104}; 105};
105 106
106/* Runtime-only commands. Keep alphabetized */ 107/* 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 @@
1#include "sway/config.h"
2#include "log.h"
3#include "sway/commands.h"
4#include "sway/server.h"
5#include "util.h"
6
7struct cmd_results *cmd_xwayland(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xwayland", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12
13#ifdef HAVE_XWAYLAND
14 config->xwayland = parse_boolean(argv[0], config->xwayland);
15#else
16 wlr_log(WLR_INFO, "Ignoring `xwayland` command, "
17 "sway hasn't been built with Xwayland support");
18#endif
19
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
21}
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) {
204 config->font_height = 17; // height of monospace 10 204 config->font_height = 17; // height of monospace 10
205 config->urgent_timeout = 500; 205 config->urgent_timeout = 500;
206 config->popup_during_fullscreen = POPUP_SMART; 206 config->popup_during_fullscreen = POPUP_SMART;
207 config->xwayland = true;
207 208
208 config->titlebar_border_thickness = 1; 209 config->titlebar_border_thickness = 1;
209 config->titlebar_h_padding = 5; 210 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) {
369 } 369 }
370 370
371 if (!terminate_request) { 371 if (!terminate_request) {
372 if (!server_start_backend(&server)) { 372 if (!server_start(&server)) {
373 sway_terminate(EXIT_FAILURE); 373 sway_terminate(EXIT_FAILURE);
374 } 374 }
375 } 375 }
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(
104 'commands/workspace.c', 104 'commands/workspace.c',
105 'commands/workspace_layout.c', 105 'commands/workspace_layout.c',
106 'commands/ws_auto_back_and_forth.c', 106 'commands/ws_auto_back_and_forth.c',
107 'commands/xwayland.c',
107 108
108 'commands/bar/bind.c', 109 'commands/bar/bind.c',
109 'commands/bar/binding_mode_indicator.c', 110 '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) {
84 &server->xdg_shell_surface); 84 &server->xdg_shell_surface);
85 server->xdg_shell_surface.notify = handle_xdg_shell_surface; 85 server->xdg_shell_surface.notify = handle_xdg_shell_surface;
86 86
87 // TODO: configurable cursor theme and size
88 int cursor_size = 24;
89 const char *cursor_theme = NULL;
90
91 char cursor_size_fmt[16];
92 snprintf(cursor_size_fmt, sizeof(cursor_size_fmt), "%d", cursor_size);
93 setenv("XCURSOR_SIZE", cursor_size_fmt, 1);
94 if (cursor_theme != NULL) {
95 setenv("XCURSOR_THEME", cursor_theme, 1);
96 }
97
98#if HAVE_XWAYLAND
99 server->xwayland.wlr_xwayland =
100 wlr_xwayland_create(server->wl_display, server->compositor, true);
101 wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface,
102 &server->xwayland_surface);
103 server->xwayland_surface.notify = handle_xwayland_surface;
104 wl_signal_add(&server->xwayland.wlr_xwayland->events.ready,
105 &server->xwayland_ready);
106 server->xwayland_ready.notify = handle_xwayland_ready;
107
108 server->xwayland.xcursor_manager =
109 wlr_xcursor_manager_create(cursor_theme, cursor_size);
110 wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1);
111 struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor(
112 server->xwayland.xcursor_manager, "left_ptr", 1);
113 if (xcursor != NULL) {
114 struct wlr_xcursor_image *image = xcursor->images[0];
115 wlr_xwayland_set_cursor(server->xwayland.wlr_xwayland, image->buffer,
116 image->width * 4, image->width, image->height, image->hotspot_x,
117 image->hotspot_y);
118 }
119#endif
120
121 server->server_decoration_manager = 87 server->server_decoration_manager =
122 wlr_server_decoration_manager_create(server->wl_display); 88 wlr_server_decoration_manager_create(server->wl_display);
123 wlr_server_decoration_manager_set_default_mode( 89 wlr_server_decoration_manager_set_default_mode(
@@ -175,7 +141,44 @@ void server_fini(struct sway_server *server) {
175 list_free(server->transactions); 141 list_free(server->transactions);
176} 142}
177 143
178bool server_start_backend(struct sway_server *server) { 144bool server_start(struct sway_server *server) {
145 // TODO: configurable cursor theme and size
146 int cursor_size = 24;
147 const char *cursor_theme = NULL;
148
149 char cursor_size_fmt[16];
150 snprintf(cursor_size_fmt, sizeof(cursor_size_fmt), "%d", cursor_size);
151 setenv("XCURSOR_SIZE", cursor_size_fmt, 1);
152 if (cursor_theme != NULL) {
153 setenv("XCURSOR_THEME", cursor_theme, 1);
154 }
155
156#if HAVE_XWAYLAND
157 if (config->xwayland) {
158 wlr_log(WLR_DEBUG, "Initializing Xwayland");
159 server->xwayland.wlr_xwayland =
160 wlr_xwayland_create(server->wl_display, server->compositor, true);
161 wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface,
162 &server->xwayland_surface);
163 server->xwayland_surface.notify = handle_xwayland_surface;
164 wl_signal_add(&server->xwayland.wlr_xwayland->events.ready,
165 &server->xwayland_ready);
166 server->xwayland_ready.notify = handle_xwayland_ready;
167
168 server->xwayland.xcursor_manager =
169 wlr_xcursor_manager_create(cursor_theme, cursor_size);
170 wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1);
171 struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor(
172 server->xwayland.xcursor_manager, "left_ptr", 1);
173 if (xcursor != NULL) {
174 struct wlr_xcursor_image *image = xcursor->images[0];
175 wlr_xwayland_set_cursor(server->xwayland.wlr_xwayland, image->buffer,
176 image->width * 4, image->width, image->height, image->hotspot_x,
177 image->hotspot_y);
178 }
179 }
180#endif
181
179 wlr_log(WLR_INFO, "Starting backend on wayland display '%s'", 182 wlr_log(WLR_INFO, "Starting backend on wayland display '%s'",
180 server->socket); 183 server->socket);
181 if (!wlr_backend_start(server->backend)) { 184 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.
84 It can be disabled by setting the command to a single dash: 84 It can be disabled by setting the command to a single dash:
85 _swaynag\_command -_ 85 _swaynag\_command -_
86 86
87*xwayland* enable|disable
88 Enables or disables Xwayland support, which allows X11 applications to be
89 used.
90
87The following commands cannot be used directly in the configuration file. 91The following commands cannot be used directly in the configuration file.
88They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). 92They are expected to be used with *bindsym* or at runtime through *swaymsg*(1).
89 93