blob: ccedfbc44d67d78fba41430b2f2cbe4b04fc559d [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>
Antonio Borneo39578632019-04-26 23:57:31 +020033#include <errno.h>
Alexander Larsson73469ed2013-05-28 16:23:34 +020034#include <cairo.h>
35
36#include <linux/input.h>
37#include <wayland-client.h>
38#include "window.h"
Jonas Ådahl496adb32015-11-17 16:00:27 +080039#include "fullscreen-shell-unstable-v1-client-protocol.h"
Pekka Paalanenecbdcfd2019-04-04 14:46:00 +030040#include <libweston/zalloc.h>
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -050041
42struct fs_output {
43 struct wl_list link;
44 struct output *output;
45};
Alexander Larsson73469ed2013-05-28 16:23:34 +020046
47struct fullscreen {
48 struct display *display;
49 struct window *window;
50 struct widget *widget;
Jonas Ådahl496adb32015-11-17 16:00:27 +080051 struct zwp_fullscreen_shell_v1 *fshell;
52 enum zwp_fullscreen_shell_v1_present_method present_method;
Alexander Larsson73469ed2013-05-28 16:23:34 +020053 int width, height;
54 int fullscreen;
55 float pointer_x, pointer_y;
Jasper St. Pierreaf314bb2014-05-12 11:23:44 -040056 int draw_cursor;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -050057
58 struct wl_list output_list;
59 struct fs_output *current_output;
Alexander Larsson73469ed2013-05-28 16:23:34 +020060};
61
62static void
63fullscreen_handler(struct window *window, void *data)
64{
65 struct fullscreen *fullscreen = data;
66
67 fullscreen->fullscreen ^= 1;
68 window_set_fullscreen(window, fullscreen->fullscreen);
69}
70
71static void
Alexander Larsson73469ed2013-05-28 16:23:34 +020072draw_string(cairo_t *cr,
73 const char *fmt, ...)
74{
75 char buffer[4096];
76 char *p, *end;
77 va_list argp;
78 cairo_text_extents_t text_extents;
79 cairo_font_extents_t font_extents;
80
81 cairo_save(cr);
82
Alyssa Ross7c121822021-11-17 17:25:17 +000083 cairo_select_font_face(cr, "sans-serif",
Alexander Larsson73469ed2013-05-28 16:23:34 +020084 CAIRO_FONT_SLANT_NORMAL,
85 CAIRO_FONT_WEIGHT_NORMAL);
86 cairo_set_font_size(cr, 14);
87
88 cairo_font_extents (cr, &font_extents);
89
90 va_start(argp, fmt);
91
92 vsnprintf(buffer, sizeof(buffer), fmt, argp);
93
94 p = buffer;
95 while (*p) {
96 end = strchr(p, '\n');
97 if (end)
98 *end = 0;
99
100 cairo_show_text(cr, p);
101 cairo_text_extents (cr, p, &text_extents);
102 cairo_rel_move_to (cr, -text_extents.x_advance, font_extents.height);
103
104 if (end)
105 p = end + 1;
106 else
107 break;
108 }
109
110 va_end(argp);
111
112 cairo_restore(cr);
113
114}
115
116static void
117redraw_handler(struct widget *widget, void *data)
118{
119 struct fullscreen *fullscreen = data;
120 struct rectangle allocation;
121 cairo_surface_t *surface;
122 cairo_t *cr;
123 int i;
124 double x, y, border;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500125 const char *method_name[] = { "default", "center", "zoom", "zoom_crop", "stretch"};
Alexander Larsson73469ed2013-05-28 16:23:34 +0200126
127 surface = window_get_surface(fullscreen->window);
128 if (surface == NULL ||
129 cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
130 fprintf(stderr, "failed to create cairo egl surface\n");
131 return;
132 }
133
134 widget_get_allocation(fullscreen->widget, &allocation);
135
136 cr = widget_cairo_create(widget);
137
138 cairo_set_source_rgb(cr, 0, 0, 0);
139 cairo_paint (cr);
140
141 cairo_set_source_rgb(cr, 0, 0, 1);
142 cairo_set_line_width (cr, 10);
143 cairo_rectangle(cr, 5, 5, allocation.width - 10, allocation.height - 10);
144 cairo_stroke (cr);
145
146 cairo_move_to(cr,
147 allocation.x + 15,
148 allocation.y + 25);
149 cairo_set_source_rgb(cr, 1, 1, 1);
150
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500151 if (fullscreen->fshell) {
152 draw_string(cr,
153 "Surface size: %d, %d\n"
154 "Scale: %d, transform: %d\n"
155 "Pointer: %f,%f\n"
156 "Output: %s, present method: %s\n"
157 "Keys: (s)cale, (t)ransform, si(z)e, (m)ethod,\n"
158 " (o)utput, modes(w)itch, (q)uit\n",
159 fullscreen->width, fullscreen->height,
160 window_get_buffer_scale (fullscreen->window),
161 window_get_buffer_transform (fullscreen->window),
162 fullscreen->pointer_x, fullscreen->pointer_y,
163 method_name[fullscreen->present_method],
164 fullscreen->current_output ? output_get_model(fullscreen->current_output->output): "null");
165 } else {
166 draw_string(cr,
167 "Surface size: %d, %d\n"
168 "Scale: %d, transform: %d\n"
169 "Pointer: %f,%f\n"
170 "Fullscreen: %d\n"
171 "Keys: (s)cale, (t)ransform, si(z)e, (f)ullscreen, (q)uit\n",
172 fullscreen->width, fullscreen->height,
173 window_get_buffer_scale (fullscreen->window),
174 window_get_buffer_transform (fullscreen->window),
175 fullscreen->pointer_x, fullscreen->pointer_y,
176 fullscreen->fullscreen);
177 }
Alexander Larsson73469ed2013-05-28 16:23:34 +0200178
179 y = 100;
180 i = 0;
181 while (y + 60 < fullscreen->height) {
182 border = (i++ % 2 == 0) ? 1 : 0.5;
183
184 x = 50;
185 cairo_set_line_width (cr, border);
186 while (x + 70 < fullscreen->width) {
Jasper St. Pierreaf314bb2014-05-12 11:23:44 -0400187 if (window_has_focus(fullscreen->window) &&
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500188 fullscreen->pointer_x >= x && fullscreen->pointer_x < x + 50 &&
Alexander Larsson73469ed2013-05-28 16:23:34 +0200189 fullscreen->pointer_y >= y && fullscreen->pointer_y < y + 40) {
190 cairo_set_source_rgb(cr, 1, 0, 0);
191 cairo_rectangle(cr,
192 x, y,
193 50, 40);
194 cairo_fill(cr);
195 }
196 cairo_set_source_rgb(cr, 0, 1, 0);
197 cairo_rectangle(cr,
198 x + border/2.0, y + border/2.0,
199 50, 40);
200 cairo_stroke(cr);
201 x += 60;
202 }
203
204 y += 50;
205 }
206
Jasper St. Pierreaf314bb2014-05-12 11:23:44 -0400207 if (window_has_focus(fullscreen->window) && fullscreen->draw_cursor) {
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500208 cairo_set_source_rgb(cr, 1, 1, 1);
209 cairo_set_line_width (cr, 8);
210 cairo_move_to(cr,
211 fullscreen->pointer_x - 12,
212 fullscreen->pointer_y - 12);
213 cairo_line_to(cr,
214 fullscreen->pointer_x + 12,
215 fullscreen->pointer_y + 12);
216 cairo_stroke(cr);
217
218 cairo_move_to(cr,
219 fullscreen->pointer_x + 12,
220 fullscreen->pointer_y - 12);
221 cairo_line_to(cr,
222 fullscreen->pointer_x - 12,
223 fullscreen->pointer_y + 12);
224 cairo_stroke(cr);
225
226 cairo_set_source_rgb(cr, 0, 0, 0);
227 cairo_set_line_width (cr, 4);
228 cairo_move_to(cr,
229 fullscreen->pointer_x - 10,
230 fullscreen->pointer_y - 10);
231 cairo_line_to(cr,
232 fullscreen->pointer_x + 10,
233 fullscreen->pointer_y + 10);
234 cairo_stroke(cr);
235
236 cairo_move_to(cr,
237 fullscreen->pointer_x + 10,
238 fullscreen->pointer_y - 10);
239 cairo_line_to(cr,
240 fullscreen->pointer_x - 10,
241 fullscreen->pointer_y + 10);
242 cairo_stroke(cr);
243 }
244
Alexander Larsson73469ed2013-05-28 16:23:34 +0200245 cairo_destroy(cr);
246}
247
248static void
249key_handler(struct window *window, struct input *input, uint32_t time,
250 uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
251 void *data)
252{
253 struct fullscreen *fullscreen = data;
254 int transform, scale;
255 static int current_size = 0;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500256 struct fs_output *fsout;
257 struct wl_output *wl_output;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200258 int widths[] = { 640, 320, 800, 400 };
259 int heights[] = { 480, 240, 600, 300 };
260
261 if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
262 return;
263
264 switch (sym) {
265 case XKB_KEY_t:
266 transform = window_get_buffer_transform (window);
267 transform = (transform + 1) % 8;
268 window_set_buffer_transform(window, transform);
269 window_schedule_redraw(window);
270 break;
271
272 case XKB_KEY_s:
273 scale = window_get_buffer_scale (window);
274 if (scale == 1)
275 scale = 2;
276 else
277 scale = 1;
278 window_set_buffer_scale(window, scale);
279 window_schedule_redraw(window);
280 break;
281
282 case XKB_KEY_z:
Marius Vlad7e0f2032019-08-25 22:33:41 +0300283 if (fullscreen->fullscreen)
284 break;
285
Alexander Larsson73469ed2013-05-28 16:23:34 +0200286 current_size = (current_size + 1) % 4;
287 fullscreen->width = widths[current_size];
288 fullscreen->height = heights[current_size];
289 window_schedule_resize(fullscreen->window,
290 fullscreen->width, fullscreen->height);
291 break;
292
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500293 case XKB_KEY_m:
294 if (!fullscreen->fshell)
295 break;
296
297 wl_output = NULL;
298 if (fullscreen->current_output)
299 wl_output = output_get_wl_output(fullscreen->current_output->output);
300 fullscreen->present_method = (fullscreen->present_method + 1) % 5;
Jonas Ådahl496adb32015-11-17 16:00:27 +0800301 zwp_fullscreen_shell_v1_present_surface(fullscreen->fshell,
302 window_get_wl_surface(fullscreen->window),
303 fullscreen->present_method,
304 wl_output);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500305 window_schedule_redraw(window);
306 break;
307
308 case XKB_KEY_o:
309 if (!fullscreen->fshell)
310 break;
311
312 fsout = fullscreen->current_output;
313 wl_output = fsout ? output_get_wl_output(fsout->output) : NULL;
314
315 /* Clear the current presentation */
Jonas Ådahl496adb32015-11-17 16:00:27 +0800316 zwp_fullscreen_shell_v1_present_surface(fullscreen->fshell, NULL,
317 0, wl_output);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500318
319 if (fullscreen->current_output) {
320 if (fullscreen->current_output->link.next == &fullscreen->output_list)
321 fsout = NULL;
322 else
323 fsout = wl_container_of(fullscreen->current_output->link.next,
324 fsout, link);
325 } else {
326 fsout = wl_container_of(fullscreen->output_list.next,
327 fsout, link);
328 }
329
330 fullscreen->current_output = fsout;
331 wl_output = fsout ? output_get_wl_output(fsout->output) : NULL;
Jonas Ådahl496adb32015-11-17 16:00:27 +0800332 zwp_fullscreen_shell_v1_present_surface(fullscreen->fshell,
333 window_get_wl_surface(fullscreen->window),
334 fullscreen->present_method,
335 wl_output);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500336 window_schedule_redraw(window);
337 break;
338
339 case XKB_KEY_w:
340 if (!fullscreen->fshell || !fullscreen->current_output)
341 break;
342
343 wl_output = NULL;
344 if (fullscreen->current_output)
345 wl_output = output_get_wl_output(fullscreen->current_output->output);
Jonas Ådahl496adb32015-11-17 16:00:27 +0800346 zwp_fullscreen_shell_mode_feedback_v1_destroy(
347 zwp_fullscreen_shell_v1_present_surface_for_mode(fullscreen->fshell,
348 window_get_wl_surface(fullscreen->window),
349 wl_output, 0));
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500350 window_schedule_redraw(window);
351 break;
352
Alexander Larsson73469ed2013-05-28 16:23:34 +0200353 case XKB_KEY_f:
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500354 if (fullscreen->fshell)
355 break;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200356 fullscreen->fullscreen ^= 1;
357 window_set_fullscreen(window, fullscreen->fullscreen);
358 break;
359
360 case XKB_KEY_q:
361 exit (0);
362 break;
363 }
364}
365
366static int
367motion_handler(struct widget *widget,
368 struct input *input,
369 uint32_t time,
370 float x,
371 float y, void *data)
372{
373 struct fullscreen *fullscreen = data;
374
375 fullscreen->pointer_x = x;
376 fullscreen->pointer_y = y;
377
378 widget_schedule_redraw(widget);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500379
380 return fullscreen->draw_cursor ? CURSOR_BLANK : CURSOR_LEFT_PTR;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200381}
382
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500383static int
384enter_handler(struct widget *widget,
385 struct input *input,
386 float x, float y, void *data)
387{
388 struct fullscreen *fullscreen = data;
389
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500390 fullscreen->pointer_x = x;
391 fullscreen->pointer_y = y;
392
393 widget_schedule_redraw(widget);
394
395 return fullscreen->draw_cursor ? CURSOR_BLANK : CURSOR_LEFT_PTR;
396}
397
398static void
Alexander Larsson73469ed2013-05-28 16:23:34 +0200399button_handler(struct widget *widget,
400 struct input *input, uint32_t time,
401 uint32_t button, enum wl_pointer_button_state state, void *data)
402{
403 struct fullscreen *fullscreen = data;
404
405 switch (button) {
406 case BTN_LEFT:
407 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
408 window_move(fullscreen->window, input,
409 display_get_serial(fullscreen->display));
410 break;
411 case BTN_RIGHT:
412 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
413 window_show_frame_menu(fullscreen->window, input, time);
414 break;
415 }
416}
417
418static void
Michael Vetter2a18a522015-05-15 17:17:47 +0200419touch_handler(struct widget *widget, struct input *input,
420 uint32_t serial, uint32_t time, int32_t id,
Rusty Lynch1084da52013-08-15 09:10:08 -0700421 float x, float y, void *data)
422{
423 struct fullscreen *fullscreen = data;
Jasper St. Pierre01eaaac2013-11-12 20:19:57 -0500424 window_move(fullscreen->window, input, display_get_serial(fullscreen->display));
Rusty Lynch1084da52013-08-15 09:10:08 -0700425}
426
427static void
Jonas Ådahl496adb32015-11-17 16:00:27 +0800428fshell_capability_handler(void *data, struct zwp_fullscreen_shell_v1 *fshell,
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500429 uint32_t capability)
430{
431 struct fullscreen *fullscreen = data;
432
433 switch (capability) {
Jonas Ådahl496adb32015-11-17 16:00:27 +0800434 case ZWP_FULLSCREEN_SHELL_V1_CAPABILITY_CURSOR_PLANE:
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500435 fullscreen->draw_cursor = 0;
436 break;
437 default:
438 break;
439 }
440}
441
Jonas Ådahl496adb32015-11-17 16:00:27 +0800442struct zwp_fullscreen_shell_v1_listener fullscreen_shell_listener = {
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500443 fshell_capability_handler
444};
445
446static void
Alexander Larsson73469ed2013-05-28 16:23:34 +0200447usage(int error_code)
448{
449 fprintf(stderr, "Usage: fullscreen [OPTIONS]\n\n"
450 " -w <width>\tSet window width to <width>\n"
451 " -h <height>\tSet window height to <height>\n"
452 " --help\tShow this help text\n\n");
453
454 exit(error_code);
455}
456
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500457static void
458output_handler(struct output *output, void *data)
459{
460 struct fullscreen *fullscreen = data;
461 struct fs_output *fsout;
462
463 /* If we've already seen this one, don't add it to the list */
464 wl_list_for_each(fsout, &fullscreen->output_list, link)
465 if (fsout->output == output)
466 return;
467
Bryce Harrington0d1a6222016-02-11 16:42:49 -0800468 fsout = zalloc(sizeof *fsout);
469 if (fsout == NULL) {
470 fprintf(stderr, "out of memory in output_handler\n");
471 return;
472 }
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500473 fsout->output = output;
474 wl_list_insert(&fullscreen->output_list, &fsout->link);
475}
476
477static void
478global_handler(struct display *display, uint32_t id, const char *interface,
479 uint32_t version, void *data)
480{
481 struct fullscreen *fullscreen = data;
482
Jonas Ådahl496adb32015-11-17 16:00:27 +0800483 if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) {
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500484 fullscreen->fshell = display_bind(display, id,
Jonas Ådahl496adb32015-11-17 16:00:27 +0800485 &zwp_fullscreen_shell_v1_interface,
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500486 1);
Jonas Ådahl496adb32015-11-17 16:00:27 +0800487 zwp_fullscreen_shell_v1_add_listener(fullscreen->fshell,
488 &fullscreen_shell_listener,
489 fullscreen);
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500490 }
491}
492
Alexander Larsson73469ed2013-05-28 16:23:34 +0200493int main(int argc, char *argv[])
494{
495 struct fullscreen fullscreen;
496 struct display *d;
497 int i;
498
499 fullscreen.width = 640;
500 fullscreen.height = 480;
501 fullscreen.fullscreen = 0;
Jonas Ådahl496adb32015-11-17 16:00:27 +0800502 fullscreen.present_method = ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500503 wl_list_init(&fullscreen.output_list);
504 fullscreen.current_output = NULL;
Alexander Larsson73469ed2013-05-28 16:23:34 +0200505
506 for (i = 1; i < argc; i++) {
507 if (strcmp(argv[i], "-w") == 0) {
508 if (++i >= argc)
509 usage(EXIT_FAILURE);
510
511 fullscreen.width = atol(argv[i]);
512 } else if (strcmp(argv[i], "-h") == 0) {
513 if (++i >= argc)
514 usage(EXIT_FAILURE);
515
516 fullscreen.height = atol(argv[i]);
517 } else if (strcmp(argv[i], "--help") == 0)
518 usage(EXIT_SUCCESS);
519 else
520 usage(EXIT_FAILURE);
521 }
522
523 d = display_create(&argc, argv);
524 if (d == NULL) {
Antonio Borneo39578632019-04-26 23:57:31 +0200525 fprintf(stderr, "failed to create display: %s\n",
526 strerror(errno));
Alexander Larsson73469ed2013-05-28 16:23:34 +0200527 return -1;
528 }
529
530 fullscreen.display = d;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500531 fullscreen.fshell = NULL;
532 display_set_user_data(fullscreen.display, &fullscreen);
533 display_set_global_handler(fullscreen.display, global_handler);
534 display_set_output_configure_handler(fullscreen.display, output_handler);
535
536 if (fullscreen.fshell) {
537 fullscreen.window = window_create_custom(d);
Jonas Ådahl496adb32015-11-17 16:00:27 +0800538 zwp_fullscreen_shell_v1_present_surface(fullscreen.fshell,
539 window_get_wl_surface(fullscreen.window),
540 fullscreen.present_method,
541 NULL);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500542 /* If we get the CURSOR_PLANE capability, we'll change this */
543 fullscreen.draw_cursor = 1;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500544 } else {
545 fullscreen.window = window_create(d);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500546 fullscreen.draw_cursor = 0;
Jason Ekstrand2bb72fe2014-04-02 19:53:52 -0500547 }
548
Alexander Larsson73469ed2013-05-28 16:23:34 +0200549 fullscreen.widget =
550 window_add_widget(fullscreen.window, &fullscreen);
551
552 window_set_title(fullscreen.window, "Fullscreen");
Marius Vladb3544c22021-09-09 13:52:18 +0300553 window_set_appid(fullscreen.window, "org.freedesktop.weston.fullscreen");
Alexander Larsson73469ed2013-05-28 16:23:34 +0200554
555 widget_set_transparent(fullscreen.widget, 0);
Alexander Larsson73469ed2013-05-28 16:23:34 +0200556
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500557 widget_set_default_cursor(fullscreen.widget, CURSOR_LEFT_PTR);
Alexander Larsson73469ed2013-05-28 16:23:34 +0200558 widget_set_redraw_handler(fullscreen.widget, redraw_handler);
559 widget_set_button_handler(fullscreen.widget, button_handler);
560 widget_set_motion_handler(fullscreen.widget, motion_handler);
Jason Ekstrand7a17d422014-04-02 19:53:53 -0500561 widget_set_enter_handler(fullscreen.widget, enter_handler);
Alexander Larsson73469ed2013-05-28 16:23:34 +0200562
Rusty Lynch1084da52013-08-15 09:10:08 -0700563 widget_set_touch_down_handler(fullscreen.widget, touch_handler);
564
Alexander Larsson73469ed2013-05-28 16:23:34 +0200565 window_set_key_handler(fullscreen.window, key_handler);
566 window_set_fullscreen_handler(fullscreen.window, fullscreen_handler);
567
568 window_set_user_data(fullscreen.window, &fullscreen);
569 /* Hack to set minimum allocation so we can shrink later */
570 window_schedule_resize(fullscreen.window,
571 1, 1);
572 window_schedule_resize(fullscreen.window,
573 fullscreen.width, fullscreen.height);
574
575 display_run(d);
576
vivek31732f72014-05-15 18:58:16 +0530577 widget_destroy(fullscreen.widget);
578 window_destroy(fullscreen.window);
579 display_destroy(d);
580
Alexander Larsson73469ed2013-05-28 16:23:34 +0200581 return 0;
582}