69135a902d85ba3e2d950d5baff6080b95be895d
[profile/ivi/weston.git] / src / compositor-wayland.c
1 /*
2  * Copyright © 2010-2011 Benjamin Franzke
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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stddef.h>
28 #define _GNU_SOURCE
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <fcntl.h>
33 #include <unistd.h>
34
35 #include <wayland-client.h>
36 #include <wayland-egl.h>
37
38 #include <GLES2/gl2.h>
39 #include <GLES2/gl2ext.h>
40 #include <EGL/egl.h>
41 #include <EGL/eglext.h>
42
43 #include "compositor.h"
44
45 struct wayland_compositor {
46         struct weston_compositor         base;
47
48         struct wl_egl_pixmap            *dummy_pixmap;
49         EGLSurface                       dummy_egl_surface;;
50
51         struct {
52                 struct wl_display *display;
53                 struct wl_compositor *compositor;
54                 struct wl_shell *shell;
55                 struct wl_output *output;
56
57                 struct {
58                         int32_t x, y, width, height;
59                 } screen_allocation;
60
61                 struct wl_event_source *wl_source;
62                 uint32_t event_mask;
63         } parent;
64
65         struct {
66                 int32_t top, bottom, left, right;
67                 GLuint texture;
68                 int32_t width, height;
69         } border;
70
71         struct wl_list input_list;
72 };
73
74 struct wayland_output {
75         struct weston_output    base;
76
77         struct {
78                 struct wl_surface       *surface;
79                 struct wl_shell_surface *shell_surface;
80                 struct wl_egl_window    *egl_window;
81         } parent;
82         EGLSurface egl_surface;
83         struct weston_mode      mode;
84 };
85
86 struct wayland_input {
87         struct wayland_compositor *compositor;
88         struct wl_input_device *input_device;
89         struct wl_list link;
90 };
91
92
93 static int
94 texture_border(struct wayland_output *output)
95 {
96         struct wayland_compositor *c =
97                 (struct wayland_compositor *) output->base.compositor;
98         GLfloat *d;
99         unsigned int *p;
100         int i, j, k, n;
101         GLfloat x[4], y[4], u[4], v[4];
102
103         x[0] = -c->border.left;
104         x[1] = 0;
105         x[2] = output->base.current->width;
106         x[3] = output->base.current->width + c->border.right;
107
108         y[0] = -c->border.top;
109         y[1] = 0;
110         y[2] = output->base.current->height;
111         y[3] = output->base.current->height + c->border.bottom;
112
113         u[0] = 0.0;
114         u[1] = (GLfloat) c->border.left / c->border.width;
115         u[2] = (GLfloat) (c->border.width - c->border.right) / c->border.width;
116         u[3] = 1.0;
117
118         v[0] = 0.0;
119         v[1] = (GLfloat) c->border.top / c->border.height;
120         v[2] = (GLfloat) (c->border.height - c->border.bottom) / c->border.height;
121         v[3] = 1.0;
122
123         n = 8;
124         d = wl_array_add(&c->base.vertices, n * 16 * sizeof *d);
125         p = wl_array_add(&c->base.indices, n * 6 * sizeof *p);
126
127         k = 0;
128         for (i = 0; i < 3; i++)
129                 for (j = 0; j < 3; j++) {
130
131                         if (i == 1 && j == 1)
132                                 continue;
133
134                         d[ 0] = x[i];
135                         d[ 1] = y[j];
136                         d[ 2] = u[i];
137                         d[ 3] = v[j];
138
139                         d[ 4] = x[i];
140                         d[ 5] = y[j + 1];
141                         d[ 6] = u[i];
142                         d[ 7] = v[j + 1];
143
144                         d[ 8] = x[i + 1];
145                         d[ 9] = y[j];
146                         d[10] = u[i + 1];
147                         d[11] = v[j];
148
149                         d[12] = x[i + 1];
150                         d[13] = y[j + 1];
151                         d[14] = u[i + 1];
152                         d[15] = v[j + 1];
153
154                         p[0] = k + 0;
155                         p[1] = k + 1;
156                         p[2] = k + 2;
157                         p[3] = k + 2;
158                         p[4] = k + 1;
159                         p[5] = k + 3;
160
161                         d += 16;
162                         p += 6;
163                         k += 4;
164                 }
165
166         return k / 4;
167 }
168
169 static void
170 draw_border(struct wayland_output *output)
171 {
172         struct wayland_compositor *c =
173                 (struct wayland_compositor *) output->base.compositor;
174         struct weston_shader *shader = &c->base.texture_shader;
175         GLfloat *v;
176         int n;
177
178         glDisable(GL_BLEND);
179         glUseProgram(shader->program);
180         c->base.current_shader = shader;
181
182         glUniformMatrix4fv(shader->proj_uniform,
183                            1, GL_FALSE, output->base.matrix.d);
184
185         glUniform1i(shader->tex_uniform, 0);
186         glUniform1f(shader->alpha_uniform, 1);
187         glUniform1f(shader->texwidth_uniform, 1);
188
189         n = texture_border(output);
190
191         glBindTexture(GL_TEXTURE_2D, c->border.texture);
192
193         v = c->base.vertices.data;
194         glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
195         glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]);
196         glEnableVertexAttribArray(0);
197         glEnableVertexAttribArray(1);
198
199         glDrawElements(GL_TRIANGLES, n * 6,
200                        GL_UNSIGNED_INT, c->base.indices.data);
201
202         glDisableVertexAttribArray(1);
203         glDisableVertexAttribArray(0);
204
205         c->base.vertices.size = 0;
206         c->base.indices.size = 0;
207 }
208
209 static void
210 create_border(struct wayland_compositor *c)
211 {
212         pixman_image_t *image;
213
214         image = load_image(DATADIR "/weston/border.png");
215         if (!image) {
216                 fprintf(stderr, "could'nt load border image\n");
217                 return;
218         }
219
220         c->border.width = pixman_image_get_width(image);
221         c->border.height = pixman_image_get_height(image);
222
223         glGenTextures(1, &c->border.texture);
224         glBindTexture(GL_TEXTURE_2D, c->border.texture);
225         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
226         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
227         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
228         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
229
230         glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
231                      c->border.width,
232                      c->border.height,
233                      0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,
234                      pixman_image_get_data(image));
235
236         c->border.top = 25;
237         c->border.bottom = 50;
238         c->border.left = 25;
239         c->border.right = 25;
240
241         pixman_image_unref(image);
242 }
243
244 static int
245 wayland_input_create(struct wayland_compositor *c)
246 {
247         struct weston_input_device *input;
248
249         input = malloc(sizeof *input);
250         if (input == NULL)
251                 return -1;
252
253         memset(input, 0, sizeof *input);
254         weston_input_device_init(input, &c->base);
255
256         c->base.input_device = &input->input_device;
257
258         return 0;
259 }
260
261 static int
262 wayland_compositor_init_egl(struct wayland_compositor *c)
263 {
264         EGLint major, minor;
265         EGLint n;
266         EGLint config_attribs[] = {
267                 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
268                 EGL_RED_SIZE, 1,
269                 EGL_GREEN_SIZE, 1,
270                 EGL_BLUE_SIZE, 1,
271                 EGL_ALPHA_SIZE, 1,
272                 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
273                 EGL_NONE
274         };
275         static const EGLint context_attribs[] = {
276                 EGL_CONTEXT_CLIENT_VERSION, 2,
277                 EGL_NONE
278         };
279
280         c->base.display = eglGetDisplay(c->parent.display);
281         if (c->base.display == NULL) {
282                 fprintf(stderr, "failed to create display\n");
283                 return -1;
284         }
285
286         if (!eglInitialize(c->base.display, &major, &minor)) {
287                 fprintf(stderr, "failed to initialize display\n");
288                 return -1;
289         }
290
291         if (!eglBindAPI(EGL_OPENGL_ES_API)) {
292                 fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
293                 return -1;
294         }
295         if (!eglChooseConfig(c->base.display, config_attribs,
296                              &c->base.config, 1, &n) || n == 0) {
297                 fprintf(stderr, "failed to choose config: %d\n", n);
298                 return -1;
299         }
300
301         c->base.context = eglCreateContext(c->base.display, c->base.config,
302                                            EGL_NO_CONTEXT, context_attribs);
303         if (c->base.context == NULL) {
304                 fprintf(stderr, "failed to create context\n");
305                 return -1;
306         }
307
308         c->dummy_pixmap = wl_egl_pixmap_create(10, 10, 0);
309         if (!c->dummy_pixmap) {
310                 fprintf(stderr, "failure to create dummy_pixmap\n");
311                 return -1;
312         }
313
314         c->dummy_egl_surface =
315                 eglCreatePixmapSurface(c->base.display, c->base.config,
316                                        c->dummy_pixmap, NULL);
317         if (!eglMakeCurrent(c->base.display, c->dummy_egl_surface,
318                             c->dummy_egl_surface, c->base.context)) {
319                 fprintf(stderr, "failed to make context current\n");
320                 return -1;
321         }
322
323         return 0;
324 }
325
326 static void
327 frame_done(void *data, struct wl_callback *callback, uint32_t time)
328 {
329         struct weston_output *output = data;
330
331         wl_callback_destroy(callback);
332         weston_output_finish_frame(output, time);
333 }
334
335 static const struct wl_callback_listener frame_listener = {
336         frame_done
337 };
338
339 static void
340 wayland_output_repaint(struct weston_output *output_base,
341                        pixman_region32_t *damage)
342 {
343         struct wayland_output *output = (struct wayland_output *) output_base;
344         struct wayland_compositor *compositor =
345                 (struct wayland_compositor *) output->base.compositor;
346         struct wl_callback *callback;
347         struct weston_surface *surface;
348
349         if (!eglMakeCurrent(compositor->base.display, output->egl_surface,
350                             output->egl_surface, compositor->base.context)) {
351                 fprintf(stderr, "failed to make current\n");
352                 return;
353         }
354
355         wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
356                 weston_surface_draw(surface, &output->base, damage);
357
358         draw_border(output);
359
360         weston_output_do_read_pixels(&output->base);
361
362         eglSwapBuffers(compositor->base.display, output->egl_surface);
363         callback = wl_surface_frame(output->parent.surface);
364         wl_callback_add_listener(callback, &frame_listener, output);
365
366         return;
367 }
368
369 static void
370 wayland_output_destroy(struct weston_output *output_base)
371 {
372         struct wayland_output *output = (struct wayland_output *) output_base;
373         struct weston_compositor *ec = output->base.compositor;
374
375         eglDestroySurface(ec->display, output->egl_surface);
376         wl_egl_window_destroy(output->parent.egl_window);
377         free(output);
378
379         return;
380 }
381
382 static int
383 wayland_compositor_create_output(struct wayland_compositor *c,
384                                  int width, int height)
385 {
386         struct wayland_output *output;
387
388         output = malloc(sizeof *output);
389         if (output == NULL)
390                 return -1;
391         memset(output, 0, sizeof *output);
392
393         output->mode.flags =
394                 WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
395         output->mode.width = width;
396         output->mode.height = height;
397         output->mode.refresh = 60;
398         wl_list_init(&output->base.mode_list);
399         wl_list_insert(&output->base.mode_list, &output->mode.link);
400
401         output->base.current = &output->mode;
402         weston_output_init(&output->base, &c->base, 0, 0, width, height,
403                          WL_OUTPUT_FLIPPED);
404
405         output->base.border.top = c->border.top;
406         output->base.border.bottom = c->border.bottom;
407         output->base.border.left = c->border.left;
408         output->base.border.right = c->border.right;
409
410         weston_output_move(&output->base, 0, 0);
411
412         output->parent.surface =
413                 wl_compositor_create_surface(c->parent.compositor);
414         wl_surface_set_user_data(output->parent.surface, output);
415
416         output->parent.egl_window =
417                 wl_egl_window_create(output->parent.surface,
418                                      width + c->border.left + c->border.right,
419                                      height + c->border.top + c->border.bottom);
420         if (!output->parent.egl_window) {
421                 fprintf(stderr, "failure to create wl_egl_window\n");
422                 goto cleanup_output;
423         }
424
425         output->egl_surface =
426                 eglCreateWindowSurface(c->base.display, c->base.config,
427                                        output->parent.egl_window, NULL);
428         if (!output->egl_surface) {
429                 fprintf(stderr, "failed to create window surface\n");
430                 goto cleanup_window;
431         }
432
433         if (!eglMakeCurrent(c->base.display, output->egl_surface,
434                             output->egl_surface, c->base.context)) {
435                 fprintf(stderr, "failed to make surface current\n");
436                 goto cleanup_surface;
437                 return -1;
438         }
439
440         output->parent.shell_surface =
441                 wl_shell_get_shell_surface(c->parent.shell,
442                                            output->parent.surface);
443         /* FIXME: add shell_surface listener for resizing */
444         wl_shell_surface_set_toplevel(output->parent.shell_surface);
445
446         output->base.origin = output->base.current;
447         output->base.repaint = wayland_output_repaint;
448         output->base.destroy = wayland_output_destroy;
449         output->base.assign_planes = NULL;
450         output->base.set_backlight = NULL;
451         output->base.set_dpms = NULL;
452         output->base.switch_mode = NULL;
453
454         wl_list_insert(c->base.output_list.prev, &output->base.link);
455
456         return 0;
457
458 cleanup_surface:
459         eglDestroySurface(c->base.display, output->egl_surface);
460 cleanup_window:
461         wl_egl_window_destroy(output->parent.egl_window);
462 cleanup_output:
463         /* FIXME: cleanup weston_output */
464         free(output);
465
466         return -1;
467 }
468
469 /* Events received from the wayland-server this compositor is client of: */
470
471 /* parent output interface */
472 static void
473 display_handle_geometry(void *data,
474                         struct wl_output *wl_output,
475                         int x,
476                         int y,
477                         int physical_width,
478                         int physical_height,
479                         int subpixel,
480                         const char *make,
481                         const char *model)
482 {
483         struct wayland_compositor *c = data;
484
485         c->parent.screen_allocation.x = x;
486         c->parent.screen_allocation.y = y;
487 }
488
489 static void
490 display_handle_mode(void *data,
491                     struct wl_output *wl_output,
492                     uint32_t flags,
493                     int width,
494                     int height,
495                     int refresh)
496 {
497         struct wayland_compositor *c = data;
498
499         c->parent.screen_allocation.width = width;
500         c->parent.screen_allocation.height = height;
501 }
502
503 static const struct wl_output_listener output_listener = {
504         display_handle_geometry,
505         display_handle_mode
506 };
507
508 /* parent input interface */
509 static void
510 input_handle_motion(void *data, struct wl_input_device *input_device,
511                     uint32_t time, wl_fixed_t x, wl_fixed_t y)
512 {
513         struct wayland_input *input = data;
514         struct wayland_compositor *c = input->compositor;
515
516         notify_motion(c->base.input_device, time,
517                       x - wl_fixed_from_int(c->border.left),
518                       y - wl_fixed_from_int(c->border.top));
519 }
520
521 static void
522 input_handle_button(void *data,
523                     struct wl_input_device *input_device,
524                     uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
525 {
526         struct wayland_input *input = data;
527         struct wayland_compositor *c = input->compositor;
528
529         notify_button(c->base.input_device, time, button, state);
530 }
531
532 static void
533 input_handle_axis(void *data, struct wl_input_device *input_device,
534                   uint32_t time, uint32_t axis, int32_t value)
535 {
536         struct wayland_input *input = data;
537         struct wayland_compositor *c = input->compositor;
538
539         notify_axis(c->base.input_device, time, axis, value);
540 }
541
542 static void
543 input_handle_key(void *data, struct wl_input_device *input_device,
544                  uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
545 {
546         struct wayland_input *input = data;
547         struct wayland_compositor *c = input->compositor;
548
549         notify_key(c->base.input_device, time, key, state);
550 }
551
552 static void
553 input_handle_pointer_enter(void *data,
554                            struct wl_input_device *input_device,
555                            uint32_t time, struct wl_surface *surface,
556                            wl_fixed_t x, wl_fixed_t y)
557 {
558         struct wayland_input *input = data;
559         struct wayland_output *output;
560         struct wayland_compositor *c = input->compositor;
561
562         output = wl_surface_get_user_data(surface);
563         notify_pointer_focus(c->base.input_device, &output->base, x, y);
564         wl_input_device_attach(input->input_device, time, NULL, 0, 0);
565 }
566
567 static void
568 input_handle_pointer_leave(void *data,
569                            struct wl_input_device *input_device,
570                            uint32_t time, struct wl_surface *surface)
571 {
572         struct wayland_input *input = data;
573         struct wayland_compositor *c = input->compositor;
574
575         notify_pointer_focus(c->base.input_device, NULL, 0, 0);
576 }
577
578 static void
579 input_handle_keyboard_enter(void *data,
580                             struct wl_input_device *input_device,
581                             uint32_t time,
582                             struct wl_surface *surface,
583                             struct wl_array *keys)
584 {
585         struct wayland_input *input = data;
586         struct wayland_compositor *c = input->compositor;
587
588         notify_keyboard_focus(c->base.input_device, keys);
589 }
590
591 static void
592 input_handle_keyboard_leave(void *data,
593                             struct wl_input_device *input_device,
594                             uint32_t time,
595                             struct wl_surface *surface)
596 {
597         struct wayland_input *input = data;
598         struct wayland_compositor *c = input->compositor;
599
600         notify_keyboard_focus(c->base.input_device, NULL);
601 }
602
603 static const struct wl_input_device_listener input_device_listener = {
604         input_handle_motion,
605         input_handle_button,
606         input_handle_axis,
607         input_handle_key,
608         input_handle_pointer_enter,
609         input_handle_pointer_leave,
610         input_handle_keyboard_enter,
611         input_handle_keyboard_leave,
612 };
613
614 static void
615 display_add_input(struct wayland_compositor *c, uint32_t id)
616 {
617         struct wayland_input *input;
618
619         input = malloc(sizeof *input);
620         if (input == NULL)
621                 return;
622
623         memset(input, 0, sizeof *input);
624
625         input->compositor = c;
626         input->input_device = wl_display_bind(c->parent.display,
627                                               id, &wl_input_device_interface);
628         wl_list_insert(c->input_list.prev, &input->link);
629
630         wl_input_device_add_listener(input->input_device,
631                                      &input_device_listener, input);
632         wl_input_device_set_user_data(input->input_device, input);
633 }
634
635 static void
636 display_handle_global(struct wl_display *display, uint32_t id,
637                       const char *interface, uint32_t version, void *data)
638 {
639         struct wayland_compositor *c = data;
640
641         if (strcmp(interface, "wl_compositor") == 0) {
642                 c->parent.compositor =
643                         wl_display_bind(display, id, &wl_compositor_interface);
644         } else if (strcmp(interface, "wl_output") == 0) {
645                 c->parent.output =
646                         wl_display_bind(display, id, &wl_output_interface);
647                 wl_output_add_listener(c->parent.output, &output_listener, c);
648         } else if (strcmp(interface, "wl_input_device") == 0) {
649                 display_add_input(c, id);
650         } else if (strcmp(interface, "wl_shell") == 0) {
651                 c->parent.shell =
652                         wl_display_bind(display, id, &wl_shell_interface);
653         }
654 }
655
656 static int
657 update_event_mask(uint32_t mask, void *data)
658 {
659         struct wayland_compositor *c = data;
660
661         c->parent.event_mask = mask;
662         if (c->parent.wl_source)
663                 wl_event_source_fd_update(c->parent.wl_source, mask);
664
665         return 0;
666 }
667
668 static int
669 wayland_compositor_handle_event(int fd, uint32_t mask, void *data)
670 {
671         struct wayland_compositor *c = data;
672
673         if (mask & WL_EVENT_READABLE)
674                 wl_display_iterate(c->parent.display, WL_DISPLAY_READABLE);
675         if (mask & WL_EVENT_WRITABLE)
676                 wl_display_iterate(c->parent.display, WL_DISPLAY_WRITABLE);
677
678         return 1;
679 }
680
681 static void
682 wayland_destroy(struct weston_compositor *ec)
683 {
684         weston_compositor_shutdown(ec);
685
686         free(ec);
687 }
688
689 static struct weston_compositor *
690 wayland_compositor_create(struct wl_display *display,
691                           int width, int height, const char *display_name)
692 {
693         struct wayland_compositor *c;
694         struct wl_event_loop *loop;
695         int fd;
696
697         c = malloc(sizeof *c);
698         if (c == NULL)
699                 return NULL;
700
701         memset(c, 0, sizeof *c);
702
703         c->parent.display = wl_display_connect(display_name);
704
705         if (c->parent.display == NULL) {
706                 fprintf(stderr, "failed to create display: %m\n");
707                 return NULL;
708         }
709
710         wl_list_init(&c->input_list);
711         wl_display_add_global_listener(c->parent.display,
712                                 display_handle_global, c);
713
714         wl_display_iterate(c->parent.display, WL_DISPLAY_READABLE);
715
716         c->base.wl_display = display;
717         if (wayland_compositor_init_egl(c) < 0)
718                 return NULL;
719
720         c->base.destroy = wayland_destroy;
721
722         /* Can't init base class until we have a current egl context */
723         if (weston_compositor_init(&c->base, display) < 0)
724                 return NULL;
725
726         create_border(c);
727         if (wayland_compositor_create_output(c, width, height) < 0)
728                 return NULL;
729
730         if (wayland_input_create(c) < 0)
731                 return NULL;
732
733         loop = wl_display_get_event_loop(c->base.wl_display);
734
735         fd = wl_display_get_fd(c->parent.display, update_event_mask, c);
736         c->parent.wl_source =
737                 wl_event_loop_add_fd(loop, fd, c->parent.event_mask,
738                                      wayland_compositor_handle_event, c);
739         if (c->parent.wl_source == NULL)
740                 return NULL;
741
742         return &c->base;
743 }
744
745 WL_EXPORT struct weston_compositor *
746 backend_init(struct wl_display *display, int argc, char *argv[])
747 {
748         int width = 1024, height = 640;
749         char *display_name = NULL;
750
751         const struct weston_option wayland_options[] = {
752                 { WESTON_OPTION_INTEGER, "width", 0, &width },
753                 { WESTON_OPTION_INTEGER, "height", 0, &height },
754                 { WESTON_OPTION_STRING, "display", 0, &display_name },
755         };
756
757         parse_options(wayland_options,
758                       ARRAY_LENGTH(wayland_options), argc, argv);
759
760         return wayland_compositor_create(display, width, height, display_name);
761 }