Add xwayland command
This commit is contained in:
parent
67d24e8fc5
commit
311c7db7e3
|
@ -176,8 +176,9 @@ sway_cmd cmd_title_format;
|
|||
sway_cmd cmd_unmark;
|
||||
sway_cmd cmd_urgent;
|
||||
sway_cmd cmd_workspace;
|
||||
sway_cmd cmd_ws_auto_back_and_forth;
|
||||
sway_cmd cmd_workspace_layout;
|
||||
sway_cmd cmd_ws_auto_back_and_forth;
|
||||
sway_cmd cmd_xwayland;
|
||||
|
||||
sway_cmd bar_cmd_activate_button;
|
||||
sway_cmd bar_cmd_binding_mode_indicator;
|
||||
|
|
|
@ -393,6 +393,7 @@ struct sway_config {
|
|||
size_t urgent_timeout;
|
||||
enum sway_fowa focus_on_window_activation;
|
||||
enum sway_popup_during_fullscreen popup_during_fullscreen;
|
||||
bool xwayland;
|
||||
|
||||
// Flags
|
||||
enum focus_follows_mouse_mode focus_follows_mouse;
|
||||
|
|
|
@ -71,7 +71,7 @@ struct sway_server server;
|
|||
bool server_privileged_prepare(struct sway_server *server);
|
||||
bool server_init(struct sway_server *server);
|
||||
void server_fini(struct sway_server *server);
|
||||
bool server_start_backend(struct sway_server *server);
|
||||
bool server_start(struct sway_server *server);
|
||||
void server_run(struct sway_server *server);
|
||||
|
||||
void handle_new_output(struct wl_listener *listener, void *data);
|
||||
|
|
|
@ -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 */
|
||||
|
|
21
sway/commands/xwayland.c
Normal file
21
sway/commands/xwayland.c
Normal file
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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).
|
||||
|
||||
|
|
Loading…
Reference in a new issue