Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2011 Intel Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and |
| 5 | * its documentation for any purpose is hereby granted without fee, provided |
| 6 | * that the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of the copyright holders not be used in |
| 9 | * advertising or publicity pertaining to distribution of the software |
| 10 | * without specific, written prior permission. The copyright holders make |
| 11 | * no representations about the suitability of this software for any |
| 12 | * purpose. It is provided "as is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #define _GNU_SOURCE |
| 24 | |
| 25 | #include <stdlib.h> |
| 26 | #include <stdio.h> |
| 27 | #include <string.h> |
| 28 | #include <sys/socket.h> |
| 29 | #include <sys/un.h> |
| 30 | #include <fcntl.h> |
| 31 | #include <errno.h> |
| 32 | #include <unistd.h> |
| 33 | #include <signal.h> |
| 34 | |
| 35 | #include "xwayland.h" |
| 36 | #include "xserver-server-protocol.h" |
| 37 | |
| 38 | |
| 39 | static int |
| 40 | weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data) |
| 41 | { |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 42 | struct weston_xserver *wxs = data; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 43 | char display[8], s[8]; |
| 44 | int sv[2], client_fd; |
| 45 | |
| 46 | if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 47 | weston_log("socketpair failed\n"); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 48 | return 1; |
| 49 | } |
| 50 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 51 | wxs->process.pid = fork(); |
| 52 | switch (wxs->process.pid) { |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 53 | case 0: |
| 54 | /* SOCK_CLOEXEC closes both ends, so we need to unset |
| 55 | * the flag on the client fd. */ |
| 56 | client_fd = dup(sv[1]); |
| 57 | if (client_fd < 0) |
| 58 | return 1; |
| 59 | |
| 60 | snprintf(s, sizeof s, "%d", client_fd); |
| 61 | setenv("WAYLAND_SOCKET", s, 1); |
| 62 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 63 | snprintf(display, sizeof display, ":%d", wxs->display); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 64 | |
| 65 | if (execl(XSERVER_PATH, |
| 66 | XSERVER_PATH, |
| 67 | display, |
| 68 | "-wayland", |
| 69 | "-rootless", |
| 70 | "-retro", |
| 71 | "-nolisten", "all", |
| 72 | "-terminate", |
| 73 | NULL) < 0) |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 74 | weston_log("exec failed: %m\n"); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 75 | exit(-1); |
| 76 | |
| 77 | default: |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 78 | weston_log("forked X server, pid %d\n", wxs->process.pid); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 79 | |
| 80 | close(sv[1]); |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 81 | wxs->client = wl_client_create(wxs->wl_display, sv[0]); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 82 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 83 | weston_watch_process(&wxs->process); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 84 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 85 | wl_event_source_remove(wxs->abstract_source); |
| 86 | wl_event_source_remove(wxs->unix_source); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 87 | break; |
| 88 | |
| 89 | case -1: |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 90 | weston_log( "failed to fork\n"); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 91 | break; |
| 92 | } |
| 93 | |
| 94 | return 1; |
| 95 | } |
| 96 | |
| 97 | static void |
| 98 | weston_xserver_shutdown(struct weston_xserver *wxs) |
| 99 | { |
| 100 | char path[256]; |
| 101 | |
| 102 | snprintf(path, sizeof path, "/tmp/.X%d-lock", wxs->display); |
| 103 | unlink(path); |
| 104 | snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display); |
| 105 | unlink(path); |
| 106 | if (wxs->process.pid == 0) { |
| 107 | wl_event_source_remove(wxs->abstract_source); |
| 108 | wl_event_source_remove(wxs->unix_source); |
| 109 | } |
| 110 | close(wxs->abstract_fd); |
| 111 | close(wxs->unix_fd); |
| 112 | if (wxs->wm) |
| 113 | weston_wm_destroy(wxs->wm); |
| 114 | wxs->loop = NULL; |
| 115 | } |
| 116 | |
| 117 | static void |
| 118 | weston_xserver_cleanup(struct weston_process *process, int status) |
| 119 | { |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 120 | struct weston_xserver *wxs = |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 121 | container_of(process, struct weston_xserver, process); |
| 122 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 123 | wxs->process.pid = 0; |
| 124 | wxs->client = NULL; |
| 125 | wxs->resource = NULL; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 126 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 127 | wxs->abstract_source = |
| 128 | wl_event_loop_add_fd(wxs->loop, wxs->abstract_fd, |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 129 | WL_EVENT_READABLE, |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 130 | weston_xserver_handle_event, wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 131 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 132 | wxs->unix_source = |
| 133 | wl_event_loop_add_fd(wxs->loop, wxs->unix_fd, |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 134 | WL_EVENT_READABLE, |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 135 | weston_xserver_handle_event, wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 136 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 137 | if (wxs->wm) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 138 | weston_log("xserver exited, code %d\n", status); |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 139 | weston_wm_destroy(wxs->wm); |
| 140 | wxs->wm = NULL; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 141 | } else { |
| 142 | /* If the X server crashes before it binds to the |
| 143 | * xserver interface, shut down and don't try |
| 144 | * again. */ |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 145 | weston_log("xserver crashing too fast: %d\n", status); |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 146 | weston_xserver_shutdown(wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 147 | } |
| 148 | } |
| 149 | |
| 150 | static void |
| 151 | bind_xserver(struct wl_client *client, |
| 152 | void *data, uint32_t version, uint32_t id) |
| 153 | { |
| 154 | struct weston_xserver *wxs = data; |
| 155 | |
| 156 | /* If it's a different client than the xserver we launched, |
| 157 | * don't start the wm. */ |
| 158 | if (client != wxs->client) |
| 159 | return; |
| 160 | |
| 161 | wxs->resource = |
| 162 | wl_client_add_object(client, &xserver_interface, |
| 163 | &xserver_implementation, id, wxs); |
| 164 | |
| 165 | wxs->wm = weston_wm_create(wxs); |
| 166 | if (wxs->wm == NULL) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 167 | weston_log("failed to create wm\n"); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | xserver_send_listen_socket(wxs->resource, wxs->abstract_fd); |
| 171 | xserver_send_listen_socket(wxs->resource, wxs->unix_fd); |
| 172 | } |
| 173 | |
| 174 | static int |
| 175 | bind_to_abstract_socket(int display) |
| 176 | { |
| 177 | struct sockaddr_un addr; |
| 178 | socklen_t size, name_size; |
| 179 | int fd; |
| 180 | |
| 181 | fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0); |
| 182 | if (fd < 0) |
| 183 | return -1; |
| 184 | |
| 185 | addr.sun_family = AF_LOCAL; |
| 186 | name_size = snprintf(addr.sun_path, sizeof addr.sun_path, |
| 187 | "%c/tmp/.X11-unix/X%d", 0, display); |
| 188 | size = offsetof(struct sockaddr_un, sun_path) + name_size; |
| 189 | if (bind(fd, (struct sockaddr *) &addr, size) < 0) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 190 | weston_log("failed to bind to @%s: %s\n", |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 191 | addr.sun_path + 1, strerror(errno)); |
| 192 | close(fd); |
| 193 | return -1; |
| 194 | } |
| 195 | |
| 196 | if (listen(fd, 1) < 0) { |
| 197 | close(fd); |
| 198 | return -1; |
| 199 | } |
| 200 | |
| 201 | return fd; |
| 202 | } |
| 203 | |
| 204 | static int |
| 205 | bind_to_unix_socket(int display) |
| 206 | { |
| 207 | struct sockaddr_un addr; |
| 208 | socklen_t size, name_size; |
| 209 | int fd; |
| 210 | |
| 211 | fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0); |
| 212 | if (fd < 0) |
| 213 | return -1; |
| 214 | |
| 215 | addr.sun_family = AF_LOCAL; |
| 216 | name_size = snprintf(addr.sun_path, sizeof addr.sun_path, |
| 217 | "/tmp/.X11-unix/X%d", display) + 1; |
| 218 | size = offsetof(struct sockaddr_un, sun_path) + name_size; |
| 219 | unlink(addr.sun_path); |
| 220 | if (bind(fd, (struct sockaddr *) &addr, size) < 0) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 221 | weston_log("failed to bind to %s (%s)\n", |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 222 | addr.sun_path, strerror(errno)); |
| 223 | close(fd); |
| 224 | return -1; |
| 225 | } |
| 226 | |
| 227 | if (listen(fd, 1) < 0) { |
| 228 | unlink(addr.sun_path); |
| 229 | close(fd); |
| 230 | return -1; |
| 231 | } |
| 232 | |
| 233 | return fd; |
| 234 | } |
| 235 | |
| 236 | static int |
| 237 | create_lockfile(int display, char *lockfile, size_t lsize) |
| 238 | { |
| 239 | char pid[16], *end; |
| 240 | int fd, size; |
| 241 | pid_t other; |
| 242 | |
| 243 | snprintf(lockfile, lsize, "/tmp/.X%d-lock", display); |
| 244 | fd = open(lockfile, O_WRONLY | O_CLOEXEC | O_CREAT | O_EXCL, 0444); |
| 245 | if (fd < 0 && errno == EEXIST) { |
| 246 | fd = open(lockfile, O_CLOEXEC, O_RDONLY); |
| 247 | if (fd < 0 || read(fd, pid, 11) != 11) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 248 | weston_log("can't read lock file %s: %s\n", |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 249 | lockfile, strerror(errno)); |
| 250 | errno = EEXIST; |
| 251 | return -1; |
| 252 | } |
| 253 | |
| 254 | other = strtol(pid, &end, 0); |
| 255 | if (end != pid + 10) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 256 | weston_log("can't parse lock file %s\n", |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 257 | lockfile); |
| 258 | close(fd); |
| 259 | errno = EEXIST; |
| 260 | return -1; |
| 261 | } |
| 262 | |
| 263 | if (kill(other, 0) < 0 && errno == ESRCH) { |
| 264 | /* stale lock file; unlink and try again */ |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 265 | weston_log("unlinking stale lock file %s\n", lockfile); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 266 | close(fd); |
| 267 | if (unlink(lockfile)) |
| 268 | /* If we fail to unlink, return EEXIST |
| 269 | so we try the next display number.*/ |
| 270 | errno = EEXIST; |
| 271 | else |
| 272 | errno = EAGAIN; |
| 273 | return -1; |
| 274 | } |
| 275 | |
Martin Olsson | 1972141 | 2012-07-08 03:03:45 +0200 | [diff] [blame] | 276 | close(fd); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 277 | errno = EEXIST; |
| 278 | return -1; |
| 279 | } else if (fd < 0) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 280 | weston_log("failed to create lock file %s: %s\n", |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 281 | lockfile, strerror(errno)); |
| 282 | return -1; |
| 283 | } |
| 284 | |
| 285 | /* Subtle detail: we use the pid of the wayland |
| 286 | * compositor, not the xserver in the lock file. */ |
| 287 | size = snprintf(pid, sizeof pid, "%10d\n", getpid()); |
| 288 | if (write(fd, pid, size) != size) { |
| 289 | unlink(lockfile); |
| 290 | close(fd); |
| 291 | return -1; |
| 292 | } |
| 293 | |
| 294 | close(fd); |
| 295 | |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | static void |
| 300 | weston_xserver_destroy(struct wl_listener *l, void *data) |
| 301 | { |
| 302 | struct weston_xserver *wxs = |
| 303 | container_of(l, struct weston_xserver, destroy_listener); |
| 304 | |
| 305 | if (!wxs) |
| 306 | return; |
| 307 | |
| 308 | if (wxs->loop) |
| 309 | weston_xserver_shutdown(wxs); |
| 310 | |
| 311 | free(wxs); |
| 312 | } |
| 313 | |
| 314 | WL_EXPORT int |
Kristian Høgsberg | b00a9d3 | 2012-09-11 14:06:27 -0400 | [diff] [blame] | 315 | module_init(struct weston_compositor *compositor) |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 316 | { |
| 317 | struct wl_display *display = compositor->wl_display; |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 318 | struct weston_xserver *wxs; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 319 | char lockfile[256], display_name[8]; |
| 320 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 321 | wxs = malloc(sizeof *wxs); |
| 322 | memset(wxs, 0, sizeof *wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 323 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 324 | wxs->process.cleanup = weston_xserver_cleanup; |
| 325 | wxs->wl_display = display; |
| 326 | wxs->compositor = compositor; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 327 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 328 | wxs->display = 0; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 329 | |
| 330 | retry: |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 331 | if (create_lockfile(wxs->display, lockfile, sizeof lockfile) < 0) { |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 332 | if (errno == EAGAIN) { |
| 333 | goto retry; |
| 334 | } else if (errno == EEXIST) { |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 335 | wxs->display++; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 336 | goto retry; |
| 337 | } else { |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 338 | free(wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 339 | return -1; |
| 340 | } |
| 341 | } |
| 342 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 343 | wxs->abstract_fd = bind_to_abstract_socket(wxs->display); |
| 344 | if (wxs->abstract_fd < 0 && errno == EADDRINUSE) { |
| 345 | wxs->display++; |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 346 | unlink(lockfile); |
| 347 | goto retry; |
| 348 | } |
| 349 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 350 | wxs->unix_fd = bind_to_unix_socket(wxs->display); |
| 351 | if (wxs->unix_fd < 0) { |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 352 | unlink(lockfile); |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 353 | close(wxs->abstract_fd); |
| 354 | free(wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 355 | return -1; |
| 356 | } |
| 357 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 358 | snprintf(display_name, sizeof display_name, ":%d", wxs->display); |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 359 | weston_log("xserver listening on display %s\n", display_name); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 360 | setenv("DISPLAY", display_name, 1); |
| 361 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 362 | wxs->loop = wl_display_get_event_loop(display); |
| 363 | wxs->abstract_source = |
| 364 | wl_event_loop_add_fd(wxs->loop, wxs->abstract_fd, |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 365 | WL_EVENT_READABLE, |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 366 | weston_xserver_handle_event, wxs); |
| 367 | wxs->unix_source = |
| 368 | wl_event_loop_add_fd(wxs->loop, wxs->unix_fd, |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 369 | WL_EVENT_READABLE, |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 370 | weston_xserver_handle_event, wxs); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 371 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 372 | wl_display_add_global(display, &xserver_interface, wxs, bind_xserver); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 373 | |
Tiago Vignatti | f268446 | 2012-11-30 17:19:56 -0200 | [diff] [blame^] | 374 | wxs->destroy_listener.notify = weston_xserver_destroy; |
| 375 | wl_signal_add(&compositor->destroy_signal, &wxs->destroy_listener); |
Kristian Høgsberg | e10b124 | 2012-05-21 16:48:05 -0400 | [diff] [blame] | 376 | |
| 377 | return 0; |
| 378 | } |