blob: fb9e28a5bbc2e8761b57fd0b2e19d841125dede5 [file] [log] [blame]
Kristian Høgsberg61017b12008-11-02 18:51:48 -05001#include <stdint.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
Kristian Høgsberg61017b12008-11-02 18:51:48 -05005#include <fcntl.h>
6#include <unistd.h>
7#include <math.h>
8#include <time.h>
9#include <cairo.h>
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050010#include <glib.h>
Kristian Høgsberg61017b12008-11-02 18:51:48 -050011
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050012#include <GL/gl.h>
13#include <eagle.h>
14
Kristian Høgsberg61017b12008-11-02 18:51:48 -050015#include "wayland-client.h"
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050016#include "wayland-glib.h"
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050017
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050018#include "gears.h"
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050019#include "cairo-util.h"
Kristian Høgsberg61017b12008-11-02 18:51:48 -050020
21static const char gem_device[] = "/dev/dri/card0";
22static const char socket_name[] = "\0wayland";
23
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050024static void die(const char *msg)
25{
26 fprintf(stderr, "%s", msg);
27 exit(EXIT_FAILURE);
28}
29
Kristian Høgsberg61017b12008-11-02 18:51:48 -050030struct window {
Kristian Høgsberg40979232008-11-25 22:40:39 -050031 struct wl_display *display;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050032 struct wl_surface *surface;
Kristian Høgsberg78231c82008-11-08 15:06:01 -050033 int x, y, width, height;
Kristian Høgsberg40979232008-11-25 22:40:39 -050034 int margin;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050035 int drag_x, drag_y, last_x, last_y;
36 int state;
37 uint32_t name;
38 int fd;
Kristian Høgsberg40979232008-11-25 22:40:39 -050039 int resized;
Kristian Høgsberg78231c82008-11-08 15:06:01 -050040 cairo_pattern_t *background;
41
42 struct buffer *buffer;
43 struct buffer *egl_buffer;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050044
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050045 GLfloat gears_angle;
46 struct gears *gears;
Kristian Høgsberg40979232008-11-25 22:40:39 -050047 EGLDisplay egl_display;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050048 EGLContext context;
49 EGLConfig config;
50 EGLSurface egl_surface;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050051};
52
Kristian Høgsberge4feb562008-11-08 18:53:37 -050053static void
54rounded_rect(cairo_t *cr, int x0, int y0, int x1, int y1, int radius)
55{
56 cairo_move_to(cr, x0, y0 + radius);
57 cairo_arc(cr, x0 + radius, y0 + radius, radius, M_PI, 3 * M_PI / 2);
58 cairo_line_to(cr, x1 - radius, y0);
59 cairo_arc(cr, x1 - radius, y0 + radius, radius, 3 * M_PI / 2, 2 * M_PI);
60 cairo_line_to(cr, x1, y1 - radius);
61 cairo_arc(cr, x1 - radius, y1 - radius, radius, 0, M_PI / 2);
62 cairo_line_to(cr, x0 + radius, y1);
63 cairo_arc(cr, x0 + radius, y1 - radius, radius, M_PI / 2, M_PI);
64 cairo_close_path(cr);
65}
66
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050067static gboolean
68draw_window(void *data)
Kristian Høgsberg61017b12008-11-02 18:51:48 -050069{
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050070 struct window *window = data;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050071 cairo_surface_t *surface;
72 cairo_t *cr;
Kristian Høgsberg40979232008-11-25 22:40:39 -050073 int border = 2, radius = 5;
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -050074 cairo_text_extents_t extents;
Kristian Høgsberge4feb562008-11-08 18:53:37 -050075 cairo_pattern_t *gradient, *outline, *bright, *dim;
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -050076 const static char title[] = "Wayland First Post";
Kristian Høgsberg40979232008-11-25 22:40:39 -050077 struct buffer *buffer;
Kristian Høgsberge9d550b2008-11-19 00:49:39 -050078 int width, height;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050079
80 surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
Kristian Høgsberg40979232008-11-25 22:40:39 -050081 window->width + window->margin * 2,
82 window->height + window->margin * 2);
Kristian Høgsberg61017b12008-11-02 18:51:48 -050083
Kristian Høgsberge4feb562008-11-08 18:53:37 -050084 outline = cairo_pattern_create_rgb(0.1, 0.1, 0.1);
Kristian Høgsberge9d550b2008-11-19 00:49:39 -050085 bright = cairo_pattern_create_rgb(0.8, 0.8, 0.8);
Kristian Høgsberge4feb562008-11-08 18:53:37 -050086 dim = cairo_pattern_create_rgb(0.4, 0.4, 0.4);
87
Kristian Høgsberg61017b12008-11-02 18:51:48 -050088 cr = cairo_create(surface);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050089
Kristian Høgsberg40979232008-11-25 22:40:39 -050090 cairo_translate(cr, window->margin + 7, window->margin + 5);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050091 cairo_set_line_width (cr, border);
Kristian Høgsberge9d550b2008-11-19 00:49:39 -050092 cairo_set_source_rgba(cr, 0, 0, 0, 0.7);
Kristian Høgsberg8c304f62008-11-10 10:46:53 -050093 rounded_rect(cr, 0, 0, window->width, window->height, radius);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050094 cairo_fill(cr);
Kristian Høgsberg87330262008-11-17 22:23:55 -050095 blur_surface(surface, 24 + radius);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050096
Kristian Høgsberge9d550b2008-11-19 00:49:39 -050097 cairo_translate(cr, -7, -5);
Kristian Høgsberg61017b12008-11-02 18:51:48 -050098 cairo_set_line_width (cr, border);
Kristian Høgsberge4feb562008-11-08 18:53:37 -050099 rounded_rect(cr, 1, 1, window->width - 1, window->height - 1, radius);
100 cairo_set_source(cr, outline);
101 cairo_stroke(cr);
Kristian Høgsberg6e635f32008-11-09 09:15:46 -0500102 rounded_rect(cr, 2, 2, window->width - 2, window->height - 2, radius - 1);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500103 cairo_set_source(cr, bright);
104 cairo_stroke(cr);
Kristian Høgsberg6e635f32008-11-09 09:15:46 -0500105 rounded_rect(cr, 3, 3, window->width - 2, window->height - 2, radius - 1);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500106 cairo_set_source(cr, dim);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500107 cairo_stroke(cr);
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -0500108
Kristian Høgsberg6e635f32008-11-09 09:15:46 -0500109 rounded_rect(cr, 2, 2, window->width - 2, window->height - 2, radius - 1);
110 gradient = cairo_pattern_create_linear (0, 0, 0, 100);
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500111 cairo_pattern_add_color_stop_rgb(gradient, 0, 0.6, 0.6, 0.4);
112 cairo_pattern_add_color_stop_rgb(gradient, 1, 0.8, 0.8, 0.7);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500113 cairo_set_source(cr, gradient);
114 cairo_fill(cr);
115 cairo_pattern_destroy(gradient);
116
117 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
118 cairo_move_to(cr, 10, 50);
119 cairo_line_to(cr, window->width - 10, 50);
120 cairo_line_to(cr, window->width - 10, window->height - 10);
121 cairo_line_to(cr, 10, window->height - 10);
122 cairo_close_path(cr);
123 cairo_set_source(cr, dim);
124 cairo_stroke(cr);
125
126 cairo_move_to(cr, 11, 51);
127 cairo_line_to(cr, window->width - 10, 51);
128 cairo_line_to(cr, window->width - 10, window->height - 10);
129 cairo_line_to(cr, 11, window->height - 10);
130 cairo_close_path(cr);
131 cairo_set_source(cr, bright);
132 cairo_stroke(cr);
133
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500134 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
135 cairo_set_font_size(cr, 14);
136 cairo_text_extents(cr, title, &extents);
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -0500137 cairo_move_to(cr, (window->width - extents.width) / 2, 10 - extents.y_bearing);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500138 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
139 cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
140 cairo_set_line_width (cr, 4);
141 cairo_text_path(cr, title);
142 cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
143 cairo_stroke_preserve(cr);
144 cairo_set_source_rgb(cr, 1, 1, 1);
145 cairo_fill(cr);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500146 cairo_destroy(cr);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500147
Kristian Høgsberg40979232008-11-25 22:40:39 -0500148 window->buffer = buffer_create_from_cairo_surface(window->fd, surface);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500149 cairo_surface_destroy(surface);
150
Kristian Høgsberg40979232008-11-25 22:40:39 -0500151 wl_surface_attach(window->surface,
152 window->buffer->name,
153 window->buffer->width,
154 window->buffer->height,
155 window->buffer->stride);
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500156
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500157 width = window->width - 20;
158 height = window->height - 60;
159 buffer = buffer_create(window->fd, width, height, (width * 4 + 15) & ~15);
160 window->egl_buffer = buffer;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500161 window->egl_surface = eglCreateSurfaceForName(window->egl_display,
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500162 window->config, buffer->name,
163 buffer->width, buffer->height,
164 buffer->stride, NULL);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500165 if (!eglMakeCurrent(window->egl_display,
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500166 window->egl_surface, window->egl_surface, window->context))
167 die("failed to make context current\n");
168
169 glViewport(0, 0, width, height);
170
171 if (window->gears == NULL)
172 window->gears = gears_create(0, 0, 0, 0.92);
173
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500174 window->resized = 0;
175
176 return FALSE;
177}
178
179
180static gboolean
181animate_gears(gpointer data)
182{
183 struct window *window = data;
184 struct buffer *buffer;
185 static uint32_t key;
186
187 /* Right now, resizing the window from the animation is fine,
188 * since the window drawing code is so slow, but once we
189 * implement faster resizing, this will show lag between
190 * pointer motion and window size even if resizing is fast.
191 * We need to keep processing motion events and posting new
192 * frames as fast as possible so when the server composites
193 * the next frame it will have the most recent size possible.
194 * In that case, we need the two ack protocol, where the first
195 * ack signals that the server got the request so we can free
196 * the buffer, to prevent us from allocating a ton of buffer
197 * that will never be displayed. */
198 if (window->resized)
199 draw_window(window);
200
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500201 gears_draw(window->gears, window->gears_angle);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500202
203 buffer = window->egl_buffer;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500204 wl_surface_copy(window->surface,
205 10 + window->margin, 50 + window->margin,
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500206 buffer->name, buffer->stride,
207 0, 0, buffer->width, buffer->height);
208
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500209 /* Shouldn't need to do this here, but without proper commit
210 * support in the server, doing this before rendering the
211 * gears show the window briefly before it's fully
212 * rendered. */
Kristian Høgsberg40979232008-11-25 22:40:39 -0500213
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500214 wl_surface_map(window->surface,
215 window->x - window->margin,
216 window->y - window->margin,
217 window->width + 2 * window->margin,
218 window->height + 2 * window->margin);
219
220 wl_display_commit(window->display, key++);
221 window->gears_angle += 1;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500222
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500223 return FALSE;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500224}
225
226enum window_state {
227 WINDOW_STABLE,
228 WINDOW_MOVING,
229 WINDOW_RESIZING_UPPER_LEFT,
230 WINDOW_RESIZING_UPPER_RIGHT,
231 WINDOW_RESIZING_LOWER_LEFT,
232 WINDOW_RESIZING_LOWER_RIGHT
233};
234
235enum location {
236 LOCATION_INTERIOR,
237 LOCATION_UPPER_LEFT,
238 LOCATION_UPPER_RIGHT,
239 LOCATION_LOWER_LEFT,
240 LOCATION_LOWER_RIGHT,
241 LOCATION_OUTSIDE
242};
243
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500244static void
245event_handler(struct wl_display *display,
Kristian Høgsberg40979232008-11-25 22:40:39 -0500246 uint32_t object, uint32_t opcode,
247 uint32_t size, uint32_t *p, void *data)
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500248{
249 struct window *window = data;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500250 int location;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500251 int grip_size = 16;
252
Kristian Høgsberg40979232008-11-25 22:40:39 -0500253 /* FIXME: Object ID 1 is the display, for anything else we
254 * assume it's an input device. */
255 if (object == 1 && opcode == 3) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500256 /* The acknowledge event means that the server
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500257 * processed our last commit request and we can now
258 * safely free the buffer. */
259 if (window->buffer != NULL) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500260 buffer_destroy(window->buffer, window->fd);
261 window->buffer = NULL;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500262 }
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500263
264 g_idle_add(animate_gears, window);
265
266 } else if (object == 1) {
267 fprintf(stderr, "unexpected event from display: %d\n",
268 opcode);
269 exit(-1);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500270 } else if (opcode == 0) {
271 int x = p[0], y = p[1];
272
273 window->last_x = x;
274 window->last_y = y;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500275 switch (window->state) {
276 case WINDOW_MOVING:
Kristian Høgsberg40979232008-11-25 22:40:39 -0500277 window->x = window->drag_x + x;
278 window->y = window->drag_y + y;
279 wl_surface_map(window->surface,
280 window->x - window->margin,
281 window->y - window->margin,
282 window->width + 2 * window->margin,
283 window->height + 2 * window->margin);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500284 /* FIXME: We should do this here:
285 *
286 * wl_display_commit(window->display, 1);
287 *
288 * to make sure the server processes the move,
289 * but that'll mess with the other commit from
290 * animate_gears with the current server
291 * implementation. Since the current server
292 * doesn't rely on commit anyway yet, we can
293 * just forget about it for now. */
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500294 break;
295 case WINDOW_RESIZING_LOWER_RIGHT:
Kristian Høgsberg40979232008-11-25 22:40:39 -0500296 window->width = window->drag_x + x;
297 window->height = window->drag_y + y;
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500298 if (window->width < 400)
299 window->width = 400;
300 if (window->height < 400)
301 window->height = 400;
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500302 window->resized = 1;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500303 break;
304 }
Kristian Høgsberg40979232008-11-25 22:40:39 -0500305 } else if (opcode == 1) {
306 int button = p[0], state = p[1];
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500307
Kristian Høgsberg40979232008-11-25 22:40:39 -0500308 if (window->x + window->width - grip_size <= window->last_x &&
309 window->last_x < window->x + window->width &&
310 window->y + window->height - grip_size <= window->last_y &&
311 window->last_y < window->y + window->height) {
312 location = LOCATION_LOWER_RIGHT;
313 } else if (window->x <= window->last_x &&
314 window->last_x < window->x + window->width &&
315 window->y <= window->last_y &&
316 window->last_y < window->y + window->height) {
317 location = LOCATION_INTERIOR;
318 } else {
319 location = LOCATION_OUTSIDE;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500320 }
Kristian Høgsberg40979232008-11-25 22:40:39 -0500321
322 if (button == 0 && state == 1) {
323 switch (location) {
324 case LOCATION_INTERIOR:
325 window->drag_x = window->x - window->last_x;
326 window->drag_y = window->y - window->last_y;
327 window->state = WINDOW_MOVING;
328 break;
329 case LOCATION_LOWER_RIGHT:
330 window->drag_x = window->width - window->last_x;
331 window->drag_y = window->height - window->last_y;
332 window->state = WINDOW_RESIZING_LOWER_RIGHT;
333 break;
334 default:
335 window->state = WINDOW_STABLE;
336 break;
337 }
338 } else if (button == 0 && state == 0) {
339 window->state = WINDOW_STABLE;
340 }
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500341 }
342}
343
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500344static struct window *
345window_create(struct wl_display *display, int fd)
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500346{
347 EGLint major, minor, count;
348 EGLConfig configs[64];
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500349 struct window *window;
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500350 const GLfloat red = 0, green = 0, blue = 0, alpha = 0.92;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500351
352 window = malloc(sizeof *window);
353 if (window == NULL)
354 return NULL;
355
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500356 memset(window, 0, sizeof *window);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500357 window->display = display;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500358 window->surface = wl_display_create_surface(display);
359 window->x = 200;
360 window->y = 200;
361 window->width = 450;
362 window->height = 500;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500363 window->margin = 16;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500364 window->state = WINDOW_STABLE;
365 window->fd = fd;
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500366 window->background = cairo_pattern_create_rgba (red, green, blue, alpha);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500367 window->resized = 1;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500368
Kristian Høgsberg40979232008-11-25 22:40:39 -0500369 window->egl_display = eglCreateDisplayNative("/dev/dri/card0", "i965");
370 if (window->egl_display == NULL)
371 die("failed to create egl display\n");
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500372
Kristian Høgsberg40979232008-11-25 22:40:39 -0500373 if (!eglInitialize(window->egl_display, &major, &minor))
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500374 die("failed to initialize display\n");
375
Kristian Høgsberg40979232008-11-25 22:40:39 -0500376 if (!eglGetConfigs(window->egl_display, configs, 64, &count))
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500377 die("failed to get configs\n");
378
379 window->config = configs[24];
Kristian Høgsberg40979232008-11-25 22:40:39 -0500380 window->context = eglCreateContext(window->egl_display, window->config, NULL, NULL);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500381 if (window->context == NULL)
382 die("failed to create context\n");
383
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500384 animate_gears(window);
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500385
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500386 return window;
387}
388
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500389int main(int argc, char *argv[])
390{
391 struct wl_display *display;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500392 int fd;
393 struct window *window;
394 GMainLoop *loop;
395 GSource *source;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500396
397 fd = open(gem_device, O_RDWR);
398 if (fd < 0) {
399 fprintf(stderr, "drm open failed: %m\n");
400 return -1;
401 }
402
Kristian Høgsbergfb590842008-11-07 14:27:23 -0500403 display = wl_display_create(socket_name);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500404 if (display == NULL) {
405 fprintf(stderr, "failed to create display: %m\n");
406 return -1;
407 }
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500408
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500409 loop = g_main_loop_new(NULL, FALSE);
410 source = wayland_source_new(display);
411 g_source_attach(source, NULL);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500412
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500413 window = window_create(display, fd);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500414
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500415 wl_display_set_event_handler(display, event_handler, window);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500416
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500417 g_main_loop_run(loop);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500418
419 return 0;
420}