mirror of
https://github.com/swaywm/sway.git
synced 2026-05-01 06:46:25 -04:00
make xwayland optional
This commit is contained in:
parent
b1e72461cf
commit
e8b9c5208e
16 changed files with 75 additions and 2 deletions
|
|
@ -24,7 +24,9 @@ struct criteria {
|
|||
pcre *instance;
|
||||
pcre *con_mark;
|
||||
uint32_t con_id; // internal ID
|
||||
#ifdef HAVE_XWAYLAND
|
||||
uint32_t id; // X11 window ID
|
||||
#endif
|
||||
pcre *window_role;
|
||||
uint32_t window_type;
|
||||
bool floating;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@
|
|||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
// TODO WLR: make Xwayland optional
|
||||
#ifdef HAVE_XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
#endif
|
||||
|
||||
struct sway_server {
|
||||
struct wl_display *wl_display;
|
||||
|
|
@ -37,9 +39,13 @@ struct sway_server {
|
|||
struct wlr_xdg_shell *xdg_shell;
|
||||
struct wl_listener xdg_shell_surface;
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct wlr_xwayland *xwayland;
|
||||
#endif
|
||||
struct wlr_xcursor_manager *xcursor_manager;
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct wl_listener xwayland_surface;
|
||||
#endif
|
||||
|
||||
struct wlr_wl_shell *wl_shell;
|
||||
struct wl_listener wl_shell_surface;
|
||||
|
|
@ -56,6 +62,8 @@ void handle_new_output(struct wl_listener *listener, void *data);
|
|||
void handle_layer_shell_surface(struct wl_listener *listener, void *data);
|
||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
|
||||
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
|
||||
#ifdef HAVE_XWAYLAND
|
||||
void handle_xwayland_surface(struct wl_listener *listener, void *data);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ struct sway_root {
|
|||
|
||||
struct wl_listener output_layout_change;
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
|
||||
#endif
|
||||
|
||||
struct wlr_texture *debug_tree;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||
#ifdef HAVE_XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
#endif
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
|
||||
|
|
@ -12,7 +14,9 @@ struct sway_container;
|
|||
enum sway_view_type {
|
||||
SWAY_VIEW_XDG_SHELL_V6,
|
||||
SWAY_VIEW_XDG_SHELL,
|
||||
#ifdef HAVE_XWAYLAND
|
||||
SWAY_VIEW_XWAYLAND,
|
||||
#endif
|
||||
};
|
||||
|
||||
enum sway_view_prop {
|
||||
|
|
@ -22,7 +26,9 @@ enum sway_view_prop {
|
|||
VIEW_PROP_INSTANCE,
|
||||
VIEW_PROP_WINDOW_TYPE,
|
||||
VIEW_PROP_WINDOW_ROLE,
|
||||
#ifdef HAVE_XWAYLAND
|
||||
VIEW_PROP_X11_WINDOW_ID,
|
||||
#endif
|
||||
};
|
||||
|
||||
struct sway_view_impl {
|
||||
|
|
@ -79,7 +85,9 @@ struct sway_view {
|
|||
union {
|
||||
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
|
||||
struct wlr_xdg_surface *wlr_xdg_surface;
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
||||
#endif
|
||||
struct wlr_wl_shell_surface *wlr_wl_shell_surface;
|
||||
};
|
||||
|
||||
|
|
@ -123,6 +131,7 @@ struct sway_xdg_shell_view {
|
|||
int pending_width, pending_height;
|
||||
};
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct sway_xwayland_view {
|
||||
struct sway_view view;
|
||||
|
||||
|
|
@ -156,6 +165,7 @@ struct sway_xwayland_unmanaged {
|
|||
struct wl_listener unmap;
|
||||
struct wl_listener destroy;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct sway_view_child;
|
||||
|
||||
|
|
@ -204,7 +214,9 @@ const char *view_get_class(struct sway_view *view);
|
|||
|
||||
const char *view_get_instance(struct sway_view *view);
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
uint32_t view_get_x11_window_id(struct sway_view *view);
|
||||
#endif
|
||||
|
||||
const char *view_get_window_role(struct sway_view *view);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ git = find_program('git', required: false)
|
|||
|
||||
conf_data = configuration_data()
|
||||
|
||||
if get_option('enable-xwayland')
|
||||
conf_data.set('HAVE_XWAYLAND', true)
|
||||
endif
|
||||
|
||||
if gdk_pixbuf.found()
|
||||
conf_data.set('HAVE_GDK_PIXBUF', true)
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
option('sway_version', type : 'string', description: 'The version string reported in `sway --version`.')
|
||||
option('default_wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.')
|
||||
option('zsh_completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
|
||||
option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications')
|
||||
|
|
|
|||
|
|
@ -13,10 +13,14 @@ static bool test_con_id(struct sway_container *container, void *con_id) {
|
|||
}
|
||||
|
||||
static bool test_id(struct sway_container *container, void *id) {
|
||||
#ifdef HAVE_XWAYLAND
|
||||
xcb_window_t *wid = id;
|
||||
return (container->type == C_VIEW
|
||||
&& container->sway_view->type == SWAY_VIEW_XWAYLAND
|
||||
&& container->sway_view->wlr_xwayland_surface->window_id == *wid);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool test_mark(struct sway_container *container, void *mark) {
|
||||
|
|
@ -42,8 +46,10 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
|
|||
|
||||
char *value = join_args(argv + 3, argc - 3);
|
||||
if (strcasecmp(argv[2], "id") == 0) {
|
||||
#ifdef HAVE_XWAYLAND
|
||||
xcb_window_t id = strtol(value, NULL, 0);
|
||||
other = container_find(&root_container, test_id, (void *)&id);
|
||||
#endif
|
||||
} else if (strcasecmp(argv[2], "con_id") == 0) {
|
||||
size_t con_id = atoi(value);
|
||||
other = container_find(&root_container, test_con_id, (void *)con_id);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ bool criteria_is_empty(struct criteria *criteria) {
|
|||
&& !criteria->instance
|
||||
&& !criteria->con_mark
|
||||
&& !criteria->con_id
|
||||
#ifdef HAVE_XWAYLAND
|
||||
&& !criteria->id
|
||||
#endif
|
||||
&& !criteria->window_role
|
||||
&& !criteria->window_type
|
||||
&& !criteria->floating
|
||||
|
|
@ -102,12 +104,14 @@ static bool criteria_matches_view(struct criteria *criteria,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_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) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (criteria->window_role) {
|
||||
// TODO
|
||||
|
|
@ -377,12 +381,14 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
|
|||
case T_WINDOW_TYPE:
|
||||
// TODO: This is a string but will be stored as an enum or integer
|
||||
break;
|
||||
#ifdef HAVE_XWAYLAND
|
||||
case T_ID:
|
||||
criteria->id = strtoul(effective_value, &endptr, 10);
|
||||
if (*endptr != 0) {
|
||||
error = strdup("The value for 'id' should be numeric");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case T_FLOATING:
|
||||
criteria->floating = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ static void layer_for_each_surface(struct wl_list *layer_surfaces,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
static void unmanaged_for_each_surface(struct wl_list *unmanaged,
|
||||
struct sway_output *output, struct root_geometry *geo,
|
||||
wlr_surface_iterator_func_t iterator, void *user_data) {
|
||||
|
|
@ -160,6 +161,7 @@ static void unmanaged_for_each_surface(struct wl_list *unmanaged,
|
|||
iterator, user_data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void scale_box(struct wlr_box *box, float scale) {
|
||||
box->x *= scale;
|
||||
|
|
@ -259,6 +261,7 @@ static void render_layer(struct sway_output *output,
|
|||
render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
static void render_unmanaged(struct sway_output *output,
|
||||
pixman_region32_t *damage, struct wl_list *unmanaged) {
|
||||
struct render_data data = {
|
||||
|
|
@ -269,6 +272,7 @@ static void render_unmanaged(struct sway_output *output,
|
|||
unmanaged_for_each_surface(unmanaged, output, &data.root_geo,
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void render_rect(struct wlr_output *wlr_output,
|
||||
pixman_region32_t *output_damage, const struct wlr_box *_box,
|
||||
|
|
@ -880,10 +884,12 @@ static void render_output(struct sway_output *output, struct timespec *when,
|
|||
render_view_surfaces(
|
||||
workspace->sway_workspace->fullscreen, output, damage, 1.0f);
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
if (workspace->sway_workspace->fullscreen->type == SWAY_VIEW_XWAYLAND) {
|
||||
render_unmanaged(output, damage,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
|
||||
|
||||
|
|
@ -904,8 +910,10 @@ static void render_output(struct sway_output *output, struct timespec *when,
|
|||
render_container(output, damage, workspace, focus == workspace);
|
||||
render_floating(output, damage);
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
render_unmanaged(output, damage,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
#endif
|
||||
render_layer(output, damage,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
|
||||
}
|
||||
|
|
@ -955,11 +963,13 @@ static void send_frame_done_layer(struct send_frame_done_data *data,
|
|||
send_frame_done_iterator, data);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
static void send_frame_done_unmanaged(struct send_frame_done_data *data,
|
||||
struct wl_list *unmanaged) {
|
||||
unmanaged_for_each_surface(unmanaged, data->output, &data->root_geo,
|
||||
send_frame_done_iterator, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void send_frame_done_container_iterator(struct sway_container *con,
|
||||
void *_data) {
|
||||
|
|
@ -993,10 +1003,12 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) {
|
|||
send_frame_done_container_iterator(
|
||||
workspace->sway_workspace->fullscreen->swayc, &data);
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
if (workspace->sway_workspace->fullscreen->type == SWAY_VIEW_XWAYLAND) {
|
||||
send_frame_done_unmanaged(&data,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
send_frame_done_layer(&data,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
|
||||
|
|
@ -1006,8 +1018,10 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) {
|
|||
send_frame_done_container(&data, workspace);
|
||||
send_frame_done_container(&data, workspace->sway_workspace->floating);
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
send_frame_done_unmanaged(&data,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
#endif
|
||||
send_frame_done_layer(&data,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#define _POSIX_C_SOURCE 199309L
|
||||
#ifdef HAVE_XWAYLAND
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wayland-server.h>
|
||||
|
|
@ -411,3 +412,4 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
wl_signal_add(&xsurface->events.map, &xwayland_view->map);
|
||||
xwayland_view->map.notify = handle_map;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ static struct sway_container *container_at_coords(
|
|||
struct sway_seat *seat, double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx, double *sy) {
|
||||
// check for unmanaged views first
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged;
|
||||
struct sway_xwayland_unmanaged *unmanaged_surface;
|
||||
wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) {
|
||||
|
|
@ -64,7 +65,7 @@ static struct sway_container *container_at_coords(
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// find the output the cursor is on
|
||||
struct wlr_output_layout *output_layout =
|
||||
root_container.sway_root->output_layout;
|
||||
|
|
|
|||
|
|
@ -95,10 +95,12 @@ static void seat_send_focus(struct sway_container *con,
|
|||
|
||||
if (con->type == C_VIEW
|
||||
&& seat_is_input_allowed(seat, con->sway_view->surface)) {
|
||||
#ifdef HAVE_XWAYLAND
|
||||
if (con->sway_view->type == SWAY_VIEW_XWAYLAND) {
|
||||
struct wlr_xwayland *xwayland = seat->input->server->xwayland;
|
||||
wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
|
||||
}
|
||||
#endif
|
||||
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
|
||||
if (keyboard) {
|
||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
#include <wlr/types/wlr_xdg_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
// TODO WLR: make Xwayland optional
|
||||
#ifdef HAVE_XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
#endif
|
||||
#include "sway/config.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/server.h"
|
||||
|
|
@ -72,12 +74,13 @@ bool server_init(struct sway_server *server) {
|
|||
server->xdg_shell_surface.notify = handle_xdg_shell_surface;
|
||||
|
||||
// TODO make xwayland optional
|
||||
#ifdef HAVE_XWAYLAND
|
||||
server->xwayland =
|
||||
wlr_xwayland_create(server->wl_display, server->compositor, true);
|
||||
wl_signal_add(&server->xwayland->events.new_surface,
|
||||
&server->xwayland_surface);
|
||||
server->xwayland_surface.notify = handle_xwayland_surface;
|
||||
|
||||
#endif
|
||||
// TODO: configurable cursor theme and size
|
||||
server->xcursor_manager = wlr_xcursor_manager_create(NULL, 24);
|
||||
wlr_xcursor_manager_load(server->xcursor_manager, 1);
|
||||
|
|
@ -85,9 +88,11 @@ bool server_init(struct sway_server *server) {
|
|||
server->xcursor_manager, "left_ptr", 1);
|
||||
if (xcursor != NULL) {
|
||||
struct wlr_xcursor_image *image = xcursor->images[0];
|
||||
#ifdef HAVE_XWAYLAND
|
||||
wlr_xwayland_set_cursor(server->xwayland, image->buffer,
|
||||
image->width * 4, image->width, image->height, image->hotspot_x,
|
||||
image->hotspot_y);
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Integration with sway borders
|
||||
|
|
|
|||
|
|
@ -487,10 +487,12 @@ static struct sway_container *container_at_view(struct sway_container *swayc,
|
|||
double _sx, _sy;
|
||||
struct wlr_surface *_surface = NULL;
|
||||
switch (sview->type) {
|
||||
#ifdef HAVE_XWAYLAND
|
||||
case SWAY_VIEW_XWAYLAND:
|
||||
_surface = wlr_surface_surface_at(sview->surface,
|
||||
view_sx, view_sy, &_sx, &_sy);
|
||||
break;
|
||||
#endif
|
||||
case SWAY_VIEW_XDG_SHELL_V6:
|
||||
// the top left corner of the sway container is the
|
||||
// coordinate of the top left corner of the window geometry
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ void layout_init(void) {
|
|||
|
||||
root_container.sway_root = calloc(1, sizeof(*root_container.sway_root));
|
||||
root_container.sway_root->output_layout = wlr_output_layout_create();
|
||||
#ifdef HAVE_XWAYLAND
|
||||
wl_list_init(&root_container.sway_root->xwayland_unmanaged);
|
||||
#endif
|
||||
wl_signal_init(&root_container.sway_root->events.new_container);
|
||||
|
||||
root_container.sway_root->output_layout_change.notify =
|
||||
|
|
|
|||
|
|
@ -86,12 +86,14 @@ const char *view_get_instance(struct sway_view *view) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_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);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *view_get_window_role(struct sway_view *view) {
|
||||
if (view->impl->get_string_prop) {
|
||||
|
|
@ -113,8 +115,10 @@ const char *view_get_shell(struct sway_view *view) {
|
|||
return "xdg_shell_v6";
|
||||
case SWAY_VIEW_XDG_SHELL:
|
||||
return "xdg_shell";
|
||||
#ifdef HAVE_XWAYLAND
|
||||
case SWAY_VIEW_XWAYLAND:
|
||||
return "xwayland";
|
||||
#endif
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue