blob: 4753f6368805c1aca07e490fb7a3e4b74d014bb7 [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øgsbergfbdbbdc2008-11-28 17:06:06 -0500157 wl_surface_map(window->surface,
158 window->x - window->margin,
159 window->y - window->margin,
160 window->width + 2 * window->margin,
161 window->height + 2 * window->margin);
162
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500163 width = window->width - 20;
164 height = window->height - 60;
165 buffer = buffer_create(window->fd, width, height, (width * 4 + 15) & ~15);
166 window->egl_buffer = buffer;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500167 window->egl_surface = eglCreateSurfaceForName(window->egl_display,
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500168 window->config, buffer->name,
169 buffer->width, buffer->height,
170 buffer->stride, NULL);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500171 if (!eglMakeCurrent(window->egl_display,
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500172 window->egl_surface, window->egl_surface, window->context))
173 die("failed to make context current\n");
174
175 glViewport(0, 0, width, height);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500176 window->resized = 0;
177
178 return FALSE;
179}
180
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500181enum window_state {
182 WINDOW_STABLE,
183 WINDOW_MOVING,
184 WINDOW_RESIZING_UPPER_LEFT,
185 WINDOW_RESIZING_UPPER_RIGHT,
186 WINDOW_RESIZING_LOWER_LEFT,
187 WINDOW_RESIZING_LOWER_RIGHT
188};
189
190enum location {
191 LOCATION_INTERIOR,
192 LOCATION_UPPER_LEFT,
193 LOCATION_UPPER_RIGHT,
194 LOCATION_LOWER_LEFT,
195 LOCATION_LOWER_RIGHT,
196 LOCATION_OUTSIDE
197};
198
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500199static int
200update_gears(void *data)
201{
202 struct window *window = data;
203
204 if (window->resized)
205 draw_window(window);
206 gears_draw(window->gears, window->gears_angle);
207
208 return FALSE;
209}
210
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500211static void
212event_handler(struct wl_display *display,
Kristian Høgsberg40979232008-11-25 22:40:39 -0500213 uint32_t object, uint32_t opcode,
214 uint32_t size, uint32_t *p, void *data)
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500215{
216 struct window *window = data;
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500217 struct buffer *buffer;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500218 int location;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500219 int grip_size = 16;
220
Kristian Høgsberg40979232008-11-25 22:40:39 -0500221 /* FIXME: Object ID 1 is the display, for anything else we
222 * assume it's an input device. */
223 if (object == 1 && opcode == 3) {
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500224 uint32_t key = p[0];
225
226 /* Ignore acknowledge events for window move requests. */
227 if (key != 0)
228 return;
229
Kristian Høgsberg40979232008-11-25 22:40:39 -0500230 /* The acknowledge event means that the server
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500231 * processed our last commit request and we can now
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500232 * safely free the old window buffer if we resized and
233 * render the next frame into our back buffer.. */
234
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500235 if (window->buffer != NULL) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500236 buffer_destroy(window->buffer, window->fd);
237 window->buffer = NULL;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500238 }
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500239 g_idle_add(update_gears, window);
240 } else if (object == 1 && opcode == 4) {
241 /* The frame event means that the previous frame was
242 * composited, and we can now send the request to copy
243 * the frame we've rendered in the mean time into the
244 * servers surface buffer. */
245 buffer = window->egl_buffer;
246 wl_surface_copy(window->surface,
247 10 + window->margin, 50 + window->margin,
248 buffer->name, buffer->stride,
249 0, 0, buffer->width, buffer->height);
250 wl_display_commit(window->display, 0);
251 window->gears_angle += 1;
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500252
253 } else if (object == 1) {
254 fprintf(stderr, "unexpected event from display: %d\n",
255 opcode);
256 exit(-1);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500257 } else if (opcode == 0) {
258 int x = p[0], y = p[1];
259
260 window->last_x = x;
261 window->last_y = y;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500262 switch (window->state) {
263 case WINDOW_MOVING:
Kristian Høgsberg40979232008-11-25 22:40:39 -0500264 window->x = window->drag_x + x;
265 window->y = window->drag_y + y;
266 wl_surface_map(window->surface,
267 window->x - window->margin,
268 window->y - window->margin,
269 window->width + 2 * window->margin,
270 window->height + 2 * window->margin);
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500271 wl_display_commit(window->display, 1);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500272 break;
273 case WINDOW_RESIZING_LOWER_RIGHT:
Kristian Høgsberg40979232008-11-25 22:40:39 -0500274 window->width = window->drag_x + x;
275 window->height = window->drag_y + y;
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500276 if (window->width < 400)
277 window->width = 400;
278 if (window->height < 400)
279 window->height = 400;
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500280
281 /* Right now, resizing the window from the
282 * per-frame callback is fine, since the
283 * window drawing code is so slow that we
284 * can't draw more than one window per frame
285 * anyway. However, once we implement faster
286 * resizing, this will show lag between
287 * pointer motion and window size even if
288 * resizing is fast. We need to keep
289 * processing motion events and posting new
290 * frames as fast as possible so when the
291 * server composites the next frame it will
292 * have the most recent size possible, like
293 * what we do for window moves. */
294
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500295 window->resized = 1;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500296 break;
297 }
Kristian Høgsberg40979232008-11-25 22:40:39 -0500298 } else if (opcode == 1) {
299 int button = p[0], state = p[1];
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500300
Kristian Høgsberg40979232008-11-25 22:40:39 -0500301 if (window->x + window->width - grip_size <= window->last_x &&
302 window->last_x < window->x + window->width &&
303 window->y + window->height - grip_size <= window->last_y &&
304 window->last_y < window->y + window->height) {
305 location = LOCATION_LOWER_RIGHT;
306 } else if (window->x <= window->last_x &&
307 window->last_x < window->x + window->width &&
308 window->y <= window->last_y &&
309 window->last_y < window->y + window->height) {
310 location = LOCATION_INTERIOR;
311 } else {
312 location = LOCATION_OUTSIDE;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500313 }
Kristian Høgsberg40979232008-11-25 22:40:39 -0500314
315 if (button == 0 && state == 1) {
316 switch (location) {
317 case LOCATION_INTERIOR:
318 window->drag_x = window->x - window->last_x;
319 window->drag_y = window->y - window->last_y;
320 window->state = WINDOW_MOVING;
321 break;
322 case LOCATION_LOWER_RIGHT:
323 window->drag_x = window->width - window->last_x;
324 window->drag_y = window->height - window->last_y;
325 window->state = WINDOW_RESIZING_LOWER_RIGHT;
326 break;
327 default:
328 window->state = WINDOW_STABLE;
329 break;
330 }
331 } else if (button == 0 && state == 0) {
332 window->state = WINDOW_STABLE;
333 }
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500334 }
335}
336
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500337static struct window *
338window_create(struct wl_display *display, int fd)
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500339{
340 EGLint major, minor, count;
341 EGLConfig configs[64];
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500342 struct window *window;
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500343 const GLfloat red = 0, green = 0, blue = 0, alpha = 0.92;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500344
345 window = malloc(sizeof *window);
346 if (window == NULL)
347 return NULL;
348
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500349 memset(window, 0, sizeof *window);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500350 window->display = display;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500351 window->surface = wl_display_create_surface(display);
352 window->x = 200;
353 window->y = 200;
354 window->width = 450;
355 window->height = 500;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500356 window->margin = 16;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500357 window->state = WINDOW_STABLE;
358 window->fd = fd;
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500359 window->background = cairo_pattern_create_rgba (red, green, blue, alpha);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500360
Kristian Høgsberg40979232008-11-25 22:40:39 -0500361 window->egl_display = eglCreateDisplayNative("/dev/dri/card0", "i965");
362 if (window->egl_display == NULL)
363 die("failed to create egl display\n");
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500364
Kristian Høgsberg40979232008-11-25 22:40:39 -0500365 if (!eglInitialize(window->egl_display, &major, &minor))
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500366 die("failed to initialize display\n");
367
Kristian Høgsberg40979232008-11-25 22:40:39 -0500368 if (!eglGetConfigs(window->egl_display, configs, 64, &count))
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500369 die("failed to get configs\n");
370
371 window->config = configs[24];
Kristian Høgsberg40979232008-11-25 22:40:39 -0500372 window->context = eglCreateContext(window->egl_display, window->config, NULL, NULL);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500373 if (window->context == NULL)
374 die("failed to create context\n");
375
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500376 draw_window(window);
377 window->gears = gears_create(0, 0, 0, 0.92);
378 gears_draw(window->gears, window->gears_angle);
379 window->gears_angle += 1;
380 wl_display_commit(window->display, 0);
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500381
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500382 return window;
383}
384
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500385int main(int argc, char *argv[])
386{
387 struct wl_display *display;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500388 int fd;
389 struct window *window;
390 GMainLoop *loop;
391 GSource *source;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500392
393 fd = open(gem_device, O_RDWR);
394 if (fd < 0) {
395 fprintf(stderr, "drm open failed: %m\n");
396 return -1;
397 }
398
Kristian Høgsbergfb590842008-11-07 14:27:23 -0500399 display = wl_display_create(socket_name);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500400 if (display == NULL) {
401 fprintf(stderr, "failed to create display: %m\n");
402 return -1;
403 }
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500404
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500405 loop = g_main_loop_new(NULL, FALSE);
406 source = wayland_source_new(display);
407 g_source_attach(source, NULL);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500408
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500409 window = window_create(display, fd);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500410
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500411 wl_display_set_event_handler(display, event_handler, window);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500412
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500413 g_main_loop_run(loop);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500414
415 return 0;
416}