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 | * |
Bryce Harrington | 1f6b0d1 | 2015-06-10 22:48:59 -0700 | [diff] [blame] | 5 | * 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: |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 11 | * |
Bryce Harrington | 1f6b0d1 | 2015-06-10 22:48:59 -0700 | [diff] [blame] | 12 | * 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. |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 23 | */ |
| 24 | |
U. Artie Eoff | 3c94677 | 2014-01-15 10:59:50 -0800 | [diff] [blame] | 25 | #include "config.h" |
| 26 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 27 | #include <stdint.h> |
| 28 | #include <stdio.h> |
| 29 | #include <stdlib.h> |
| 30 | #include <string.h> |
| 31 | #include <fcntl.h> |
| 32 | #include <unistd.h> |
U. Artie Eoff | 3c94677 | 2014-01-15 10:59:50 -0800 | [diff] [blame] | 33 | #include <errno.h> |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 34 | #include <math.h> |
| 35 | #include <cairo.h> |
| 36 | #include <sys/wait.h> |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 37 | #include <sys/timerfd.h> |
Michael Vetter | 2a18a52 | 2015-05-15 17:17:47 +0200 | [diff] [blame] | 38 | #include <sys/epoll.h> |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 39 | #include <linux/input.h> |
Tiago Vignatti | 6150072 | 2012-05-23 22:06:28 +0300 | [diff] [blame] | 40 | #include <libgen.h> |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 41 | #include <ctype.h> |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 42 | #include <time.h> |
Quentin Glidic | f9574f2 | 2016-06-23 18:55:21 +0200 | [diff] [blame^] | 43 | #include <assert.h> |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 44 | |
Pekka Paalanen | 50719bc | 2011-11-22 14:18:50 +0200 | [diff] [blame] | 45 | #include <wayland-client.h> |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 46 | #include "window.h" |
Jon Cruz | 4678bab | 2015-06-15 15:37:07 -0700 | [diff] [blame] | 47 | #include "shared/cairo-util.h" |
| 48 | #include "shared/config-parser.h" |
Jon Cruz | 867d50e | 2015-06-15 15:37:10 -0700 | [diff] [blame] | 49 | #include "shared/helpers.h" |
Bryce Harrington | e99e4bf | 2016-03-16 14:15:18 -0700 | [diff] [blame] | 50 | #include "shared/xalloc.h" |
Bryce Harrington | 0d1a622 | 2016-02-11 16:42:49 -0800 | [diff] [blame] | 51 | #include "shared/zalloc.h" |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 52 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 53 | #include "weston-desktop-shell-client-protocol.h" |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 54 | |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 55 | #define DEFAULT_CLOCK_FORMAT CLOCK_FORMAT_MINUTES |
| 56 | |
Pekka Paalanen | b6df4f7 | 2012-08-03 14:39:15 +0300 | [diff] [blame] | 57 | extern char **environ; /* defined by libc */ |
| 58 | |
Quentin Glidic | f9574f2 | 2016-06-23 18:55:21 +0200 | [diff] [blame^] | 59 | enum clock_format { |
| 60 | CLOCK_FORMAT_MINUTES, |
| 61 | CLOCK_FORMAT_SECONDS, |
| 62 | CLOCK_FORMAT_NONE |
| 63 | }; |
| 64 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 65 | struct desktop { |
| 66 | struct display *display; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 67 | struct weston_desktop_shell *shell; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 68 | struct unlock_dialog *unlock_dialog; |
| 69 | struct task unlock_task; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 70 | struct wl_list outputs; |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 71 | |
Quentin Glidic | 55d5701 | 2016-06-23 18:55:18 +0200 | [diff] [blame] | 72 | int want_panel; |
| 73 | enum weston_desktop_shell_panel_position panel_position; |
| 74 | |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 75 | struct window *grab_window; |
| 76 | struct widget *grab_widget; |
| 77 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 78 | struct weston_config *config; |
| 79 | int locking; |
| 80 | |
Scott Moreau | ec11602 | 2012-07-22 18:23:52 -0600 | [diff] [blame] | 81 | enum cursor_type grab_cursor; |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 82 | |
| 83 | int painted; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | struct surface { |
| 87 | void (*configure)(void *data, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 88 | struct weston_desktop_shell *desktop_shell, |
Kristian Høgsberg | eae5de7 | 2012-04-11 22:42:15 -0400 | [diff] [blame] | 89 | uint32_t edges, struct window *window, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 90 | int32_t width, int32_t height); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | struct panel { |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 94 | struct surface base; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 95 | struct window *window; |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 96 | struct widget *widget; |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 97 | struct wl_list launcher_list; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 98 | struct panel_clock *clock; |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 99 | int painted; |
Quentin Glidic | f9574f2 | 2016-06-23 18:55:21 +0200 | [diff] [blame^] | 100 | enum clock_format clock_format; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 101 | uint32_t color; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 102 | }; |
| 103 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 104 | struct background { |
| 105 | struct surface base; |
| 106 | struct window *window; |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 107 | struct widget *widget; |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 108 | int painted; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 109 | |
| 110 | char *image; |
| 111 | int type; |
| 112 | uint32_t color; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | struct output { |
| 116 | struct wl_output *output; |
Xiong Zhang | 83d8ee7 | 2013-10-23 13:58:35 +0800 | [diff] [blame] | 117 | uint32_t server_output_id; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 118 | struct wl_list link; |
| 119 | |
| 120 | struct panel *panel; |
| 121 | struct background *background; |
| 122 | }; |
| 123 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 124 | struct panel_launcher { |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 125 | struct widget *widget; |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 126 | struct panel *panel; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 127 | cairo_surface_t *icon; |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 128 | int focused, pressed; |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 129 | char *path; |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 130 | struct wl_list link; |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 131 | struct wl_array envp; |
| 132 | struct wl_array argv; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 133 | }; |
| 134 | |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 135 | struct panel_clock { |
| 136 | struct widget *widget; |
| 137 | struct panel *panel; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 138 | struct task clock_task; |
| 139 | int clock_fd; |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 140 | char *format_string; |
| 141 | time_t refresh_timer; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 142 | }; |
| 143 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 144 | struct unlock_dialog { |
| 145 | struct window *window; |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 146 | struct widget *widget; |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 147 | struct widget *button; |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 148 | int button_focused; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 149 | int closing; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 150 | struct desktop *desktop; |
| 151 | }; |
| 152 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 153 | static void |
| 154 | panel_add_launchers(struct panel *panel, struct desktop *desktop); |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 155 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 156 | static void |
| 157 | sigchild_handler(int s) |
| 158 | { |
| 159 | int status; |
| 160 | pid_t pid; |
| 161 | |
| 162 | while (pid = waitpid(-1, &status, WNOHANG), pid > 0) |
| 163 | fprintf(stderr, "child %d exited\n", pid); |
| 164 | } |
| 165 | |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 166 | static int |
| 167 | is_desktop_painted(struct desktop *desktop) |
| 168 | { |
| 169 | struct output *output; |
| 170 | |
| 171 | wl_list_for_each(output, &desktop->outputs, link) { |
| 172 | if (output->panel && !output->panel->painted) |
| 173 | return 0; |
| 174 | if (output->background && !output->background->painted) |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | return 1; |
| 179 | } |
| 180 | |
| 181 | static void |
| 182 | check_desktop_ready(struct window *window) |
| 183 | { |
| 184 | struct display *display; |
| 185 | struct desktop *desktop; |
| 186 | |
| 187 | display = window_get_display(window); |
| 188 | desktop = display_get_user_data(display); |
| 189 | |
| 190 | if (!desktop->painted && is_desktop_painted(desktop)) { |
| 191 | desktop->painted = 1; |
| 192 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 193 | weston_desktop_shell_desktop_ready(desktop->shell); |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | |
Kristian Høgsberg | bcee9a4 | 2011-10-12 00:36:16 -0400 | [diff] [blame] | 197 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 198 | panel_launcher_activate(struct panel_launcher *widget) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 199 | { |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 200 | char **argv; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 201 | pid_t pid; |
| 202 | |
| 203 | pid = fork(); |
| 204 | if (pid < 0) { |
| 205 | fprintf(stderr, "fork failed: %m\n"); |
| 206 | return; |
| 207 | } |
| 208 | |
| 209 | if (pid) |
| 210 | return; |
Benjamin Franzke | d775971 | 2011-11-22 12:38:48 +0100 | [diff] [blame] | 211 | |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 212 | argv = widget->argv.data; |
| 213 | if (execve(argv[0], argv, widget->envp.data) < 0) { |
| 214 | fprintf(stderr, "execl '%s' failed: %m\n", argv[0]); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 215 | exit(1); |
| 216 | } |
| 217 | } |
| 218 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 219 | static void |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 220 | panel_launcher_redraw_handler(struct widget *widget, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 221 | { |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 222 | struct panel_launcher *launcher = data; |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 223 | struct rectangle allocation; |
| 224 | cairo_t *cr; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 225 | |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 226 | cr = widget_cairo_create(launcher->panel->widget); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 227 | |
| 228 | widget_get_allocation(widget, &allocation); |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 229 | if (launcher->pressed) { |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 230 | allocation.x++; |
| 231 | allocation.y++; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 232 | } |
| 233 | |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 234 | cairo_set_source_surface(cr, launcher->icon, |
| 235 | allocation.x, allocation.y); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 236 | cairo_paint(cr); |
| 237 | |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 238 | if (launcher->focused) { |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 239 | cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.4); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 240 | cairo_mask_surface(cr, launcher->icon, |
| 241 | allocation.x, allocation.y); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 242 | } |
Kristian Høgsberg | e28d05b | 2011-09-20 21:43:54 -0400 | [diff] [blame] | 243 | |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 244 | cairo_destroy(cr); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 245 | } |
| 246 | |
Tiago Vignatti | 6150072 | 2012-05-23 22:06:28 +0300 | [diff] [blame] | 247 | static int |
| 248 | panel_launcher_motion_handler(struct widget *widget, struct input *input, |
| 249 | uint32_t time, float x, float y, void *data) |
| 250 | { |
| 251 | struct panel_launcher *launcher = data; |
| 252 | |
| 253 | widget_set_tooltip(widget, basename((char *)launcher->path), x, y); |
| 254 | |
Ander Conselvan de Oliveira | dc8c8fc | 2012-05-25 16:01:41 +0300 | [diff] [blame] | 255 | return CURSOR_LEFT_PTR; |
Tiago Vignatti | 6150072 | 2012-05-23 22:06:28 +0300 | [diff] [blame] | 256 | } |
| 257 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 258 | static void |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 259 | set_hex_color(cairo_t *cr, uint32_t color) |
| 260 | { |
Michael Vetter | 2a18a52 | 2015-05-15 17:17:47 +0200 | [diff] [blame] | 261 | cairo_set_source_rgba(cr, |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 262 | ((color >> 16) & 0xff) / 255.0, |
| 263 | ((color >> 8) & 0xff) / 255.0, |
| 264 | ((color >> 0) & 0xff) / 255.0, |
| 265 | ((color >> 24) & 0xff) / 255.0); |
| 266 | } |
| 267 | |
| 268 | static void |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 269 | panel_redraw_handler(struct widget *widget, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 270 | { |
| 271 | cairo_surface_t *surface; |
| 272 | cairo_t *cr; |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 273 | struct panel *panel = data; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 274 | |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 275 | cr = widget_cairo_create(panel->widget); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 276 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 277 | set_hex_color(cr, panel->color); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 278 | cairo_paint(cr); |
| 279 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 280 | cairo_destroy(cr); |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 281 | surface = window_get_surface(panel->window); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 282 | cairo_surface_destroy(surface); |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 283 | panel->painted = 1; |
| 284 | check_desktop_ready(panel->window); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 285 | } |
| 286 | |
Kristian Høgsberg | bb901fa | 2012-01-09 11:22:32 -0500 | [diff] [blame] | 287 | static int |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 288 | panel_launcher_enter_handler(struct widget *widget, struct input *input, |
Kristian Høgsberg | 80680c7 | 2012-05-10 12:21:37 -0400 | [diff] [blame] | 289 | float x, float y, void *data) |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 290 | { |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 291 | struct panel_launcher *launcher = data; |
| 292 | |
| 293 | launcher->focused = 1; |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 294 | widget_schedule_redraw(widget); |
Kristian Høgsberg | bb901fa | 2012-01-09 11:22:32 -0500 | [diff] [blame] | 295 | |
Ander Conselvan de Oliveira | dc8c8fc | 2012-05-25 16:01:41 +0300 | [diff] [blame] | 296 | return CURSOR_LEFT_PTR; |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 300 | panel_launcher_leave_handler(struct widget *widget, |
| 301 | struct input *input, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 302 | { |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 303 | struct panel_launcher *launcher = data; |
| 304 | |
| 305 | launcher->focused = 0; |
Tiago Vignatti | 6150072 | 2012-05-23 22:06:28 +0300 | [diff] [blame] | 306 | widget_destroy_tooltip(widget); |
Kristian Høgsberg | 9a13dab | 2012-01-08 15:18:19 -0500 | [diff] [blame] | 307 | widget_schedule_redraw(widget); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 311 | panel_launcher_button_handler(struct widget *widget, |
| 312 | struct input *input, uint32_t time, |
Daniel Stone | 4dbadb1 | 2012-05-30 16:31:51 +0100 | [diff] [blame] | 313 | uint32_t button, |
| 314 | enum wl_pointer_button_state state, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 315 | { |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 316 | struct panel_launcher *launcher; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 317 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 318 | launcher = widget_get_user_data(widget); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 319 | widget_schedule_redraw(widget); |
Daniel Stone | 4dbadb1 | 2012-05-30 16:31:51 +0100 | [diff] [blame] | 320 | if (state == WL_POINTER_BUTTON_STATE_RELEASED) |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 321 | panel_launcher_activate(launcher); |
Rusty Lynch | 4384a24 | 2013-08-08 21:28:22 -0700 | [diff] [blame] | 322 | |
| 323 | } |
| 324 | |
| 325 | static void |
Rusty Lynch | 1084da5 | 2013-08-15 09:10:08 -0700 | [diff] [blame] | 326 | panel_launcher_touch_down_handler(struct widget *widget, struct input *input, |
| 327 | uint32_t serial, uint32_t time, int32_t id, |
Rusty Lynch | 4384a24 | 2013-08-08 21:28:22 -0700 | [diff] [blame] | 328 | float x, float y, void *data) |
| 329 | { |
| 330 | struct panel_launcher *launcher; |
| 331 | |
| 332 | launcher = widget_get_user_data(widget); |
| 333 | launcher->focused = 1; |
| 334 | widget_schedule_redraw(widget); |
| 335 | } |
| 336 | |
| 337 | static void |
Rusty Lynch | 1084da5 | 2013-08-15 09:10:08 -0700 | [diff] [blame] | 338 | panel_launcher_touch_up_handler(struct widget *widget, struct input *input, |
Michael Vetter | 2a18a52 | 2015-05-15 17:17:47 +0200 | [diff] [blame] | 339 | uint32_t serial, uint32_t time, int32_t id, |
Rusty Lynch | 1084da5 | 2013-08-15 09:10:08 -0700 | [diff] [blame] | 340 | void *data) |
Rusty Lynch | 4384a24 | 2013-08-08 21:28:22 -0700 | [diff] [blame] | 341 | { |
| 342 | struct panel_launcher *launcher; |
| 343 | |
| 344 | launcher = widget_get_user_data(widget); |
| 345 | launcher->focused = 0; |
| 346 | widget_schedule_redraw(widget); |
| 347 | panel_launcher_activate(launcher); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 348 | } |
| 349 | |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 350 | static void |
| 351 | clock_func(struct task *task, uint32_t events) |
| 352 | { |
| 353 | struct panel_clock *clock = |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 354 | container_of(task, struct panel_clock, clock_task); |
Kristian Høgsberg | 70226bb | 2012-06-08 16:54:52 -0400 | [diff] [blame] | 355 | uint64_t exp; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 356 | |
Martin Olsson | 8df662a | 2012-07-08 03:03:47 +0200 | [diff] [blame] | 357 | if (read(clock->clock_fd, &exp, sizeof exp) != sizeof exp) |
| 358 | abort(); |
Kristian Høgsberg | 92a984a | 2012-06-11 11:10:57 -0400 | [diff] [blame] | 359 | widget_schedule_redraw(clock->widget); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | static void |
| 363 | panel_clock_redraw_handler(struct widget *widget, void *data) |
| 364 | { |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 365 | struct panel_clock *clock = data; |
| 366 | cairo_t *cr; |
| 367 | struct rectangle allocation; |
| 368 | cairo_text_extents_t extents; |
| 369 | cairo_font_extents_t font_extents; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 370 | time_t rawtime; |
| 371 | struct tm * timeinfo; |
Kristian Høgsberg | 92a984a | 2012-06-11 11:10:57 -0400 | [diff] [blame] | 372 | char string[128]; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 373 | |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 374 | time(&rawtime); |
| 375 | timeinfo = localtime(&rawtime); |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 376 | strftime(string, sizeof string, clock->format_string, timeinfo); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 377 | |
| 378 | widget_get_allocation(widget, &allocation); |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 379 | if (allocation.width == 0) |
| 380 | return; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 381 | |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 382 | cr = widget_cairo_create(clock->panel->widget); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 383 | cairo_select_font_face(cr, "sans", |
| 384 | CAIRO_FONT_SLANT_NORMAL, |
| 385 | CAIRO_FONT_WEIGHT_NORMAL); |
| 386 | cairo_set_font_size(cr, 14); |
Kristian Høgsberg | 92a984a | 2012-06-11 11:10:57 -0400 | [diff] [blame] | 387 | cairo_text_extents(cr, string, &extents); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 388 | cairo_font_extents (cr, &font_extents); |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 389 | cairo_move_to(cr, allocation.x + 5, |
| 390 | allocation.y + 3 * (allocation.height >> 2) + 1); |
| 391 | cairo_set_source_rgb(cr, 0, 0, 0); |
Kristian Høgsberg | 92a984a | 2012-06-11 11:10:57 -0400 | [diff] [blame] | 392 | cairo_show_text(cr, string); |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 393 | cairo_move_to(cr, allocation.x + 4, |
| 394 | allocation.y + 3 * (allocation.height >> 2)); |
| 395 | cairo_set_source_rgb(cr, 1, 1, 1); |
Kristian Høgsberg | 92a984a | 2012-06-11 11:10:57 -0400 | [diff] [blame] | 396 | cairo_show_text(cr, string); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 397 | cairo_destroy(cr); |
| 398 | } |
| 399 | |
| 400 | static int |
| 401 | clock_timer_reset(struct panel_clock *clock) |
| 402 | { |
| 403 | struct itimerspec its; |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 404 | |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 405 | its.it_interval.tv_sec = clock->refresh_timer; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 406 | its.it_interval.tv_nsec = 0; |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 407 | its.it_value.tv_sec = clock->refresh_timer; |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 408 | its.it_value.tv_nsec = 0; |
| 409 | if (timerfd_settime(clock->clock_fd, 0, &its, NULL) < 0) { |
| 410 | fprintf(stderr, "could not set timerfd\n: %m"); |
| 411 | return -1; |
| 412 | } |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | static void |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 418 | panel_destroy_clock(struct panel_clock *clock) |
| 419 | { |
| 420 | widget_destroy(clock->widget); |
| 421 | |
| 422 | close(clock->clock_fd); |
| 423 | |
| 424 | free(clock); |
| 425 | } |
| 426 | |
| 427 | static void |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 428 | panel_add_clock(struct panel *panel) |
| 429 | { |
| 430 | struct panel_clock *clock; |
| 431 | int timerfd; |
| 432 | |
| 433 | timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); |
| 434 | if (timerfd < 0) { |
| 435 | fprintf(stderr, "could not create timerfd\n: %m"); |
| 436 | return; |
| 437 | } |
| 438 | |
Peter Hutterer | f3d6227 | 2013-08-08 11:57:05 +1000 | [diff] [blame] | 439 | clock = xzalloc(sizeof *clock); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 440 | clock->panel = panel; |
| 441 | panel->clock = clock; |
| 442 | clock->clock_fd = timerfd; |
| 443 | |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 444 | switch (panel->clock_format) { |
| 445 | case CLOCK_FORMAT_MINUTES: |
| 446 | clock->format_string = "%a %b %d, %I:%M %p"; |
| 447 | clock->refresh_timer = 60; |
| 448 | break; |
| 449 | case CLOCK_FORMAT_SECONDS: |
| 450 | clock->format_string = "%a %b %d, %I:%M:%S %p"; |
| 451 | clock->refresh_timer = 1; |
| 452 | break; |
Quentin Glidic | f9574f2 | 2016-06-23 18:55:21 +0200 | [diff] [blame^] | 453 | case CLOCK_FORMAT_NONE: |
| 454 | assert(!"not reached"); |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 455 | } |
| 456 | |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 457 | clock->clock_task.run = clock_func; |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 458 | display_watch_fd(window_get_display(panel->window), clock->clock_fd, |
| 459 | EPOLLIN, &clock->clock_task); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 460 | clock_timer_reset(clock); |
| 461 | |
| 462 | clock->widget = widget_add_widget(panel->widget, clock); |
Kristian Høgsberg | bb262cf | 2012-06-11 11:03:03 -0400 | [diff] [blame] | 463 | widget_set_redraw_handler(clock->widget, panel_clock_redraw_handler); |
Martin Minarik | 1e51a87 | 2012-06-08 00:39:11 +0200 | [diff] [blame] | 464 | } |
| 465 | |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 466 | static void |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 467 | panel_resize_handler(struct widget *widget, |
| 468 | int32_t width, int32_t height, void *data) |
| 469 | { |
| 470 | struct panel_launcher *launcher; |
| 471 | struct panel *panel = data; |
| 472 | int x, y, w, h; |
Michael Vetter | 2a18a52 | 2015-05-15 17:17:47 +0200 | [diff] [blame] | 473 | |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 474 | x = 10; |
| 475 | y = 16; |
| 476 | wl_list_for_each(launcher, &panel->launcher_list, link) { |
| 477 | w = cairo_image_surface_get_width(launcher->icon); |
| 478 | h = cairo_image_surface_get_height(launcher->icon); |
| 479 | widget_set_allocation(launcher->widget, |
| 480 | x, y - h / 2, w + 1, h + 1); |
| 481 | x += w + 10; |
| 482 | } |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 483 | |
| 484 | h = 20; |
| 485 | |
| 486 | if (panel->clock_format == CLOCK_FORMAT_SECONDS) |
| 487 | w = 190; |
| 488 | else /* CLOCK_FORMAT_MINUTES */ |
| 489 | w = 170; |
Pekka Paalanen | 01b1725 | 2012-06-12 17:42:26 +0300 | [diff] [blame] | 490 | |
| 491 | if (panel->clock) |
| 492 | widget_set_allocation(panel->clock->widget, |
| 493 | width - w - 8, y - h / 2, w + 1, h + 1); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | static void |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 497 | panel_configure(void *data, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 498 | struct weston_desktop_shell *desktop_shell, |
Kristian Høgsberg | eae5de7 | 2012-04-11 22:42:15 -0400 | [diff] [blame] | 499 | uint32_t edges, struct window *window, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 500 | int32_t width, int32_t height) |
| 501 | { |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 502 | struct surface *surface = window_get_user_data(window); |
| 503 | struct panel *panel = container_of(surface, struct panel, base); |
| 504 | |
| 505 | window_schedule_resize(panel->window, width, 32); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 506 | } |
| 507 | |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 508 | static void |
| 509 | panel_destroy_launcher(struct panel_launcher *launcher) |
| 510 | { |
| 511 | wl_array_release(&launcher->argv); |
| 512 | wl_array_release(&launcher->envp); |
| 513 | |
| 514 | free(launcher->path); |
| 515 | |
| 516 | cairo_surface_destroy(launcher->icon); |
| 517 | |
| 518 | widget_destroy(launcher->widget); |
| 519 | wl_list_remove(&launcher->link); |
| 520 | |
| 521 | free(launcher); |
| 522 | } |
| 523 | |
| 524 | static void |
| 525 | panel_destroy(struct panel *panel) |
| 526 | { |
| 527 | struct panel_launcher *tmp; |
| 528 | struct panel_launcher *launcher; |
| 529 | |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 530 | if (panel->clock) |
| 531 | panel_destroy_clock(panel->clock); |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 532 | |
| 533 | wl_list_for_each_safe(launcher, tmp, &panel->launcher_list, link) |
| 534 | panel_destroy_launcher(launcher); |
| 535 | |
| 536 | widget_destroy(panel->widget); |
| 537 | window_destroy(panel->window); |
| 538 | |
| 539 | free(panel); |
| 540 | } |
| 541 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 542 | static struct panel * |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 543 | panel_create(struct desktop *desktop) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 544 | { |
| 545 | struct panel *panel; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 546 | struct weston_config_section *s; |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 547 | char *clock_format_option = NULL; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 548 | |
Peter Hutterer | f3d6227 | 2013-08-08 11:57:05 +1000 | [diff] [blame] | 549 | panel = xzalloc(sizeof *panel); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 550 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 551 | panel->base.configure = panel_configure; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 552 | panel->window = window_create_custom(desktop->display); |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 553 | panel->widget = window_add_widget(panel->window, panel); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 554 | wl_list_init(&panel->launcher_list); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 555 | |
| 556 | window_set_title(panel->window, "panel"); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 557 | window_set_user_data(panel->window, panel); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 558 | |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 559 | widget_set_redraw_handler(panel->widget, panel_redraw_handler); |
| 560 | widget_set_resize_handler(panel->widget, panel_resize_handler); |
Michael Vetter | 2a18a52 | 2015-05-15 17:17:47 +0200 | [diff] [blame] | 561 | |
Armin Krezović | c6a55db | 2016-03-10 18:02:34 +0100 | [diff] [blame] | 562 | s = weston_config_get_section(desktop->config, "shell", NULL, NULL); |
| 563 | weston_config_section_get_string(s, "clock-format", &clock_format_option, ""); |
| 564 | |
| 565 | if (strcmp(clock_format_option, "minutes") == 0) |
| 566 | panel->clock_format = CLOCK_FORMAT_MINUTES; |
| 567 | else if (strcmp(clock_format_option, "seconds") == 0) |
| 568 | panel->clock_format = CLOCK_FORMAT_SECONDS; |
| 569 | else if (strcmp(clock_format_option, "none") == 0) |
| 570 | panel->clock_format = CLOCK_FORMAT_NONE; |
| 571 | else |
| 572 | panel->clock_format = DEFAULT_CLOCK_FORMAT; |
| 573 | |
| 574 | if (panel->clock_format != CLOCK_FORMAT_NONE) |
| 575 | panel_add_clock(panel); |
| 576 | |
| 577 | free (clock_format_option); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 578 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 579 | s = weston_config_get_section(desktop->config, "shell", NULL, NULL); |
Bryce Harrington | e776f2a | 2016-07-14 18:28:03 -0700 | [diff] [blame] | 580 | weston_config_section_get_color(s, "panel-color", |
| 581 | &panel->color, 0xaa000000); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 582 | |
| 583 | panel_add_launchers(panel, desktop); |
| 584 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 585 | return panel; |
| 586 | } |
| 587 | |
Philipp Brüschweiler | 467668c | 2012-08-29 10:53:36 +0200 | [diff] [blame] | 588 | static cairo_surface_t * |
| 589 | load_icon_or_fallback(const char *icon) |
| 590 | { |
| 591 | cairo_surface_t *surface = cairo_image_surface_create_from_png(icon); |
Philipp Brüschweiler | 96386b8 | 2013-04-15 20:10:40 +0200 | [diff] [blame] | 592 | cairo_status_t status; |
Philipp Brüschweiler | 467668c | 2012-08-29 10:53:36 +0200 | [diff] [blame] | 593 | cairo_t *cr; |
| 594 | |
Philipp Brüschweiler | 96386b8 | 2013-04-15 20:10:40 +0200 | [diff] [blame] | 595 | status = cairo_surface_status(surface); |
| 596 | if (status == CAIRO_STATUS_SUCCESS) |
Philipp Brüschweiler | 467668c | 2012-08-29 10:53:36 +0200 | [diff] [blame] | 597 | return surface; |
| 598 | |
| 599 | cairo_surface_destroy(surface); |
Philipp Brüschweiler | 96386b8 | 2013-04-15 20:10:40 +0200 | [diff] [blame] | 600 | fprintf(stderr, "ERROR loading icon from file '%s', error: '%s'\n", |
| 601 | icon, cairo_status_to_string(status)); |
Philipp Brüschweiler | 467668c | 2012-08-29 10:53:36 +0200 | [diff] [blame] | 602 | |
| 603 | /* draw fallback icon */ |
| 604 | surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
| 605 | 20, 20); |
| 606 | cr = cairo_create(surface); |
| 607 | |
| 608 | cairo_set_source_rgba(cr, 0.8, 0.8, 0.8, 1); |
| 609 | cairo_paint(cr); |
| 610 | |
| 611 | cairo_set_source_rgba(cr, 0, 0, 0, 1); |
| 612 | cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); |
| 613 | cairo_rectangle(cr, 0, 0, 20, 20); |
| 614 | cairo_move_to(cr, 4, 4); |
| 615 | cairo_line_to(cr, 16, 16); |
| 616 | cairo_move_to(cr, 4, 16); |
| 617 | cairo_line_to(cr, 16, 4); |
| 618 | cairo_stroke(cr); |
| 619 | |
| 620 | cairo_destroy(cr); |
| 621 | |
| 622 | return surface; |
| 623 | } |
| 624 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 625 | static void |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 626 | 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] | 627 | { |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 628 | struct panel_launcher *launcher; |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 629 | char *start, *p, *eq, **ps; |
| 630 | int i, j, k; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 631 | |
Peter Hutterer | f3d6227 | 2013-08-08 11:57:05 +1000 | [diff] [blame] | 632 | launcher = xzalloc(sizeof *launcher); |
Philipp Brüschweiler | 467668c | 2012-08-29 10:53:36 +0200 | [diff] [blame] | 633 | launcher->icon = load_icon_or_fallback(icon); |
U. Artie Eoff | 3c94677 | 2014-01-15 10:59:50 -0800 | [diff] [blame] | 634 | launcher->path = xstrdup(path); |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 635 | |
| 636 | wl_array_init(&launcher->envp); |
| 637 | wl_array_init(&launcher->argv); |
Pekka Paalanen | b6df4f7 | 2012-08-03 14:39:15 +0300 | [diff] [blame] | 638 | for (i = 0; environ[i]; i++) { |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 639 | ps = wl_array_add(&launcher->envp, sizeof *ps); |
Pekka Paalanen | b6df4f7 | 2012-08-03 14:39:15 +0300 | [diff] [blame] | 640 | *ps = environ[i]; |
Kristian Høgsberg | d1936b9 | 2012-07-23 22:59:33 -0400 | [diff] [blame] | 641 | } |
| 642 | j = 0; |
| 643 | |
| 644 | start = launcher->path; |
| 645 | while (*start) { |
| 646 | for (p = start, eq = NULL; *p && !isspace(*p); p++) |
| 647 | if (*p == '=') |
| 648 | eq = p; |
| 649 | |
| 650 | if (eq && j == 0) { |
| 651 | ps = launcher->envp.data; |
| 652 | for (k = 0; k < i; k++) |
| 653 | if (strncmp(ps[k], start, eq - start) == 0) { |
| 654 | ps[k] = start; |
| 655 | break; |
| 656 | } |
| 657 | if (k == i) { |
| 658 | ps = wl_array_add(&launcher->envp, sizeof *ps); |
| 659 | *ps = start; |
| 660 | i++; |
| 661 | } |
| 662 | } else { |
| 663 | ps = wl_array_add(&launcher->argv, sizeof *ps); |
| 664 | *ps = start; |
| 665 | j++; |
| 666 | } |
| 667 | |
| 668 | while (*p && isspace(*p)) |
| 669 | *p++ = '\0'; |
| 670 | |
| 671 | start = p; |
| 672 | } |
| 673 | |
| 674 | ps = wl_array_add(&launcher->envp, sizeof *ps); |
| 675 | *ps = NULL; |
| 676 | ps = wl_array_add(&launcher->argv, sizeof *ps); |
| 677 | *ps = NULL; |
| 678 | |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 679 | launcher->panel = panel; |
Kristian Høgsberg | 75bc667 | 2012-01-10 09:43:58 -0500 | [diff] [blame] | 680 | wl_list_insert(panel->launcher_list.prev, &launcher->link); |
| 681 | |
Kristian Høgsberg | 441338c | 2012-01-10 13:52:34 -0500 | [diff] [blame] | 682 | launcher->widget = widget_add_widget(panel->widget, launcher); |
Kristian Høgsberg | 5388080 | 2012-01-09 11:16:50 -0500 | [diff] [blame] | 683 | widget_set_enter_handler(launcher->widget, |
| 684 | panel_launcher_enter_handler); |
| 685 | widget_set_leave_handler(launcher->widget, |
| 686 | panel_launcher_leave_handler); |
| 687 | widget_set_button_handler(launcher->widget, |
| 688 | panel_launcher_button_handler); |
Rusty Lynch | 4384a24 | 2013-08-08 21:28:22 -0700 | [diff] [blame] | 689 | widget_set_touch_down_handler(launcher->widget, |
| 690 | panel_launcher_touch_down_handler); |
| 691 | widget_set_touch_up_handler(launcher->widget, |
| 692 | panel_launcher_touch_up_handler); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 693 | widget_set_redraw_handler(launcher->widget, |
| 694 | panel_launcher_redraw_handler); |
Tiago Vignatti | 6150072 | 2012-05-23 22:06:28 +0300 | [diff] [blame] | 695 | widget_set_motion_handler(launcher->widget, |
| 696 | panel_launcher_motion_handler); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 697 | } |
| 698 | |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 699 | enum { |
| 700 | BACKGROUND_SCALE, |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 701 | BACKGROUND_SCALE_CROP, |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 702 | BACKGROUND_TILE |
| 703 | }; |
| 704 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 705 | static void |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 706 | background_draw(struct widget *widget, void *data) |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 707 | { |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 708 | struct background *background = data; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 709 | cairo_surface_t *surface, *image; |
Kristian Høgsberg | 7e69000 | 2011-09-08 18:18:02 -0400 | [diff] [blame] | 710 | cairo_pattern_t *pattern; |
| 711 | cairo_matrix_t matrix; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 712 | cairo_t *cr; |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 713 | double im_w, im_h; |
| 714 | double sx, sy, s; |
| 715 | double tx, ty; |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 716 | struct rectangle allocation; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 717 | |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 718 | surface = window_get_surface(background->window); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 719 | |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 720 | cr = widget_cairo_create(background->widget); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 721 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 722 | cairo_set_source_rgba(cr, 0.0, 0.0, 0.2, 1.0); |
| 723 | cairo_paint(cr); |
| 724 | |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 725 | widget_get_allocation(widget, &allocation); |
Kristian Høgsberg | 8129bc0 | 2012-01-25 14:55:33 -0500 | [diff] [blame] | 726 | image = NULL; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 727 | if (background->image) |
| 728 | image = load_cairo_surface(background->image); |
Kristian Høgsberg | 4c3661f | 2014-04-21 22:54:37 -0700 | [diff] [blame] | 729 | else if (background->color == 0) |
| 730 | image = load_cairo_surface(DATADIR "/weston/pattern.png"); |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 731 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 732 | if (image && background->type != -1) { |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 733 | im_w = cairo_image_surface_get_width(image); |
| 734 | im_h = cairo_image_surface_get_height(image); |
| 735 | sx = im_w / allocation.width; |
| 736 | sy = im_h / allocation.height; |
| 737 | |
Kristian Høgsberg | 7e69000 | 2011-09-08 18:18:02 -0400 | [diff] [blame] | 738 | pattern = cairo_pattern_create_for_surface(image); |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 739 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 740 | switch (background->type) { |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 741 | case BACKGROUND_SCALE: |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 742 | cairo_matrix_init_scale(&matrix, sx, sy); |
| 743 | cairo_pattern_set_matrix(pattern, &matrix); |
Bill Spitzak | 79b7cb3 | 2014-05-08 20:00:35 -0700 | [diff] [blame] | 744 | cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD); |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 745 | break; |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 746 | case BACKGROUND_SCALE_CROP: |
| 747 | s = (sx < sy) ? sx : sy; |
| 748 | /* align center */ |
| 749 | tx = (im_w - s * allocation.width) * 0.5; |
| 750 | ty = (im_h - s * allocation.height) * 0.5; |
| 751 | cairo_matrix_init_translate(&matrix, tx, ty); |
| 752 | cairo_matrix_scale(&matrix, s, s); |
| 753 | cairo_pattern_set_matrix(pattern, &matrix); |
Bill Spitzak | 79b7cb3 | 2014-05-08 20:00:35 -0700 | [diff] [blame] | 754 | cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD); |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 755 | break; |
Kristian Høgsberg | 07f7294 | 2012-01-25 16:34:36 -0500 | [diff] [blame] | 756 | case BACKGROUND_TILE: |
| 757 | cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); |
| 758 | break; |
| 759 | } |
Pekka Paalanen | a402b05 | 2013-05-22 18:03:10 +0300 | [diff] [blame] | 760 | |
Kristian Høgsberg | 7e69000 | 2011-09-08 18:18:02 -0400 | [diff] [blame] | 761 | cairo_set_source(cr, pattern); |
| 762 | cairo_pattern_destroy (pattern); |
Kristian Høgsberg | 27d3866 | 2011-10-20 13:11:12 -0400 | [diff] [blame] | 763 | cairo_surface_destroy(image); |
Kristian Høgsberg | 8129bc0 | 2012-01-25 14:55:33 -0500 | [diff] [blame] | 764 | } else { |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 765 | set_hex_color(cr, background->color); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 766 | } |
| 767 | |
Kristian Høgsberg | 8129bc0 | 2012-01-25 14:55:33 -0500 | [diff] [blame] | 768 | cairo_paint(cr); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 769 | cairo_destroy(cr); |
| 770 | cairo_surface_destroy(surface); |
Pekka Paalanen | 9564c75 | 2012-10-24 09:43:08 +0300 | [diff] [blame] | 771 | |
Pekka Paalanen | 79346ab | 2013-05-22 18:03:09 +0300 | [diff] [blame] | 772 | background->painted = 1; |
| 773 | check_desktop_ready(background->window); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 774 | } |
| 775 | |
| 776 | static void |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 777 | background_configure(void *data, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 778 | struct weston_desktop_shell *desktop_shell, |
Kristian Høgsberg | eae5de7 | 2012-04-11 22:42:15 -0400 | [diff] [blame] | 779 | uint32_t edges, struct window *window, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 780 | int32_t width, int32_t height) |
| 781 | { |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 782 | struct background *background = |
| 783 | (struct background *) window_get_user_data(window); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 784 | |
Kristian Høgsberg | 4598f96 | 2014-01-01 16:32:09 -0800 | [diff] [blame] | 785 | widget_schedule_resize(background->widget, width, height); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | static void |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 789 | unlock_dialog_redraw_handler(struct widget *widget, void *data) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 790 | { |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 791 | struct unlock_dialog *dialog = data; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 792 | struct rectangle allocation; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 793 | cairo_surface_t *surface; |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 794 | cairo_t *cr; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 795 | cairo_pattern_t *pat; |
| 796 | double cx, cy, r, f; |
| 797 | |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 798 | cr = widget_cairo_create(widget); |
Kristian Høgsberg | 41c5c4e | 2012-03-05 20:37:51 -0500 | [diff] [blame] | 799 | |
Kristian Høgsberg | bb97700 | 2012-01-10 19:11:42 -0500 | [diff] [blame] | 800 | widget_get_allocation(dialog->widget, &allocation); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 801 | cairo_rectangle(cr, allocation.x, allocation.y, |
| 802 | allocation.width, allocation.height); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 803 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 804 | cairo_set_source_rgba(cr, 0, 0, 0, 0.6); |
Kristian Høgsberg | 41c5c4e | 2012-03-05 20:37:51 -0500 | [diff] [blame] | 805 | cairo_fill(cr); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 806 | |
Kristian Høgsberg | 41c5c4e | 2012-03-05 20:37:51 -0500 | [diff] [blame] | 807 | cairo_translate(cr, allocation.x, allocation.y); |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 808 | if (dialog->button_focused) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 809 | f = 1.0; |
| 810 | else |
| 811 | f = 0.7; |
| 812 | |
| 813 | cx = allocation.width / 2.0; |
| 814 | cy = allocation.height / 2.0; |
| 815 | r = (cx < cy ? cx : cy) * 0.4; |
| 816 | pat = cairo_pattern_create_radial(cx, cy, r * 0.7, cx, cy, r); |
| 817 | cairo_pattern_add_color_stop_rgb(pat, 0.0, 0, 0.86 * f, 0); |
| 818 | cairo_pattern_add_color_stop_rgb(pat, 0.85, 0.2 * f, f, 0.2 * f); |
| 819 | cairo_pattern_add_color_stop_rgb(pat, 1.0, 0, 0.86 * f, 0); |
| 820 | cairo_set_source(cr, pat); |
Kristian Høgsberg | 41c5c4e | 2012-03-05 20:37:51 -0500 | [diff] [blame] | 821 | cairo_pattern_destroy(pat); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 822 | cairo_arc(cr, cx, cy, r, 0.0, 2.0 * M_PI); |
| 823 | cairo_fill(cr); |
| 824 | |
Kristian Høgsberg | c51f799 | 2012-01-08 15:09:53 -0500 | [diff] [blame] | 825 | widget_set_allocation(dialog->button, |
Kristian Høgsberg | 41c5c4e | 2012-03-05 20:37:51 -0500 | [diff] [blame] | 826 | allocation.x + cx - r, |
| 827 | allocation.y + cy - r, 2 * r, 2 * r); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 828 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 829 | cairo_destroy(cr); |
| 830 | |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 831 | surface = window_get_surface(dialog->window); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 832 | cairo_surface_destroy(surface); |
| 833 | } |
| 834 | |
| 835 | static void |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 836 | unlock_dialog_button_handler(struct widget *widget, |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 837 | struct input *input, uint32_t time, |
Daniel Stone | 4dbadb1 | 2012-05-30 16:31:51 +0100 | [diff] [blame] | 838 | uint32_t button, |
| 839 | enum wl_pointer_button_state state, void *data) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 840 | { |
| 841 | struct unlock_dialog *dialog = data; |
| 842 | struct desktop *desktop = dialog->desktop; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 843 | |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 844 | if (button == BTN_LEFT) { |
Daniel Stone | 4dbadb1 | 2012-05-30 16:31:51 +0100 | [diff] [blame] | 845 | if (state == WL_POINTER_BUTTON_STATE_RELEASED && |
| 846 | !dialog->closing) { |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 847 | display_defer(desktop->display, &desktop->unlock_task); |
| 848 | dialog->closing = 1; |
| 849 | } |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | static void |
Brian J Lovin | c4df408 | 2013-08-26 15:58:22 -0700 | [diff] [blame] | 854 | unlock_dialog_touch_down_handler(struct widget *widget, struct input *input, |
| 855 | uint32_t serial, uint32_t time, int32_t id, |
| 856 | float x, float y, void *data) |
| 857 | { |
| 858 | struct unlock_dialog *dialog = data; |
| 859 | |
| 860 | dialog->button_focused = 1; |
| 861 | widget_schedule_redraw(widget); |
| 862 | } |
| 863 | |
| 864 | static void |
| 865 | unlock_dialog_touch_up_handler(struct widget *widget, struct input *input, |
| 866 | uint32_t serial, uint32_t time, int32_t id, |
| 867 | void *data) |
| 868 | { |
| 869 | struct unlock_dialog *dialog = data; |
| 870 | struct desktop *desktop = dialog->desktop; |
| 871 | |
| 872 | dialog->button_focused = 0; |
| 873 | widget_schedule_redraw(widget); |
| 874 | display_defer(desktop->display, &desktop->unlock_task); |
| 875 | dialog->closing = 1; |
| 876 | } |
| 877 | |
| 878 | static void |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 879 | unlock_dialog_keyboard_focus_handler(struct window *window, |
| 880 | struct input *device, void *data) |
| 881 | { |
| 882 | window_schedule_redraw(window); |
| 883 | } |
| 884 | |
Kristian Høgsberg | bb901fa | 2012-01-09 11:22:32 -0500 | [diff] [blame] | 885 | static int |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 886 | unlock_dialog_widget_enter_handler(struct widget *widget, |
Kristian Høgsberg | eae5de7 | 2012-04-11 22:42:15 -0400 | [diff] [blame] | 887 | struct input *input, |
Kristian Høgsberg | 80680c7 | 2012-05-10 12:21:37 -0400 | [diff] [blame] | 888 | float x, float y, void *data) |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 889 | { |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 890 | struct unlock_dialog *dialog = data; |
| 891 | |
| 892 | dialog->button_focused = 1; |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 893 | widget_schedule_redraw(widget); |
Kristian Høgsberg | bb901fa | 2012-01-09 11:22:32 -0500 | [diff] [blame] | 894 | |
Ander Conselvan de Oliveira | dc8c8fc | 2012-05-25 16:01:41 +0300 | [diff] [blame] | 895 | return CURSOR_LEFT_PTR; |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | static void |
| 899 | unlock_dialog_widget_leave_handler(struct widget *widget, |
| 900 | struct input *input, void *data) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 901 | { |
Kristian Høgsberg | b632351 | 2012-01-11 00:04:42 -0500 | [diff] [blame] | 902 | struct unlock_dialog *dialog = data; |
| 903 | |
| 904 | dialog->button_focused = 0; |
Kristian Høgsberg | 9a13dab | 2012-01-08 15:18:19 -0500 | [diff] [blame] | 905 | widget_schedule_redraw(widget); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | static struct unlock_dialog * |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 909 | unlock_dialog_create(struct desktop *desktop) |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 910 | { |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 911 | struct display *display = desktop->display; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 912 | struct unlock_dialog *dialog; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 913 | struct wl_surface *surface; |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 914 | |
Peter Hutterer | f3d6227 | 2013-08-08 11:57:05 +1000 | [diff] [blame] | 915 | dialog = xzalloc(sizeof *dialog); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 916 | |
Kristian Høgsberg | 730c94d | 2012-06-26 21:44:35 -0400 | [diff] [blame] | 917 | dialog->window = window_create_custom(display); |
Jason Ekstrand | ee7fefc | 2013-10-13 19:08:38 -0500 | [diff] [blame] | 918 | dialog->widget = window_frame_create(dialog->window, dialog); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 919 | window_set_title(dialog->window, "Unlock your desktop"); |
| 920 | |
| 921 | window_set_user_data(dialog->window, dialog); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 922 | window_set_keyboard_focus_handler(dialog->window, |
| 923 | unlock_dialog_keyboard_focus_handler); |
Kristian Høgsberg | 441338c | 2012-01-10 13:52:34 -0500 | [diff] [blame] | 924 | dialog->button = widget_add_widget(dialog->widget, dialog); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 925 | widget_set_redraw_handler(dialog->widget, |
| 926 | unlock_dialog_redraw_handler); |
Kristian Høgsberg | ee14323 | 2012-01-09 08:42:24 -0500 | [diff] [blame] | 927 | widget_set_enter_handler(dialog->button, |
| 928 | unlock_dialog_widget_enter_handler); |
| 929 | widget_set_leave_handler(dialog->button, |
| 930 | unlock_dialog_widget_leave_handler); |
Kristian Høgsberg | a8a0db3 | 2012-01-09 11:12:05 -0500 | [diff] [blame] | 931 | widget_set_button_handler(dialog->button, |
| 932 | unlock_dialog_button_handler); |
Brian J Lovin | c4df408 | 2013-08-26 15:58:22 -0700 | [diff] [blame] | 933 | widget_set_touch_down_handler(dialog->button, |
| 934 | unlock_dialog_touch_down_handler); |
| 935 | widget_set_touch_up_handler(dialog->button, |
| 936 | unlock_dialog_touch_up_handler); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 937 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 938 | surface = window_get_wl_surface(dialog->window); |
| 939 | weston_desktop_shell_set_lock_surface(desktop->shell, surface); |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 940 | |
Pekka Paalanen | 40e49ac | 2012-01-18 16:51:30 +0200 | [diff] [blame] | 941 | window_schedule_resize(dialog->window, 260, 230); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 942 | |
| 943 | return dialog; |
| 944 | } |
| 945 | |
| 946 | static void |
| 947 | unlock_dialog_destroy(struct unlock_dialog *dialog) |
| 948 | { |
| 949 | window_destroy(dialog->window); |
| 950 | free(dialog); |
| 951 | } |
| 952 | |
| 953 | static void |
| 954 | unlock_dialog_finish(struct task *task, uint32_t events) |
| 955 | { |
| 956 | struct desktop *desktop = |
Benjamin Franzke | d775971 | 2011-11-22 12:38:48 +0100 | [diff] [blame] | 957 | container_of(task, struct desktop, unlock_task); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 958 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 959 | weston_desktop_shell_unlock(desktop->shell); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 960 | unlock_dialog_destroy(desktop->unlock_dialog); |
| 961 | desktop->unlock_dialog = NULL; |
| 962 | } |
| 963 | |
| 964 | static void |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 965 | desktop_shell_configure(void *data, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 966 | struct weston_desktop_shell *desktop_shell, |
Kristian Høgsberg | eae5de7 | 2012-04-11 22:42:15 -0400 | [diff] [blame] | 967 | uint32_t edges, |
Kristian Høgsberg | 962342c | 2012-06-26 16:29:50 -0400 | [diff] [blame] | 968 | struct wl_surface *surface, |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 969 | int32_t width, int32_t height) |
| 970 | { |
Kristian Høgsberg | 962342c | 2012-06-26 16:29:50 -0400 | [diff] [blame] | 971 | struct window *window = wl_surface_get_user_data(surface); |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 972 | struct surface *s = window_get_user_data(window); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 973 | |
Kristian Høgsberg | eae5de7 | 2012-04-11 22:42:15 -0400 | [diff] [blame] | 974 | s->configure(data, desktop_shell, edges, window, width, height); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 975 | } |
| 976 | |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 977 | static void |
| 978 | desktop_shell_prepare_lock_surface(void *data, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 979 | struct weston_desktop_shell *desktop_shell) |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 980 | { |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 981 | struct desktop *desktop = data; |
| 982 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 983 | if (!desktop->locking) { |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 984 | weston_desktop_shell_unlock(desktop->shell); |
Pekka Paalanen | fd83b6d | 2011-12-08 10:06:53 +0200 | [diff] [blame] | 985 | return; |
| 986 | } |
| 987 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 988 | if (!desktop->unlock_dialog) { |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 989 | desktop->unlock_dialog = unlock_dialog_create(desktop); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 990 | desktop->unlock_dialog->desktop = desktop; |
| 991 | } |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 992 | } |
| 993 | |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 994 | static void |
| 995 | desktop_shell_grab_cursor(void *data, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 996 | struct weston_desktop_shell *desktop_shell, |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 997 | uint32_t cursor) |
| 998 | { |
| 999 | struct desktop *desktop = data; |
| 1000 | |
| 1001 | switch (cursor) { |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1002 | case WESTON_DESKTOP_SHELL_CURSOR_NONE: |
Philipp Brüschweiler | 16d59d7 | 2012-08-24 15:43:55 +0200 | [diff] [blame] | 1003 | desktop->grab_cursor = CURSOR_BLANK; |
| 1004 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1005 | case WESTON_DESKTOP_SHELL_CURSOR_BUSY: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1006 | desktop->grab_cursor = CURSOR_WATCH; |
| 1007 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1008 | case WESTON_DESKTOP_SHELL_CURSOR_MOVE: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1009 | desktop->grab_cursor = CURSOR_DRAGGING; |
| 1010 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1011 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_TOP: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1012 | desktop->grab_cursor = CURSOR_TOP; |
| 1013 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1014 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_BOTTOM: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1015 | desktop->grab_cursor = CURSOR_BOTTOM; |
| 1016 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1017 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_LEFT: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1018 | desktop->grab_cursor = CURSOR_LEFT; |
| 1019 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1020 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_RIGHT: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1021 | desktop->grab_cursor = CURSOR_RIGHT; |
| 1022 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1023 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_TOP_LEFT: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1024 | desktop->grab_cursor = CURSOR_TOP_LEFT; |
| 1025 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1026 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_TOP_RIGHT: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1027 | desktop->grab_cursor = CURSOR_TOP_RIGHT; |
| 1028 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1029 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_BOTTOM_LEFT: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1030 | desktop->grab_cursor = CURSOR_BOTTOM_LEFT; |
| 1031 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1032 | case WESTON_DESKTOP_SHELL_CURSOR_RESIZE_BOTTOM_RIGHT: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1033 | desktop->grab_cursor = CURSOR_BOTTOM_RIGHT; |
| 1034 | break; |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1035 | case WESTON_DESKTOP_SHELL_CURSOR_ARROW: |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1036 | default: |
| 1037 | desktop->grab_cursor = CURSOR_LEFT_PTR; |
| 1038 | } |
| 1039 | } |
| 1040 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1041 | static const struct weston_desktop_shell_listener listener = { |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1042 | desktop_shell_configure, |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1043 | desktop_shell_prepare_lock_surface, |
| 1044 | desktop_shell_grab_cursor |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1045 | }; |
| 1046 | |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1047 | static void |
| 1048 | background_destroy(struct background *background) |
| 1049 | { |
| 1050 | widget_destroy(background->widget); |
| 1051 | window_destroy(background->window); |
| 1052 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1053 | free(background->image); |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1054 | free(background); |
| 1055 | } |
| 1056 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1057 | static struct background * |
| 1058 | background_create(struct desktop *desktop) |
| 1059 | { |
| 1060 | struct background *background; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1061 | struct weston_config_section *s; |
| 1062 | char *type; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1063 | |
Peter Hutterer | f3d6227 | 2013-08-08 11:57:05 +1000 | [diff] [blame] | 1064 | background = xzalloc(sizeof *background); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1065 | background->base.configure = background_configure; |
Kristian Høgsberg | 962342c | 2012-06-26 16:29:50 -0400 | [diff] [blame] | 1066 | background->window = window_create_custom(desktop->display); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 1067 | background->widget = window_add_widget(background->window, background); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1068 | window_set_user_data(background->window, background); |
Kristian Høgsberg | b67e94b | 2012-01-10 12:23:19 -0500 | [diff] [blame] | 1069 | widget_set_redraw_handler(background->widget, background_draw); |
Arnaud Vrac | fb754a0 | 2014-08-25 20:56:49 +0200 | [diff] [blame] | 1070 | widget_set_transparent(background->widget, 0); |
Tomeu Vizoso | bee45a1 | 2013-08-06 20:05:54 +0200 | [diff] [blame] | 1071 | window_set_preferred_format(background->window, |
| 1072 | WINDOW_PREFERRED_FORMAT_RGB565); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1073 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1074 | s = weston_config_get_section(desktop->config, "shell", NULL, NULL); |
| 1075 | weston_config_section_get_string(s, "background-image", |
Kristian Høgsberg | 4c3661f | 2014-04-21 22:54:37 -0700 | [diff] [blame] | 1076 | &background->image, NULL); |
Bryce Harrington | e776f2a | 2016-07-14 18:28:03 -0700 | [diff] [blame] | 1077 | weston_config_section_get_color(s, "background-color", |
| 1078 | &background->color, 0x00000000); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1079 | |
| 1080 | weston_config_section_get_string(s, "background-type", |
| 1081 | &type, "tile"); |
U. Artie Eoff | 3c94677 | 2014-01-15 10:59:50 -0800 | [diff] [blame] | 1082 | if (type == NULL) { |
| 1083 | fprintf(stderr, "%s: out of memory\n", program_invocation_short_name); |
| 1084 | exit(EXIT_FAILURE); |
| 1085 | } |
| 1086 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1087 | if (strcmp(type, "scale") == 0) { |
| 1088 | background->type = BACKGROUND_SCALE; |
| 1089 | } else if (strcmp(type, "scale-crop") == 0) { |
| 1090 | background->type = BACKGROUND_SCALE_CROP; |
| 1091 | } else if (strcmp(type, "tile") == 0) { |
| 1092 | background->type = BACKGROUND_TILE; |
| 1093 | } else { |
| 1094 | background->type = -1; |
| 1095 | fprintf(stderr, "invalid background-type: %s\n", |
| 1096 | type); |
| 1097 | } |
| 1098 | |
| 1099 | free(type); |
| 1100 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1101 | return background; |
| 1102 | } |
| 1103 | |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1104 | static int |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1105 | grab_surface_enter_handler(struct widget *widget, struct input *input, |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1106 | float x, float y, void *data) |
| 1107 | { |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1108 | struct desktop *desktop = data; |
| 1109 | |
| 1110 | return desktop->grab_cursor; |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | static void |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1114 | grab_surface_destroy(struct desktop *desktop) |
| 1115 | { |
| 1116 | widget_destroy(desktop->grab_widget); |
| 1117 | window_destroy(desktop->grab_window); |
| 1118 | } |
| 1119 | |
| 1120 | static void |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1121 | grab_surface_create(struct desktop *desktop) |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1122 | { |
| 1123 | struct wl_surface *s; |
| 1124 | |
Ander Conselvan de Oliveira | 07a91cd | 2012-07-16 14:15:50 +0300 | [diff] [blame] | 1125 | desktop->grab_window = window_create_custom(desktop->display); |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1126 | window_set_user_data(desktop->grab_window, desktop); |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1127 | |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1128 | s = window_get_wl_surface(desktop->grab_window); |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1129 | weston_desktop_shell_set_grab_surface(desktop->shell, s); |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1130 | |
| 1131 | desktop->grab_widget = |
| 1132 | window_add_widget(desktop->grab_window, desktop); |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1133 | /* We set the allocation to 1x1 at 0,0 so the fake enter event |
| 1134 | * at 0,0 will go to this widget. */ |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1135 | widget_set_allocation(desktop->grab_widget, 0, 0, 1, 1); |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1136 | |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1137 | widget_set_enter_handler(desktop->grab_widget, |
| 1138 | grab_surface_enter_handler); |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1139 | } |
| 1140 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1141 | static void |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1142 | output_destroy(struct output *output) |
| 1143 | { |
| 1144 | background_destroy(output->background); |
Jonny Lamb | e67118c | 2014-08-12 15:07:51 +0200 | [diff] [blame] | 1145 | if (output->panel) |
| 1146 | panel_destroy(output->panel); |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1147 | wl_output_destroy(output->output); |
| 1148 | wl_list_remove(&output->link); |
| 1149 | |
| 1150 | free(output); |
| 1151 | } |
| 1152 | |
| 1153 | static void |
| 1154 | desktop_destroy_outputs(struct desktop *desktop) |
| 1155 | { |
| 1156 | struct output *tmp; |
| 1157 | struct output *output; |
| 1158 | |
| 1159 | wl_list_for_each_safe(output, tmp, &desktop->outputs, link) |
| 1160 | output_destroy(output); |
| 1161 | } |
| 1162 | |
| 1163 | static void |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 1164 | output_handle_geometry(void *data, |
| 1165 | struct wl_output *wl_output, |
| 1166 | int x, int y, |
| 1167 | int physical_width, |
| 1168 | int physical_height, |
| 1169 | int subpixel, |
| 1170 | const char *make, |
| 1171 | const char *model, |
| 1172 | int transform) |
| 1173 | { |
| 1174 | struct output *output = data; |
| 1175 | |
Jonny Lamb | e67118c | 2014-08-12 15:07:51 +0200 | [diff] [blame] | 1176 | if (output->panel) |
| 1177 | window_set_buffer_transform(output->panel->window, transform); |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 1178 | window_set_buffer_transform(output->background->window, transform); |
| 1179 | } |
| 1180 | |
| 1181 | static void |
| 1182 | output_handle_mode(void *data, |
| 1183 | struct wl_output *wl_output, |
| 1184 | uint32_t flags, |
| 1185 | int width, |
| 1186 | int height, |
| 1187 | int refresh) |
| 1188 | { |
| 1189 | } |
| 1190 | |
| 1191 | static void |
| 1192 | output_handle_done(void *data, |
| 1193 | struct wl_output *wl_output) |
| 1194 | { |
| 1195 | } |
| 1196 | |
| 1197 | static void |
| 1198 | output_handle_scale(void *data, |
| 1199 | struct wl_output *wl_output, |
Alexander Larsson | edddbd1 | 2013-05-24 13:09:43 +0200 | [diff] [blame] | 1200 | int32_t scale) |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 1201 | { |
| 1202 | struct output *output = data; |
| 1203 | |
Jonny Lamb | e67118c | 2014-08-12 15:07:51 +0200 | [diff] [blame] | 1204 | if (output->panel) |
| 1205 | window_set_buffer_scale(output->panel->window, scale); |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 1206 | window_set_buffer_scale(output->background->window, scale); |
| 1207 | } |
| 1208 | |
| 1209 | static const struct wl_output_listener output_listener = { |
| 1210 | output_handle_geometry, |
| 1211 | output_handle_mode, |
| 1212 | output_handle_done, |
| 1213 | output_handle_scale |
| 1214 | }; |
| 1215 | |
| 1216 | static void |
Ander Conselvan de Oliveira | e492549 | 2013-07-05 16:05:28 +0300 | [diff] [blame] | 1217 | output_init(struct output *output, struct desktop *desktop) |
| 1218 | { |
| 1219 | struct wl_surface *surface; |
| 1220 | |
Quentin Glidic | 55d5701 | 2016-06-23 18:55:18 +0200 | [diff] [blame] | 1221 | if (desktop->want_panel) { |
Jonny Lamb | e67118c | 2014-08-12 15:07:51 +0200 | [diff] [blame] | 1222 | output->panel = panel_create(desktop); |
| 1223 | surface = window_get_wl_surface(output->panel->window); |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1224 | weston_desktop_shell_set_panel(desktop->shell, |
| 1225 | output->output, surface); |
Jonny Lamb | e67118c | 2014-08-12 15:07:51 +0200 | [diff] [blame] | 1226 | } |
Ander Conselvan de Oliveira | e492549 | 2013-07-05 16:05:28 +0300 | [diff] [blame] | 1227 | |
| 1228 | output->background = background_create(desktop); |
| 1229 | surface = window_get_wl_surface(output->background->window); |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1230 | weston_desktop_shell_set_background(desktop->shell, |
| 1231 | output->output, surface); |
Ander Conselvan de Oliveira | e492549 | 2013-07-05 16:05:28 +0300 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | static void |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1235 | create_output(struct desktop *desktop, uint32_t id) |
| 1236 | { |
| 1237 | struct output *output; |
| 1238 | |
Bryce Harrington | 0d1a622 | 2016-02-11 16:42:49 -0800 | [diff] [blame] | 1239 | output = zalloc(sizeof *output); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1240 | if (!output) |
| 1241 | return; |
| 1242 | |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 1243 | output->output = |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 1244 | display_bind(desktop->display, id, &wl_output_interface, 2); |
Xiong Zhang | 83d8ee7 | 2013-10-23 13:58:35 +0800 | [diff] [blame] | 1245 | output->server_output_id = id; |
Alexander Larsson | c584fa6 | 2013-05-22 14:41:32 +0200 | [diff] [blame] | 1246 | |
| 1247 | wl_output_add_listener(output->output, &output_listener, output); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1248 | |
| 1249 | wl_list_insert(&desktop->outputs, &output->link); |
Ander Conselvan de Oliveira | e492549 | 2013-07-05 16:05:28 +0300 | [diff] [blame] | 1250 | |
| 1251 | /* On start up we may process an output global before the shell global |
| 1252 | * in which case we can't create the panel and background just yet */ |
| 1253 | if (desktop->shell) |
| 1254 | output_init(output, desktop); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1255 | } |
| 1256 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1257 | static void |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 1258 | global_handler(struct display *display, uint32_t id, |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1259 | const char *interface, uint32_t version, void *data) |
| 1260 | { |
| 1261 | struct desktop *desktop = data; |
| 1262 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1263 | if (!strcmp(interface, "weston_desktop_shell")) { |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 1264 | desktop->shell = display_bind(desktop->display, |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1265 | id, |
| 1266 | &weston_desktop_shell_interface, |
| 1267 | 1); |
| 1268 | weston_desktop_shell_add_listener(desktop->shell, |
| 1269 | &listener, |
| 1270 | desktop); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1271 | } else if (!strcmp(interface, "wl_output")) { |
| 1272 | create_output(desktop, id); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1273 | } |
| 1274 | } |
| 1275 | |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 1276 | static void |
Xiong Zhang | 83d8ee7 | 2013-10-23 13:58:35 +0800 | [diff] [blame] | 1277 | global_handler_remove(struct display *display, uint32_t id, |
| 1278 | const char *interface, uint32_t version, void *data) |
| 1279 | { |
| 1280 | struct desktop *desktop = data; |
| 1281 | struct output *output; |
| 1282 | |
| 1283 | if (!strcmp(interface, "wl_output")) { |
| 1284 | wl_list_for_each(output, &desktop->outputs, link) { |
| 1285 | if (output->server_output_id == id) { |
| 1286 | output_destroy(output); |
| 1287 | break; |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | static void |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1294 | panel_add_launchers(struct panel *panel, struct desktop *desktop) |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 1295 | { |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1296 | struct weston_config_section *s; |
| 1297 | char *icon, *path; |
| 1298 | const char *name; |
| 1299 | int count; |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 1300 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1301 | count = 0; |
| 1302 | s = NULL; |
| 1303 | while (weston_config_next_section(desktop->config, &s, &name)) { |
| 1304 | if (strcmp(name, "launcher") != 0) |
| 1305 | continue; |
| 1306 | |
| 1307 | weston_config_section_get_string(s, "icon", &icon, NULL); |
| 1308 | weston_config_section_get_string(s, "path", &path, NULL); |
| 1309 | |
| 1310 | if (icon != NULL && path != NULL) { |
| 1311 | panel_add_launcher(panel, icon, path); |
Rob Bradford | 09252d4 | 2013-07-26 16:29:45 +0100 | [diff] [blame] | 1312 | count++; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1313 | } else { |
| 1314 | fprintf(stderr, "invalid launcher section\n"); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | free(icon); |
| 1318 | free(path); |
Kristian Høgsberg | ac3a59a | 2011-11-14 22:43:37 -0500 | [diff] [blame] | 1319 | } |
| 1320 | |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1321 | if (count == 0) { |
| 1322 | /* add default launcher */ |
| 1323 | panel_add_launcher(panel, |
Kristian Høgsberg | 6af8eb9 | 2012-01-25 16:57:11 -0500 | [diff] [blame] | 1324 | DATADIR "/weston/terminal.png", |
Rodney Lorrimar | 99ff01b | 2012-02-29 17:31:03 +0100 | [diff] [blame] | 1325 | BINDIR "/weston-terminal"); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1326 | } |
Kristian Høgsberg | 6af8eb9 | 2012-01-25 16:57:11 -0500 | [diff] [blame] | 1327 | } |
| 1328 | |
Quentin Glidic | 55d5701 | 2016-06-23 18:55:18 +0200 | [diff] [blame] | 1329 | static void |
| 1330 | parse_panel_position(struct desktop *desktop, struct weston_config_section *s) |
| 1331 | { |
| 1332 | char *position; |
| 1333 | |
| 1334 | weston_config_section_get_string(s, "panel-position", &position, "top"); |
| 1335 | if (strcmp(position, "top") == 0) |
| 1336 | desktop->panel_position = WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP; |
| 1337 | else if (strcmp(position, "bottom") == 0) |
| 1338 | desktop->panel_position = WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM; |
| 1339 | else if (strcmp(position, "left") == 0) |
| 1340 | desktop->panel_position = WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT; |
| 1341 | else if (strcmp(position, "right") == 0) |
| 1342 | desktop->panel_position = WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT; |
| 1343 | else |
| 1344 | fprintf(stderr, "Wrong panel position: %s\n", position); |
| 1345 | free(position); |
| 1346 | |
| 1347 | if (desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP |
| 1348 | || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM) { |
| 1349 | desktop->want_panel = 1; |
| 1350 | } else if (desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT |
| 1351 | || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT) { |
| 1352 | fprintf(stderr, "Unsupported panel position\n"); |
| 1353 | } |
| 1354 | } |
| 1355 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1356 | int main(int argc, char *argv[]) |
| 1357 | { |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 1358 | struct desktop desktop = { 0 }; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1359 | struct output *output; |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1360 | struct weston_config_section *s; |
Pekka Paalanen | 6c71aae | 2015-03-24 15:56:19 +0200 | [diff] [blame] | 1361 | const char *config_file; |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1362 | |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 1363 | desktop.unlock_task.run = unlock_dialog_finish; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1364 | wl_list_init(&desktop.outputs); |
Pekka Paalanen | bfbb26b | 2011-11-15 13:34:56 +0200 | [diff] [blame] | 1365 | |
Pekka Paalanen | 6c71aae | 2015-03-24 15:56:19 +0200 | [diff] [blame] | 1366 | config_file = weston_config_get_name_from_env(); |
| 1367 | desktop.config = weston_config_parse(config_file); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1368 | s = weston_config_get_section(desktop.config, "shell", NULL, NULL); |
| 1369 | weston_config_section_get_bool(s, "locking", &desktop.locking, 1); |
Quentin Glidic | 55d5701 | 2016-06-23 18:55:18 +0200 | [diff] [blame] | 1370 | parse_panel_position(&desktop, s); |
Ander Conselvan de Oliveira | 6d75da7 | 2013-07-05 16:05:27 +0300 | [diff] [blame] | 1371 | |
Kristian Høgsberg | 4172f66 | 2013-02-20 15:27:49 -0500 | [diff] [blame] | 1372 | desktop.display = display_create(&argc, argv); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1373 | if (desktop.display == NULL) { |
| 1374 | fprintf(stderr, "failed to create display: %m\n"); |
| 1375 | return -1; |
| 1376 | } |
| 1377 | |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1378 | display_set_user_data(desktop.display, &desktop); |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 1379 | display_set_global_handler(desktop.display, global_handler); |
Xiong Zhang | 83d8ee7 | 2013-10-23 13:58:35 +0800 | [diff] [blame] | 1380 | display_set_global_handler_remove(desktop.display, global_handler_remove); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1381 | |
Ander Conselvan de Oliveira | e492549 | 2013-07-05 16:05:28 +0300 | [diff] [blame] | 1382 | /* Create panel and background for outputs processed before the shell |
| 1383 | * global interface was processed */ |
Quentin Glidic | 55d5701 | 2016-06-23 18:55:18 +0200 | [diff] [blame] | 1384 | if (desktop.want_panel) |
| 1385 | weston_desktop_shell_set_panel_position(desktop.shell, desktop.panel_position); |
Ander Conselvan de Oliveira | e492549 | 2013-07-05 16:05:28 +0300 | [diff] [blame] | 1386 | wl_list_for_each(output, &desktop.outputs, link) |
| 1387 | if (!output->panel) |
| 1388 | output_init(output, &desktop); |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1389 | |
Ander Conselvan de Oliveira | b9d2a0f | 2012-06-28 18:08:05 +0300 | [diff] [blame] | 1390 | grab_surface_create(&desktop); |
Kristian Høgsberg | d56bd90 | 2012-06-05 09:58:51 -0400 | [diff] [blame] | 1391 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1392 | signal(SIGCHLD, sigchild_handler); |
| 1393 | |
| 1394 | display_run(desktop.display); |
| 1395 | |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1396 | /* Cleanup */ |
| 1397 | grab_surface_destroy(&desktop); |
| 1398 | desktop_destroy_outputs(&desktop); |
| 1399 | if (desktop.unlock_dialog) |
| 1400 | unlock_dialog_destroy(desktop.unlock_dialog); |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 1401 | weston_desktop_shell_destroy(desktop.shell); |
U. Artie Eoff | 44874d9 | 2012-10-02 21:12:35 -0700 | [diff] [blame] | 1402 | display_destroy(desktop.display); |
| 1403 | |
Kristian Høgsberg | 0c29eb2 | 2011-09-06 18:02:34 -0400 | [diff] [blame] | 1404 | return 0; |
| 1405 | } |