diff options
-rw-r--r-- | include/sway/criteria.h | 2 | ||||
-rw-r--r-- | include/sway/server.h | 9 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 3 | ||||
-rw-r--r-- | include/sway/tree/view.h | 15 | ||||
-rw-r--r-- | include/sway/xwayland.h | 2 | ||||
-rw-r--r-- | meson.build | 6 | ||||
-rw-r--r-- | meson_options.txt | 1 | ||||
-rw-r--r-- | sway/commands/swap.c | 6 | ||||
-rw-r--r-- | sway/criteria.c | 12 | ||||
-rw-r--r-- | sway/desktop/output.c | 15 | ||||
-rw-r--r-- | sway/desktop/render.c | 10 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 3 | ||||
-rw-r--r-- | sway/input/seat.c | 2 | ||||
-rw-r--r-- | sway/server.c | 4 | ||||
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/layout.c | 2 | ||||
-rw-r--r-- | sway/tree/view.c | 16 |
18 files changed, 92 insertions, 20 deletions
diff --git a/include/sway/criteria.h b/include/sway/criteria.h index 6a8337c5..5b5c0f58 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h | |||
@@ -25,7 +25,9 @@ struct criteria { | |||
25 | pcre *instance; | 25 | pcre *instance; |
26 | pcre *con_mark; | 26 | pcre *con_mark; |
27 | uint32_t con_id; // internal ID | 27 | uint32_t con_id; // internal ID |
28 | #ifdef HAVE_XWAYLAND | ||
28 | uint32_t id; // X11 window ID | 29 | uint32_t id; // X11 window ID |
30 | #endif | ||
29 | pcre *window_role; | 31 | pcre *window_role; |
30 | uint32_t window_type; | 32 | uint32_t window_type; |
31 | bool floating; | 33 | bool floating; |
diff --git a/include/sway/server.h b/include/sway/server.h index 70bde6d4..fb22125f 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -12,7 +12,9 @@ | |||
12 | #include <wlr/render/wlr_renderer.h> | 12 | #include <wlr/render/wlr_renderer.h> |
13 | // TODO WLR: make Xwayland optional | 13 | // TODO WLR: make Xwayland optional |
14 | #include "list.h" | 14 | #include "list.h" |
15 | #ifdef HAVE_XWAYLAND | ||
15 | #include "sway/xwayland.h" | 16 | #include "sway/xwayland.h" |
17 | #endif | ||
16 | 18 | ||
17 | struct sway_server { | 19 | struct sway_server { |
18 | struct wl_display *wl_display; | 20 | struct wl_display *wl_display; |
@@ -39,11 +41,11 @@ struct sway_server { | |||
39 | 41 | ||
40 | struct wlr_xdg_shell *xdg_shell; | 42 | struct wlr_xdg_shell *xdg_shell; |
41 | struct wl_listener xdg_shell_surface; | 43 | struct wl_listener xdg_shell_surface; |
42 | 44 | #ifdef HAVE_XWAYLAND | |
43 | struct sway_xwayland xwayland; | 45 | struct sway_xwayland xwayland; |
44 | struct wl_listener xwayland_surface; | 46 | struct wl_listener xwayland_surface; |
45 | struct wl_listener xwayland_ready; | 47 | struct wl_listener xwayland_ready; |
46 | 48 | #endif | |
47 | bool debug_txn_timings; | 49 | bool debug_txn_timings; |
48 | 50 | ||
49 | list_t *transactions; | 51 | list_t *transactions; |
@@ -65,6 +67,7 @@ void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); | |||
65 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); | 67 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); |
66 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); | 68 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); |
67 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); | 69 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); |
70 | #ifdef HAVE_XWAYLAND | ||
68 | void handle_xwayland_surface(struct wl_listener *listener, void *data); | 71 | void handle_xwayland_surface(struct wl_listener *listener, void *data); |
69 | 72 | #endif | |
70 | #endif | 73 | #endif |
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 7d7da2d7..da74e205 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h | |||
@@ -27,8 +27,9 @@ struct sway_root { | |||
27 | struct wlr_output_layout *output_layout; | 27 | struct wlr_output_layout *output_layout; |
28 | 28 | ||
29 | struct wl_listener output_layout_change; | 29 | struct wl_listener output_layout_change; |
30 | 30 | #ifdef HAVE_XWAYLAND | |
31 | struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link | 31 | struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link |
32 | #endif | ||
32 | struct wl_list drag_icons; // sway_drag_icon::link | 33 | struct wl_list drag_icons; // sway_drag_icon::link |
33 | 34 | ||
34 | struct wlr_texture *debug_tree; | 35 | struct wlr_texture *debug_tree; |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 3bdfe252..af12cf88 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -3,7 +3,9 @@ | |||
3 | #include <wayland-server.h> | 3 | #include <wayland-server.h> |
4 | #include <wlr/types/wlr_surface.h> | 4 | #include <wlr/types/wlr_surface.h> |
5 | #include <wlr/types/wlr_xdg_shell_v6.h> | 5 | #include <wlr/types/wlr_xdg_shell_v6.h> |
6 | #ifdef HAVE_XWAYLAND | ||
6 | #include <wlr/xwayland.h> | 7 | #include <wlr/xwayland.h> |
8 | #endif | ||
7 | #include "sway/input/input-manager.h" | 9 | #include "sway/input/input-manager.h" |
8 | #include "sway/input/seat.h" | 10 | #include "sway/input/seat.h" |
9 | 11 | ||
@@ -12,7 +14,9 @@ struct sway_container; | |||
12 | enum sway_view_type { | 14 | enum sway_view_type { |
13 | SWAY_VIEW_XDG_SHELL_V6, | 15 | SWAY_VIEW_XDG_SHELL_V6, |
14 | SWAY_VIEW_XDG_SHELL, | 16 | SWAY_VIEW_XDG_SHELL, |
17 | #ifdef HAVE_XWAYLAND | ||
15 | SWAY_VIEW_XWAYLAND, | 18 | SWAY_VIEW_XWAYLAND, |
19 | #endif | ||
16 | }; | 20 | }; |
17 | 21 | ||
18 | enum sway_view_prop { | 22 | enum sway_view_prop { |
@@ -22,7 +26,9 @@ enum sway_view_prop { | |||
22 | VIEW_PROP_INSTANCE, | 26 | VIEW_PROP_INSTANCE, |
23 | VIEW_PROP_WINDOW_TYPE, | 27 | VIEW_PROP_WINDOW_TYPE, |
24 | VIEW_PROP_WINDOW_ROLE, | 28 | VIEW_PROP_WINDOW_ROLE, |
29 | #ifdef HAVE_XWAYLAND | ||
25 | VIEW_PROP_X11_WINDOW_ID, | 30 | VIEW_PROP_X11_WINDOW_ID, |
31 | #endif | ||
26 | }; | 32 | }; |
27 | 33 | ||
28 | struct sway_view_impl { | 34 | struct sway_view_impl { |
@@ -90,7 +96,9 @@ struct sway_view { | |||
90 | union { | 96 | union { |
91 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; | 97 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; |
92 | struct wlr_xdg_surface *wlr_xdg_surface; | 98 | struct wlr_xdg_surface *wlr_xdg_surface; |
99 | #ifdef HAVE_XWAYLAND | ||
93 | struct wlr_xwayland_surface *wlr_xwayland_surface; | 100 | struct wlr_xwayland_surface *wlr_xwayland_surface; |
101 | #endif | ||
94 | struct wlr_wl_shell_surface *wlr_wl_shell_surface; | 102 | struct wlr_wl_shell_surface *wlr_wl_shell_surface; |
95 | }; | 103 | }; |
96 | 104 | ||
@@ -133,7 +141,7 @@ struct sway_xdg_shell_view { | |||
133 | struct wl_listener unmap; | 141 | struct wl_listener unmap; |
134 | struct wl_listener destroy; | 142 | struct wl_listener destroy; |
135 | }; | 143 | }; |
136 | 144 | #ifdef HAVE_XWAYLAND | |
137 | struct sway_xwayland_view { | 145 | struct sway_xwayland_view { |
138 | struct sway_view view; | 146 | struct sway_view view; |
139 | 147 | ||
@@ -165,7 +173,7 @@ struct sway_xwayland_unmanaged { | |||
165 | struct wl_listener unmap; | 173 | struct wl_listener unmap; |
166 | struct wl_listener destroy; | 174 | struct wl_listener destroy; |
167 | }; | 175 | }; |
168 | 176 | #endif | |
169 | struct sway_view_child; | 177 | struct sway_view_child; |
170 | 178 | ||
171 | struct sway_view_child_impl { | 179 | struct sway_view_child_impl { |
@@ -281,9 +289,10 @@ struct sway_view *view_from_wlr_xdg_surface( | |||
281 | struct wlr_xdg_surface *xdg_surface); | 289 | struct wlr_xdg_surface *xdg_surface); |
282 | struct sway_view *view_from_wlr_xdg_surface_v6( | 290 | struct sway_view *view_from_wlr_xdg_surface_v6( |
283 | struct wlr_xdg_surface_v6 *xdg_surface_v6); | 291 | struct wlr_xdg_surface_v6 *xdg_surface_v6); |
292 | #ifdef HAVE_XWAYLAND | ||
284 | struct sway_view *view_from_wlr_xwayland_surface( | 293 | struct sway_view *view_from_wlr_xwayland_surface( |
285 | struct wlr_xwayland_surface *xsurface); | 294 | struct wlr_xwayland_surface *xsurface); |
286 | 295 | #endif | |
287 | struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); | 296 | struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); |
288 | 297 | ||
289 | /** | 298 | /** |
diff --git a/include/sway/xwayland.h b/include/sway/xwayland.h index 78d1053b..e6572ae9 100644 --- a/include/sway/xwayland.h +++ b/include/sway/xwayland.h | |||
@@ -1,3 +1,4 @@ | |||
1 | #ifdef HAVE_XWAYLAND | ||
1 | #ifndef SWAY_XWAYLAND_H | 2 | #ifndef SWAY_XWAYLAND_H |
2 | #define SWAY_XWAYLAND_H | 3 | #define SWAY_XWAYLAND_H |
3 | 4 | ||
@@ -23,3 +24,4 @@ struct sway_xwayland { | |||
23 | void handle_xwayland_ready(struct wl_listener *listener, void *data); | 24 | void handle_xwayland_ready(struct wl_listener *listener, void *data); |
24 | 25 | ||
25 | #endif | 26 | #endif |
27 | #endif | ||
diff --git a/meson.build b/meson.build index 1d40581a..a2def755 100644 --- a/meson.build +++ b/meson.build | |||
@@ -48,6 +48,12 @@ git = find_program('git', required: false) | |||
48 | 48 | ||
49 | conf_data = configuration_data() | 49 | conf_data = configuration_data() |
50 | 50 | ||
51 | if get_option('enable-xwayland') | ||
52 | conf_data.set('HAVE_XWAYLAND', true) | ||
53 | else | ||
54 | conf_data.set('HAVE_XWAYLAND', false) | ||
55 | endif | ||
56 | |||
51 | if gdk_pixbuf.found() | 57 | if gdk_pixbuf.found() |
52 | conf_data.set('HAVE_GDK_PIXBUF', true) | 58 | conf_data.set('HAVE_GDK_PIXBUF', true) |
53 | endif | 59 | endif |
diff --git a/meson_options.txt b/meson_options.txt index 541ccf13..1897cba6 100644 --- a/meson_options.txt +++ b/meson_options.txt | |||
@@ -1,3 +1,4 @@ | |||
1 | option('sway_version', type : 'string', description: 'The version string reported in `sway --version`.') | 1 | option('sway_version', type : 'string', description: 'The version string reported in `sway --version`.') |
2 | option('default_wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.') | 2 | option('default_wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.') |
3 | option('zsh_completions', type: 'boolean', value: true, description: 'Install zsh shell completions.') | 3 | option('zsh_completions', type: 'boolean', value: true, description: 'Install zsh shell completions.') |
4 | option('enable-xwayland', type: 'boolean', value: false, description: 'Enable support X11 applications') | ||
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 2fc88308..3563cdd9 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -14,10 +14,14 @@ static bool test_con_id(struct sway_container *container, void *con_id) { | |||
14 | } | 14 | } |
15 | 15 | ||
16 | static bool test_id(struct sway_container *container, void *id) { | 16 | static bool test_id(struct sway_container *container, void *id) { |
17 | #ifdef HAVE_XWAYLAND | ||
17 | xcb_window_t *wid = id; | 18 | xcb_window_t *wid = id; |
18 | return (container->type == C_VIEW | 19 | return (container->type == C_VIEW |
19 | && container->sway_view->type == SWAY_VIEW_XWAYLAND | 20 | && container->sway_view->type == SWAY_VIEW_XWAYLAND |
20 | && container->sway_view->wlr_xwayland_surface->window_id == *wid); | 21 | && container->sway_view->wlr_xwayland_surface->window_id == *wid); |
22 | #else | ||
23 | return false; | ||
24 | #endif | ||
21 | } | 25 | } |
22 | 26 | ||
23 | static bool test_mark(struct sway_container *container, void *mark) { | 27 | static bool test_mark(struct sway_container *container, void *mark) { |
@@ -43,8 +47,10 @@ struct cmd_results *cmd_swap(int argc, char **argv) { | |||
43 | 47 | ||
44 | char *value = join_args(argv + 3, argc - 3); | 48 | char *value = join_args(argv + 3, argc - 3); |
45 | if (strcasecmp(argv[2], "id") == 0) { | 49 | if (strcasecmp(argv[2], "id") == 0) { |
50 | #ifdef HAVE_XWAYLAND | ||
46 | xcb_window_t id = strtol(value, NULL, 0); | 51 | xcb_window_t id = strtol(value, NULL, 0); |
47 | other = container_find(&root_container, test_id, (void *)&id); | 52 | other = container_find(&root_container, test_id, (void *)&id); |
53 | #endif | ||
48 | } else if (strcasecmp(argv[2], "con_id") == 0) { | 54 | } else if (strcasecmp(argv[2], "con_id") == 0) { |
49 | size_t con_id = atoi(value); | 55 | size_t con_id = atoi(value); |
50 | other = container_find(&root_container, test_con_id, (void *)con_id); | 56 | other = container_find(&root_container, test_con_id, (void *)con_id); |
diff --git a/sway/criteria.c b/sway/criteria.c index c2e9c07e..b2c6edf9 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -19,7 +19,9 @@ bool criteria_is_empty(struct criteria *criteria) { | |||
19 | && !criteria->instance | 19 | && !criteria->instance |
20 | && !criteria->con_mark | 20 | && !criteria->con_mark |
21 | && !criteria->con_id | 21 | && !criteria->con_id |
22 | #ifdef HAVE_XWAYLAND | ||
22 | && !criteria->id | 23 | && !criteria->id |
24 | #endif | ||
23 | && !criteria->window_role | 25 | && !criteria->window_role |
24 | && !criteria->window_type | 26 | && !criteria->window_type |
25 | && !criteria->floating | 27 | && !criteria->floating |
@@ -127,12 +129,14 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
127 | } | 129 | } |
128 | } | 130 | } |
129 | 131 | ||
132 | #ifdef HAVE_XWAYLAND | ||
130 | if (criteria->id) { // X11 window ID | 133 | if (criteria->id) { // X11 window ID |
131 | uint32_t x11_window_id = view_get_x11_window_id(view); | 134 | uint32_t x11_window_id = view_get_x11_window_id(view); |
132 | if (!x11_window_id || x11_window_id != criteria->id) { | 135 | if (!x11_window_id || x11_window_id != criteria->id) { |
133 | return false; | 136 | return false; |
134 | } | 137 | } |
135 | } | 138 | } |
139 | #endif | ||
136 | 140 | ||
137 | if (criteria->window_role) { | 141 | if (criteria->window_role) { |
138 | // TODO | 142 | // TODO |
@@ -265,7 +269,9 @@ enum criteria_token { | |||
265 | T_CON_ID, | 269 | T_CON_ID, |
266 | T_CON_MARK, | 270 | T_CON_MARK, |
267 | T_FLOATING, | 271 | T_FLOATING, |
272 | #ifdef HAVE_XWAYLAND | ||
268 | T_ID, | 273 | T_ID, |
274 | #endif | ||
269 | T_INSTANCE, | 275 | T_INSTANCE, |
270 | T_SHELL, | 276 | T_SHELL, |
271 | T_TILING, | 277 | T_TILING, |
@@ -287,8 +293,10 @@ static enum criteria_token token_from_name(char *name) { | |||
287 | return T_CON_ID; | 293 | return T_CON_ID; |
288 | } else if (strcmp(name, "con_mark") == 0) { | 294 | } else if (strcmp(name, "con_mark") == 0) { |
289 | return T_CON_MARK; | 295 | return T_CON_MARK; |
296 | #ifdef HAVE_XWAYLAND | ||
290 | } else if (strcmp(name, "id") == 0) { | 297 | } else if (strcmp(name, "id") == 0) { |
291 | return T_ID; | 298 | return T_ID; |
299 | #endif | ||
292 | } else if (strcmp(name, "instance") == 0) { | 300 | } else if (strcmp(name, "instance") == 0) { |
293 | return T_INSTANCE; | 301 | return T_INSTANCE; |
294 | } else if (strcmp(name, "shell") == 0) { | 302 | } else if (strcmp(name, "shell") == 0) { |
@@ -355,7 +363,9 @@ static char *get_focused_prop(enum criteria_token token) { | |||
355 | case T_CON_ID: // These do not support __focused__ | 363 | case T_CON_ID: // These do not support __focused__ |
356 | case T_CON_MARK: | 364 | case T_CON_MARK: |
357 | case T_FLOATING: | 365 | case T_FLOATING: |
366 | #ifdef HAVE_XWAYLAND | ||
358 | case T_ID: | 367 | case T_ID: |
368 | #endif | ||
359 | case T_TILING: | 369 | case T_TILING: |
360 | case T_URGENT: | 370 | case T_URGENT: |
361 | case T_WINDOW_TYPE: | 371 | case T_WINDOW_TYPE: |
@@ -426,12 +436,14 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { | |||
426 | case T_WINDOW_TYPE: | 436 | case T_WINDOW_TYPE: |
427 | // TODO: This is a string but will be stored as an enum or integer | 437 | // TODO: This is a string but will be stored as an enum or integer |
428 | break; | 438 | break; |
439 | #ifdef HAVE_XWAYLAND | ||
429 | case T_ID: | 440 | case T_ID: |
430 | criteria->id = strtoul(effective_value, &endptr, 10); | 441 | criteria->id = strtoul(effective_value, &endptr, 10); |
431 | if (*endptr != 0) { | 442 | if (*endptr != 0) { |
432 | error = strdup("The value for 'id' should be numeric"); | 443 | error = strdup("The value for 'id' should be numeric"); |
433 | } | 444 | } |
434 | break; | 445 | break; |
446 | #endif | ||
435 | case T_FLOATING: | 447 | case T_FLOATING: |
436 | criteria->floating = true; | 448 | criteria->floating = true; |
437 | break; | 449 | break; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index a206ac6b..7cca23bd 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -128,7 +128,7 @@ void output_layer_for_each_surface(struct wl_list *layer_surfaces, | |||
128 | user_data); | 128 | user_data); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | #ifdef HAVE_XWAYLAND | |
132 | void output_unmanaged_for_each_surface(struct wl_list *unmanaged, | 132 | void output_unmanaged_for_each_surface(struct wl_list *unmanaged, |
133 | struct sway_output *output, struct root_geometry *geo, | 133 | struct sway_output *output, struct root_geometry *geo, |
134 | wlr_surface_iterator_func_t iterator, void *user_data) { | 134 | wlr_surface_iterator_func_t iterator, void *user_data) { |
@@ -143,7 +143,7 @@ void output_unmanaged_for_each_surface(struct wl_list *unmanaged, | |||
143 | iterator, user_data); | 143 | iterator, user_data); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | #endif | |
147 | void output_drag_icons_for_each_surface(struct wl_list *drag_icons, | 147 | void output_drag_icons_for_each_surface(struct wl_list *drag_icons, |
148 | struct sway_output *output, struct root_geometry *geo, | 148 | struct sway_output *output, struct root_geometry *geo, |
149 | wlr_surface_iterator_func_t iterator, void *user_data) { | 149 | wlr_surface_iterator_func_t iterator, void *user_data) { |
@@ -244,13 +244,13 @@ static void send_frame_done_layer(struct send_frame_done_data *data, | |||
244 | output_layer_for_each_surface(layer_surfaces, &data->root_geo, | 244 | output_layer_for_each_surface(layer_surfaces, &data->root_geo, |
245 | send_frame_done_iterator, data); | 245 | send_frame_done_iterator, data); |
246 | } | 246 | } |
247 | 247 | #ifdef HAVE_XWAYLAND | |
248 | static void send_frame_done_unmanaged(struct send_frame_done_data *data, | 248 | static void send_frame_done_unmanaged(struct send_frame_done_data *data, |
249 | struct wl_list *unmanaged) { | 249 | struct wl_list *unmanaged) { |
250 | output_unmanaged_for_each_surface(unmanaged, data->output, &data->root_geo, | 250 | output_unmanaged_for_each_surface(unmanaged, data->output, &data->root_geo, |
251 | send_frame_done_iterator, data); | 251 | send_frame_done_iterator, data); |
252 | } | 252 | } |
253 | 253 | #endif | |
254 | static void send_frame_done_drag_icons(struct send_frame_done_data *data, | 254 | static void send_frame_done_drag_icons(struct send_frame_done_data *data, |
255 | struct wl_list *drag_icons) { | 255 | struct wl_list *drag_icons) { |
256 | output_drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo, | 256 | output_drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo, |
@@ -291,11 +291,12 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { | |||
291 | if (workspace->current.ws_fullscreen) { | 291 | if (workspace->current.ws_fullscreen) { |
292 | send_frame_done_container_iterator( | 292 | send_frame_done_container_iterator( |
293 | workspace->current.ws_fullscreen->swayc, &data); | 293 | workspace->current.ws_fullscreen->swayc, &data); |
294 | 294 | #ifdef HAVE_XWAYLAND | |
295 | if (workspace->current.ws_fullscreen->type == SWAY_VIEW_XWAYLAND) { | 295 | if (workspace->current.ws_fullscreen->type == SWAY_VIEW_XWAYLAND) { |
296 | send_frame_done_unmanaged(&data, | 296 | send_frame_done_unmanaged(&data, |
297 | &root_container.sway_root->xwayland_unmanaged); | 297 | &root_container.sway_root->xwayland_unmanaged); |
298 | } | 298 | } |
299 | #endif | ||
299 | } else { | 300 | } else { |
300 | send_frame_done_layer(&data, | 301 | send_frame_done_layer(&data, |
301 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); | 302 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); |
@@ -304,9 +305,11 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { | |||
304 | 305 | ||
305 | send_frame_done_container(&data, workspace); | 306 | send_frame_done_container(&data, workspace); |
306 | send_frame_done_container(&data, workspace->sway_workspace->floating); | 307 | send_frame_done_container(&data, workspace->sway_workspace->floating); |
307 | 308 | ||
309 | #ifdef HAVE_XWAYLAND | ||
308 | send_frame_done_unmanaged(&data, | 310 | send_frame_done_unmanaged(&data, |
309 | &root_container.sway_root->xwayland_unmanaged); | 311 | &root_container.sway_root->xwayland_unmanaged); |
312 | #endif | ||
310 | send_frame_done_layer(&data, | 313 | send_frame_done_layer(&data, |
311 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 314 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
312 | } | 315 | } |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 7da54594..46bfec6b 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -132,7 +132,7 @@ static void render_layer(struct sway_output *output, | |||
132 | output_layer_for_each_surface(layer_surfaces, &data.root_geo, | 132 | output_layer_for_each_surface(layer_surfaces, &data.root_geo, |
133 | render_surface_iterator, &data); | 133 | render_surface_iterator, &data); |
134 | } | 134 | } |
135 | 135 | #ifdef HAVE_XWAYLAND | |
136 | static void render_unmanaged(struct sway_output *output, | 136 | static void render_unmanaged(struct sway_output *output, |
137 | pixman_region32_t *damage, struct wl_list *unmanaged) { | 137 | pixman_region32_t *damage, struct wl_list *unmanaged) { |
138 | struct render_data data = { | 138 | struct render_data data = { |
@@ -143,7 +143,7 @@ static void render_unmanaged(struct sway_output *output, | |||
143 | output_unmanaged_for_each_surface(unmanaged, output, &data.root_geo, | 143 | output_unmanaged_for_each_surface(unmanaged, output, &data.root_geo, |
144 | render_surface_iterator, &data); | 144 | render_surface_iterator, &data); |
145 | } | 145 | } |
146 | 146 | #endif | |
147 | static void render_drag_icons(struct sway_output *output, | 147 | static void render_drag_icons(struct sway_output *output, |
148 | pixman_region32_t *damage, struct wl_list *drag_icons) { | 148 | pixman_region32_t *damage, struct wl_list *drag_icons) { |
149 | struct render_data data = { | 149 | struct render_data data = { |
@@ -866,11 +866,12 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
866 | } else { | 866 | } else { |
867 | render_view_surfaces(fullscreen_view, output, damage, 1.0f); | 867 | render_view_surfaces(fullscreen_view, output, damage, 1.0f); |
868 | } | 868 | } |
869 | 869 | #ifdef HAVE_XWAYLAND | |
870 | if (fullscreen_view->type == SWAY_VIEW_XWAYLAND) { | 870 | if (fullscreen_view->type == SWAY_VIEW_XWAYLAND) { |
871 | render_unmanaged(output, damage, | 871 | render_unmanaged(output, damage, |
872 | &root_container.sway_root->xwayland_unmanaged); | 872 | &root_container.sway_root->xwayland_unmanaged); |
873 | } | 873 | } |
874 | #endif | ||
874 | } else { | 875 | } else { |
875 | float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; | 876 | float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; |
876 | 877 | ||
@@ -888,9 +889,10 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
888 | 889 | ||
889 | render_container(output, damage, workspace, workspace->current.focused); | 890 | render_container(output, damage, workspace, workspace->current.focused); |
890 | render_floating(output, damage); | 891 | render_floating(output, damage); |
891 | 892 | #ifdef HAVE_XWAYLAND | |
892 | render_unmanaged(output, damage, | 893 | render_unmanaged(output, damage, |
893 | &root_container.sway_root->xwayland_unmanaged); | 894 | &root_container.sway_root->xwayland_unmanaged); |
895 | #endif | ||
894 | render_layer(output, damage, | 896 | render_layer(output, damage, |
895 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 897 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
896 | } | 898 | } |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 65d4fcd4..d940d47b 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #define _POSIX_C_SOURCE 199309L | 1 | #define _POSIX_C_SOURCE 199309L |
2 | #ifdef HAVE_XWAYLAND | ||
2 | #include <stdbool.h> | 3 | #include <stdbool.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 5 | #include <wayland-server.h> |
@@ -591,3 +592,4 @@ void handle_xwayland_ready(struct wl_listener *listener, void *data) { | |||
591 | 592 | ||
592 | xcb_disconnect(xcb_conn); | 593 | xcb_disconnect(xcb_conn); |
593 | } | 594 | } |
595 | #endif | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 27597640..c873a20e 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -54,6 +54,7 @@ static struct sway_container *container_at_coords( | |||
54 | struct sway_seat *seat, double lx, double ly, | 54 | struct sway_seat *seat, double lx, double ly, |
55 | struct wlr_surface **surface, double *sx, double *sy) { | 55 | struct wlr_surface **surface, double *sx, double *sy) { |
56 | // check for unmanaged views first | 56 | // check for unmanaged views first |
57 | #ifdef HAVE_XWAYLAND | ||
57 | struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; | 58 | struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; |
58 | struct sway_xwayland_unmanaged *unmanaged_surface; | 59 | struct sway_xwayland_unmanaged *unmanaged_surface; |
59 | wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { | 60 | wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { |
@@ -69,7 +70,7 @@ static struct sway_container *container_at_coords( | |||
69 | return NULL; | 70 | return NULL; |
70 | } | 71 | } |
71 | } | 72 | } |
72 | 73 | #endif | |
73 | // find the output the cursor is on | 74 | // find the output the cursor is on |
74 | struct wlr_output_layout *output_layout = | 75 | struct wlr_output_layout *output_layout = |
75 | root_container.sway_root->output_layout; | 76 | root_container.sway_root->output_layout; |
diff --git a/sway/input/seat.c b/sway/input/seat.c index fc9e54b6..66d11eea 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -103,11 +103,13 @@ static void seat_send_focus(struct sway_container *con, | |||
103 | 103 | ||
104 | if (con->type == C_VIEW | 104 | if (con->type == C_VIEW |
105 | && seat_is_input_allowed(seat, con->sway_view->surface)) { | 105 | && seat_is_input_allowed(seat, con->sway_view->surface)) { |
106 | #ifdef HAVE_XWAYLAND | ||
106 | if (con->sway_view->type == SWAY_VIEW_XWAYLAND) { | 107 | if (con->sway_view->type == SWAY_VIEW_XWAYLAND) { |
107 | struct wlr_xwayland *xwayland = | 108 | struct wlr_xwayland *xwayland = |
108 | seat->input->server->xwayland.wlr_xwayland; | 109 | seat->input->server->xwayland.wlr_xwayland; |
109 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); | 110 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); |
110 | } | 111 | } |
112 | #endif | ||
111 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); | 113 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); |
112 | if (keyboard) { | 114 | if (keyboard) { |
113 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, | 115 | wlr_seat_keyboard_notify_enter(seat->wlr_seat, |
diff --git a/sway/server.c b/sway/server.c index 89dfbf8c..90f25dbc 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -25,7 +25,9 @@ | |||
25 | #include "sway/input/input-manager.h" | 25 | #include "sway/input/input-manager.h" |
26 | #include "sway/server.h" | 26 | #include "sway/server.h" |
27 | #include "sway/tree/layout.h" | 27 | #include "sway/tree/layout.h" |
28 | #ifdef HAVE_XWAYLAND | ||
28 | #include "sway/xwayland.h" | 29 | #include "sway/xwayland.h" |
30 | #endif | ||
29 | 31 | ||
30 | bool server_privileged_prepare(struct sway_server *server) { | 32 | bool server_privileged_prepare(struct sway_server *server) { |
31 | wlr_log(WLR_DEBUG, "Preparing Wayland server initialization"); | 33 | wlr_log(WLR_DEBUG, "Preparing Wayland server initialization"); |
@@ -81,6 +83,7 @@ bool server_init(struct sway_server *server) { | |||
81 | server->xdg_shell_surface.notify = handle_xdg_shell_surface; | 83 | server->xdg_shell_surface.notify = handle_xdg_shell_surface; |
82 | 84 | ||
83 | // TODO make xwayland optional | 85 | // TODO make xwayland optional |
86 | #ifdef HAVE_XWAYLAND | ||
84 | server->xwayland.wlr_xwayland = | 87 | server->xwayland.wlr_xwayland = |
85 | wlr_xwayland_create(server->wl_display, server->compositor, true); | 88 | wlr_xwayland_create(server->wl_display, server->compositor, true); |
86 | wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface, | 89 | wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface, |
@@ -101,6 +104,7 @@ bool server_init(struct sway_server *server) { | |||
101 | image->width * 4, image->width, image->height, image->hotspot_x, | 104 | image->width * 4, image->width, image->height, image->hotspot_x, |
102 | image->hotspot_y); | 105 | image->hotspot_y); |
103 | } | 106 | } |
107 | #endif | ||
104 | 108 | ||
105 | // TODO: Integration with sway borders | 109 | // TODO: Integration with sway borders |
106 | struct wlr_server_decoration_manager *deco_manager = | 110 | struct wlr_server_decoration_manager *deco_manager = |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 4f743c40..0a655db5 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -527,10 +527,12 @@ static struct sway_container *container_at_view(struct sway_container *swayc, | |||
527 | double _sx, _sy; | 527 | double _sx, _sy; |
528 | struct wlr_surface *_surface = NULL; | 528 | struct wlr_surface *_surface = NULL; |
529 | switch (sview->type) { | 529 | switch (sview->type) { |
530 | #ifdef HAVE_XWAYLAND | ||
530 | case SWAY_VIEW_XWAYLAND: | 531 | case SWAY_VIEW_XWAYLAND: |
531 | _surface = wlr_surface_surface_at(sview->surface, | 532 | _surface = wlr_surface_surface_at(sview->surface, |
532 | view_sx, view_sy, &_sx, &_sy); | 533 | view_sx, view_sy, &_sx, &_sy); |
533 | break; | 534 | break; |
535 | #endif | ||
534 | case SWAY_VIEW_XDG_SHELL_V6: | 536 | case SWAY_VIEW_XDG_SHELL_V6: |
535 | _surface = wlr_xdg_surface_v6_surface_at( | 537 | _surface = wlr_xdg_surface_v6_surface_at( |
536 | sview->wlr_xdg_surface_v6, | 538 | sview->wlr_xdg_surface_v6, |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index a2be0ef3..91350c3f 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -39,7 +39,9 @@ void layout_init(void) { | |||
39 | root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); | 39 | root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); |
40 | root_container.sway_root->output_layout = wlr_output_layout_create(); | 40 | root_container.sway_root->output_layout = wlr_output_layout_create(); |
41 | wl_list_init(&root_container.sway_root->outputs); | 41 | wl_list_init(&root_container.sway_root->outputs); |
42 | #ifdef HAVE_XWAYLAND | ||
42 | wl_list_init(&root_container.sway_root->xwayland_unmanaged); | 43 | wl_list_init(&root_container.sway_root->xwayland_unmanaged); |
44 | #endif | ||
43 | wl_list_init(&root_container.sway_root->drag_icons); | 45 | wl_list_init(&root_container.sway_root->drag_icons); |
44 | wl_signal_init(&root_container.sway_root->events.new_container); | 46 | wl_signal_init(&root_container.sway_root->events.new_container); |
45 | root_container.sway_root->scratchpad = create_list(); | 47 | root_container.sway_root->scratchpad = create_list(); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index a55c8a29..e99b938e 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -3,7 +3,9 @@ | |||
3 | #include <wayland-server.h> | 3 | #include <wayland-server.h> |
4 | #include <wlr/render/wlr_renderer.h> | 4 | #include <wlr/render/wlr_renderer.h> |
5 | #include <wlr/types/wlr_output_layout.h> | 5 | #include <wlr/types/wlr_output_layout.h> |
6 | #ifdef HAVE_XWAYLAND | ||
6 | #include <wlr/xwayland.h> | 7 | #include <wlr/xwayland.h> |
8 | #endif | ||
7 | #include "list.h" | 9 | #include "list.h" |
8 | #include "log.h" | 10 | #include "log.h" |
9 | #include "sway/criteria.h" | 11 | #include "sway/criteria.h" |
@@ -108,14 +110,14 @@ const char *view_get_instance(struct sway_view *view) { | |||
108 | } | 110 | } |
109 | return NULL; | 111 | return NULL; |
110 | } | 112 | } |
111 | 113 | #ifdef HAVE_XWAYLAND | |
112 | uint32_t view_get_x11_window_id(struct sway_view *view) { | 114 | uint32_t view_get_x11_window_id(struct sway_view *view) { |
113 | if (view->impl->get_int_prop) { | 115 | if (view->impl->get_int_prop) { |
114 | return view->impl->get_int_prop(view, VIEW_PROP_X11_WINDOW_ID); | 116 | return view->impl->get_int_prop(view, VIEW_PROP_X11_WINDOW_ID); |
115 | } | 117 | } |
116 | return 0; | 118 | return 0; |
117 | } | 119 | } |
118 | 120 | #endif | |
119 | const char *view_get_window_role(struct sway_view *view) { | 121 | const char *view_get_window_role(struct sway_view *view) { |
120 | if (view->impl->get_string_prop) { | 122 | if (view->impl->get_string_prop) { |
121 | return view->impl->get_string_prop(view, VIEW_PROP_WINDOW_ROLE); | 123 | return view->impl->get_string_prop(view, VIEW_PROP_WINDOW_ROLE); |
@@ -136,8 +138,10 @@ const char *view_get_shell(struct sway_view *view) { | |||
136 | return "xdg_shell_v6"; | 138 | return "xdg_shell_v6"; |
137 | case SWAY_VIEW_XDG_SHELL: | 139 | case SWAY_VIEW_XDG_SHELL: |
138 | return "xdg_shell"; | 140 | return "xdg_shell"; |
141 | #ifdef HAVE_XWAYLAND | ||
139 | case SWAY_VIEW_XWAYLAND: | 142 | case SWAY_VIEW_XWAYLAND: |
140 | return "xwayland"; | 143 | return "xwayland"; |
144 | #endif | ||
141 | } | 145 | } |
142 | return "unknown"; | 146 | return "unknown"; |
143 | } | 147 | } |
@@ -563,6 +567,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
563 | } | 567 | } |
564 | 568 | ||
565 | pid_t pid; | 569 | pid_t pid; |
570 | #ifdef HAVE_XWAYLAND | ||
566 | if (view->type == SWAY_VIEW_XWAYLAND) { | 571 | if (view->type == SWAY_VIEW_XWAYLAND) { |
567 | struct wlr_xwayland_surface *surf = | 572 | struct wlr_xwayland_surface *surf = |
568 | wlr_xwayland_surface_from_wlr_surface(wlr_surface); | 573 | wlr_xwayland_surface_from_wlr_surface(wlr_surface); |
@@ -572,6 +577,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
572 | wl_resource_get_client(wlr_surface->resource); | 577 | wl_resource_get_client(wlr_surface->resource); |
573 | wl_client_get_credentials(client, &pid, NULL, NULL); | 578 | wl_client_get_credentials(client, &pid, NULL, NULL); |
574 | } | 579 | } |
580 | #else | ||
581 | struct wl_client *client = | ||
582 | wl_resource_get_client(wlr_surface->resource); | ||
583 | wl_client_get_credentials(client, &pid, NULL, NULL); | ||
584 | #endif | ||
575 | 585 | ||
576 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 586 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
577 | struct sway_container *target_sibling = | 587 | struct sway_container *target_sibling = |
@@ -825,11 +835,13 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { | |||
825 | wlr_xdg_surface_v6_from_wlr_surface(wlr_surface); | 835 | wlr_xdg_surface_v6_from_wlr_surface(wlr_surface); |
826 | return view_from_wlr_xdg_surface_v6(xdg_surface_v6); | 836 | return view_from_wlr_xdg_surface_v6(xdg_surface_v6); |
827 | } | 837 | } |
838 | #ifdef HAVE_XWAYLAND | ||
828 | if (wlr_surface_is_xwayland_surface(wlr_surface)) { | 839 | if (wlr_surface_is_xwayland_surface(wlr_surface)) { |
829 | struct wlr_xwayland_surface *xsurface = | 840 | struct wlr_xwayland_surface *xsurface = |
830 | wlr_xwayland_surface_from_wlr_surface(wlr_surface); | 841 | wlr_xwayland_surface_from_wlr_surface(wlr_surface); |
831 | return view_from_wlr_xwayland_surface(xsurface); | 842 | return view_from_wlr_xwayland_surface(xsurface); |
832 | } | 843 | } |
844 | #endif | ||
833 | if (wlr_surface_is_subsurface(wlr_surface)) { | 845 | if (wlr_surface_is_subsurface(wlr_surface)) { |
834 | struct wlr_subsurface *subsurface = | 846 | struct wlr_subsurface *subsurface = |
835 | wlr_subsurface_from_wlr_surface(wlr_surface); | 847 | wlr_subsurface_from_wlr_surface(wlr_surface); |