blob: b767839f5680b72f941d3c55a65d5d41f8c9e138 [file] [log] [blame]
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -04001/*
2 * Copyright © 2011 Kristian Høgsberg
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +02003 * Copyright © 2011 Collabora, Ltd.
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -04004 *
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting documentation, and
9 * that the name of the copyright holders not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no representations
12 * about the suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
14 *
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21 * OF THIS SOFTWARE.
22 */
23
24#include <stdint.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <fcntl.h>
29#include <unistd.h>
30#include <math.h>
31#include <cairo.h>
32#include <sys/wait.h>
33#include <linux/input.h>
Tiago Vignatti61500722012-05-23 22:06:28 +030034#include <libgen.h>
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040035
Pekka Paalanen50719bc2011-11-22 14:18:50 +020036#include <wayland-client.h>
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040037#include "window.h"
Kristian Høgsberg5a315bc2012-05-15 22:33:43 -040038#include "../shared/cairo-util.h"
Kristian Høgsberg9b935c82011-12-08 12:44:27 -050039#include "../shared/config-parser.h"
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040040
Pekka Paalanen50719bc2011-11-22 14:18:50 +020041#include "desktop-shell-client-protocol.h"
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040042
43struct desktop {
44 struct display *display;
45 struct desktop_shell *shell;
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +020046 struct unlock_dialog *unlock_dialog;
47 struct task unlock_task;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010048 struct wl_list outputs;
Kristian Høgsbergd56bd902012-06-05 09:58:51 -040049
50 struct window *busy_window;
51 struct widget *busy_widget;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010052};
53
54struct surface {
55 void (*configure)(void *data,
56 struct desktop_shell *desktop_shell,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -040057 uint32_t edges, struct window *window,
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010058 int32_t width, int32_t height);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040059};
60
61struct panel {
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010062 struct surface base;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040063 struct window *window;
Kristian Høgsberg75bc6672012-01-10 09:43:58 -050064 struct widget *widget;
Kristian Høgsberg75bc6672012-01-10 09:43:58 -050065 struct wl_list launcher_list;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040066};
67
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010068struct background {
69 struct surface base;
70 struct window *window;
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -050071 struct widget *widget;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010072};
73
74struct output {
75 struct wl_output *output;
76 struct wl_list link;
77
78 struct panel *panel;
79 struct background *background;
80};
81
Kristian Høgsberg53880802012-01-09 11:16:50 -050082struct panel_launcher {
Kristian Høgsbergc51f7992012-01-08 15:09:53 -050083 struct widget *widget;
Kristian Høgsberge28d05b2011-09-20 21:43:54 -040084 struct panel *panel;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040085 cairo_surface_t *icon;
Kristian Høgsbergb6323512012-01-11 00:04:42 -050086 int focused, pressed;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040087 const char *path;
Kristian Høgsberg75bc6672012-01-10 09:43:58 -050088 struct wl_list link;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -040089};
90
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +020091struct unlock_dialog {
92 struct window *window;
Kristian Høgsberg75bc6672012-01-10 09:43:58 -050093 struct widget *widget;
Kristian Høgsbergc51f7992012-01-08 15:09:53 -050094 struct widget *button;
Kristian Høgsbergb6323512012-01-11 00:04:42 -050095 int button_focused;
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +020096 int closing;
97
98 struct desktop *desktop;
99};
100
Kristian Høgsberg6af8eb92012-01-25 16:57:11 -0500101static char *key_background_image = DATADIR "/weston/pattern.png";
102static char *key_background_type = "tile";
103static uint32_t key_panel_color = 0xaa000000;
104static uint32_t key_background_color = 0xff002244;
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500105static char *key_launcher_icon;
106static char *key_launcher_path;
107static void launcher_section_done(void *data);
Pekka Paalanenfd83b6d2011-12-08 10:06:53 +0200108static int key_locking = 1;
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500109
110static const struct config_key shell_config_keys[] = {
111 { "background-image", CONFIG_KEY_STRING, &key_background_image },
Kristian Høgsberg07f72942012-01-25 16:34:36 -0500112 { "background-type", CONFIG_KEY_STRING, &key_background_type },
Scott Moreaufa1de692012-01-27 13:25:49 -0700113 { "panel-color", CONFIG_KEY_UNSIGNED_INTEGER, &key_panel_color },
114 { "background-color", CONFIG_KEY_UNSIGNED_INTEGER, &key_background_color },
Pekka Paalanenfd83b6d2011-12-08 10:06:53 +0200115 { "locking", CONFIG_KEY_BOOLEAN, &key_locking },
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500116};
117
118static const struct config_key launcher_config_keys[] = {
119 { "icon", CONFIG_KEY_STRING, &key_launcher_icon },
120 { "path", CONFIG_KEY_STRING, &key_launcher_path },
121};
122
123static const struct config_section config_sections[] = {
Tiago Vignatti9a206c42012-03-21 19:49:18 +0200124 { "shell",
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500125 shell_config_keys, ARRAY_LENGTH(shell_config_keys) },
126 { "launcher",
127 launcher_config_keys, ARRAY_LENGTH(launcher_config_keys),
128 launcher_section_done }
129};
130
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400131static void
132sigchild_handler(int s)
133{
134 int status;
135 pid_t pid;
136
137 while (pid = waitpid(-1, &status, WNOHANG), pid > 0)
138 fprintf(stderr, "child %d exited\n", pid);
139}
140
141static void
Pekka Paalanen9e30a822012-01-19 16:40:28 +0200142menu_func(struct window *window, int index, void *data)
143{
144 printf("Selected index %d from a panel menu.\n", index);
145}
146
147static void
Kristian Høgsbergb3cca0a2012-01-04 22:19:14 -0500148show_menu(struct panel *panel, struct input *input, uint32_t time)
Kristian Høgsbergbcee9a42011-10-12 00:36:16 -0400149{
Kristian Høgsbergb3cca0a2012-01-04 22:19:14 -0500150 int32_t x, y;
151 static const char *entries[] = {
152 "Roy", "Pris", "Leon", "Zhora"
153 };
Kristian Høgsbergbcee9a42011-10-12 00:36:16 -0400154
155 input_get_position(input, &x, &y);
Pekka Paalanen6d174cf2012-01-19 15:17:59 +0200156 window_show_menu(window_get_display(panel->window),
157 input, time, panel->window,
Pekka Paalanen9e30a822012-01-19 16:40:28 +0200158 x - 10, y - 10, menu_func, entries, 4);
Kristian Høgsbergbcee9a42011-10-12 00:36:16 -0400159}
160
161static void
Kristian Høgsberg53880802012-01-09 11:16:50 -0500162panel_launcher_activate(struct panel_launcher *widget)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400163{
164 pid_t pid;
165
166 pid = fork();
167 if (pid < 0) {
168 fprintf(stderr, "fork failed: %m\n");
169 return;
170 }
171
172 if (pid)
173 return;
Benjamin Franzked7759712011-11-22 12:38:48 +0100174
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500175 if (execl(widget->path, widget->path, NULL) < 0) {
Pekka Paalanena291ae52012-01-27 09:50:02 +0200176 fprintf(stderr, "execl '%s' failed: %m\n", widget->path);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400177 exit(1);
178 }
179}
180
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400181static void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500182panel_launcher_redraw_handler(struct widget *widget, void *data)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400183{
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500184 struct panel_launcher *launcher = data;
185 cairo_surface_t *surface;
186 struct rectangle allocation;
187 cairo_t *cr;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400188
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500189 surface = window_get_surface(launcher->panel->window);
190 cr = cairo_create(surface);
191
192 widget_get_allocation(widget, &allocation);
Kristian Høgsberg75bc6672012-01-10 09:43:58 -0500193 if (launcher->pressed) {
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500194 allocation.x++;
195 allocation.y++;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400196 }
197
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500198 cairo_set_source_surface(cr, launcher->icon,
199 allocation.x, allocation.y);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400200 cairo_paint(cr);
201
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500202 if (launcher->focused) {
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400203 cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.4);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500204 cairo_mask_surface(cr, launcher->icon,
205 allocation.x, allocation.y);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400206 }
Kristian Høgsberge28d05b2011-09-20 21:43:54 -0400207
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500208 cairo_destroy(cr);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400209}
210
Tiago Vignatti61500722012-05-23 22:06:28 +0300211static int
212panel_launcher_motion_handler(struct widget *widget, struct input *input,
213 uint32_t time, float x, float y, void *data)
214{
215 struct panel_launcher *launcher = data;
216
217 widget_set_tooltip(widget, basename((char *)launcher->path), x, y);
218
Ander Conselvan de Oliveiradc8c8fc2012-05-25 16:01:41 +0300219 return CURSOR_LEFT_PTR;
Tiago Vignatti61500722012-05-23 22:06:28 +0300220}
221
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400222static void
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500223set_hex_color(cairo_t *cr, uint32_t color)
224{
225 cairo_set_source_rgba(cr,
226 ((color >> 16) & 0xff) / 255.0,
227 ((color >> 8) & 0xff) / 255.0,
228 ((color >> 0) & 0xff) / 255.0,
229 ((color >> 24) & 0xff) / 255.0);
230}
231
232static void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500233panel_redraw_handler(struct widget *widget, void *data)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400234{
235 cairo_surface_t *surface;
236 cairo_t *cr;
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500237 struct panel *panel = data;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400238
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500239 surface = window_get_surface(panel->window);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400240 cr = cairo_create(surface);
241 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500242 set_hex_color(cr, key_panel_color);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400243 cairo_paint(cr);
244
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400245 cairo_destroy(cr);
246 cairo_surface_destroy(surface);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400247}
248
Kristian Høgsbergbb901fa2012-01-09 11:22:32 -0500249static int
Kristian Høgsberg53880802012-01-09 11:16:50 -0500250panel_launcher_enter_handler(struct widget *widget, struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400251 float x, float y, void *data)
Kristian Høgsbergee143232012-01-09 08:42:24 -0500252{
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500253 struct panel_launcher *launcher = data;
254
255 launcher->focused = 1;
Kristian Høgsbergee143232012-01-09 08:42:24 -0500256 widget_schedule_redraw(widget);
Kristian Høgsbergbb901fa2012-01-09 11:22:32 -0500257
Ander Conselvan de Oliveiradc8c8fc2012-05-25 16:01:41 +0300258 return CURSOR_LEFT_PTR;
Kristian Høgsbergee143232012-01-09 08:42:24 -0500259}
260
261static void
Kristian Høgsberg53880802012-01-09 11:16:50 -0500262panel_launcher_leave_handler(struct widget *widget,
263 struct input *input, void *data)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400264{
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500265 struct panel_launcher *launcher = data;
266
267 launcher->focused = 0;
Tiago Vignatti61500722012-05-23 22:06:28 +0300268 widget_destroy_tooltip(widget);
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500269 widget_schedule_redraw(widget);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400270}
271
272static void
Kristian Høgsberg53880802012-01-09 11:16:50 -0500273panel_launcher_button_handler(struct widget *widget,
274 struct input *input, uint32_t time,
Daniel Stone4dbadb12012-05-30 16:31:51 +0100275 uint32_t button,
276 enum wl_pointer_button_state state, void *data)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400277{
Kristian Høgsberg53880802012-01-09 11:16:50 -0500278 struct panel_launcher *launcher;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400279
Kristian Høgsberg53880802012-01-09 11:16:50 -0500280 launcher = widget_get_user_data(widget);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500281 widget_schedule_redraw(widget);
Daniel Stone4dbadb12012-05-30 16:31:51 +0100282 if (state == WL_POINTER_BUTTON_STATE_RELEASED)
Kristian Høgsberg53880802012-01-09 11:16:50 -0500283 panel_launcher_activate(launcher);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500284}
285
286static void
287panel_button_handler(struct widget *widget,
288 struct input *input, uint32_t time,
Daniel Stone4dbadb12012-05-30 16:31:51 +0100289 uint32_t button,
290 enum wl_pointer_button_state state, void *data)
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500291{
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500292 struct panel *panel = data;
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500293
Daniel Stone4dbadb12012-05-30 16:31:51 +0100294 if (button == BTN_RIGHT && state == WL_POINTER_BUTTON_STATE_PRESSED)
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500295 show_menu(panel, input, time);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400296}
297
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100298static void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500299panel_resize_handler(struct widget *widget,
300 int32_t width, int32_t height, void *data)
301{
302 struct panel_launcher *launcher;
303 struct panel *panel = data;
304 int x, y, w, h;
305
306 x = 10;
307 y = 16;
308 wl_list_for_each(launcher, &panel->launcher_list, link) {
309 w = cairo_image_surface_get_width(launcher->icon);
310 h = cairo_image_surface_get_height(launcher->icon);
311 widget_set_allocation(launcher->widget,
312 x, y - h / 2, w + 1, h + 1);
313 x += w + 10;
314 }
315}
316
317static void
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100318panel_configure(void *data,
319 struct desktop_shell *desktop_shell,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400320 uint32_t edges, struct window *window,
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100321 int32_t width, int32_t height)
322{
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500323 struct surface *surface = window_get_user_data(window);
324 struct panel *panel = container_of(surface, struct panel, base);
325
326 window_schedule_resize(panel->window, width, 32);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100327}
328
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400329static struct panel *
330panel_create(struct display *display)
331{
332 struct panel *panel;
333
334 panel = malloc(sizeof *panel);
335 memset(panel, 0, sizeof *panel);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400336
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100337 panel->base.configure = panel_configure;
Kristian Høgsberg009ac0a2012-01-31 15:24:48 -0500338 panel->window = window_create(display);
Kristian Høgsberg75bc6672012-01-10 09:43:58 -0500339 panel->widget = window_add_widget(panel->window, panel);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500340 wl_list_init(&panel->launcher_list);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400341
342 window_set_title(panel->window, "panel");
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400343 window_set_custom(panel->window);
344 window_set_user_data(panel->window, panel);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500345
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500346 widget_set_redraw_handler(panel->widget, panel_redraw_handler);
347 widget_set_resize_handler(panel->widget, panel_resize_handler);
Kristian Høgsberg75bc6672012-01-10 09:43:58 -0500348 widget_set_button_handler(panel->widget, panel_button_handler);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400349
350 return panel;
351}
352
353static void
Kristian Høgsberg53880802012-01-09 11:16:50 -0500354panel_add_launcher(struct panel *panel, const char *icon, const char *path)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400355{
Kristian Høgsberg53880802012-01-09 11:16:50 -0500356 struct panel_launcher *launcher;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400357
Kristian Høgsberg53880802012-01-09 11:16:50 -0500358 launcher = malloc(sizeof *launcher);
359 memset(launcher, 0, sizeof *launcher);
360 launcher->icon = cairo_image_surface_create_from_png(icon);
361 launcher->path = strdup(path);
362 launcher->panel = panel;
Kristian Høgsberg75bc6672012-01-10 09:43:58 -0500363 wl_list_insert(panel->launcher_list.prev, &launcher->link);
364
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500365 launcher->widget = widget_add_widget(panel->widget, launcher);
Kristian Høgsberg53880802012-01-09 11:16:50 -0500366 widget_set_enter_handler(launcher->widget,
367 panel_launcher_enter_handler);
368 widget_set_leave_handler(launcher->widget,
369 panel_launcher_leave_handler);
370 widget_set_button_handler(launcher->widget,
371 panel_launcher_button_handler);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500372 widget_set_redraw_handler(launcher->widget,
373 panel_launcher_redraw_handler);
Tiago Vignatti61500722012-05-23 22:06:28 +0300374 widget_set_motion_handler(launcher->widget,
375 panel_launcher_motion_handler);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400376}
377
Kristian Høgsberg07f72942012-01-25 16:34:36 -0500378enum {
379 BACKGROUND_SCALE,
380 BACKGROUND_TILE
381};
382
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400383static void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500384background_draw(struct widget *widget, void *data)
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400385{
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500386 struct background *background = data;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400387 cairo_surface_t *surface, *image;
Kristian Høgsberg7e690002011-09-08 18:18:02 -0400388 cairo_pattern_t *pattern;
389 cairo_matrix_t matrix;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400390 cairo_t *cr;
Kristian Høgsberg7e690002011-09-08 18:18:02 -0400391 double sx, sy;
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500392 struct rectangle allocation;
Kristian Høgsberg07f72942012-01-25 16:34:36 -0500393 int type = -1;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400394
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500395 surface = window_get_surface(background->window);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400396
397 cr = cairo_create(surface);
398 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
399 cairo_set_source_rgba(cr, 0.0, 0.0, 0.2, 1.0);
400 cairo_paint(cr);
401
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500402 widget_get_allocation(widget, &allocation);
Kristian Høgsberg8129bc02012-01-25 14:55:33 -0500403 image = NULL;
404 if (key_background_image)
Kristian Høgsbergf02a6492012-03-12 01:05:25 -0400405 image = load_cairo_surface(key_background_image);
Kristian Høgsberg07f72942012-01-25 16:34:36 -0500406
407 if (strcmp(key_background_type, "scale") == 0)
408 type = BACKGROUND_SCALE;
409 else if (strcmp(key_background_type, "tile") == 0)
410 type = BACKGROUND_TILE;
411 else
412 fprintf(stderr, "invalid background-type: %s\n",
413 key_background_type);
414
415 if (image && type != -1) {
Kristian Høgsberg7e690002011-09-08 18:18:02 -0400416 pattern = cairo_pattern_create_for_surface(image);
Kristian Høgsberg07f72942012-01-25 16:34:36 -0500417 switch (type) {
418 case BACKGROUND_SCALE:
419 sx = (double) cairo_image_surface_get_width(image) /
420 allocation.width;
421 sy = (double) cairo_image_surface_get_height(image) /
422 allocation.height;
423 cairo_matrix_init_scale(&matrix, sx, sy);
424 cairo_pattern_set_matrix(pattern, &matrix);
425 break;
426 case BACKGROUND_TILE:
427 cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
428 break;
429 }
Kristian Høgsberg7e690002011-09-08 18:18:02 -0400430 cairo_set_source(cr, pattern);
431 cairo_pattern_destroy (pattern);
Kristian Høgsberg27d38662011-10-20 13:11:12 -0400432 cairo_surface_destroy(image);
Kristian Høgsberg8129bc02012-01-25 14:55:33 -0500433 } else {
434 set_hex_color(cr, key_background_color);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400435 }
436
Kristian Høgsberg8129bc02012-01-25 14:55:33 -0500437 cairo_paint(cr);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400438 cairo_destroy(cr);
439 cairo_surface_destroy(surface);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400440}
441
442static void
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100443background_configure(void *data,
444 struct desktop_shell *desktop_shell,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400445 uint32_t edges, struct window *window,
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100446 int32_t width, int32_t height)
447{
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500448 struct background *background =
449 (struct background *) window_get_user_data(window);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100450
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500451 widget_schedule_resize(background->widget, width, height);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100452}
453
454static void
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500455unlock_dialog_redraw_handler(struct widget *widget, void *data)
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200456{
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500457 struct unlock_dialog *dialog = data;
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200458 struct rectangle allocation;
459 cairo_t *cr;
460 cairo_surface_t *surface;
461 cairo_pattern_t *pat;
462 double cx, cy, r, f;
463
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200464 surface = window_get_surface(dialog->window);
465 cr = cairo_create(surface);
Kristian Høgsberg41c5c4e2012-03-05 20:37:51 -0500466
Kristian Høgsbergbb977002012-01-10 19:11:42 -0500467 widget_get_allocation(dialog->widget, &allocation);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200468 cairo_rectangle(cr, allocation.x, allocation.y,
469 allocation.width, allocation.height);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200470 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
471 cairo_set_source_rgba(cr, 0, 0, 0, 0.6);
Kristian Høgsberg41c5c4e2012-03-05 20:37:51 -0500472 cairo_fill(cr);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200473
Kristian Høgsberg41c5c4e2012-03-05 20:37:51 -0500474 cairo_translate(cr, allocation.x, allocation.y);
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500475 if (dialog->button_focused)
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200476 f = 1.0;
477 else
478 f = 0.7;
479
480 cx = allocation.width / 2.0;
481 cy = allocation.height / 2.0;
482 r = (cx < cy ? cx : cy) * 0.4;
483 pat = cairo_pattern_create_radial(cx, cy, r * 0.7, cx, cy, r);
484 cairo_pattern_add_color_stop_rgb(pat, 0.0, 0, 0.86 * f, 0);
485 cairo_pattern_add_color_stop_rgb(pat, 0.85, 0.2 * f, f, 0.2 * f);
486 cairo_pattern_add_color_stop_rgb(pat, 1.0, 0, 0.86 * f, 0);
487 cairo_set_source(cr, pat);
Kristian Høgsberg41c5c4e2012-03-05 20:37:51 -0500488 cairo_pattern_destroy(pat);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200489 cairo_arc(cr, cx, cy, r, 0.0, 2.0 * M_PI);
490 cairo_fill(cr);
491
Kristian Høgsbergc51f7992012-01-08 15:09:53 -0500492 widget_set_allocation(dialog->button,
Kristian Høgsberg41c5c4e2012-03-05 20:37:51 -0500493 allocation.x + cx - r,
494 allocation.y + cy - r, 2 * r, 2 * r);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200495
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200496 cairo_destroy(cr);
497
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200498 cairo_surface_destroy(surface);
499}
500
501static void
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500502unlock_dialog_button_handler(struct widget *widget,
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200503 struct input *input, uint32_t time,
Daniel Stone4dbadb12012-05-30 16:31:51 +0100504 uint32_t button,
505 enum wl_pointer_button_state state, void *data)
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200506{
507 struct unlock_dialog *dialog = data;
508 struct desktop *desktop = dialog->desktop;
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200509
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500510 if (button == BTN_LEFT) {
Daniel Stone4dbadb12012-05-30 16:31:51 +0100511 if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
512 !dialog->closing) {
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200513 display_defer(desktop->display, &desktop->unlock_task);
514 dialog->closing = 1;
515 }
516 }
517}
518
519static void
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200520unlock_dialog_keyboard_focus_handler(struct window *window,
521 struct input *device, void *data)
522{
523 window_schedule_redraw(window);
524}
525
Kristian Høgsbergbb901fa2012-01-09 11:22:32 -0500526static int
Kristian Høgsbergee143232012-01-09 08:42:24 -0500527unlock_dialog_widget_enter_handler(struct widget *widget,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400528 struct input *input,
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400529 float x, float y, void *data)
Kristian Høgsbergee143232012-01-09 08:42:24 -0500530{
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500531 struct unlock_dialog *dialog = data;
532
533 dialog->button_focused = 1;
Kristian Høgsbergee143232012-01-09 08:42:24 -0500534 widget_schedule_redraw(widget);
Kristian Høgsbergbb901fa2012-01-09 11:22:32 -0500535
Ander Conselvan de Oliveiradc8c8fc2012-05-25 16:01:41 +0300536 return CURSOR_LEFT_PTR;
Kristian Høgsbergee143232012-01-09 08:42:24 -0500537}
538
539static void
540unlock_dialog_widget_leave_handler(struct widget *widget,
541 struct input *input, void *data)
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200542{
Kristian Høgsbergb6323512012-01-11 00:04:42 -0500543 struct unlock_dialog *dialog = data;
544
545 dialog->button_focused = 0;
Kristian Høgsberg9a13dab2012-01-08 15:18:19 -0500546 widget_schedule_redraw(widget);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200547}
548
549static struct unlock_dialog *
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500550unlock_dialog_create(struct desktop *desktop)
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200551{
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500552 struct display *display = desktop->display;
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200553 struct unlock_dialog *dialog;
554
555 dialog = malloc(sizeof *dialog);
556 if (!dialog)
557 return NULL;
558 memset(dialog, 0, sizeof *dialog);
559
Kristian Høgsberg009ac0a2012-01-31 15:24:48 -0500560 dialog->window = window_create(display);
Kristian Høgsberg29af3eb2012-01-10 22:41:05 -0500561 dialog->widget = frame_create(dialog->window, dialog);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200562 window_set_title(dialog->window, "Unlock your desktop");
Benjamin Franzke8193bc12011-11-23 19:35:07 +0100563 window_set_custom(dialog->window);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200564
565 window_set_user_data(dialog->window, dialog);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200566 window_set_keyboard_focus_handler(dialog->window,
567 unlock_dialog_keyboard_focus_handler);
Kristian Høgsberg441338c2012-01-10 13:52:34 -0500568 dialog->button = widget_add_widget(dialog->widget, dialog);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500569 widget_set_redraw_handler(dialog->widget,
570 unlock_dialog_redraw_handler);
Kristian Høgsbergee143232012-01-09 08:42:24 -0500571 widget_set_enter_handler(dialog->button,
572 unlock_dialog_widget_enter_handler);
573 widget_set_leave_handler(dialog->button,
574 unlock_dialog_widget_leave_handler);
Kristian Høgsberga8a0db32012-01-09 11:12:05 -0500575 widget_set_button_handler(dialog->button,
576 unlock_dialog_button_handler);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200577
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500578 desktop_shell_set_lock_surface(desktop->shell,
Pekka Paalanen068ae942011-11-28 14:11:15 +0200579 window_get_wl_shell_surface(dialog->window));
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500580
Pekka Paalanen40e49ac2012-01-18 16:51:30 +0200581 window_schedule_resize(dialog->window, 260, 230);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200582
583 return dialog;
584}
585
586static void
587unlock_dialog_destroy(struct unlock_dialog *dialog)
588{
589 window_destroy(dialog->window);
590 free(dialog);
591}
592
593static void
594unlock_dialog_finish(struct task *task, uint32_t events)
595{
596 struct desktop *desktop =
Benjamin Franzked7759712011-11-22 12:38:48 +0100597 container_of(task, struct desktop, unlock_task);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200598
599 desktop_shell_unlock(desktop->shell);
600 unlock_dialog_destroy(desktop->unlock_dialog);
601 desktop->unlock_dialog = NULL;
602}
603
604static void
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400605desktop_shell_configure(void *data,
606 struct desktop_shell *desktop_shell,
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400607 uint32_t edges,
Pekka Paalanen068ae942011-11-28 14:11:15 +0200608 struct wl_shell_surface *shell_surface,
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400609 int32_t width, int32_t height)
610{
Pekka Paalanen068ae942011-11-28 14:11:15 +0200611 struct window *window = wl_shell_surface_get_user_data(shell_surface);
612 struct surface *s = window_get_user_data(window);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400613
Kristian Høgsbergeae5de72012-04-11 22:42:15 -0400614 s->configure(data, desktop_shell, edges, window, width, height);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400615}
616
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200617static void
618desktop_shell_prepare_lock_surface(void *data,
619 struct desktop_shell *desktop_shell)
620{
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200621 struct desktop *desktop = data;
622
Pekka Paalanenfd83b6d2011-12-08 10:06:53 +0200623 if (!key_locking) {
624 desktop_shell_unlock(desktop->shell);
625 return;
626 }
627
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200628 if (!desktop->unlock_dialog) {
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500629 desktop->unlock_dialog = unlock_dialog_create(desktop);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200630 desktop->unlock_dialog->desktop = desktop;
631 }
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200632}
633
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400634static const struct desktop_shell_listener listener = {
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200635 desktop_shell_configure,
636 desktop_shell_prepare_lock_surface
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400637};
638
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100639static struct background *
640background_create(struct desktop *desktop)
641{
642 struct background *background;
643
644 background = malloc(sizeof *background);
645 memset(background, 0, sizeof *background);
646
647 background->base.configure = background_configure;
Kristian Høgsberg009ac0a2012-01-31 15:24:48 -0500648 background->window = window_create(desktop->display);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500649 background->widget = window_add_widget(background->window, background);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100650 window_set_custom(background->window);
651 window_set_user_data(background->window, background);
Kristian Høgsbergb67e94b2012-01-10 12:23:19 -0500652 widget_set_redraw_handler(background->widget, background_draw);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100653
654 return background;
655}
656
Kristian Høgsbergd56bd902012-06-05 09:58:51 -0400657static const struct wl_callback_listener busy_cursor_listener;
658
659static void
660busy_cursor_frame_callback(void *data,
661 struct wl_callback *callback, uint32_t time)
662{
663 struct input *input = data;
664 struct display *display = input_get_display(input);
665 struct desktop *desktop = display_get_user_data(display);
666 struct wl_surface *surface;
667 int index;
668
669 if (callback)
670 wl_callback_destroy(callback);
671 if (input_get_focus_widget(input) != desktop->busy_widget)
672 return;
673
674 /* FIXME: Get frame duration and number of frames from cursor. */
675 index = (time / 100) % 8;
676 input_set_pointer_image_index(input, CURSOR_WATCH, index);
677
678 surface = window_get_wl_surface(desktop->busy_window);
679 callback = wl_surface_frame(surface);
680 wl_callback_add_listener(callback, &busy_cursor_listener, input);
681}
682
683static const struct wl_callback_listener busy_cursor_listener = {
684 busy_cursor_frame_callback
685};
686
687static int
688busy_surface_enter_handler(struct widget *widget, struct input *input,
689 float x, float y, void *data)
690{
691 busy_cursor_frame_callback(input, NULL, 0);
692
693 return CURSOR_WATCH;
694}
695
696static void
697busy_surface_create(struct desktop *desktop)
698{
699 struct wl_surface *s;
700
701 desktop->busy_window = window_create(desktop->display);
702 s = window_get_wl_surface(desktop->busy_window);
703 desktop_shell_set_busy_surface(desktop->shell, s);
704
705 desktop->busy_widget =
706 window_add_widget(desktop->busy_window, desktop);
707 /* We set the allocation to 1x1 at 0,0 so the fake enter event
708 * at 0,0 will go to this widget. */
709 widget_set_allocation(desktop->busy_widget, 0, 0, 1, 1);
710
711 widget_set_enter_handler(desktop->busy_widget,
712 busy_surface_enter_handler);
713}
714
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100715static void
716create_output(struct desktop *desktop, uint32_t id)
717{
718 struct output *output;
719
720 output = calloc(1, sizeof *output);
721 if (!output)
722 return;
723
724 output->output = wl_display_bind(display_get_display(desktop->display),
725 id, &wl_output_interface);
726
727 wl_list_insert(&desktop->outputs, &output->link);
728}
729
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400730static void
731global_handler(struct wl_display *display, uint32_t id,
732 const char *interface, uint32_t version, void *data)
733{
734 struct desktop *desktop = data;
735
736 if (!strcmp(interface, "desktop_shell")) {
737 desktop->shell =
738 wl_display_bind(display, id, &desktop_shell_interface);
739 desktop_shell_add_listener(desktop->shell, &listener, desktop);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100740 } else if (!strcmp(interface, "wl_output")) {
741 create_output(desktop, id);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400742 }
743}
744
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500745static void
746launcher_section_done(void *data)
747{
748 struct desktop *desktop = data;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100749 struct output *output;
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500750
751 if (key_launcher_icon == NULL || key_launcher_path == NULL) {
752 fprintf(stderr, "invalid launcher section\n");
753 return;
754 }
755
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100756 wl_list_for_each(output, &desktop->outputs, link)
Kristian Høgsberg53880802012-01-09 11:16:50 -0500757 panel_add_launcher(output->panel,
758 key_launcher_icon, key_launcher_path);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100759
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500760 free(key_launcher_icon);
761 key_launcher_icon = NULL;
762 free(key_launcher_path);
763 key_launcher_path = NULL;
764}
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400765
Kristian Høgsberg6af8eb92012-01-25 16:57:11 -0500766static void
767add_default_launcher(struct desktop *desktop)
768{
769 struct output *output;
770
771 wl_list_for_each(output, &desktop->outputs, link)
772 panel_add_launcher(output->panel,
773 DATADIR "/weston/terminal.png",
Rodney Lorrimar99ff01b2012-02-29 17:31:03 +0100774 BINDIR "/weston-terminal");
Kristian Høgsberg6af8eb92012-01-25 16:57:11 -0500775}
776
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400777int main(int argc, char *argv[])
778{
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200779 struct desktop desktop = { 0 };
Pekka Paalanen668dd562011-11-15 11:45:40 +0200780 char *config_file;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100781 struct output *output;
Kristian Høgsberg6af8eb92012-01-25 16:57:11 -0500782 int ret;
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400783
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200784 desktop.unlock_task.run = unlock_dialog_finish;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100785 wl_list_init(&desktop.outputs);
Pekka Paalanenbfbb26b2011-11-15 13:34:56 +0200786
Kristian Høgsbergbcacef12012-03-11 21:05:57 -0400787 desktop.display = display_create(argc, argv);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400788 if (desktop.display == NULL) {
789 fprintf(stderr, "failed to create display: %m\n");
790 return -1;
791 }
792
Kristian Høgsbergd56bd902012-06-05 09:58:51 -0400793 display_set_user_data(desktop.display, &desktop);
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400794 wl_display_add_global_listener(display_get_display(desktop.display),
795 global_handler, &desktop);
796
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100797 wl_list_for_each(output, &desktop.outputs, link) {
Pekka Paalanen068ae942011-11-28 14:11:15 +0200798 struct wl_shell_surface *s;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100799
800 output->panel = panel_create(desktop.display);
Pekka Paalanen068ae942011-11-28 14:11:15 +0200801 s = window_get_wl_shell_surface(output->panel->window);
802 desktop_shell_set_panel(desktop.shell, output->output, s);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100803
804 output->background = background_create(&desktop);
Pekka Paalanen068ae942011-11-28 14:11:15 +0200805 s = window_get_wl_shell_surface(output->background->window);
806 desktop_shell_set_background(desktop.shell, output->output, s);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100807 }
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400808
Kristian Høgsbergd56bd902012-06-05 09:58:51 -0400809 busy_surface_create(&desktop);
810
Tiago Vignatti9a206c42012-03-21 19:49:18 +0200811 config_file = config_file_path("weston.ini");
Kristian Høgsberg6af8eb92012-01-25 16:57:11 -0500812 ret = parse_config_file(config_file,
813 config_sections, ARRAY_LENGTH(config_sections),
814 &desktop);
Pekka Paalanen668dd562011-11-15 11:45:40 +0200815 free(config_file);
Kristian Høgsberg6af8eb92012-01-25 16:57:11 -0500816 if (ret < 0)
817 add_default_launcher(&desktop);
Kristian Høgsbergac3a59a2011-11-14 22:43:37 -0500818
Kristian Høgsberg0c29eb22011-09-06 18:02:34 -0400819 signal(SIGCHLD, sigchild_handler);
820
821 display_run(desktop.display);
822
823 return 0;
824}