aboutsummaryrefslogtreecommitdiffstats
path: root/sway/server.c
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/server.c
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/server.c')
-rw-r--r--sway/server.c73
1 files changed, 38 insertions, 35 deletions
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)) {