Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2011 Kristian Høgsberg |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 3 | * Copyright © 2011 Collabora, Ltd. |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 4 | * |
| 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> |
| 34 | |
Pekka Paalanen | 50719bc | 2011-11-22 14:18:50 +0200 | [diff] [blame] | 35 | #include <wayland-client.h> |
Kristian Høgsberg | 27d3866 | 2011-10-20 13:11:12 -0400 | [diff] [blame] | 36 | #include "cairo-util.h" |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 37 | #include "window.h" |
Kristian Høgsberg | 9b935c8 | 2011-12-08 12:44:27 -0500 | [diff] [blame] | 38 | #include "../shared/config-parser.h" |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 39 | |
Pekka Paalanen | 50719bc | 2011-11-22 14:18:50 +0200 | [diff] [blame] | 40 | #include "desktop-shell-client-protocol.h" |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 41 | |
| 42 | struct desktop { |
| 43 | struct display *display; |
| 44 | struct desktop_shell *shell; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 45 | const char *background_path; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 46 | struct unlock_dialog *unlock_dialog; |
| 47 | struct task unlock_task; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 48 | struct wl_list outputs; |
| 49 | }; |
| 50 | |
| 51 | struct surface { |
| 52 | void (*configure)(void *data, |
| 53 | struct desktop_shell *desktop_shell, |
| 54 | uint32_t time, uint32_t edges, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 55 | struct window *window, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 56 | int32_t width, int32_t height); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct panel { |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 60 | struct surface base; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 61 | struct window *window; |
Kristian Høgsberg | bcee9a4 | 2011-10-12 00:36:16 -0400 | [diff] [blame] | 62 | struct window *menu; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 63 | }; |
| 64 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 65 | struct background { |
| 66 | struct surface base; |
| 67 | struct window *window; |
| 68 | }; |
| 69 | |
| 70 | struct output { |
| 71 | struct wl_output *output; |
| 72 | struct wl_list link; |
| 73 | |
| 74 | struct panel *panel; |
| 75 | struct background *background; |
| 76 | }; |
| 77 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 78 | struct panel_launcher { |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 79 | struct widget *widget; |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 80 | struct panel *panel; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 81 | cairo_surface_t *icon; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 82 | int pressed; |
| 83 | const char *path; |
| 84 | }; |
| 85 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 86 | struct unlock_dialog { |
| 87 | struct window *window; |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 88 | struct widget *button; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 89 | int closing; |
| 90 | |
| 91 | struct desktop *desktop; |
| 92 | }; |
| 93 | |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 94 | static char *key_background_image; |
| 95 | static uint32_t key_panel_color; |
| 96 | static char *key_launcher_icon; |
| 97 | static char *key_launcher_path; |
| 98 | static void launcher_section_done(void *data); |
Pekka Paalanen | fd83b6d | 2011-12-08 10:06:53 +0200 | [diff] [blame] | 99 | static int key_locking = 1; |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 100 | |
| 101 | static const struct config_key shell_config_keys[] = { |
| 102 | { "background-image", CONFIG_KEY_STRING, &key_background_image }, |
| 103 | { "panel-color", CONFIG_KEY_INTEGER, &key_panel_color }, |
Pekka Paalanen | fd83b6d | 2011-12-08 10:06:53 +0200 | [diff] [blame] | 104 | { "locking", CONFIG_KEY_BOOLEAN, &key_locking }, |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | static const struct config_key launcher_config_keys[] = { |
| 108 | { "icon", CONFIG_KEY_STRING, &key_launcher_icon }, |
| 109 | { "path", CONFIG_KEY_STRING, &key_launcher_path }, |
| 110 | }; |
| 111 | |
| 112 | static const struct config_section config_sections[] = { |
Kristian Høgsberg | 9724b51 | 2012-01-03 14:35:49 -0500 | [diff] [blame] | 113 | { "desktop-shell", |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 114 | shell_config_keys, ARRAY_LENGTH(shell_config_keys) }, |
| 115 | { "launcher", |
| 116 | launcher_config_keys, ARRAY_LENGTH(launcher_config_keys), |
| 117 | launcher_section_done } |
| 118 | }; |
| 119 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 120 | static void |
| 121 | sigchild_handler(int s) |
| 122 | { |
| 123 | int status; |
| 124 | pid_t pid; |
| 125 | |
| 126 | while (pid = waitpid(-1, &status, WNOHANG), pid > 0) |
| 127 | fprintf(stderr, "child %d exited\n", pid); |
| 128 | } |
| 129 | |
| 130 | static void |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame] | 131 | show_menu(struct panel *panel, struct input *input, uint32_t time) |
Kristian Høgsberg | bcee9a4 | 2011-10-12 00:36:16 -0400 | [diff] [blame] | 132 | { |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame] | 133 | int32_t x, y; |
| 134 | static const char *entries[] = { |
| 135 | "Roy", "Pris", "Leon", "Zhora" |
| 136 | }; |
Kristian Høgsberg | bcee9a4 | 2011-10-12 00:36:16 -0400 | [diff] [blame] | 137 | |
| 138 | input_get_position(input, &x, &y); |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame] | 139 | panel->menu = window_create_menu(window_get_display(panel->window), |
| 140 | input, time, panel->window, |
Kristian Høgsberg | 4f7dcd6 | 2012-01-06 21:59:05 -0500 | [diff] [blame] | 141 | x - 10, y - 10, NULL, entries, 4); |
Kristian Høgsberg | bcee9a4 | 2011-10-12 00:36:16 -0400 | [diff] [blame] | 142 | |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame] | 143 | window_schedule_redraw(panel->menu); |
Kristian Høgsberg | bcee9a4 | 2011-10-12 00:36:16 -0400 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 147 | panel_launcher_activate(struct panel_launcher *widget) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 148 | { |
| 149 | pid_t pid; |
| 150 | |
| 151 | pid = fork(); |
| 152 | if (pid < 0) { |
| 153 | fprintf(stderr, "fork failed: %m\n"); |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | if (pid) |
| 158 | return; |
Benjamin Franzke | d775971 | 2011-11-22 12:38:48 +0100 | [diff] [blame] | 159 | |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 160 | if (execl(widget->path, widget->path, NULL) < 0) { |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 161 | fprintf(stderr, "execl failed: %m\n"); |
| 162 | exit(1); |
| 163 | } |
| 164 | } |
| 165 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 166 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 167 | panel_draw_launcher(struct widget *widget, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 168 | { |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 169 | cairo_t *cr = data; |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 170 | struct panel_launcher *pi; |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 171 | int x, y, width, height; |
| 172 | double dx, dy; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 173 | |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 174 | pi = widget_get_user_data(widget); |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 175 | width = cairo_image_surface_get_width(pi->icon); |
| 176 | height = cairo_image_surface_get_height(pi->icon); |
| 177 | x = 0; |
| 178 | y = -height / 2; |
| 179 | if (pi->pressed) { |
| 180 | x++; |
| 181 | y++; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 182 | } |
| 183 | |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 184 | dx = x; |
| 185 | dy = y; |
| 186 | cairo_user_to_device(cr, &dx, &dy); |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 187 | widget_set_allocation(widget, dx, dy, width, height); |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 188 | |
| 189 | cairo_set_source_surface(cr, pi->icon, x, y); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 190 | cairo_paint(cr); |
| 191 | |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 192 | if (window_get_focus_widget(pi->panel->window) == widget) { |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 193 | cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.4); |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 194 | cairo_mask_surface(cr, pi->icon, x, y); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 195 | } |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 196 | |
| 197 | cairo_translate(cr, width + 10, 0); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | static void |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 201 | set_hex_color(cairo_t *cr, uint32_t color) |
| 202 | { |
| 203 | cairo_set_source_rgba(cr, |
| 204 | ((color >> 16) & 0xff) / 255.0, |
| 205 | ((color >> 8) & 0xff) / 255.0, |
| 206 | ((color >> 0) & 0xff) / 255.0, |
| 207 | ((color >> 24) & 0xff) / 255.0); |
| 208 | } |
| 209 | |
| 210 | static void |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 211 | panel_redraw_handler(struct window *window, void *data) |
| 212 | { |
| 213 | cairo_surface_t *surface; |
| 214 | cairo_t *cr; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 215 | |
| 216 | window_draw(window); |
| 217 | surface = window_get_surface(window); |
| 218 | cr = cairo_create(surface); |
| 219 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 220 | set_hex_color(cr, key_panel_color); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 221 | cairo_paint(cr); |
| 222 | |
| 223 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 224 | cairo_translate(cr, 10, 32 / 2); |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 225 | window_for_each_widget(window, panel_draw_launcher, cr); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 226 | |
| 227 | cairo_destroy(cr); |
| 228 | cairo_surface_destroy(surface); |
| 229 | window_flush(window); |
| 230 | } |
| 231 | |
| 232 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 233 | panel_launcher_enter_handler(struct widget *widget, struct input *input, |
| 234 | uint32_t time, int32_t x, int32_t y, void *data) |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 235 | { |
| 236 | widget_schedule_redraw(widget); |
| 237 | } |
| 238 | |
| 239 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 240 | panel_launcher_leave_handler(struct widget *widget, |
| 241 | struct input *input, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 242 | { |
Kristian Høgsberg | 9a13dab | 2012-01-08 15:18:19 -0500 | [diff] [blame] | 243 | widget_schedule_redraw(widget); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 247 | panel_launcher_button_handler(struct widget *widget, |
| 248 | struct input *input, uint32_t time, |
| 249 | int button, int state, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 250 | { |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 251 | struct panel_launcher *launcher; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 252 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 253 | launcher = widget_get_user_data(widget); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 254 | widget_schedule_redraw(widget); |
| 255 | if (state == 0) |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 256 | panel_launcher_activate(launcher); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static void |
| 260 | panel_button_handler(struct widget *widget, |
| 261 | struct input *input, uint32_t time, |
| 262 | int button, int state, void *data) |
| 263 | { |
| 264 | struct window *window = data; |
| 265 | struct panel *panel = window_get_user_data(window); |
| 266 | |
| 267 | if (button == BTN_RIGHT && state) |
| 268 | show_menu(panel, input, time); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 269 | } |
| 270 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 271 | static void |
| 272 | panel_configure(void *data, |
| 273 | struct desktop_shell *desktop_shell, |
| 274 | uint32_t time, uint32_t edges, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 275 | struct window *window, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 276 | int32_t width, int32_t height) |
| 277 | { |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 278 | window_set_child_size(window, width, 32); |
| 279 | window_schedule_redraw(window); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 280 | } |
| 281 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 282 | static struct panel * |
| 283 | panel_create(struct display *display) |
| 284 | { |
| 285 | struct panel *panel; |
| 286 | |
| 287 | panel = malloc(sizeof *panel); |
| 288 | memset(panel, 0, sizeof *panel); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 289 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 290 | panel->base.configure = panel_configure; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 291 | panel->window = window_create(display, 0, 0); |
| 292 | |
| 293 | window_set_title(panel->window, "panel"); |
| 294 | window_set_decoration(panel->window, 0); |
| 295 | window_set_redraw_handler(panel->window, panel_redraw_handler); |
| 296 | window_set_custom(panel->window); |
| 297 | window_set_user_data(panel->window, panel); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 298 | |
| 299 | widget_set_button_handler(window_get_widget(panel->window), |
| 300 | panel_button_handler); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 301 | |
| 302 | return panel; |
| 303 | } |
| 304 | |
| 305 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 306 | panel_add_launcher(struct panel *panel, const char *icon, const char *path) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 307 | { |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 308 | struct panel_launcher *launcher; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 309 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 310 | launcher = malloc(sizeof *launcher); |
| 311 | memset(launcher, 0, sizeof *launcher); |
| 312 | launcher->icon = cairo_image_surface_create_from_png(icon); |
| 313 | launcher->path = strdup(path); |
| 314 | launcher->panel = panel; |
Kristian Høgsberg | 9a13dab | 2012-01-08 15:18:19 -0500 | [diff] [blame] | 315 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 316 | launcher->widget = window_add_widget(panel->window, launcher); |
| 317 | widget_set_enter_handler(launcher->widget, |
| 318 | panel_launcher_enter_handler); |
| 319 | widget_set_leave_handler(launcher->widget, |
| 320 | panel_launcher_leave_handler); |
| 321 | widget_set_button_handler(launcher->widget, |
| 322 | panel_launcher_button_handler); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | static void |
| 326 | background_draw(struct window *window, int width, int height, const char *path) |
| 327 | { |
| 328 | cairo_surface_t *surface, *image; |
Kristian Høgsberg | 7e69000 | 2011-09-08 18:18:02 -0400 | [diff] [blame] | 329 | cairo_pattern_t *pattern; |
| 330 | cairo_matrix_t matrix; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 331 | cairo_t *cr; |
Kristian Høgsberg | 7e69000 | 2011-09-08 18:18:02 -0400 | [diff] [blame] | 332 | double sx, sy; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 333 | |
| 334 | window_set_child_size(window, width, height); |
| 335 | window_draw(window); |
| 336 | surface = window_get_surface(window); |
| 337 | |
| 338 | cr = cairo_create(surface); |
| 339 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 340 | cairo_set_source_rgba(cr, 0.0, 0.0, 0.2, 1.0); |
| 341 | cairo_paint(cr); |
| 342 | |
| 343 | if (path) { |
Kristian Høgsberg | 27d3866 | 2011-10-20 13:11:12 -0400 | [diff] [blame] | 344 | image = load_jpeg(path); |
Kristian Høgsberg | 7e69000 | 2011-09-08 18:18:02 -0400 | [diff] [blame] | 345 | pattern = cairo_pattern_create_for_surface(image); |
| 346 | sx = (double) cairo_image_surface_get_width(image) / width; |
| 347 | sy = (double) cairo_image_surface_get_height(image) / height; |
| 348 | cairo_matrix_init_scale(&matrix, sx, sy); |
| 349 | cairo_pattern_set_matrix(pattern, &matrix); |
| 350 | cairo_set_source(cr, pattern); |
| 351 | cairo_pattern_destroy (pattern); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 352 | cairo_paint(cr); |
Kristian Høgsberg | 27d3866 | 2011-10-20 13:11:12 -0400 | [diff] [blame] | 353 | cairo_surface_destroy(image); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | cairo_destroy(cr); |
| 357 | cairo_surface_destroy(surface); |
| 358 | window_flush(window); |
| 359 | } |
| 360 | |
| 361 | static void |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 362 | background_configure(void *data, |
| 363 | struct desktop_shell *desktop_shell, |
| 364 | uint32_t time, uint32_t edges, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 365 | struct window *window, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 366 | int32_t width, int32_t height) |
| 367 | { |
| 368 | struct desktop *desktop = data; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 369 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 370 | background_draw(window, width, height, desktop->background_path); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | static void |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 374 | unlock_dialog_draw(struct unlock_dialog *dialog) |
| 375 | { |
| 376 | struct rectangle allocation; |
| 377 | cairo_t *cr; |
| 378 | cairo_surface_t *surface; |
| 379 | cairo_pattern_t *pat; |
| 380 | double cx, cy, r, f; |
| 381 | |
| 382 | window_draw(dialog->window); |
| 383 | |
| 384 | surface = window_get_surface(dialog->window); |
| 385 | cr = cairo_create(surface); |
| 386 | window_get_child_allocation(dialog->window, &allocation); |
| 387 | cairo_rectangle(cr, allocation.x, allocation.y, |
| 388 | allocation.width, allocation.height); |
| 389 | cairo_clip(cr); |
| 390 | cairo_push_group(cr); |
| 391 | cairo_translate(cr, allocation.x, allocation.y); |
| 392 | |
| 393 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 394 | cairo_set_source_rgba(cr, 0, 0, 0, 0.6); |
| 395 | cairo_paint(cr); |
| 396 | |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 397 | if (window_get_focus_widget(dialog->window) == dialog->button) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 398 | f = 1.0; |
| 399 | else |
| 400 | f = 0.7; |
| 401 | |
| 402 | cx = allocation.width / 2.0; |
| 403 | cy = allocation.height / 2.0; |
| 404 | r = (cx < cy ? cx : cy) * 0.4; |
| 405 | pat = cairo_pattern_create_radial(cx, cy, r * 0.7, cx, cy, r); |
| 406 | cairo_pattern_add_color_stop_rgb(pat, 0.0, 0, 0.86 * f, 0); |
| 407 | cairo_pattern_add_color_stop_rgb(pat, 0.85, 0.2 * f, f, 0.2 * f); |
| 408 | cairo_pattern_add_color_stop_rgb(pat, 1.0, 0, 0.86 * f, 0); |
| 409 | cairo_set_source(cr, pat); |
| 410 | cairo_arc(cr, cx, cy, r, 0.0, 2.0 * M_PI); |
| 411 | cairo_fill(cr); |
| 412 | |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 413 | widget_set_allocation(dialog->button, |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 414 | allocation.x + cx - r, |
| 415 | allocation.y + cy - r, 2 * r, 2 * r); |
| 416 | cairo_pattern_destroy(pat); |
| 417 | |
| 418 | cairo_pop_group_to_source(cr); |
| 419 | cairo_paint(cr); |
| 420 | cairo_destroy(cr); |
| 421 | |
| 422 | window_flush(dialog->window); |
| 423 | cairo_surface_destroy(surface); |
| 424 | } |
| 425 | |
| 426 | static void |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 427 | unlock_dialog_button_handler(struct widget *widget, |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 428 | struct input *input, uint32_t time, |
| 429 | int button, int state, void *data) |
| 430 | { |
| 431 | struct unlock_dialog *dialog = data; |
| 432 | struct desktop *desktop = dialog->desktop; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 433 | |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 434 | if (button == BTN_LEFT) { |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 435 | if (state == 0 && !dialog->closing) { |
| 436 | display_defer(desktop->display, &desktop->unlock_task); |
| 437 | dialog->closing = 1; |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | static void |
| 443 | unlock_dialog_redraw_handler(struct window *window, void *data) |
| 444 | { |
| 445 | struct unlock_dialog *dialog = data; |
| 446 | |
| 447 | unlock_dialog_draw(dialog); |
| 448 | } |
| 449 | |
| 450 | static void |
| 451 | unlock_dialog_keyboard_focus_handler(struct window *window, |
| 452 | struct input *device, void *data) |
| 453 | { |
| 454 | window_schedule_redraw(window); |
| 455 | } |
| 456 | |
| 457 | static void |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 458 | unlock_dialog_widget_enter_handler(struct widget *widget, |
| 459 | struct input *input, uint32_t time, |
| 460 | int32_t x, int32_t y, void *data) |
| 461 | { |
| 462 | widget_schedule_redraw(widget); |
| 463 | } |
| 464 | |
| 465 | static void |
| 466 | unlock_dialog_widget_leave_handler(struct widget *widget, |
| 467 | struct input *input, void *data) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 468 | { |
Kristian Høgsberg | 9a13dab | 2012-01-08 15:18:19 -0500 | [diff] [blame] | 469 | widget_schedule_redraw(widget); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | static struct unlock_dialog * |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 473 | unlock_dialog_create(struct desktop *desktop) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 474 | { |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 475 | struct display *display = desktop->display; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 476 | struct unlock_dialog *dialog; |
| 477 | |
| 478 | dialog = malloc(sizeof *dialog); |
| 479 | if (!dialog) |
| 480 | return NULL; |
| 481 | memset(dialog, 0, sizeof *dialog); |
| 482 | |
| 483 | dialog->window = window_create(display, 260, 230); |
| 484 | window_set_title(dialog->window, "Unlock your desktop"); |
Benjamin Franzke | 8193bc1 | 2011-11-23 19:35:07 +0100 | [diff] [blame] | 485 | window_set_custom(dialog->window); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 486 | |
| 487 | window_set_user_data(dialog->window, dialog); |
| 488 | window_set_redraw_handler(dialog->window, unlock_dialog_redraw_handler); |
| 489 | window_set_keyboard_focus_handler(dialog->window, |
| 490 | unlock_dialog_keyboard_focus_handler); |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 491 | dialog->button = window_add_widget(dialog->window, NULL); |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 492 | widget_set_enter_handler(dialog->button, |
| 493 | unlock_dialog_widget_enter_handler); |
| 494 | widget_set_leave_handler(dialog->button, |
| 495 | unlock_dialog_widget_leave_handler); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 496 | widget_set_button_handler(dialog->button, |
| 497 | unlock_dialog_button_handler); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 498 | |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 499 | desktop_shell_set_lock_surface(desktop->shell, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 500 | window_get_wl_shell_surface(dialog->window)); |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 501 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 502 | unlock_dialog_draw(dialog); |
| 503 | |
| 504 | return dialog; |
| 505 | } |
| 506 | |
| 507 | static void |
| 508 | unlock_dialog_destroy(struct unlock_dialog *dialog) |
| 509 | { |
| 510 | window_destroy(dialog->window); |
| 511 | free(dialog); |
| 512 | } |
| 513 | |
| 514 | static void |
| 515 | unlock_dialog_finish(struct task *task, uint32_t events) |
| 516 | { |
| 517 | struct desktop *desktop = |
Benjamin Franzke | d775971 | 2011-11-22 12:38:48 +0100 | [diff] [blame] | 518 | container_of(task, struct desktop, unlock_task); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 519 | |
| 520 | desktop_shell_unlock(desktop->shell); |
| 521 | unlock_dialog_destroy(desktop->unlock_dialog); |
| 522 | desktop->unlock_dialog = NULL; |
| 523 | } |
| 524 | |
| 525 | static void |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 526 | desktop_shell_configure(void *data, |
| 527 | struct desktop_shell *desktop_shell, |
| 528 | uint32_t time, uint32_t edges, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 529 | struct wl_shell_surface *shell_surface, |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 530 | int32_t width, int32_t height) |
| 531 | { |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 532 | struct window *window = wl_shell_surface_get_user_data(shell_surface); |
| 533 | struct surface *s = window_get_user_data(window); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 534 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 535 | s->configure(data, desktop_shell, time, edges, window, width, height); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 536 | } |
| 537 | |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 538 | static void |
| 539 | desktop_shell_prepare_lock_surface(void *data, |
| 540 | struct desktop_shell *desktop_shell) |
| 541 | { |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 542 | struct desktop *desktop = data; |
| 543 | |
Pekka Paalanen | fd83b6d | 2011-12-08 10:06:53 +0200 | [diff] [blame] | 544 | if (!key_locking) { |
| 545 | desktop_shell_unlock(desktop->shell); |
| 546 | return; |
| 547 | } |
| 548 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 549 | if (!desktop->unlock_dialog) { |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 550 | desktop->unlock_dialog = unlock_dialog_create(desktop); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 551 | desktop->unlock_dialog->desktop = desktop; |
| 552 | } |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 553 | } |
| 554 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 555 | static const struct desktop_shell_listener listener = { |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 556 | desktop_shell_configure, |
| 557 | desktop_shell_prepare_lock_surface |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 558 | }; |
| 559 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 560 | static struct background * |
| 561 | background_create(struct desktop *desktop) |
| 562 | { |
| 563 | struct background *background; |
| 564 | |
| 565 | background = malloc(sizeof *background); |
| 566 | memset(background, 0, sizeof *background); |
| 567 | |
| 568 | background->base.configure = background_configure; |
| 569 | background->window = window_create(desktop->display, 0, 0); |
| 570 | window_set_decoration(background->window, 0); |
| 571 | window_set_custom(background->window); |
| 572 | window_set_user_data(background->window, background); |
| 573 | |
| 574 | return background; |
| 575 | } |
| 576 | |
| 577 | static void |
| 578 | create_output(struct desktop *desktop, uint32_t id) |
| 579 | { |
| 580 | struct output *output; |
| 581 | |
| 582 | output = calloc(1, sizeof *output); |
| 583 | if (!output) |
| 584 | return; |
| 585 | |
| 586 | output->output = wl_display_bind(display_get_display(desktop->display), |
| 587 | id, &wl_output_interface); |
| 588 | |
| 589 | wl_list_insert(&desktop->outputs, &output->link); |
| 590 | } |
| 591 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 592 | static void |
| 593 | global_handler(struct wl_display *display, uint32_t id, |
| 594 | const char *interface, uint32_t version, void *data) |
| 595 | { |
| 596 | struct desktop *desktop = data; |
| 597 | |
| 598 | if (!strcmp(interface, "desktop_shell")) { |
| 599 | desktop->shell = |
| 600 | wl_display_bind(display, id, &desktop_shell_interface); |
| 601 | desktop_shell_add_listener(desktop->shell, &listener, desktop); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 602 | } else if (!strcmp(interface, "wl_output")) { |
| 603 | create_output(desktop, id); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 604 | } |
| 605 | } |
| 606 | |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 607 | static void |
| 608 | launcher_section_done(void *data) |
| 609 | { |
| 610 | struct desktop *desktop = data; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 611 | struct output *output; |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 612 | |
| 613 | if (key_launcher_icon == NULL || key_launcher_path == NULL) { |
| 614 | fprintf(stderr, "invalid launcher section\n"); |
| 615 | return; |
| 616 | } |
| 617 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 618 | wl_list_for_each(output, &desktop->outputs, link) |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame^] | 619 | panel_add_launcher(output->panel, |
| 620 | key_launcher_icon, key_launcher_path); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 621 | |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 622 | free(key_launcher_icon); |
| 623 | key_launcher_icon = NULL; |
| 624 | free(key_launcher_path); |
| 625 | key_launcher_path = NULL; |
| 626 | } |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 627 | |
| 628 | int main(int argc, char *argv[]) |
| 629 | { |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 630 | struct desktop desktop = { 0 }; |
Pekka Paalanen | 668dd56 | 2011-11-15 11:45:40 +0200 | [diff] [blame] | 631 | char *config_file; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 632 | struct output *output; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 633 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 634 | desktop.unlock_task.run = unlock_dialog_finish; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 635 | wl_list_init(&desktop.outputs); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 636 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 637 | desktop.display = display_create(&argc, &argv, NULL); |
| 638 | if (desktop.display == NULL) { |
| 639 | fprintf(stderr, "failed to create display: %m\n"); |
| 640 | return -1; |
| 641 | } |
| 642 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 643 | wl_display_add_global_listener(display_get_display(desktop.display), |
| 644 | global_handler, &desktop); |
| 645 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 646 | wl_list_for_each(output, &desktop.outputs, link) { |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 647 | struct wl_shell_surface *s; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 648 | |
| 649 | output->panel = panel_create(desktop.display); |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 650 | s = window_get_wl_shell_surface(output->panel->window); |
| 651 | desktop_shell_set_panel(desktop.shell, output->output, s); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 652 | |
| 653 | output->background = background_create(&desktop); |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 654 | s = window_get_wl_shell_surface(output->background->window); |
| 655 | desktop_shell_set_background(desktop.shell, output->output, s); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 656 | } |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 657 | |
Kristian Høgsberg | 9724b51 | 2012-01-03 14:35:49 -0500 | [diff] [blame] | 658 | config_file = config_file_path("weston-desktop-shell.ini"); |
Pekka Paalanen | 668dd56 | 2011-11-15 11:45:40 +0200 | [diff] [blame] | 659 | parse_config_file(config_file, |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 660 | config_sections, ARRAY_LENGTH(config_sections), |
| 661 | &desktop); |
Pekka Paalanen | 668dd56 | 2011-11-15 11:45:40 +0200 | [diff] [blame] | 662 | free(config_file); |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 663 | |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 664 | desktop.background_path = key_background_image; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 665 | |
| 666 | signal(SIGCHLD, sigchild_handler); |
| 667 | |
| 668 | display_run(desktop.display); |
| 669 | |
| 670 | return 0; |
| 671 | } |