blob: e2e6477f1bb3a22a994e17bc41fcea7c602d0541 [file] [log] [blame]
Alexander Larsson73469ed2013-05-28 16:23:34 +02001/*
2 * Copyright © 2008 Kristian Høgsberg
3 * Copyright © 2012 Intel Corporation
4 *
Bryce Harrington1f6b0d12015-06-10 22:48:59 -07005 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
Alexander Larsson73469ed2013-05-28 16:23:34 +020011 *
Bryce Harrington1f6b0d12015-06-10 22:48:59 -070012 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Alexander Larsson73469ed2013-05-28 16:23:34 +020023 */
24
Andrew Wedgbury9cd661e2014-04-07 12:40:35 +010025#include "config.h"
26
Alexander Larsson73469ed2013-05-28 16:23:34 +020027#include <stdint.h>
28#include <stdio.h>
29#include <stdlib.h>
30#include <stdarg.h>
31#include <string.h>
32#include <math.h>
33#include <cairo.h>
34
35#include <linux/input.h>
36#include <wayland-client.h>
37#include "window.h"
Jonas Ådahl496adb32015-11-17 16:00:27 +080038#include "fullscreen-shell-unstable-v1-client-protocol.h"
Bryce Harrington0d1a6222016-02-11 16:42:49 -080039#include "shared/zalloc.h"
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -050040
41struct fs_output {
42 struct wl_list link;
43 struct output *output;
44};
Alexander Larsson73469ed2013-05-28 16:23:34 +020045
46struct fullscreen {
47 struct display *display;
48 struct window *window;
49 struct widget *widget;
Jonas Ådahl496adb32015-11-17 16:00:27 +080050 struct zwp_fullscreen_shell_v1 *fshell;
51 enum zwp_fullscreen_shell_v1_present_method present_method;
Alexander Larsson73469ed2013-05-28 16:23:34 +020052 int width, height;
53 int fullscreen;
54 float pointer_x, pointer_y;
Jasper St. Pierreaf314bb2014-05-12 11:23:44 -040055 int draw_cursor;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -050056
57 struct wl_list output_list;
58 struct fs_output *current_output;
Alexander Larsson73469ed2013-05-28 16:23:34 +020059};
60
61static void
62fullscreen_handler(struct window *window, void *data)
63{
64 struct fullscreen *fullscreen = data;
65
66 fullscreen->fullscreen ^= 1;
67 window_set_fullscreen(window, fullscreen->fullscreen);
68}
69
70static void
Alexander Larsson73469ed2013-05-28 16:23:34 +020071draw_string(cairo_t *cr,
72 const char *fmt, ...)
73{
74 char buffer[4096];
75 char *p, *end;
76 va_list argp;
77 cairo_text_extents_t text_extents;
78 cairo_font_extents_t font_extents;
79
80 cairo_save(cr);
81
82 cairo_select_font_face(cr, "sans",
83 CAIRO_FONT_SLANT_NORMAL,
84 CAIRO_FONT_WEIGHT_NORMAL);
85 cairo_set_font_size(cr, 14);
86
87 cairo_font_extents (cr, &font_extents);
88
89 va_start(argp, fmt);
90
91 vsnprintf(buffer, sizeof(buffer), fmt, argp);
92
93 p = buffer;
94 while (*p) {
95 end = strchr(p, '\n');
96 if (end)
97 *end = 0;
98
99 cairo_show_text(cr, p);
100 cairo_text_extents (cr, p, &text_extents);
101 cairo_rel_move_to (cr, -text_extents.x_advance, font_extents.height);
102
103 if (end)
104 p = end + 1;
105 else
106 break;
107 }
108
109 va_end(argp);
110
111 cairo_restore(cr);
112
113}
114
115static void
116redraw_handler(struct widget *widget, void *data)
117{
118 struct fullscreen *fullscreen = data;
119 struct rectangle allocation;
120 cairo_surface_t *surface;
121 cairo_t *cr;
122 int i;
123 double x, y, border;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500124 const char *method_name[] = { "default", "center", "zoom", "zoom_crop", "stretch"};
Alexander Larsson73469ed2013-05-28 16:23:34 +0200125
126 surface = window_get_surface(fullscreen->window);
127 if (surface == NULL ||
128 cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
129 fprintf(stderr, "failed to create cairo egl surface\n");
130 return;
131 }
132
133 widget_get_allocation(fullscreen->widget, &allocation);
134
135 cr = widget_cairo_create(widget);
136
137 cairo_set_source_rgb(cr, 0, 0, 0);
138 cairo_paint (cr);
139
140 cairo_set_source_rgb(cr, 0, 0, 1);
141 cairo_set_line_width (cr, 10);
142 cairo_rectangle(cr, 5, 5, allocation.width - 10, allocation.height - 10);
143 cairo_stroke (cr);
144
145 cairo_move_to(cr,
146 allocation.x + 15,
147 allocation.y + 25);
148 cairo_set_source_rgb(cr, 1, 1, 1);
149
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500150 if (fullscreen->fshell) {
151 draw_string(cr,
152 "Surface size: %d, %d\n"
153 "Scale: %d, transform: %d\n"
154 "Pointer: %f,%f\n"
155 "Output: %s, present method: %s\n"
156 "Keys: (s)cale, (t)ransform, si(z)e, (m)ethod,\n"
157 " (o)utput, modes(w)itch, (q)uit\n",
158 fullscreen->width, fullscreen->height,
159 window_get_buffer_scale (fullscreen->window),
160 window_get_buffer_transform (fullscreen->window),
161 fullscreen->pointer_x, fullscreen->pointer_y,
162 method_name[fullscreen->present_method],
163 fullscreen->current_output ? output_get_model(fullscreen->current_output->output): "null");
164 } else {
165 draw_string(cr,
166 "Surface size: %d, %d\n"
167 "Scale: %d, transform: %d\n"
168 "Pointer: %f,%f\n"
169 "Fullscreen: %d\n"
170 "Keys: (s)cale, (t)ransform, si(z)e, (f)ullscreen, (q)uit\n",
171 fullscreen->width, fullscreen->height,
172 window_get_buffer_scale (fullscreen->window),
173 window_get_buffer_transform (fullscreen->window),
174 fullscreen->pointer_x, fullscreen->pointer_y,
175 fullscreen->fullscreen);
176 }
Alexander Larsson73469ed2013-05-28 16:23:34 +0200177
178 y = 100;
179 i = 0;
180 while (y + 60 < fullscreen->height) {
181 border = (i++ % 2 == 0) ? 1 : 0.5;
182
183 x = 50;
184 cairo_set_line_width (cr, border);
185 while (x + 70 < fullscreen->width) {
Jasper St. Pierreaf314bb2014-05-12 11:23:44 -0400186 if (window_has_focus(fullscreen->window) &&
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500187 fullscreen->pointer_x >= x && fullscreen->pointer_x < x + 50 &&
Alexander Larsson73469ed2013-05-28 16:23:34 +0200188 fullscreen->pointer_y >= y && fullscreen->pointer_y < y + 40) {
189 cairo_set_source_rgb(cr, 1, 0, 0);
190 cairo_rectangle(cr,
191 x, y,
192 50, 40);
193 cairo_fill(cr);
194 }
195 cairo_set_source_rgb(cr, 0, 1, 0);
196 cairo_rectangle(cr,
197 x + border/2.0, y + border/2.0,
198 50, 40);
199 cairo_stroke(cr);
200 x += 60;
201 }
202
203 y += 50;
204 }
205
Jasper St. Pierreaf314bb2014-05-12 11:23:44 -0400206 if (window_has_focus(fullscreen->window) && fullscreen->draw_cursor) {
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500207 cairo_set_source_rgb(cr, 1, 1, 1);
208 cairo_set_line_width (cr, 8);
209 cairo_move_to(cr,
210 fullscreen->pointer_x - 12,
211 fullscreen->pointer_y - 12);
212 cairo_line_to(cr,
213 fullscreen->pointer_x + 12,
214 fullscreen->pointer_y + 12);
215 cairo_stroke(cr);
216
217 cairo_move_to(cr,
218 fullscreen->pointer_x + 12,
219 fullscreen->pointer_y - 12);
220 cairo_line_to(cr,
221 fullscreen->pointer_x - 12,
222 fullscreen->pointer_y + 12);
223 cairo_stroke(cr);
224
225 cairo_set_source_rgb(cr, 0, 0, 0);
226 cairo_set_line_width (cr, 4);
227 cairo_move_to(cr,
228 fullscreen->pointer_x - 10,
229 fullscreen->pointer_y - 10);
230 cairo_line_to(cr,
231 fullscreen->pointer_x + 10,
232 fullscreen->pointer_y + 10);
233 cairo_stroke(cr);
234
235 cairo_move_to(cr,
236 fullscreen->pointer_x + 10,
237 fullscreen->pointer_y - 10);
238 cairo_line_to(cr,
239 fullscreen->pointer_x - 10,
240 fullscreen->pointer_y + 10);
241 cairo_stroke(cr);
242 }
243
Alexander Larsson73469ed2013-05-28 16:23:34 +0200244 cairo_destroy(cr);
245}
246
247static void
248key_handler(struct window *window, struct input *input, uint32_t time,
249 uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
250 void *data)
251{
252 struct fullscreen *fullscreen = data;
253 int transform, scale;
254 static int current_size = 0;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500255 struct fs_output *fsout;
256 struct wl_output *wl_output;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200257 int widths[] = { 640, 320, 800, 400 };
258 int heights[] = { 480, 240, 600, 300 };
259
260 if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
261 return;
262
263 switch (sym) {
264 case XKB_KEY_t:
265 transform = window_get_buffer_transform (window);
266 transform = (transform + 1) % 8;
267 window_set_buffer_transform(window, transform);
268 window_schedule_redraw(window);
269 break;
270
271 case XKB_KEY_s:
272 scale = window_get_buffer_scale (window);
273 if (scale == 1)
274 scale = 2;
275 else
276 scale = 1;
277 window_set_buffer_scale(window, scale);
278 window_schedule_redraw(window);
279 break;
280
281 case XKB_KEY_z:
282 current_size = (current_size + 1) % 4;
283 fullscreen->width = widths[current_size];
284 fullscreen->height = heights[current_size];
285 window_schedule_resize(fullscreen->window,
286 fullscreen->width, fullscreen->height);
287 break;
288
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500289 case XKB_KEY_m:
290 if (!fullscreen->fshell)
291 break;
292
293 wl_output = NULL;
294 if (fullscreen->current_output)
295 wl_output = output_get_wl_output(fullscreen->current_output->output);
296 fullscreen->present_method = (fullscreen->present_method + 1) % 5;
Jonas Ådahl496adb32015-11-17 16:00:27 +0800297 zwp_fullscreen_shell_v1_present_surface(fullscreen->fshell,
298 window_get_wl_surface(fullscreen->window),
299 fullscreen->present_method,
300 wl_output);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500301 window_schedule_redraw(window);
302 break;
303
304 case XKB_KEY_o:
305 if (!fullscreen->fshell)
306 break;
307
308 fsout = fullscreen->current_output;
309 wl_output = fsout ? output_get_wl_output(fsout->output) : NULL;
310
311 /* Clear the current presentation */
Jonas Ådahl496adb32015-11-17 16:00:27 +0800312 zwp_fullscreen_shell_v1_present_surface(fullscreen->fshell, NULL,
313 0, wl_output);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500314
315 if (fullscreen->current_output) {
316 if (fullscreen->current_output->link.next == &fullscreen->output_list)
317 fsout = NULL;
318 else
319 fsout = wl_container_of(fullscreen->current_output->link.next,
320 fsout, link);
321 } else {
322 fsout = wl_container_of(fullscreen->output_list.next,
323 fsout, link);
324 }
325
326 fullscreen->current_output = fsout;
327 wl_output = fsout ? output_get_wl_output(fsout->output) : NULL;
Jonas Ådahl496adb32015-11-17 16:00:27 +0800328 zwp_fullscreen_shell_v1_present_surface(fullscreen->fshell,
329 window_get_wl_surface(fullscreen->window),
330 fullscreen->present_method,
331 wl_output);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500332 window_schedule_redraw(window);
333 break;
334
335 case XKB_KEY_w:
336 if (!fullscreen->fshell || !fullscreen->current_output)
337 break;
338
339 wl_output = NULL;
340 if (fullscreen->current_output)
341 wl_output = output_get_wl_output(fullscreen->current_output->output);
Jonas Ådahl496adb32015-11-17 16:00:27 +0800342 zwp_fullscreen_shell_mode_feedback_v1_destroy(
343 zwp_fullscreen_shell_v1_present_surface_for_mode(fullscreen->fshell,
344 window_get_wl_surface(fullscreen->window),
345 wl_output, 0));
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500346 window_schedule_redraw(window);
347 break;
348
Alexander Larsson73469ed2013-05-28 16:23:34 +0200349 case XKB_KEY_f:
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500350 if (fullscreen->fshell)
351 break;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200352 fullscreen->fullscreen ^= 1;
353 window_set_fullscreen(window, fullscreen->fullscreen);
354 break;
355
356 case XKB_KEY_q:
357 exit (0);
358 break;
359 }
360}
361
362static int
363motion_handler(struct widget *widget,
364 struct input *input,
365 uint32_t time,
366 float x,
367 float y, void *data)
368{
369 struct fullscreen *fullscreen = data;
370
371 fullscreen->pointer_x = x;
372 fullscreen->pointer_y = y;
373
374 widget_schedule_redraw(widget);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500375
376 return fullscreen->draw_cursor ? CURSOR_BLANK : CURSOR_LEFT_PTR;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200377}
378
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500379static int
380enter_handler(struct widget *widget,
381 struct input *input,
382 float x, float y, void *data)
383{
384 struct fullscreen *fullscreen = data;
385
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500386 fullscreen->pointer_x = x;
387 fullscreen->pointer_y = y;
388
389 widget_schedule_redraw(widget);
390
391 return fullscreen->draw_cursor ? CURSOR_BLANK : CURSOR_LEFT_PTR;
392}
393
394static void
Alexander Larsson73469ed2013-05-28 16:23:34 +0200395button_handler(struct widget *widget,
396 struct input *input, uint32_t time,
397 uint32_t button, enum wl_pointer_button_state state, void *data)
398{
399 struct fullscreen *fullscreen = data;
400
401 switch (button) {
402 case BTN_LEFT:
403 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
404 window_move(fullscreen->window, input,
405 display_get_serial(fullscreen->display));
406 break;
407 case BTN_RIGHT:
408 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
409 window_show_frame_menu(fullscreen->window, input, time);
410 break;
411 }
412}
413
414static void
Michael Vetter2a18a522015-05-15 17:17:47 +0200415touch_handler(struct widget *widget, struct input *input,
416 uint32_t serial, uint32_t time, int32_t id,
Rusty Lynch1084da52013-08-15 09:10:08 -0700417 float x, float y, void *data)
418{
419 struct fullscreen *fullscreen = data;
Jasper St. Pierre01eaaac2013-11-12 20:19:57 -0500420 window_move(fullscreen->window, input, display_get_serial(fullscreen->display));
Rusty Lynch1084da52013-08-15 09:10:08 -0700421}
422
423static void
Jonas Ådahl496adb32015-11-17 16:00:27 +0800424fshell_capability_handler(void *data, struct zwp_fullscreen_shell_v1 *fshell,
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500425 uint32_t capability)
426{
427 struct fullscreen *fullscreen = data;
428
429 switch (capability) {
Jonas Ådahl496adb32015-11-17 16:00:27 +0800430 case ZWP_FULLSCREEN_SHELL_V1_CAPABILITY_CURSOR_PLANE:
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500431 fullscreen->draw_cursor = 0;
432 break;
433 default:
434 break;
435 }
436}
437
Jonas Ådahl496adb32015-11-17 16:00:27 +0800438struct zwp_fullscreen_shell_v1_listener fullscreen_shell_listener = {
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500439 fshell_capability_handler
440};
441
442static void
Alexander Larsson73469ed2013-05-28 16:23:34 +0200443usage(int error_code)
444{
445 fprintf(stderr, "Usage: fullscreen [OPTIONS]\n\n"
446 " -w <width>\tSet window width to <width>\n"
447 " -h <height>\tSet window height to <height>\n"
448 " --help\tShow this help text\n\n");
449
450 exit(error_code);
451}
452
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500453static void
454output_handler(struct output *output, void *data)
455{
456 struct fullscreen *fullscreen = data;
457 struct fs_output *fsout;
458
459 /* If we've already seen this one, don't add it to the list */
460 wl_list_for_each(fsout, &fullscreen->output_list, link)
461 if (fsout->output == output)
462 return;
463
Bryce Harrington0d1a6222016-02-11 16:42:49 -0800464 fsout = zalloc(sizeof *fsout);
465 if (fsout == NULL) {
466 fprintf(stderr, "out of memory in output_handler\n");
467 return;
468 }
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500469 fsout->output = output;
470 wl_list_insert(&fullscreen->output_list, &fsout->link);
471}
472
473static void
474global_handler(struct display *display, uint32_t id, const char *interface,
475 uint32_t version, void *data)
476{
477 struct fullscreen *fullscreen = data;
478
Jonas Ådahl496adb32015-11-17 16:00:27 +0800479 if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) {
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500480 fullscreen->fshell = display_bind(display, id,
Jonas Ådahl496adb32015-11-17 16:00:27 +0800481 &zwp_fullscreen_shell_v1_interface,
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500482 1);
Jonas Ådahl496adb32015-11-17 16:00:27 +0800483 zwp_fullscreen_shell_v1_add_listener(fullscreen->fshell,
484 &fullscreen_shell_listener,
485 fullscreen);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500486 }
487}
488
Alexander Larsson73469ed2013-05-28 16:23:34 +0200489int main(int argc, char *argv[])
490{
491 struct fullscreen fullscreen;
492 struct display *d;
493 int i;
494
495 fullscreen.width = 640;
496 fullscreen.height = 480;
497 fullscreen.fullscreen = 0;
Jonas Ådahl496adb32015-11-17 16:00:27 +0800498 fullscreen.present_method = ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500499 wl_list_init(&fullscreen.output_list);
500 fullscreen.current_output = NULL;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200501
502 for (i = 1; i < argc; i++) {
503 if (strcmp(argv[i], "-w") == 0) {
504 if (++i >= argc)
505 usage(EXIT_FAILURE);
506
507 fullscreen.width = atol(argv[i]);
508 } else if (strcmp(argv[i], "-h") == 0) {
509 if (++i >= argc)
510 usage(EXIT_FAILURE);
511
512 fullscreen.height = atol(argv[i]);
513 } else if (strcmp(argv[i], "--help") == 0)
514 usage(EXIT_SUCCESS);
515 else
516 usage(EXIT_FAILURE);
517 }
518
519 d = display_create(&argc, argv);
520 if (d == NULL) {
521 fprintf(stderr, "failed to create display: %m\n");
522 return -1;
523 }
524
525 fullscreen.display = d;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500526 fullscreen.fshell = NULL;
527 display_set_user_data(fullscreen.display, &fullscreen);
528 display_set_global_handler(fullscreen.display, global_handler);
529 display_set_output_configure_handler(fullscreen.display, output_handler);
530
531 if (fullscreen.fshell) {
532 fullscreen.window = window_create_custom(d);
Jonas Ådahl496adb32015-11-17 16:00:27 +0800533 zwp_fullscreen_shell_v1_present_surface(fullscreen.fshell,
534 window_get_wl_surface(fullscreen.window),
535 fullscreen.present_method,
536 NULL);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500537 /* If we get the CURSOR_PLANE capability, we'll change this */
538 fullscreen.draw_cursor = 1;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500539 } else {
540 fullscreen.window = window_create(d);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500541 fullscreen.draw_cursor = 0;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500542 }
543
Alexander Larsson73469ed2013-05-28 16:23:34 +0200544 fullscreen.widget =
545 window_add_widget(fullscreen.window, &fullscreen);
546
547 window_set_title(fullscreen.window, "Fullscreen");
Alexander Larsson73469ed2013-05-28 16:23:34 +0200548
549 widget_set_transparent(fullscreen.widget, 0);
Alexander Larsson73469ed2013-05-28 16:23:34 +0200550
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500551 widget_set_default_cursor(fullscreen.widget, CURSOR_LEFT_PTR);
Alexander Larsson73469ed2013-05-28 16:23:34 +0200552 widget_set_redraw_handler(fullscreen.widget, redraw_handler);
553 widget_set_button_handler(fullscreen.widget, button_handler);
554 widget_set_motion_handler(fullscreen.widget, motion_handler);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500555 widget_set_enter_handler(fullscreen.widget, enter_handler);
Alexander Larsson73469ed2013-05-28 16:23:34 +0200556
Rusty Lynch1084da52013-08-15 09:10:08 -0700557 widget_set_touch_down_handler(fullscreen.widget, touch_handler);
558
Alexander Larsson73469ed2013-05-28 16:23:34 +0200559 window_set_key_handler(fullscreen.window, key_handler);
560 window_set_fullscreen_handler(fullscreen.window, fullscreen_handler);
561
562 window_set_user_data(fullscreen.window, &fullscreen);
563 /* Hack to set minimum allocation so we can shrink later */
564 window_schedule_resize(fullscreen.window,
565 1, 1);
566 window_schedule_resize(fullscreen.window,
567 fullscreen.width, fullscreen.height);
568
569 display_run(d);
570
vivek31732f72014-05-15 18:58:16 +0530571 widget_destroy(fullscreen.widget);
572 window_destroy(fullscreen.window);
573 display_destroy(d);
574
Alexander Larsson73469ed2013-05-28 16:23:34 +0200575 return 0;
576}