Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 1 | /* |
Kristian Høgsberg | 96aa7da | 2011-09-15 15:43:14 -0400 | [diff] [blame] | 2 | * Copyright © 2010-2011 Benjamin Franzke |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 3 | * |
Kristian Høgsberg | 96aa7da | 2011-09-15 15:43:14 -0400 | [diff] [blame] | 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. |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 13 | * |
Kristian Høgsberg | 96aa7da | 2011-09-15 15:43:14 -0400 | [diff] [blame] | 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. |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 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> |
Daniel Stone | b7452fe | 2012-06-01 12:14:06 +0100 | [diff] [blame] | 34 | #include <sys/mman.h> |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 35 | |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 36 | #include <wayland-client.h> |
| 37 | #include <wayland-egl.h> |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 38 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 39 | #include <GLES2/gl2.h> |
| 40 | #include <GLES2/gl2ext.h> |
| 41 | #include <EGL/egl.h> |
| 42 | #include <EGL/eglext.h> |
| 43 | |
| 44 | #include "compositor.h" |
| 45 | |
| 46 | struct wayland_compositor { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 47 | struct weston_compositor base; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 48 | |
Kristian Høgsberg | b5ef591 | 2012-03-28 22:53:49 -0400 | [diff] [blame] | 49 | struct wl_egl_pixmap *dummy_pixmap; |
Kristian Høgsberg | b71302e | 2012-05-10 12:28:35 -0400 | [diff] [blame] | 50 | EGLSurface dummy_egl_surface; |
Kristian Høgsberg | b5ef591 | 2012-03-28 22:53:49 -0400 | [diff] [blame] | 51 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 52 | struct { |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 53 | struct wl_display *wl_display; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 54 | struct wl_compositor *compositor; |
| 55 | struct wl_shell *shell; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 56 | struct wl_output *output; |
| 57 | |
| 58 | struct { |
| 59 | int32_t x, y, width, height; |
| 60 | } screen_allocation; |
| 61 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 62 | struct wl_event_source *wl_source; |
| 63 | uint32_t event_mask; |
| 64 | } parent; |
| 65 | |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 66 | struct { |
| 67 | int32_t top, bottom, left, right; |
| 68 | GLuint texture; |
| 69 | int32_t width, height; |
| 70 | } border; |
| 71 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 72 | struct wl_list input_list; |
| 73 | }; |
| 74 | |
| 75 | struct wayland_output { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 76 | struct weston_output base; |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 77 | struct wl_listener frame_listener; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 78 | struct { |
| 79 | struct wl_surface *surface; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 80 | struct wl_shell_surface *shell_surface; |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 81 | struct wl_egl_window *egl_window; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 82 | } parent; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 83 | struct weston_mode mode; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | struct wayland_input { |
Kristian Høgsberg | 7af7ced | 2012-08-10 10:01:33 -0400 | [diff] [blame] | 87 | struct weston_seat base; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 88 | struct wayland_compositor *compositor; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 89 | struct wl_seat *seat; |
| 90 | struct wl_pointer *pointer; |
| 91 | struct wl_keyboard *keyboard; |
| 92 | struct wl_touch *touch; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 93 | struct wl_list link; |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 94 | uint32_t key_serial; |
Kristian Høgsberg | 539d85f | 2012-08-13 23:29:53 -0400 | [diff] [blame] | 95 | uint32_t enter_serial; |
| 96 | int focus; |
| 97 | struct wayland_output *output; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 98 | }; |
| 99 | |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 100 | |
| 101 | static int |
| 102 | texture_border(struct wayland_output *output) |
| 103 | { |
| 104 | struct wayland_compositor *c = |
| 105 | (struct wayland_compositor *) output->base.compositor; |
| 106 | GLfloat *d; |
| 107 | unsigned int *p; |
| 108 | int i, j, k, n; |
| 109 | GLfloat x[4], y[4], u[4], v[4]; |
| 110 | |
| 111 | x[0] = -c->border.left; |
| 112 | x[1] = 0; |
| 113 | x[2] = output->base.current->width; |
| 114 | x[3] = output->base.current->width + c->border.right; |
| 115 | |
| 116 | y[0] = -c->border.top; |
| 117 | y[1] = 0; |
| 118 | y[2] = output->base.current->height; |
| 119 | y[3] = output->base.current->height + c->border.bottom; |
| 120 | |
| 121 | u[0] = 0.0; |
| 122 | u[1] = (GLfloat) c->border.left / c->border.width; |
| 123 | u[2] = (GLfloat) (c->border.width - c->border.right) / c->border.width; |
| 124 | u[3] = 1.0; |
| 125 | |
| 126 | v[0] = 0.0; |
| 127 | v[1] = (GLfloat) c->border.top / c->border.height; |
| 128 | v[2] = (GLfloat) (c->border.height - c->border.bottom) / c->border.height; |
| 129 | v[3] = 1.0; |
| 130 | |
| 131 | n = 8; |
| 132 | d = wl_array_add(&c->base.vertices, n * 16 * sizeof *d); |
| 133 | p = wl_array_add(&c->base.indices, n * 6 * sizeof *p); |
| 134 | |
| 135 | k = 0; |
| 136 | for (i = 0; i < 3; i++) |
| 137 | for (j = 0; j < 3; j++) { |
| 138 | |
| 139 | if (i == 1 && j == 1) |
| 140 | continue; |
| 141 | |
| 142 | d[ 0] = x[i]; |
| 143 | d[ 1] = y[j]; |
| 144 | d[ 2] = u[i]; |
| 145 | d[ 3] = v[j]; |
| 146 | |
| 147 | d[ 4] = x[i]; |
| 148 | d[ 5] = y[j + 1]; |
| 149 | d[ 6] = u[i]; |
| 150 | d[ 7] = v[j + 1]; |
| 151 | |
| 152 | d[ 8] = x[i + 1]; |
| 153 | d[ 9] = y[j]; |
| 154 | d[10] = u[i + 1]; |
| 155 | d[11] = v[j]; |
| 156 | |
| 157 | d[12] = x[i + 1]; |
| 158 | d[13] = y[j + 1]; |
| 159 | d[14] = u[i + 1]; |
| 160 | d[15] = v[j + 1]; |
| 161 | |
| 162 | p[0] = k + 0; |
| 163 | p[1] = k + 1; |
| 164 | p[2] = k + 2; |
| 165 | p[3] = k + 2; |
| 166 | p[4] = k + 1; |
| 167 | p[5] = k + 3; |
| 168 | |
| 169 | d += 16; |
| 170 | p += 6; |
| 171 | k += 4; |
| 172 | } |
| 173 | |
| 174 | return k / 4; |
| 175 | } |
| 176 | |
| 177 | static void |
| 178 | draw_border(struct wayland_output *output) |
| 179 | { |
| 180 | struct wayland_compositor *c = |
| 181 | (struct wayland_compositor *) output->base.compositor; |
Gwenole Beauchesne | 6d03049 | 2012-04-20 11:15:51 +0200 | [diff] [blame] | 182 | struct weston_shader *shader = &c->base.texture_shader_rgba; |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 183 | GLfloat *v; |
| 184 | int n; |
| 185 | |
| 186 | glDisable(GL_BLEND); |
| 187 | glUseProgram(shader->program); |
| 188 | c->base.current_shader = shader; |
| 189 | |
| 190 | glUniformMatrix4fv(shader->proj_uniform, |
| 191 | 1, GL_FALSE, output->base.matrix.d); |
| 192 | |
Gwenole Beauchesne | 28f59b0 | 2012-04-20 11:44:06 +0200 | [diff] [blame] | 193 | glUniform1i(shader->tex_uniforms[0], 0); |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 194 | glUniform1f(shader->alpha_uniform, 1); |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 195 | |
| 196 | n = texture_border(output); |
| 197 | |
| 198 | glBindTexture(GL_TEXTURE_2D, c->border.texture); |
| 199 | |
| 200 | v = c->base.vertices.data; |
| 201 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]); |
| 202 | glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]); |
| 203 | glEnableVertexAttribArray(0); |
| 204 | glEnableVertexAttribArray(1); |
| 205 | |
| 206 | glDrawElements(GL_TRIANGLES, n * 6, |
| 207 | GL_UNSIGNED_INT, c->base.indices.data); |
| 208 | |
| 209 | glDisableVertexAttribArray(1); |
| 210 | glDisableVertexAttribArray(0); |
| 211 | |
| 212 | c->base.vertices.size = 0; |
| 213 | c->base.indices.size = 0; |
| 214 | } |
| 215 | |
| 216 | static void |
| 217 | create_border(struct wayland_compositor *c) |
| 218 | { |
Ander Conselvan de Oliveira | e2d21e8 | 2012-03-16 17:25:09 +0200 | [diff] [blame] | 219 | pixman_image_t *image; |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 220 | |
Ander Conselvan de Oliveira | e2d21e8 | 2012-03-16 17:25:09 +0200 | [diff] [blame] | 221 | image = load_image(DATADIR "/weston/border.png"); |
| 222 | if (!image) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 223 | weston_log("could'nt load border image\n"); |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 224 | return; |
| 225 | } |
| 226 | |
Ander Conselvan de Oliveira | e2d21e8 | 2012-03-16 17:25:09 +0200 | [diff] [blame] | 227 | c->border.width = pixman_image_get_width(image); |
| 228 | c->border.height = pixman_image_get_height(image); |
| 229 | |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 230 | glGenTextures(1, &c->border.texture); |
| 231 | glBindTexture(GL_TEXTURE_2D, c->border.texture); |
| 232 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 233 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 234 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 235 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 236 | |
| 237 | glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, |
| 238 | c->border.width, |
| 239 | c->border.height, |
Ander Conselvan de Oliveira | e2d21e8 | 2012-03-16 17:25:09 +0200 | [diff] [blame] | 240 | 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, |
| 241 | pixman_image_get_data(image)); |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 242 | |
| 243 | c->border.top = 25; |
| 244 | c->border.bottom = 50; |
| 245 | c->border.left = 25; |
| 246 | c->border.right = 25; |
Ander Conselvan de Oliveira | e2d21e8 | 2012-03-16 17:25:09 +0200 | [diff] [blame] | 247 | |
| 248 | pixman_image_unref(image); |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 249 | } |
| 250 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 251 | static int |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 252 | wayland_compositor_init_egl(struct wayland_compositor *c) |
| 253 | { |
| 254 | EGLint major, minor; |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 255 | EGLint n; |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 256 | EGLint config_attribs[] = { |
| 257 | EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| 258 | EGL_RED_SIZE, 1, |
| 259 | EGL_GREEN_SIZE, 1, |
| 260 | EGL_BLUE_SIZE, 1, |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 261 | EGL_ALPHA_SIZE, 1, |
Kristian Høgsberg | d28ab36 | 2011-03-02 11:36:30 -0500 | [diff] [blame] | 262 | EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 263 | EGL_NONE |
| 264 | }; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 265 | static const EGLint context_attribs[] = { |
| 266 | EGL_CONTEXT_CLIENT_VERSION, 2, |
| 267 | EGL_NONE |
| 268 | }; |
| 269 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 270 | c->base.egl_display = eglGetDisplay(c->parent.wl_display); |
| 271 | if (c->base.egl_display == NULL) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 272 | weston_log("failed to create display\n"); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 273 | return -1; |
| 274 | } |
| 275 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 276 | if (!eglInitialize(c->base.egl_display, &major, &minor)) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 277 | weston_log("failed to initialize display\n"); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 278 | return -1; |
| 279 | } |
| 280 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 281 | if (!eglBindAPI(EGL_OPENGL_ES_API)) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 282 | weston_log("failed to bind EGL_OPENGL_ES_API\n"); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 283 | return -1; |
| 284 | } |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 285 | if (!eglChooseConfig(c->base.egl_display, config_attribs, |
| 286 | &c->base.egl_config, 1, &n) || n == 0) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 287 | weston_log("failed to choose config: %d\n", n); |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 288 | return -1; |
| 289 | } |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 290 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 291 | c->base.egl_context = |
| 292 | eglCreateContext(c->base.egl_display, c->base.egl_config, |
| 293 | EGL_NO_CONTEXT, context_attribs); |
| 294 | if (c->base.egl_context == NULL) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 295 | weston_log("failed to create context\n"); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 296 | return -1; |
| 297 | } |
| 298 | |
Kristian Høgsberg | b5ef591 | 2012-03-28 22:53:49 -0400 | [diff] [blame] | 299 | c->dummy_pixmap = wl_egl_pixmap_create(10, 10, 0); |
| 300 | if (!c->dummy_pixmap) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 301 | weston_log("failure to create dummy_pixmap\n"); |
Kristian Høgsberg | b5ef591 | 2012-03-28 22:53:49 -0400 | [diff] [blame] | 302 | return -1; |
| 303 | } |
| 304 | |
| 305 | c->dummy_egl_surface = |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 306 | eglCreatePixmapSurface(c->base.egl_display, c->base.egl_config, |
Kristian Høgsberg | b5ef591 | 2012-03-28 22:53:49 -0400 | [diff] [blame] | 307 | c->dummy_pixmap, NULL); |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 308 | if (!eglMakeCurrent(c->base.egl_display, c->dummy_egl_surface, |
| 309 | c->dummy_egl_surface, c->base.egl_context)) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 310 | weston_log("failed to make context current\n"); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 311 | return -1; |
| 312 | } |
| 313 | |
| 314 | return 0; |
| 315 | } |
| 316 | |
Kristian Høgsberg | 68c479a | 2012-01-25 23:32:28 -0500 | [diff] [blame] | 317 | static void |
Kristian Høgsberg | cdd61d0 | 2012-02-07 09:56:15 -0500 | [diff] [blame] | 318 | frame_done(void *data, struct wl_callback *callback, uint32_t time) |
Kristian Høgsberg | 3341820 | 2011-08-16 23:01:28 -0400 | [diff] [blame] | 319 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 320 | struct weston_output *output = data; |
Kristian Høgsberg | 3341820 | 2011-08-16 23:01:28 -0400 | [diff] [blame] | 321 | |
Kristian Høgsberg | cdd61d0 | 2012-02-07 09:56:15 -0500 | [diff] [blame] | 322 | wl_callback_destroy(callback); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 323 | weston_output_finish_frame(output, time); |
Kristian Høgsberg | 3341820 | 2011-08-16 23:01:28 -0400 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static const struct wl_callback_listener frame_listener = { |
| 327 | frame_done |
| 328 | }; |
| 329 | |
Kristian Høgsberg | 06cf6b0 | 2012-01-25 23:47:45 -0500 | [diff] [blame] | 330 | static void |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 331 | wayland_output_frame_notify(struct wl_listener *listener, void *data) |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 332 | { |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 333 | struct wayland_output *output = |
| 334 | container_of(listener, |
| 335 | struct wayland_output, frame_listener); |
Pekka Paalanen | 07c91f8 | 2012-08-30 16:47:21 -0500 | [diff] [blame] | 336 | |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 337 | draw_border(output); |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 338 | } |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 339 | |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 340 | static void |
| 341 | wayland_output_repaint(struct weston_output *output_base, |
| 342 | pixman_region32_t *damage) |
| 343 | { |
| 344 | struct wayland_output *output = (struct wayland_output *) output_base; |
| 345 | struct wl_callback *callback; |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 346 | |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 347 | gles2_renderer_repaint_output(output_base, damage); |
| 348 | |
Kristian Høgsberg | 3341820 | 2011-08-16 23:01:28 -0400 | [diff] [blame] | 349 | callback = wl_surface_frame(output->parent.surface); |
| 350 | wl_callback_add_listener(callback, &frame_listener, output); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 351 | |
Kristian Høgsberg | 06cf6b0 | 2012-01-25 23:47:45 -0500 | [diff] [blame] | 352 | return; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 353 | } |
| 354 | |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 355 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 356 | wayland_output_destroy(struct weston_output *output_base) |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 357 | { |
| 358 | struct wayland_output *output = (struct wayland_output *) output_base; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 359 | struct weston_compositor *ec = output->base.compositor; |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 360 | |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 361 | eglDestroySurface(ec->egl_display, output->base.egl_surface); |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 362 | wl_egl_window_destroy(output->parent.egl_window); |
| 363 | free(output); |
| 364 | |
| 365 | return; |
| 366 | } |
| 367 | |
Ander Conselvan de Oliveira | 563c5b8 | 2012-06-18 17:36:21 +0300 | [diff] [blame] | 368 | static const struct wl_shell_surface_listener shell_surface_listener; |
| 369 | |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 370 | static int |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 371 | wayland_compositor_create_output(struct wayland_compositor *c, |
| 372 | int width, int height) |
| 373 | { |
| 374 | struct wayland_output *output; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 375 | |
| 376 | output = malloc(sizeof *output); |
| 377 | if (output == NULL) |
| 378 | return -1; |
| 379 | memset(output, 0, sizeof *output); |
| 380 | |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 381 | output->mode.flags = |
| 382 | WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; |
| 383 | output->mode.width = width; |
| 384 | output->mode.height = height; |
| 385 | output->mode.refresh = 60; |
| 386 | wl_list_init(&output->base.mode_list); |
| 387 | wl_list_insert(&output->base.mode_list, &output->mode.link); |
| 388 | |
| 389 | output->base.current = &output->mode; |
Scott Moreau | 1bad5db | 2012-08-18 01:04:05 -0600 | [diff] [blame] | 390 | weston_output_init(&output->base, &c->base, 0, 0, width, height, |
| 391 | WL_OUTPUT_TRANSFORM_NORMAL); |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 392 | |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 393 | output->base.border.top = c->border.top; |
| 394 | output->base.border.bottom = c->border.bottom; |
| 395 | output->base.border.left = c->border.left; |
| 396 | output->base.border.right = c->border.right; |
Kristian Høgsberg | 90bc88c | 2012-08-13 23:34:04 -0400 | [diff] [blame] | 397 | output->base.make = "waywayland"; |
| 398 | output->base.model = "none"; |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 399 | |
| 400 | weston_output_move(&output->base, 0, 0); |
| 401 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 402 | output->parent.surface = |
| 403 | wl_compositor_create_surface(c->parent.compositor); |
| 404 | wl_surface_set_user_data(output->parent.surface, output); |
| 405 | |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 406 | output->parent.egl_window = |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 407 | wl_egl_window_create(output->parent.surface, |
| 408 | width + c->border.left + c->border.right, |
| 409 | height + c->border.top + c->border.bottom); |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 410 | if (!output->parent.egl_window) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 411 | weston_log("failure to create wl_egl_window\n"); |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 412 | goto cleanup_output; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 413 | } |
| 414 | |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 415 | output->base.egl_surface = |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 416 | eglCreateWindowSurface(c->base.egl_display, c->base.egl_config, |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 417 | output->parent.egl_window, NULL); |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 418 | if (!output->base.egl_surface) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 419 | weston_log("failed to create window surface\n"); |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 420 | goto cleanup_window; |
| 421 | } |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 422 | |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 423 | if (!eglMakeCurrent(c->base.egl_display, output->base.egl_surface, |
| 424 | output->base.egl_surface, c->base.egl_context)) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 425 | weston_log("failed to make surface current\n"); |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 426 | goto cleanup_surface; |
| 427 | return -1; |
| 428 | } |
| 429 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 430 | output->parent.shell_surface = |
| 431 | wl_shell_get_shell_surface(c->parent.shell, |
| 432 | output->parent.surface); |
Ander Conselvan de Oliveira | 563c5b8 | 2012-06-18 17:36:21 +0300 | [diff] [blame] | 433 | wl_shell_surface_add_listener(output->parent.shell_surface, |
| 434 | &shell_surface_listener, output); |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 435 | wl_shell_surface_set_toplevel(output->parent.shell_surface); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 436 | |
Alex Wu | bd3354b | 2012-04-17 17:20:49 +0800 | [diff] [blame] | 437 | output->base.origin = output->base.current; |
Kristian Høgsberg | 68c479a | 2012-01-25 23:32:28 -0500 | [diff] [blame] | 438 | output->base.repaint = wayland_output_repaint; |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 439 | output->base.destroy = wayland_output_destroy; |
Jesse Barnes | 5308a5e | 2012-02-09 13:12:57 -0800 | [diff] [blame] | 440 | output->base.assign_planes = NULL; |
Tiago Vignatti | 8e53c7f | 2012-02-29 19:53:50 +0200 | [diff] [blame] | 441 | output->base.set_backlight = NULL; |
| 442 | output->base.set_dpms = NULL; |
Alex Wu | 2dda604 | 2012-04-17 17:20:47 +0800 | [diff] [blame] | 443 | output->base.switch_mode = NULL; |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 444 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 445 | wl_list_insert(c->base.output_list.prev, &output->base.link); |
| 446 | |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 447 | output->frame_listener.notify = wayland_output_frame_notify; |
| 448 | wl_signal_add(&output->base.frame_signal, &output->frame_listener); |
| 449 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 450 | return 0; |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 451 | |
| 452 | cleanup_surface: |
Kristian Høgsberg | d7c1726 | 2012-09-05 21:54:15 -0400 | [diff] [blame^] | 453 | eglDestroySurface(c->base.egl_display, output->base.egl_surface); |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 454 | cleanup_window: |
| 455 | wl_egl_window_destroy(output->parent.egl_window); |
| 456 | cleanup_output: |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 457 | /* FIXME: cleanup weston_output */ |
Benjamin Franzke | be01456 | 2011-02-18 17:04:24 +0100 | [diff] [blame] | 458 | free(output); |
| 459 | |
| 460 | return -1; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 461 | } |
| 462 | |
Ander Conselvan de Oliveira | 563c5b8 | 2012-06-18 17:36:21 +0300 | [diff] [blame] | 463 | static void |
| 464 | shell_surface_ping(void *data, struct wl_shell_surface *shell_surface, |
| 465 | uint32_t serial) |
| 466 | { |
| 467 | wl_shell_surface_pong(shell_surface, serial); |
| 468 | } |
| 469 | |
| 470 | static void |
| 471 | shell_surface_configure(void *data, struct wl_shell_surface *shell_surface, |
| 472 | uint32_t edges, int32_t width, int32_t height) |
| 473 | { |
| 474 | /* FIXME: implement resizing */ |
| 475 | } |
| 476 | |
| 477 | static void |
| 478 | shell_surface_popup_done(void *data, struct wl_shell_surface *shell_surface) |
| 479 | { |
| 480 | } |
| 481 | |
| 482 | static const struct wl_shell_surface_listener shell_surface_listener = { |
| 483 | shell_surface_ping, |
| 484 | shell_surface_configure, |
| 485 | shell_surface_popup_done |
| 486 | }; |
| 487 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 488 | /* Events received from the wayland-server this compositor is client of: */ |
| 489 | |
| 490 | /* parent output interface */ |
| 491 | static void |
| 492 | display_handle_geometry(void *data, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 493 | struct wl_output *wl_output, |
| 494 | int x, |
| 495 | int y, |
| 496 | int physical_width, |
| 497 | int physical_height, |
| 498 | int subpixel, |
| 499 | const char *make, |
Kristian Høgsberg | 0e69647 | 2012-07-22 15:49:57 -0400 | [diff] [blame] | 500 | const char *model, |
| 501 | int transform) |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 502 | { |
| 503 | struct wayland_compositor *c = data; |
| 504 | |
Kristian Høgsberg | f8fc08f | 2010-12-01 20:10:10 -0500 | [diff] [blame] | 505 | c->parent.screen_allocation.x = x; |
| 506 | c->parent.screen_allocation.y = y; |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | static void |
| 510 | display_handle_mode(void *data, |
| 511 | struct wl_output *wl_output, |
| 512 | uint32_t flags, |
| 513 | int width, |
| 514 | int height, |
| 515 | int refresh) |
| 516 | { |
| 517 | struct wayland_compositor *c = data; |
| 518 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 519 | c->parent.screen_allocation.width = width; |
| 520 | c->parent.screen_allocation.height = height; |
| 521 | } |
| 522 | |
| 523 | static const struct wl_output_listener output_listener = { |
| 524 | display_handle_geometry, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 525 | display_handle_mode |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 526 | }; |
| 527 | |
Kristian Høgsberg | 539d85f | 2012-08-13 23:29:53 -0400 | [diff] [blame] | 528 | static void |
| 529 | check_focus(struct wayland_input *input, wl_fixed_t x, wl_fixed_t y) |
| 530 | { |
| 531 | struct wayland_compositor *c = input->compositor; |
| 532 | int width, height, inside; |
| 533 | |
| 534 | width = input->output->mode.width; |
| 535 | height = input->output->mode.height; |
| 536 | |
| 537 | inside = c->border.left <= wl_fixed_to_int(x) && |
| 538 | wl_fixed_to_int(x) < width + c->border.left && |
| 539 | c->border.top <= wl_fixed_to_int(y) && |
| 540 | wl_fixed_to_int(y) < height + c->border.top; |
| 541 | |
| 542 | if (!input->focus && inside) { |
| 543 | notify_pointer_focus(&input->base, &input->output->base, |
| 544 | x - wl_fixed_from_int(c->border.left), |
| 545 | y = wl_fixed_from_int(c->border.top)); |
| 546 | wl_pointer_set_cursor(input->pointer, |
| 547 | input->enter_serial, NULL, 0, 0); |
| 548 | } else if (input->focus && !inside) { |
| 549 | notify_pointer_focus(&input->base, NULL, 0, 0); |
| 550 | /* FIXME: Should set default cursor here. */ |
| 551 | } |
| 552 | |
| 553 | input->focus = inside; |
| 554 | } |
| 555 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 556 | /* parent input interface */ |
| 557 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 558 | input_handle_pointer_enter(void *data, struct wl_pointer *pointer, |
| 559 | uint32_t serial, struct wl_surface *surface, |
Kristian Høgsberg | e11bbe4 | 2012-05-09 12:19:04 -0400 | [diff] [blame] | 560 | wl_fixed_t x, wl_fixed_t y) |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 561 | { |
| 562 | struct wayland_input *input = data; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 563 | |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 564 | /* XXX: If we get a modifier event immediately before the focus, |
| 565 | * we should try to keep the same serial. */ |
Kristian Høgsberg | 539d85f | 2012-08-13 23:29:53 -0400 | [diff] [blame] | 566 | input->enter_serial = serial; |
| 567 | input->output = wl_surface_get_user_data(surface); |
| 568 | check_focus(input, x, y); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 572 | input_handle_pointer_leave(void *data, struct wl_pointer *pointer, |
| 573 | uint32_t serial, struct wl_surface *surface) |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 574 | { |
| 575 | struct wayland_input *input = data; |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 576 | |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 577 | notify_pointer_focus(&input->base, NULL, 0, 0); |
Kristian Høgsberg | 539d85f | 2012-08-13 23:29:53 -0400 | [diff] [blame] | 578 | input->output = NULL; |
| 579 | input->focus = 0; |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 583 | input_handle_motion(void *data, struct wl_pointer *pointer, |
| 584 | uint32_t time, wl_fixed_t x, wl_fixed_t y) |
| 585 | { |
| 586 | struct wayland_input *input = data; |
| 587 | struct wayland_compositor *c = input->compositor; |
| 588 | |
Kristian Høgsberg | 539d85f | 2012-08-13 23:29:53 -0400 | [diff] [blame] | 589 | check_focus(input, x, y); |
| 590 | if (input->focus) |
| 591 | notify_motion(&input->base, time, |
| 592 | x - wl_fixed_from_int(c->border.left), |
| 593 | y - wl_fixed_from_int(c->border.top)); |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | static void |
| 597 | input_handle_button(void *data, struct wl_pointer *pointer, |
Daniel Stone | 4dbadb1 | 2012-05-30 16:31:51 +0100 | [diff] [blame] | 598 | uint32_t serial, uint32_t time, uint32_t button, |
| 599 | uint32_t state_w) |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 600 | { |
| 601 | struct wayland_input *input = data; |
Daniel Stone | 4dbadb1 | 2012-05-30 16:31:51 +0100 | [diff] [blame] | 602 | enum wl_pointer_button_state state = state_w; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 603 | |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 604 | notify_button(&input->base, time, button, state); |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | static void |
| 608 | input_handle_axis(void *data, struct wl_pointer *pointer, |
Daniel Stone | 2fce402 | 2012-05-30 16:32:00 +0100 | [diff] [blame] | 609 | uint32_t time, uint32_t axis, wl_fixed_t value) |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 610 | { |
| 611 | struct wayland_input *input = data; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 612 | |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 613 | notify_axis(&input->base, time, axis, value); |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | static const struct wl_pointer_listener pointer_listener = { |
| 617 | input_handle_pointer_enter, |
| 618 | input_handle_pointer_leave, |
| 619 | input_handle_motion, |
| 620 | input_handle_button, |
| 621 | input_handle_axis, |
| 622 | }; |
| 623 | |
| 624 | static void |
Daniel Stone | b7452fe | 2012-06-01 12:14:06 +0100 | [diff] [blame] | 625 | input_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, |
| 626 | int fd, uint32_t size) |
| 627 | { |
| 628 | struct wayland_input *input = data; |
| 629 | struct xkb_keymap *keymap; |
| 630 | char *map_str; |
| 631 | |
| 632 | if (!data) { |
| 633 | close(fd); |
| 634 | return; |
| 635 | } |
| 636 | |
| 637 | if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { |
| 638 | close(fd); |
| 639 | return; |
| 640 | } |
| 641 | |
| 642 | map_str = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); |
| 643 | if (map_str == MAP_FAILED) { |
| 644 | close(fd); |
| 645 | return; |
| 646 | } |
| 647 | |
| 648 | keymap = xkb_map_new_from_string(input->compositor->base.xkb_context, |
| 649 | map_str, |
| 650 | XKB_KEYMAP_FORMAT_TEXT_V1, |
| 651 | 0); |
| 652 | munmap(map_str, size); |
| 653 | close(fd); |
| 654 | |
| 655 | if (!keymap) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 656 | weston_log("failed to compile keymap\n"); |
Daniel Stone | b7452fe | 2012-06-01 12:14:06 +0100 | [diff] [blame] | 657 | return; |
| 658 | } |
| 659 | |
Kristian Høgsberg | 7af7ced | 2012-08-10 10:01:33 -0400 | [diff] [blame] | 660 | weston_seat_init_keyboard(&input->base, keymap); |
Daniel Stone | b7452fe | 2012-06-01 12:14:06 +0100 | [diff] [blame] | 661 | xkb_map_unref(keymap); |
| 662 | } |
| 663 | |
| 664 | static void |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 665 | input_handle_keyboard_enter(void *data, |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 666 | struct wl_keyboard *keyboard, |
| 667 | uint32_t serial, |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 668 | struct wl_surface *surface, |
| 669 | struct wl_array *keys) |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 670 | { |
Kristian Høgsberg | af82bea | 2011-01-27 20:18:17 -0500 | [diff] [blame] | 671 | struct wayland_input *input = data; |
Kristian Høgsberg | af82bea | 2011-01-27 20:18:17 -0500 | [diff] [blame] | 672 | |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 673 | /* XXX: If we get a modifier event immediately before the focus, |
| 674 | * we should try to keep the same serial. */ |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 675 | notify_keyboard_focus_in(&input->base, keys, |
Daniel Stone | d6da09e | 2012-06-22 13:21:29 +0100 | [diff] [blame] | 676 | STATE_UPDATE_AUTOMATIC); |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | static void |
| 680 | input_handle_keyboard_leave(void *data, |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 681 | struct wl_keyboard *keyboard, |
| 682 | uint32_t serial, |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 683 | struct wl_surface *surface) |
| 684 | { |
| 685 | struct wayland_input *input = data; |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 686 | |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 687 | notify_keyboard_focus_out(&input->base); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 688 | } |
| 689 | |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 690 | static void |
| 691 | input_handle_key(void *data, struct wl_keyboard *keyboard, |
| 692 | uint32_t serial, uint32_t time, uint32_t key, uint32_t state) |
| 693 | { |
| 694 | struct wayland_input *input = data; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 695 | |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 696 | input->key_serial = serial; |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 697 | notify_key(&input->base, time, key, |
Daniel Stone | c9785ea | 2012-05-30 16:31:52 +0100 | [diff] [blame] | 698 | state ? WL_KEYBOARD_KEY_STATE_PRESSED : |
Daniel Stone | 1b4e11f | 2012-06-22 13:21:37 +0100 | [diff] [blame] | 699 | WL_KEYBOARD_KEY_STATE_RELEASED, |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 700 | STATE_UPDATE_NONE); |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 701 | } |
| 702 | |
Daniel Stone | 351eb61 | 2012-05-31 15:27:47 -0400 | [diff] [blame] | 703 | static void |
| 704 | input_handle_modifiers(void *data, struct wl_keyboard *keyboard, |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 705 | uint32_t serial_in, uint32_t mods_depressed, |
Daniel Stone | 351eb61 | 2012-05-31 15:27:47 -0400 | [diff] [blame] | 706 | uint32_t mods_latched, uint32_t mods_locked, |
| 707 | uint32_t group) |
| 708 | { |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 709 | struct wayland_input *input = data; |
| 710 | struct wayland_compositor *c = input->compositor; |
| 711 | uint32_t serial_out; |
| 712 | |
| 713 | /* If we get a key event followed by a modifier event with the |
| 714 | * same serial number, then we try to preserve those semantics by |
| 715 | * reusing the same serial number on the way out too. */ |
| 716 | if (serial_in == input->key_serial) |
| 717 | serial_out = wl_display_get_serial(c->base.wl_display); |
| 718 | else |
| 719 | serial_out = wl_display_next_serial(c->base.wl_display); |
| 720 | |
Kristian Høgsberg | 7af7ced | 2012-08-10 10:01:33 -0400 | [diff] [blame] | 721 | xkb_state_update_mask(input->base.xkb_state.state, |
Daniel Stone | 5069280 | 2012-06-22 13:21:41 +0100 | [diff] [blame] | 722 | mods_depressed, mods_latched, |
| 723 | mods_locked, 0, 0, group); |
Kristian Høgsberg | cb3eaae | 2012-08-10 09:50:11 -0400 | [diff] [blame] | 724 | notify_modifiers(&input->base, serial_out); |
Daniel Stone | 351eb61 | 2012-05-31 15:27:47 -0400 | [diff] [blame] | 725 | } |
| 726 | |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 727 | static const struct wl_keyboard_listener keyboard_listener = { |
Daniel Stone | b7452fe | 2012-06-01 12:14:06 +0100 | [diff] [blame] | 728 | input_handle_keymap, |
Kristian Høgsberg | 06d58b7 | 2012-02-23 09:59:05 -0500 | [diff] [blame] | 729 | input_handle_keyboard_enter, |
| 730 | input_handle_keyboard_leave, |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 731 | input_handle_key, |
Daniel Stone | 351eb61 | 2012-05-31 15:27:47 -0400 | [diff] [blame] | 732 | input_handle_modifiers, |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 733 | }; |
| 734 | |
| 735 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 736 | input_handle_capabilities(void *data, struct wl_seat *seat, |
| 737 | enum wl_seat_capability caps) |
| 738 | { |
| 739 | struct wayland_input *input = data; |
| 740 | |
| 741 | if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) { |
| 742 | input->pointer = wl_seat_get_pointer(seat); |
| 743 | wl_pointer_set_user_data(input->pointer, input); |
| 744 | wl_pointer_add_listener(input->pointer, &pointer_listener, |
| 745 | input); |
Kristian Høgsberg | 7af7ced | 2012-08-10 10:01:33 -0400 | [diff] [blame] | 746 | weston_seat_init_pointer(&input->base); |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 747 | } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) { |
| 748 | wl_pointer_destroy(input->pointer); |
| 749 | input->pointer = NULL; |
| 750 | } |
| 751 | |
| 752 | if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) { |
| 753 | input->keyboard = wl_seat_get_keyboard(seat); |
| 754 | wl_keyboard_set_user_data(input->keyboard, input); |
| 755 | wl_keyboard_add_listener(input->keyboard, &keyboard_listener, |
| 756 | input); |
| 757 | } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) { |
| 758 | wl_keyboard_destroy(input->keyboard); |
| 759 | input->keyboard = NULL; |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | static const struct wl_seat_listener seat_listener = { |
| 764 | input_handle_capabilities, |
| 765 | }; |
| 766 | |
| 767 | static void |
| 768 | display_add_seat(struct wayland_compositor *c, uint32_t id) |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 769 | { |
| 770 | struct wayland_input *input; |
| 771 | |
| 772 | input = malloc(sizeof *input); |
| 773 | if (input == NULL) |
| 774 | return; |
| 775 | |
| 776 | memset(input, 0, sizeof *input); |
| 777 | |
Kristian Høgsberg | 7af7ced | 2012-08-10 10:01:33 -0400 | [diff] [blame] | 778 | weston_seat_init(&input->base, &c->base); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 779 | input->compositor = c; |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 780 | input->seat = wl_display_bind(c->parent.wl_display, id, |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 781 | &wl_seat_interface); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 782 | wl_list_insert(c->input_list.prev, &input->link); |
| 783 | |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 784 | wl_seat_add_listener(input->seat, &seat_listener, input); |
| 785 | wl_seat_set_user_data(input->seat, input); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | static void |
| 789 | display_handle_global(struct wl_display *display, uint32_t id, |
| 790 | const char *interface, uint32_t version, void *data) |
| 791 | { |
| 792 | struct wayland_compositor *c = data; |
| 793 | |
Benjamin Franzke | 080ab6c | 2011-04-30 10:41:27 +0200 | [diff] [blame] | 794 | if (strcmp(interface, "wl_compositor") == 0) { |
Kristian Høgsberg | f790c79 | 2011-08-19 14:41:57 -0400 | [diff] [blame] | 795 | c->parent.compositor = |
| 796 | wl_display_bind(display, id, &wl_compositor_interface); |
Benjamin Franzke | 080ab6c | 2011-04-30 10:41:27 +0200 | [diff] [blame] | 797 | } else if (strcmp(interface, "wl_output") == 0) { |
Kristian Høgsberg | f790c79 | 2011-08-19 14:41:57 -0400 | [diff] [blame] | 798 | c->parent.output = |
| 799 | wl_display_bind(display, id, &wl_output_interface); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 800 | wl_output_add_listener(c->parent.output, &output_listener, c); |
Benjamin Franzke | 080ab6c | 2011-04-30 10:41:27 +0200 | [diff] [blame] | 801 | } else if (strcmp(interface, "wl_shell") == 0) { |
Kristian Høgsberg | f790c79 | 2011-08-19 14:41:57 -0400 | [diff] [blame] | 802 | c->parent.shell = |
| 803 | wl_display_bind(display, id, &wl_shell_interface); |
Daniel Stone | 725c2c3 | 2012-06-22 14:04:36 +0100 | [diff] [blame] | 804 | } else if (strcmp(interface, "wl_seat") == 0) { |
| 805 | display_add_seat(c, id); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 806 | } |
| 807 | } |
| 808 | |
| 809 | static int |
| 810 | update_event_mask(uint32_t mask, void *data) |
| 811 | { |
| 812 | struct wayland_compositor *c = data; |
| 813 | |
| 814 | c->parent.event_mask = mask; |
| 815 | if (c->parent.wl_source) |
| 816 | wl_event_source_fd_update(c->parent.wl_source, mask); |
| 817 | |
| 818 | return 0; |
| 819 | } |
| 820 | |
Kristian Høgsberg | 95d843d | 2011-04-22 13:01:26 -0400 | [diff] [blame] | 821 | static int |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 822 | wayland_compositor_handle_event(int fd, uint32_t mask, void *data) |
| 823 | { |
| 824 | struct wayland_compositor *c = data; |
| 825 | |
| 826 | if (mask & WL_EVENT_READABLE) |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 827 | wl_display_iterate(c->parent.wl_display, WL_DISPLAY_READABLE); |
Kristian Høgsberg | f258a31 | 2011-12-28 22:51:20 -0500 | [diff] [blame] | 828 | if (mask & WL_EVENT_WRITABLE) |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 829 | wl_display_iterate(c->parent.wl_display, WL_DISPLAY_WRITABLE); |
Kristian Høgsberg | 95d843d | 2011-04-22 13:01:26 -0400 | [diff] [blame] | 830 | |
| 831 | return 1; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 832 | } |
| 833 | |
Kristian Høgsberg | caa6442 | 2010-12-01 16:52:15 -0500 | [diff] [blame] | 834 | static void |
Kristian Høgsberg | 7b884bc | 2012-07-31 14:32:01 -0400 | [diff] [blame] | 835 | wayland_restore(struct weston_compositor *ec) |
| 836 | { |
| 837 | } |
| 838 | |
| 839 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 840 | wayland_destroy(struct weston_compositor *ec) |
Kristian Høgsberg | caa6442 | 2010-12-01 16:52:15 -0500 | [diff] [blame] | 841 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 842 | weston_compositor_shutdown(ec); |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 843 | |
Kristian Høgsberg | caa6442 | 2010-12-01 16:52:15 -0500 | [diff] [blame] | 844 | free(ec); |
| 845 | } |
| 846 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 847 | static struct weston_compositor * |
Kristian Høgsberg | 2e28b10 | 2012-02-07 09:57:25 -0500 | [diff] [blame] | 848 | wayland_compositor_create(struct wl_display *display, |
Daniel Stone | baf4359 | 2012-06-01 11:11:10 -0400 | [diff] [blame] | 849 | int width, int height, const char *display_name, |
Daniel Stone | c1be8e5 | 2012-06-01 11:14:02 -0400 | [diff] [blame] | 850 | int argc, char *argv[], const char *config_file) |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 851 | { |
| 852 | struct wayland_compositor *c; |
| 853 | struct wl_event_loop *loop; |
| 854 | int fd; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 855 | |
| 856 | c = malloc(sizeof *c); |
| 857 | if (c == NULL) |
| 858 | return NULL; |
| 859 | |
| 860 | memset(c, 0, sizeof *c); |
| 861 | |
Daniel Stone | 725c2c3 | 2012-06-22 14:04:36 +0100 | [diff] [blame] | 862 | if (weston_compositor_init(&c->base, display, argc, argv, |
| 863 | config_file) < 0) |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 864 | goto err_free; |
Daniel Stone | 725c2c3 | 2012-06-22 14:04:36 +0100 | [diff] [blame] | 865 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 866 | c->parent.wl_display = wl_display_connect(display_name); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 867 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 868 | if (c->parent.wl_display == NULL) { |
Martin Minarik | 6d11836 | 2012-06-07 18:01:59 +0200 | [diff] [blame] | 869 | weston_log("failed to create display: %m\n"); |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 870 | goto err_compositor; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | wl_list_init(&c->input_list); |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 874 | wl_display_add_global_listener(c->parent.wl_display, |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 875 | display_handle_global, c); |
| 876 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 877 | wl_display_iterate(c->parent.wl_display, WL_DISPLAY_READABLE); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 878 | |
| 879 | c->base.wl_display = display; |
| 880 | if (wayland_compositor_init_egl(c) < 0) |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 881 | goto err_display; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 882 | |
Benjamin Franzke | ecfb2b9 | 2011-01-15 12:34:48 +0100 | [diff] [blame] | 883 | c->base.destroy = wayland_destroy; |
Kristian Høgsberg | 7b884bc | 2012-07-31 14:32:01 -0400 | [diff] [blame] | 884 | c->base.restore = wayland_restore; |
Benjamin Franzke | ecfb2b9 | 2011-01-15 12:34:48 +0100 | [diff] [blame] | 885 | |
Daniel Stone | 725c2c3 | 2012-06-22 14:04:36 +0100 | [diff] [blame] | 886 | if (weston_compositor_init_gl(&c->base) < 0) |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 887 | goto err_display; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 888 | |
Kristian Høgsberg | 546a812 | 2012-02-01 07:45:51 -0500 | [diff] [blame] | 889 | create_border(c); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 890 | if (wayland_compositor_create_output(c, width, height) < 0) |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 891 | goto err_display; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 892 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 893 | loop = wl_display_get_event_loop(c->base.wl_display); |
| 894 | |
Kristian Høgsberg | 362b672 | 2012-06-18 15:13:51 -0400 | [diff] [blame] | 895 | fd = wl_display_get_fd(c->parent.wl_display, update_event_mask, c); |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 896 | c->parent.wl_source = |
| 897 | wl_event_loop_add_fd(loop, fd, c->parent.event_mask, |
| 898 | wayland_compositor_handle_event, c); |
| 899 | if (c->parent.wl_source == NULL) |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 900 | goto err_display; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 901 | |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 902 | return &c->base; |
Martin Olsson | c5db50f | 2012-07-08 03:03:43 +0200 | [diff] [blame] | 903 | |
| 904 | err_display: |
| 905 | wl_display_disconnect(c->parent.wl_display); |
| 906 | err_compositor: |
| 907 | weston_compositor_shutdown(&c->base); |
| 908 | err_free: |
| 909 | free(c); |
| 910 | return NULL; |
Benjamin Franzke | ec2e642 | 2010-11-27 19:04:12 +0100 | [diff] [blame] | 911 | } |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 912 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 913 | WL_EXPORT struct weston_compositor * |
Daniel Stone | c1be8e5 | 2012-06-01 11:14:02 -0400 | [diff] [blame] | 914 | backend_init(struct wl_display *display, int argc, char *argv[], |
| 915 | const char *config_file) |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 916 | { |
Kristian Høgsberg | bcacef1 | 2012-03-11 21:05:57 -0400 | [diff] [blame] | 917 | int width = 1024, height = 640; |
| 918 | char *display_name = NULL; |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 919 | |
Kristian Høgsberg | bcacef1 | 2012-03-11 21:05:57 -0400 | [diff] [blame] | 920 | const struct weston_option wayland_options[] = { |
| 921 | { WESTON_OPTION_INTEGER, "width", 0, &width }, |
| 922 | { WESTON_OPTION_INTEGER, "height", 0, &height }, |
| 923 | { WESTON_OPTION_STRING, "display", 0, &display_name }, |
| 924 | }; |
| 925 | |
| 926 | parse_options(wayland_options, |
| 927 | ARRAY_LENGTH(wayland_options), argc, argv); |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 928 | |
Daniel Stone | baf4359 | 2012-06-01 11:11:10 -0400 | [diff] [blame] | 929 | return wayland_compositor_create(display, width, height, display_name, |
Daniel Stone | c1be8e5 | 2012-06-01 11:14:02 -0400 | [diff] [blame] | 930 | argc, argv, config_file); |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 931 | } |