blob: c765fe5697ab59facae7de220a679ece3fd81c2d [file] [log] [blame]
Kristian Høgsbergffd710e2008-12-02 15:15:01 -05001/*
2 * Copyright © 2008 Kristian Høgsberg
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
Kristian Høgsberg61017b12008-11-02 18:51:48 -050023#include <stdint.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
Kristian Høgsberg61017b12008-11-02 18:51:48 -050027#include <fcntl.h>
28#include <unistd.h>
29#include <math.h>
30#include <time.h>
31#include <cairo.h>
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050032#include <glib.h>
Kristian Høgsberg61017b12008-11-02 18:51:48 -050033
Kristian Høgsberg5ee1a602008-12-11 23:18:45 -050034#include <linux/input.h>
Kristian Høgsberg61017b12008-11-02 18:51:48 -050035#include "wayland-client.h"
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -050036#include "wayland-glib.h"
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050037
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050038#include "cairo-util.h"
Kristian Høgsberg61017b12008-11-02 18:51:48 -050039
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050040#include "window.h"
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050041
Kristian Høgsberg61017b12008-11-02 18:51:48 -050042struct window {
Kristian Høgsberg40979232008-11-25 22:40:39 -050043 struct wl_display *display;
Kristian Høgsbergd2412e22008-12-15 20:35:24 -050044 struct wl_compositor *compositor;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050045 struct wl_surface *surface;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050046 const char *title;
Kristian Høgsberg78231c82008-11-08 15:06:01 -050047 int x, y, width, height;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050048 int minimum_width, minimum_height;
Kristian Høgsberg40979232008-11-25 22:40:39 -050049 int margin;
Kristian Høgsbergc492b482008-12-12 12:00:02 -050050 int drag_x, drag_y;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050051 int state;
Kristian Høgsbergc492b482008-12-12 12:00:02 -050052 uint32_t grab_device;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050053 uint32_t name;
54 int fd;
Kristian Høgsberg78231c82008-11-08 15:06:01 -050055
56 struct buffer *buffer;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050057
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050058 window_resize_handler_t resize_handler;
59 window_frame_handler_t frame_handler;
60 window_acknowledge_handler_t acknowledge_handler;
Kristian Høgsberg6e83d582008-12-08 00:01:36 -050061 window_key_handler_t key_handler;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050062 void *user_data;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050063};
64
Kristian Høgsberge4feb562008-11-08 18:53:37 -050065static void
66rounded_rect(cairo_t *cr, int x0, int y0, int x1, int y1, int radius)
67{
68 cairo_move_to(cr, x0, y0 + radius);
69 cairo_arc(cr, x0 + radius, y0 + radius, radius, M_PI, 3 * M_PI / 2);
70 cairo_line_to(cr, x1 - radius, y0);
71 cairo_arc(cr, x1 - radius, y0 + radius, radius, 3 * M_PI / 2, 2 * M_PI);
72 cairo_line_to(cr, x1, y1 - radius);
73 cairo_arc(cr, x1 - radius, y1 - radius, radius, 0, M_PI / 2);
74 cairo_line_to(cr, x0 + radius, y1);
75 cairo_arc(cr, x0 + radius, y1 - radius, radius, M_PI / 2, M_PI);
76 cairo_close_path(cr);
77}
78
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050079void
80window_draw(struct window *window)
Kristian Høgsberg61017b12008-11-02 18:51:48 -050081{
82 cairo_surface_t *surface;
83 cairo_t *cr;
Kristian Høgsberg40979232008-11-25 22:40:39 -050084 int border = 2, radius = 5;
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -050085 cairo_text_extents_t extents;
Kristian Høgsberge4feb562008-11-08 18:53:37 -050086 cairo_pattern_t *gradient, *outline, *bright, *dim;
Kristian Høgsberg61017b12008-11-02 18:51:48 -050087
88 surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
Kristian Høgsberg40979232008-11-25 22:40:39 -050089 window->width + window->margin * 2,
90 window->height + window->margin * 2);
Kristian Høgsberg61017b12008-11-02 18:51:48 -050091
Kristian Høgsberge4feb562008-11-08 18:53:37 -050092 outline = cairo_pattern_create_rgb(0.1, 0.1, 0.1);
Kristian Høgsberge9d550b2008-11-19 00:49:39 -050093 bright = cairo_pattern_create_rgb(0.8, 0.8, 0.8);
Kristian Høgsberge4feb562008-11-08 18:53:37 -050094 dim = cairo_pattern_create_rgb(0.4, 0.4, 0.4);
95
Kristian Høgsberg61017b12008-11-02 18:51:48 -050096 cr = cairo_create(surface);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050097
Kristian Høgsberg40979232008-11-25 22:40:39 -050098 cairo_translate(cr, window->margin + 7, window->margin + 5);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -050099 cairo_set_line_width (cr, border);
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500100 cairo_set_source_rgba(cr, 0, 0, 0, 0.7);
Kristian Høgsberg8c304f62008-11-10 10:46:53 -0500101 rounded_rect(cr, 0, 0, window->width, window->height, radius);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -0500102 cairo_fill(cr);
Kristian Høgsberg87330262008-11-17 22:23:55 -0500103 blur_surface(surface, 24 + radius);
Kristian Høgsberg2f2cfae2008-11-08 22:46:30 -0500104
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500105 cairo_translate(cr, -7, -5);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500106 cairo_set_line_width (cr, border);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500107 rounded_rect(cr, 1, 1, window->width - 1, window->height - 1, radius);
108 cairo_set_source(cr, outline);
109 cairo_stroke(cr);
Kristian Høgsberg6e635f32008-11-09 09:15:46 -0500110 rounded_rect(cr, 2, 2, window->width - 2, window->height - 2, radius - 1);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500111 cairo_set_source(cr, bright);
112 cairo_stroke(cr);
Kristian Høgsberg6e635f32008-11-09 09:15:46 -0500113 rounded_rect(cr, 3, 3, window->width - 2, window->height - 2, radius - 1);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500114 cairo_set_source(cr, dim);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500115 cairo_stroke(cr);
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -0500116
Kristian Høgsberg6e635f32008-11-09 09:15:46 -0500117 rounded_rect(cr, 2, 2, window->width - 2, window->height - 2, radius - 1);
118 gradient = cairo_pattern_create_linear (0, 0, 0, 100);
Kristian Høgsberge9d550b2008-11-19 00:49:39 -0500119 cairo_pattern_add_color_stop_rgb(gradient, 0, 0.6, 0.6, 0.4);
120 cairo_pattern_add_color_stop_rgb(gradient, 1, 0.8, 0.8, 0.7);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500121 cairo_set_source(cr, gradient);
122 cairo_fill(cr);
123 cairo_pattern_destroy(gradient);
124
125 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
126 cairo_move_to(cr, 10, 50);
127 cairo_line_to(cr, window->width - 10, 50);
128 cairo_line_to(cr, window->width - 10, window->height - 10);
129 cairo_line_to(cr, 10, window->height - 10);
130 cairo_close_path(cr);
131 cairo_set_source(cr, dim);
132 cairo_stroke(cr);
133
134 cairo_move_to(cr, 11, 51);
135 cairo_line_to(cr, window->width - 10, 51);
136 cairo_line_to(cr, window->width - 10, window->height - 10);
137 cairo_line_to(cr, 11, window->height - 10);
138 cairo_close_path(cr);
139 cairo_set_source(cr, bright);
140 cairo_stroke(cr);
141
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500142 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
143 cairo_set_font_size(cr, 14);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500144 cairo_text_extents(cr, window->title, &extents);
Kristian Høgsbergca1d1f62008-11-03 06:59:52 -0500145 cairo_move_to(cr, (window->width - extents.width) / 2, 10 - extents.y_bearing);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500146 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
147 cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
148 cairo_set_line_width (cr, 4);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500149 cairo_text_path(cr, window->title);
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500150 cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
151 cairo_stroke_preserve(cr);
152 cairo_set_source_rgb(cr, 1, 1, 1);
153 cairo_fill(cr);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500154 cairo_destroy(cr);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500155
Kristian Høgsberg40979232008-11-25 22:40:39 -0500156 window->buffer = buffer_create_from_cairo_surface(window->fd, surface);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500157 cairo_surface_destroy(surface);
158
Kristian Høgsberg40979232008-11-25 22:40:39 -0500159 wl_surface_attach(window->surface,
160 window->buffer->name,
161 window->buffer->width,
162 window->buffer->height,
163 window->buffer->stride);
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500164
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500165 wl_surface_map(window->surface,
166 window->x - window->margin,
167 window->y - window->margin,
168 window->width + 2 * window->margin,
169 window->height + 2 * window->margin);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500170}
171
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500172enum window_state {
173 WINDOW_STABLE,
174 WINDOW_MOVING,
175 WINDOW_RESIZING_UPPER_LEFT,
176 WINDOW_RESIZING_UPPER_RIGHT,
177 WINDOW_RESIZING_LOWER_LEFT,
178 WINDOW_RESIZING_LOWER_RIGHT
179};
180
181enum location {
182 LOCATION_INTERIOR,
183 LOCATION_UPPER_LEFT,
184 LOCATION_UPPER_RIGHT,
185 LOCATION_LOWER_LEFT,
186 LOCATION_LOWER_RIGHT,
187 LOCATION_OUTSIDE
188};
189
Kristian Høgsberge4feb562008-11-08 18:53:37 -0500190static void
191event_handler(struct wl_display *display,
Kristian Høgsberg40979232008-11-25 22:40:39 -0500192 uint32_t object, uint32_t opcode,
193 uint32_t size, uint32_t *p, void *data)
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500194{
195 struct window *window = data;
Kristian Høgsberg1584c572008-12-08 12:59:37 -0500196 struct rectangle rectangle;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500197 int location;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500198 int grip_size = 16;
199
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500200 /* FIXME: Object ID 2 is the compositor, for anything else we
Kristian Høgsberg40979232008-11-25 22:40:39 -0500201 * assume it's an input device. */
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500202 if (object == 2 && opcode == 0) {
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500203 uint32_t key = p[0];
204
205 /* Ignore acknowledge events for window move requests. */
206 if (key != 0)
207 return;
208
Kristian Høgsberg40979232008-11-25 22:40:39 -0500209 /* The acknowledge event means that the server
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500210 * processed our last commit request and we can now
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500211 * safely free the old window buffer if we resized and
212 * render the next frame into our back buffer.. */
213
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500214 if (window->buffer != NULL) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500215 buffer_destroy(window->buffer, window->fd);
216 window->buffer = NULL;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500217 }
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500218 if (window->acknowledge_handler)
219 (*window->acknowledge_handler)(window, key,
220 window->user_data);
221
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500222 } else if (object == 2 && opcode == 1) {
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500223 /* The frame event means that the previous frame was
224 * composited, and we can now send the request to copy
225 * the frame we've rendered in the mean time into the
226 * servers surface buffer. */
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500227 if (window->frame_handler)
228 (*window->frame_handler)(window, p[0], p[1],
229 window->user_data);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500230 } else if (object == 1) {
231 fprintf(stderr, "unexpected event from display: %d\n",
232 opcode);
233 exit(-1);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500234 } else if (opcode == 0) {
235 int x = p[0], y = p[1];
236
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500237 switch (window->state) {
238 case WINDOW_MOVING:
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500239 if (window->grab_device != object)
240 break;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500241 window->x = window->drag_x + x;
242 window->y = window->drag_y + y;
243 wl_surface_map(window->surface,
244 window->x - window->margin,
245 window->y - window->margin,
246 window->width + 2 * window->margin,
247 window->height + 2 * window->margin);
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500248 wl_compositor_commit(window->compositor, 1);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500249 break;
250 case WINDOW_RESIZING_LOWER_RIGHT:
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500251 if (window->grab_device != object)
252 break;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500253 window->width = window->drag_x + x;
254 window->height = window->drag_y + y;
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500255
Kristian Høgsberg1584c572008-12-08 12:59:37 -0500256 window_get_child_rectangle(window, &rectangle);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500257 if (window->resize_handler)
258 (*window->resize_handler)(window,
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500259 window->user_data);
Kristian Høgsberg1584c572008-12-08 12:59:37 -0500260
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500261 break;
262 }
Kristian Høgsberg40979232008-11-25 22:40:39 -0500263 } else if (opcode == 1) {
264 int button = p[0], state = p[1];
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500265 int32_t x = p[2], y = p[3];
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500266
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500267 if (window->x + window->width - grip_size <= x &&
268 x < window->x + window->width &&
269 window->y + window->height - grip_size <= y &&
270 y < window->y + window->height) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500271 location = LOCATION_LOWER_RIGHT;
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500272 } else if (window->x <= x && x < window->x + window->width &&
273 window->y <= y && y < window->y + window->height) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500274 location = LOCATION_INTERIOR;
275 } else {
276 location = LOCATION_OUTSIDE;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500277 }
Kristian Høgsberg40979232008-11-25 22:40:39 -0500278
Kristian Høgsberg5ee1a602008-12-11 23:18:45 -0500279 if (button == BTN_LEFT && state == 1) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500280 switch (location) {
281 case LOCATION_INTERIOR:
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500282 window->drag_x = window->x - x;
283 window->drag_y = window->y - y;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500284 window->state = WINDOW_MOVING;
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500285 window->grab_device = object;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500286 break;
287 case LOCATION_LOWER_RIGHT:
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500288 window->drag_x = window->width - x;
289 window->drag_y = window->height - y;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500290 window->state = WINDOW_RESIZING_LOWER_RIGHT;
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500291 window->grab_device = object;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500292 break;
293 default:
294 window->state = WINDOW_STABLE;
295 break;
296 }
Kristian Høgsbergc492b482008-12-12 12:00:02 -0500297 } else if (button == BTN_LEFT &&
298 state == 0 && object == window->grab_device) {
Kristian Høgsberg40979232008-11-25 22:40:39 -0500299 window->state = WINDOW_STABLE;
300 }
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500301 } else if (opcode == 2) {
302 if (window->key_handler)
303 (*window->key_handler)(window, p[0], p[1],
304 window->user_data);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500305 }
306}
307
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500308void
309window_get_child_rectangle(struct window *window,
310 struct rectangle *rectangle)
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500311{
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500312 rectangle->x = 10;
313 rectangle->y = 50;
314 rectangle->width = window->width - 20;
315 rectangle->height = window->height - 60;
316}
317
318void
Kristian Høgsberg22106762008-12-08 13:50:07 -0500319window_set_child_size(struct window *window,
320 struct rectangle *rectangle)
321{
322 window->width = rectangle->width + 20;
323 window->height = rectangle->height + 60;
324}
325
326void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500327window_copy(struct window *window,
328 struct rectangle *rectangle,
329 uint32_t name, uint32_t stride)
330{
331 wl_surface_copy(window->surface,
332 window->margin + rectangle->x,
333 window->margin + rectangle->y,
334 name, stride,
335 0, 0, rectangle->width, rectangle->height);
336}
337
338void
339window_set_resize_handler(struct window *window,
340 window_resize_handler_t handler, void *data)
341{
342 window->resize_handler = handler;
343 window->user_data = data;
344}
345
346void
347window_set_frame_handler(struct window *window,
348 window_frame_handler_t handler, void *data)
349{
350 window->frame_handler = handler;
351 window->user_data = data;
352}
353
354void
355window_set_acknowledge_handler(struct window *window,
356 window_acknowledge_handler_t handler, void *data)
357{
358 window->acknowledge_handler = handler;
359 window->user_data = data;
360}
361
362void
Kristian Høgsberg6e83d582008-12-08 00:01:36 -0500363window_set_key_handler(struct window *window,
364 window_key_handler_t handler, void *data)
365{
366 window->key_handler = handler;
367 window->user_data = data;
368}
369
370void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500371window_set_minimum_size(struct window *window, uint32_t width, int32_t height)
372{
373 window->minimum_width = width;
374 window->minimum_height = height;
375}
376
377struct window *
378window_create(struct wl_display *display, int fd,
379 const char *title,
380 int32_t x, int32_t y, int32_t width, int32_t height)
381{
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500382 struct window *window;
383
384 window = malloc(sizeof *window);
385 if (window == NULL)
386 return NULL;
387
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500388 memset(window, 0, sizeof *window);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500389 window->display = display;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500390 window->title = strdup(title);
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500391 window->compositor = wl_display_get_compositor(display);
392 window->surface = wl_compositor_create_surface(window->compositor);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500393 window->x = x;
394 window->y = y;
395 window->minimum_width = 100;
396 window->minimum_height = 100;
397 window->width = width;
398 window->height = height;
Kristian Høgsberg40979232008-11-25 22:40:39 -0500399 window->margin = 16;
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500400 window->state = WINDOW_STABLE;
401 window->fd = fd;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500402
Kristian Høgsberg1cbaa6a2008-11-07 15:54:48 -0500403 wl_display_set_event_handler(display, event_handler, window);
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500404
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500405 return window;
Kristian Høgsberg61017b12008-11-02 18:51:48 -0500406}