diff options
author | emersion <contact@emersion.fr> | 2018-11-17 12:29:59 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-11-19 17:38:37 +0100 |
commit | 311c7db7e300bc9e749a582a56805150180138e0 (patch) | |
tree | a695f7af6143e47c8b7bb8afe32e2e8f59c39958 /sway/server.c | |
parent | Merge pull request #3152 from camoz/master (diff) | |
download | sway-311c7db7e300bc9e749a582a56805150180138e0.tar.gz sway-311c7db7e300bc9e749a582a56805150180138e0.tar.zst sway-311c7db7e300bc9e749a582a56805150180138e0.zip |
Add xwayland command
Diffstat (limited to 'sway/server.c')
-rw-r--r-- | sway/server.c | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/sway/server.c b/sway/server.c index cd3fcdf6..68142e87 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -83,40 +83,6 @@ bool server_init(struct sway_server *server) { | |||
83 | &server->xdg_shell_surface); | 83 | &server->xdg_shell_surface); |
84 | server->xdg_shell_surface.notify = handle_xdg_shell_surface; | 84 | server->xdg_shell_surface.notify = handle_xdg_shell_surface; |
85 | 85 | ||
86 | // TODO: configurable cursor theme and size | ||
87 | int cursor_size = 24; | ||
88 | const char *cursor_theme = NULL; | ||
89 | |||
90 | char cursor_size_fmt[16]; | ||
91 | snprintf(cursor_size_fmt, sizeof(cursor_size_fmt), "%d", cursor_size); | ||
92 | setenv("XCURSOR_SIZE", cursor_size_fmt, 1); | ||
93 | if (cursor_theme != NULL) { | ||
94 | setenv("XCURSOR_THEME", cursor_theme, 1); | ||
95 | } | ||
96 | |||
97 | #if HAVE_XWAYLAND | ||
98 | server->xwayland.wlr_xwayland = | ||
99 | wlr_xwayland_create(server->wl_display, server->compositor, true); | ||
100 | wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface, | ||
101 | &server->xwayland_surface); | ||
102 | server->xwayland_surface.notify = handle_xwayland_surface; | ||
103 | wl_signal_add(&server->xwayland.wlr_xwayland->events.ready, | ||
104 | &server->xwayland_ready); | ||
105 | server->xwayland_ready.notify = handle_xwayland_ready; | ||
106 | |||
107 | server->xwayland.xcursor_manager = | ||
108 | wlr_xcursor_manager_create(cursor_theme, cursor_size); | ||
109 | wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1); | ||
110 | struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( | ||
111 | server->xwayland.xcursor_manager, "left_ptr", 1); | ||
112 | if (xcursor != NULL) { | ||
113 | struct wlr_xcursor_image *image = xcursor->images[0]; | ||
114 | wlr_xwayland_set_cursor(server->xwayland.wlr_xwayland, image->buffer, | ||
115 | image->width * 4, image->width, image->height, image->hotspot_x, | ||
116 | image->hotspot_y); | ||
117 | } | ||
118 | #endif | ||
119 | |||
120 | server->server_decoration_manager = | 86 | server->server_decoration_manager = |
121 | wlr_server_decoration_manager_create(server->wl_display); | 87 | wlr_server_decoration_manager_create(server->wl_display); |
122 | wlr_server_decoration_manager_set_default_mode( | 88 | wlr_server_decoration_manager_set_default_mode( |
@@ -173,7 +139,44 @@ void server_fini(struct sway_server *server) { | |||
173 | list_free(server->transactions); | 139 | list_free(server->transactions); |
174 | } | 140 | } |
175 | 141 | ||
176 | bool server_start_backend(struct sway_server *server) { | 142 | bool server_start(struct sway_server *server) { |
143 | // TODO: configurable cursor theme and size | ||
144 | int cursor_size = 24; | ||
145 | const char *cursor_theme = NULL; | ||
146 | |||
147 | char cursor_size_fmt[16]; | ||
148 | snprintf(cursor_size_fmt, sizeof(cursor_size_fmt), "%d", cursor_size); | ||
149 | setenv("XCURSOR_SIZE", cursor_size_fmt, 1); | ||
150 | if (cursor_theme != NULL) { | ||
151 | setenv("XCURSOR_THEME", cursor_theme, 1); | ||
152 | } | ||
153 | |||
154 | #if HAVE_XWAYLAND | ||
155 | if (config->xwayland) { | ||
156 | wlr_log(WLR_DEBUG, "Initializing Xwayland"); | ||
157 | server->xwayland.wlr_xwayland = | ||
158 | wlr_xwayland_create(server->wl_display, server->compositor, true); | ||
159 | wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface, | ||
160 | &server->xwayland_surface); | ||
161 | server->xwayland_surface.notify = handle_xwayland_surface; | ||
162 | wl_signal_add(&server->xwayland.wlr_xwayland->events.ready, | ||
163 | &server->xwayland_ready); | ||
164 | server->xwayland_ready.notify = handle_xwayland_ready; | ||
165 | |||
166 | server->xwayland.xcursor_manager = | ||
167 | wlr_xcursor_manager_create(cursor_theme, cursor_size); | ||
168 | wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1); | ||
169 | struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( | ||
170 | server->xwayland.xcursor_manager, "left_ptr", 1); | ||
171 | if (xcursor != NULL) { | ||
172 | struct wlr_xcursor_image *image = xcursor->images[0]; | ||
173 | wlr_xwayland_set_cursor(server->xwayland.wlr_xwayland, image->buffer, | ||
174 | image->width * 4, image->width, image->height, image->hotspot_x, | ||
175 | image->hotspot_y); | ||
176 | } | ||
177 | } | ||
178 | #endif | ||
179 | |||
177 | wlr_log(WLR_INFO, "Starting backend on wayland display '%s'", | 180 | wlr_log(WLR_INFO, "Starting backend on wayland display '%s'", |
178 | server->socket); | 181 | server->socket); |
179 | if (!wlr_backend_start(server->backend)) { | 182 | if (!wlr_backend_start(server->backend)) { |