build: drop xwayland option

Instead of having a build-time option to enable/disable xwayland
support, just use the wlroots build config: enable xwayland in
Sway if it was enabled when building wlroots. I don't see any
use-case for disabling xwayland in Sway when enabled in wlroots:
Sway doesn't pull in any additional dependency (just pulls in
dependencies that wlroots already needs). We have a config command
to disable xwayland at runtime anyways.

This makes it so xwayland behaves the same way as other features
such as libinput backend and session support. This also reduces
the build matrix (less combinations of build options).

I think we originally introduced the xwayland option when we didn't
have a good way to figure out the wlroots build config from the
Sway build system.
This commit is contained in:
Simon Ser 2024-05-18 14:02:14 +02:00 committed by Simon Zeni
parent fd3b643d15
commit 9704152414
19 changed files with 56 additions and 59 deletions

View file

@ -18,7 +18,7 @@ static bool test_con_id(struct sway_container *container, void *data) {
return container->node.id == *con_id;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
static bool test_id(struct sway_container *container, void *data) {
xcb_window_t *wid = data;
return (container->view && container->view->type == SWAY_VIEW_XWAYLAND
@ -53,7 +53,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
char *value = join_args(argv + 3, argc - 3);
if (strcasecmp(argv[2], "id") == 0) {
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
xcb_window_t id = strtol(value, NULL, 0);
other = root_find_container(test_id, &id);
#endif

View file

@ -10,7 +10,7 @@ struct cmd_results *cmd_xwayland(int argc, char **argv) {
return error;
}
#ifdef HAVE_XWAYLAND
#ifdef WLR_HAS_XWAYLAND
enum xwayland_mode xwayland;
if (strcmp(argv[0], "force") == 0) {
xwayland = XWAYLAND_MODE_IMMEDIATE;

View file

@ -22,7 +22,7 @@ bool criteria_is_empty(struct criteria *criteria) {
&& !criteria->app_id
&& !criteria->con_mark
&& !criteria->con_id
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
&& !criteria->class
&& !criteria->id
&& !criteria->instance
@ -90,7 +90,7 @@ void criteria_destroy(struct criteria *criteria) {
pattern_destroy(criteria->title);
pattern_destroy(criteria->shell);
pattern_destroy(criteria->app_id);
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
pattern_destroy(criteria->class);
pattern_destroy(criteria->instance);
pattern_destroy(criteria->window_role);
@ -110,7 +110,7 @@ static int regex_cmp(const char *item, const pcre2_code *regex) {
return result;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
static bool view_has_window_type(struct sway_view *view, enum atom_name name) {
if (view->type != SWAY_VIEW_XWAYLAND) {
return false;
@ -251,7 +251,7 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
if (criteria->id) { // X11 window ID
uint32_t x11_window_id = view_get_x11_window_id(view);
if (!x11_window_id || x11_window_id != criteria->id) {
@ -428,7 +428,7 @@ list_t *criteria_get_containers(struct criteria *criteria) {
return matches;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
static enum atom_name parse_window_type(const char *type) {
if (strcasecmp(type, "normal") == 0) {
return NET_WM_WINDOW_TYPE_NORMAL;
@ -461,7 +461,7 @@ enum criteria_token {
T_CON_ID,
T_CON_MARK,
T_FLOATING,
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
T_CLASS,
T_ID,
T_INSTANCE,
@ -487,7 +487,7 @@ static enum criteria_token token_from_name(char *name) {
return T_CON_ID;
} else if (strcmp(name, "con_mark") == 0) {
return T_CON_MARK;
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
} else if (strcmp(name, "class") == 0) {
return T_CLASS;
} else if (strcmp(name, "id") == 0) {
@ -566,7 +566,7 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
case T_CON_MARK:
pattern_create(&criteria->con_mark, value);
break;
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
case T_CLASS:
pattern_create(&criteria->class, value);
break;
@ -674,7 +674,7 @@ struct criteria *criteria_parse(char *raw, char **error_arg) {
++head;
struct criteria *criteria = calloc(1, sizeof(struct criteria));
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
criteria->window_type = ATOM_LAST; // default value
#endif
char *name = NULL, *value = NULL;

View file

@ -761,7 +761,7 @@ static bool should_configure(struct sway_node *node,
}
struct sway_container_state *cstate = &node->sway_container->current;
struct sway_container_state *istate = &instruction->container_state;
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
// Xwayland views are position-aware and need to be reconfigured
// when their position changes.
if (node->sway_container->view->type == SWAY_VIEW_XWAYLAND) {

View file

@ -107,7 +107,7 @@ struct sway_node *node_at_coords(
return NULL;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
if (scene_descriptor_try_get(current, SWAY_SCENE_DESC_XWAYLAND_UNMANAGED)) {
return NULL;
}

View file

@ -190,7 +190,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
node->sway_container->view : NULL;
if (view && seat_is_input_allowed(seat, view->surface)) {
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
if (view->type == SWAY_VIEW_XWAYLAND) {
struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
@ -1002,7 +1002,7 @@ void seat_configure_xcursor(struct sway_seat *seat) {
setenv("XCURSOR_THEME", cursor_theme, 1);
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
if (server.xwayland.wlr_xwayland && (!server.xwayland.xcursor_manager ||
!xcursor_manager_is_named(server.xwayland.xcursor_manager,
cursor_theme) ||

View file

@ -15,7 +15,7 @@
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "log.h"
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
#include "sway/xwayland.h"
#endif
@ -234,7 +234,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
node->sway_container : NULL;
struct wlr_layer_surface_v1 *layer;
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
struct wlr_xwayland_surface *xsurface;
#endif
if ((layer = wlr_layer_surface_v1_try_from_wlr_surface(surface)) &&
@ -268,7 +268,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
seat_set_focus_container(seat, cont);
seatop_begin_down(seat, node->sway_container, sx, sy);
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
// Handle tapping on an xwayland unmanaged view
else if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(surface)) &&
xsurface->override_redirect &&
@ -514,7 +514,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
return;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
// Handle clicking on xwayland unmanaged view
struct wlr_xwayland_surface *xsurface;
if (surface &&

View file

@ -154,7 +154,7 @@ static json_object *ipc_json_output_mode_description(
return mode_object;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
static const char *ipc_json_xwindow_type_description(struct sway_view *view) {
struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
struct sway_xwayland *xwayland = &server.xwayland;
@ -633,7 +633,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
json_object_new_string(ipc_json_content_type_description(content_type)));
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
if (c->view->type == SWAY_VIEW_XWAYLAND) {
json_object_object_add(object, "window",
json_object_new_int(view_get_x11_window_id(c->view)));

View file

@ -231,7 +231,7 @@ sway_deps = [
xcb_icccm,
]
if have_xwayland
if wlroots_features['xwayland']
sway_sources += 'desktop/xwayland.c'
endif

View file

@ -56,7 +56,7 @@
#include "sway/input/cursor.h"
#include "sway/tree/root.h"
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
#include <wlr/xwayland/shell.h>
#include "sway/xwayland.h"
#endif
@ -118,7 +118,7 @@ static bool is_privileged(const struct wl_global *global) {
static bool filter_global(const struct wl_client *client,
const struct wl_global *global, void *data) {
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
if (xwayland && global == xwayland->shell_v1->global) {
return xwayland->server != NULL && client == xwayland->server->client;
@ -437,7 +437,7 @@ bool server_init(struct sway_server *server) {
void server_fini(struct sway_server *server) {
// TODO: free sway-specific resources
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
wlr_xwayland_destroy(server->xwayland.wlr_xwayland);
#endif
wl_display_destroy_clients(server->wl_display);
@ -447,7 +447,7 @@ void server_fini(struct sway_server *server) {
}
bool server_start(struct sway_server *server) {
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
if (config->xwayland != XWAYLAND_MODE_DISABLED) {
sway_log(SWAY_DEBUG, "Initializing Xwayland (lazy=%d)",
config->xwayland == XWAYLAND_MODE_LAZY);

View file

@ -53,7 +53,7 @@ struct sway_root *root_create(struct wl_display *wl_display) {
root->layers.shell_top = alloc_scene_tree(root->layer_tree, &failed);
root->layers.fullscreen = alloc_scene_tree(root->layer_tree, &failed);
root->layers.fullscreen_global = alloc_scene_tree(root->layer_tree, &failed);
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
root->layers.unmanaged = alloc_scene_tree(root->layer_tree, &failed);
#endif
root->layers.shell_overlay = alloc_scene_tree(root->layer_tree, &failed);

View file

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <strings.h>
#include <wayland-server-core.h>
#include <wlr/config.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
@ -9,8 +10,7 @@
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include "config.h"
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
#include <wlr/xwayland.h>
#endif
#include "list.h"
@ -126,7 +126,7 @@ const char *view_get_instance(struct sway_view *view) {
}
return NULL;
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
uint32_t view_get_x11_window_id(struct sway_view *view) {
if (view->impl->get_int_prop) {
return view->impl->get_int_prop(view, VIEW_PROP_X11_WINDOW_ID);
@ -159,7 +159,7 @@ const char *view_get_shell(struct sway_view *view) {
switch(view->type) {
case SWAY_VIEW_XDG_SHELL:
return "xdg_shell";
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
case SWAY_VIEW_XWAYLAND:
return "xwayland";
#endif
@ -499,7 +499,7 @@ void view_execute_criteria(struct sway_view *view) {
static void view_populate_pid(struct sway_view *view) {
pid_t pid;
switch (view->type) {
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
case SWAY_VIEW_XWAYLAND:;
struct wlr_xwayland_surface *surf =
wlr_xwayland_surface_try_from_wlr_surface(view->surface);
@ -838,7 +838,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool set_focus = should_focus(view);
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
struct wlr_xwayland_surface *xsurface;
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(wlr_surface))) {
set_focus &= wlr_xwayland_icccm_input_model(xsurface) !=
@ -954,7 +954,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface))) {
return view_from_wlr_xdg_surface(xdg_surface);
}
#if HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
struct wlr_xwayland_surface *xsurface;
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(wlr_surface))) {
return view_from_wlr_xwayland_surface(xsurface);