Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2010 Intel Corporation |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 3 | * Copyright © 2011 Collabora, Ltd. |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 4 | * |
| 5 | * Permission to use, copy, modify, distribute, and sell this software and |
| 6 | * its documentation for any purpose is hereby granted without fee, provided |
| 7 | * that the above copyright notice appear in all copies and that both that |
| 8 | * copyright notice and this permission notice appear in supporting |
| 9 | * documentation, and that the name of the copyright holders not be used in |
| 10 | * advertising or publicity pertaining to distribution of the software |
| 11 | * without specific, written prior permission. The copyright holders make |
| 12 | * no representations about the suitability of this software for any |
| 13 | * purpose. It is provided "as is" without express or implied warranty. |
| 14 | * |
| 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include <stdlib.h> |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 25 | #include <stdio.h> |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 26 | #include <stdbool.h> |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 27 | #include <string.h> |
| 28 | #include <unistd.h> |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 29 | #include <linux/input.h> |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 30 | #include <assert.h> |
Pekka Paalanen | 18027e5 | 2011-12-02 16:31:49 +0200 | [diff] [blame] | 31 | #include <signal.h> |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 32 | |
Pekka Paalanen | 50719bc | 2011-11-22 14:18:50 +0200 | [diff] [blame] | 33 | #include <wayland-server.h> |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 34 | #include "compositor.h" |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 35 | #include "desktop-shell-server-protocol.h" |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 36 | #include "../shared/config-parser.h" |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 37 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 38 | struct shell_surface; |
| 39 | |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 40 | struct wl_shell { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 41 | struct weston_compositor *compositor; |
| 42 | struct weston_shell shell; |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 43 | |
| 44 | struct { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 45 | struct weston_process process; |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 46 | struct wl_client *client; |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 47 | struct wl_resource *desktop_shell; |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 48 | } child; |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 49 | |
| 50 | bool locked; |
| 51 | bool prepare_event_sent; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 52 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 53 | struct shell_surface *lock_surface; |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 54 | struct wl_listener lock_surface_listener; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 55 | struct wl_list hidden_surface_list; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 56 | |
| 57 | struct wl_list backgrounds; |
| 58 | struct wl_list panels; |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 59 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 60 | struct { |
Pekka Paalanen | 3c64723 | 2011-12-22 13:43:43 +0200 | [diff] [blame] | 61 | char *path; |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 62 | int duration; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 63 | struct wl_resource *binding; |
| 64 | struct wl_list surfaces; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 65 | struct weston_process process; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 66 | } screensaver; |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 67 | }; |
| 68 | |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 69 | enum shell_surface_type { |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 70 | SHELL_SURFACE_NONE, |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 71 | |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 72 | SHELL_SURFACE_PANEL, |
| 73 | SHELL_SURFACE_BACKGROUND, |
| 74 | SHELL_SURFACE_LOCK, |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 75 | SHELL_SURFACE_SCREENSAVER, |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 76 | |
| 77 | SHELL_SURFACE_TOPLEVEL, |
| 78 | SHELL_SURFACE_TRANSIENT, |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 79 | SHELL_SURFACE_FULLSCREEN, |
| 80 | SHELL_SURFACE_POPUP |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
Pekka Paalanen | 56cdea9 | 2011-11-23 16:14:12 +0200 | [diff] [blame] | 83 | struct shell_surface { |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 84 | struct wl_resource resource; |
| 85 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 86 | struct weston_surface *surface; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 87 | struct wl_listener surface_destroy_listener; |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 88 | struct shell_surface *parent; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 89 | |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 90 | enum shell_surface_type type; |
| 91 | int32_t saved_x, saved_y; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 92 | |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 93 | struct { |
| 94 | struct wl_grab grab; |
| 95 | uint32_t time; |
| 96 | int32_t x, y; |
| 97 | int32_t initial_up; |
| 98 | } popup; |
| 99 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 100 | struct weston_output *output; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 101 | struct wl_list link; |
Pekka Paalanen | 56cdea9 | 2011-11-23 16:14:12 +0200 | [diff] [blame] | 102 | }; |
| 103 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 104 | struct weston_move_grab { |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 105 | struct wl_grab grab; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 106 | struct weston_surface *surface; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 107 | int32_t dx, dy; |
| 108 | }; |
| 109 | |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 110 | static int |
| 111 | shell_configuration(struct wl_shell *shell) |
| 112 | { |
| 113 | int ret; |
| 114 | char *config_file; |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 115 | char *path = NULL; |
| 116 | int duration = 60; |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 117 | |
| 118 | struct config_key saver_keys[] = { |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 119 | { "path", CONFIG_KEY_STRING, &path }, |
| 120 | { "duration", CONFIG_KEY_INTEGER, &duration }, |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | struct config_section cs[] = { |
| 124 | { "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL }, |
| 125 | }; |
| 126 | |
Kristian Høgsberg | 9724b51 | 2012-01-03 14:35:49 -0500 | [diff] [blame] | 127 | config_file = config_file_path("weston-desktop-shell.ini"); |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 128 | ret = parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell); |
| 129 | free(config_file); |
| 130 | |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 131 | shell->screensaver.path = path; |
| 132 | shell->screensaver.duration = duration; |
| 133 | |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 134 | return ret; |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 135 | } |
| 136 | |
Pekka Paalanen | 56cdea9 | 2011-11-23 16:14:12 +0200 | [diff] [blame] | 137 | static void |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 138 | noop_grab_focus(struct wl_grab *grab, uint32_t time, |
| 139 | struct wl_surface *surface, int32_t x, int32_t y) |
| 140 | { |
| 141 | grab->focus = NULL; |
| 142 | } |
| 143 | |
| 144 | static void |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 145 | move_grab_motion(struct wl_grab *grab, |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 146 | uint32_t time, int32_t x, int32_t y) |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 147 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 148 | struct weston_move_grab *move = (struct weston_move_grab *) grab; |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 149 | struct wl_input_device *device = grab->input_device; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 150 | struct weston_surface *es = move->surface; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 151 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 152 | weston_surface_configure(es, |
| 153 | device->x + move->dx, |
| 154 | device->y + move->dy, |
| 155 | es->width, es->height); |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static void |
| 159 | move_grab_button(struct wl_grab *grab, |
| 160 | uint32_t time, int32_t button, int32_t state) |
| 161 | { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 162 | struct wl_input_device *device = grab->input_device; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 163 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 164 | if (device->button_count == 0 && state == 0) { |
| 165 | wl_input_device_end_grab(device, time); |
| 166 | free(grab); |
| 167 | } |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | static const struct wl_grab_interface move_grab_interface = { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 171 | noop_grab_focus, |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 172 | move_grab_motion, |
| 173 | move_grab_button, |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 174 | }; |
| 175 | |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 176 | static int |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 177 | weston_surface_move(struct weston_surface *es, |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 178 | struct weston_input_device *wd, uint32_t time) |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 179 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 180 | struct weston_move_grab *move; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 181 | |
| 182 | move = malloc(sizeof *move); |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 183 | if (!move) |
| 184 | return -1; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 185 | |
| 186 | move->grab.interface = &move_grab_interface; |
| 187 | move->dx = es->x - wd->input_device.grab_x; |
| 188 | move->dy = es->y - wd->input_device.grab_y; |
Kristian Høgsberg | dd4046a | 2011-01-21 17:00:09 -0500 | [diff] [blame] | 189 | move->surface = es; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 190 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 191 | wl_input_device_start_grab(&wd->input_device, &move->grab, time); |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 192 | |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 193 | wl_input_device_set_pointer_focus(&wd->input_device, |
| 194 | NULL, time, 0, 0, 0, 0); |
| 195 | |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static void |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 200 | shell_surface_move(struct wl_client *client, struct wl_resource *resource, |
| 201 | struct wl_resource *input_resource, uint32_t time) |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 202 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 203 | struct weston_input_device *wd = input_resource->data; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 204 | struct shell_surface *shsurf = resource->data; |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 205 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 206 | if (wd->input_device.button_count == 0 || |
| 207 | wd->input_device.grab_time != time || |
| 208 | wd->input_device.pointer_focus != &shsurf->surface->surface) |
| 209 | return; |
| 210 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 211 | if (weston_surface_move(shsurf->surface, wd, time) < 0) |
Kristian Høgsberg | 9ebcf94 | 2011-09-01 09:54:57 -0400 | [diff] [blame] | 212 | wl_resource_post_no_memory(resource); |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 213 | } |
| 214 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 215 | struct weston_resize_grab { |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 216 | struct wl_grab grab; |
| 217 | uint32_t edges; |
| 218 | int32_t dx, dy, width, height; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 219 | struct shell_surface *shsurf; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | static void |
| 223 | resize_grab_motion(struct wl_grab *grab, |
| 224 | uint32_t time, int32_t x, int32_t y) |
| 225 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 226 | struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 227 | struct wl_input_device *device = grab->input_device; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 228 | int32_t width, height; |
| 229 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 230 | if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 231 | width = device->grab_x - device->x + resize->width; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 232 | } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 233 | width = device->x - device->grab_x + resize->width; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 234 | } else { |
| 235 | width = resize->width; |
| 236 | } |
| 237 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 238 | if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 239 | height = device->grab_y - device->y + resize->height; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 240 | } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 241 | height = device->y - device->grab_y + resize->height; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 242 | } else { |
| 243 | height = resize->height; |
| 244 | } |
| 245 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 246 | wl_resource_post_event(&resize->shsurf->resource, |
| 247 | WL_SHELL_SURFACE_CONFIGURE, time, resize->edges, |
| 248 | width, height); |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static void |
| 252 | resize_grab_button(struct wl_grab *grab, |
| 253 | uint32_t time, int32_t button, int32_t state) |
| 254 | { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 255 | struct wl_input_device *device = grab->input_device; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 256 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 257 | if (device->button_count == 0 && state == 0) { |
| 258 | wl_input_device_end_grab(device, time); |
| 259 | free(grab); |
| 260 | } |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | static const struct wl_grab_interface resize_grab_interface = { |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 264 | noop_grab_focus, |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 265 | resize_grab_motion, |
| 266 | resize_grab_button, |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 267 | }; |
| 268 | |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 269 | static int |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 270 | weston_surface_resize(struct shell_surface *shsurf, |
| 271 | struct weston_input_device *wd, |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 272 | uint32_t time, uint32_t edges) |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 273 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 274 | struct weston_resize_grab *resize; |
| 275 | struct weston_surface *es = shsurf->surface; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 276 | |
Kristian Høgsberg | 0ce2457 | 2011-01-28 15:18:33 -0500 | [diff] [blame] | 277 | /* FIXME: Reject if fullscreen */ |
| 278 | |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 279 | resize = malloc(sizeof *resize); |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 280 | if (!resize) |
| 281 | return -1; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 282 | |
| 283 | resize->grab.interface = &resize_grab_interface; |
| 284 | resize->edges = edges; |
| 285 | resize->dx = es->x - wd->input_device.grab_x; |
| 286 | resize->dy = es->y - wd->input_device.grab_y; |
| 287 | resize->width = es->width; |
| 288 | resize->height = es->height; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 289 | resize->shsurf = shsurf; |
Kristian Høgsberg | 904055a | 2011-08-18 17:55:30 -0400 | [diff] [blame] | 290 | |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 291 | if (edges == 0 || edges > 15 || |
| 292 | (edges & 3) == 3 || (edges & 12) == 12) |
Pekka Paalanen | 61b5c67 | 2012-01-04 14:09:05 +0200 | [diff] [blame] | 293 | goto err_out; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 294 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 295 | wl_input_device_start_grab(&wd->input_device, &resize->grab, time); |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 296 | |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 297 | wl_input_device_set_pointer_focus(&wd->input_device, |
| 298 | NULL, time, 0, 0, 0, 0); |
| 299 | |
| 300 | return 0; |
Pekka Paalanen | 61b5c67 | 2012-01-04 14:09:05 +0200 | [diff] [blame] | 301 | |
| 302 | err_out: |
| 303 | free(resize); |
| 304 | return 0; |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | static void |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 308 | shell_surface_resize(struct wl_client *client, struct wl_resource *resource, |
| 309 | struct wl_resource *input_resource, uint32_t time, |
| 310 | uint32_t edges) |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 311 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 312 | struct weston_input_device *wd = input_resource->data; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 313 | struct shell_surface *shsurf = resource->data; |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 314 | |
| 315 | /* FIXME: Reject if fullscreen */ |
| 316 | |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 317 | if (wd->input_device.button_count == 0 || |
| 318 | wd->input_device.grab_time != time || |
| 319 | wd->input_device.pointer_focus != &shsurf->surface->surface) |
| 320 | return; |
| 321 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 322 | if (weston_surface_resize(shsurf, wd, time, edges) < 0) |
Kristian Høgsberg | 9ebcf94 | 2011-09-01 09:54:57 -0400 | [diff] [blame] | 323 | wl_resource_post_no_memory(resource); |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 324 | } |
| 325 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 326 | static int |
| 327 | reset_shell_surface_type(struct shell_surface *surface) |
| 328 | { |
| 329 | switch (surface->type) { |
| 330 | case SHELL_SURFACE_FULLSCREEN: |
| 331 | surface->surface->x = surface->saved_x; |
| 332 | surface->surface->y = surface->saved_y; |
| 333 | surface->surface->fullscreen_output = NULL; |
| 334 | break; |
| 335 | case SHELL_SURFACE_PANEL: |
| 336 | case SHELL_SURFACE_BACKGROUND: |
| 337 | wl_list_remove(&surface->link); |
| 338 | wl_list_init(&surface->link); |
| 339 | break; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 340 | case SHELL_SURFACE_SCREENSAVER: |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 341 | case SHELL_SURFACE_LOCK: |
| 342 | wl_resource_post_error(&surface->resource, |
| 343 | WL_DISPLAY_ERROR_INVALID_METHOD, |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 344 | "cannot reassign surface type"); |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 345 | return -1; |
| 346 | case SHELL_SURFACE_NONE: |
| 347 | case SHELL_SURFACE_TOPLEVEL: |
| 348 | case SHELL_SURFACE_TRANSIENT: |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 349 | case SHELL_SURFACE_POPUP: |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 350 | break; |
| 351 | } |
| 352 | |
| 353 | surface->type = SHELL_SURFACE_NONE; |
| 354 | return 0; |
| 355 | } |
| 356 | |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 357 | static void |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 358 | shell_surface_set_toplevel(struct wl_client *client, |
| 359 | struct wl_resource *resource) |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 360 | |
| 361 | { |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 362 | struct shell_surface *surface = resource->data; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 363 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 364 | if (reset_shell_surface_type(surface)) |
| 365 | return; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 366 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 367 | weston_surface_damage(surface->surface); |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 368 | surface->type = SHELL_SURFACE_TOPLEVEL; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | static void |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 372 | shell_surface_set_transient(struct wl_client *client, |
| 373 | struct wl_resource *resource, |
| 374 | struct wl_resource *parent_resource, |
| 375 | int x, int y, uint32_t flags) |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 376 | { |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 377 | struct shell_surface *shsurf = resource->data; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 378 | struct weston_surface *es = shsurf->surface; |
Pekka Paalanen | 01e7b00 | 2011-12-08 16:42:33 +0200 | [diff] [blame] | 379 | struct shell_surface *pshsurf = parent_resource->data; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 380 | struct weston_surface *pes = pshsurf->surface; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 381 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 382 | if (reset_shell_surface_type(shsurf)) |
| 383 | return; |
| 384 | |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 385 | /* assign to parents output */ |
| 386 | es->output = pes->output; |
| 387 | |
| 388 | es->x = pes->x + x; |
| 389 | es->y = pes->y + y; |
| 390 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 391 | weston_surface_damage(es); |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 392 | shsurf->type = SHELL_SURFACE_TRANSIENT; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 393 | } |
| 394 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 395 | static struct weston_output * |
| 396 | get_default_output(struct weston_compositor *compositor) |
Pekka Paalanen | af0e34c | 2011-12-02 10:59:17 +0200 | [diff] [blame] | 397 | { |
| 398 | return container_of(compositor->output_list.next, |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 399 | struct weston_output, link); |
Pekka Paalanen | af0e34c | 2011-12-02 10:59:17 +0200 | [diff] [blame] | 400 | } |
| 401 | |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 402 | static void |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 403 | shell_surface_set_fullscreen(struct wl_client *client, |
| 404 | struct wl_resource *resource) |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 405 | |
| 406 | { |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 407 | struct shell_surface *shsurf = resource->data; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 408 | struct weston_surface *es = shsurf->surface; |
| 409 | struct weston_output *output; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 410 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 411 | if (reset_shell_surface_type(shsurf)) |
| 412 | return; |
| 413 | |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 414 | /* FIXME: Fullscreen on first output */ |
| 415 | /* FIXME: Handle output going away */ |
Pekka Paalanen | af0e34c | 2011-12-02 10:59:17 +0200 | [diff] [blame] | 416 | output = get_default_output(es->compositor); |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 417 | es->output = output; |
| 418 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 419 | shsurf->saved_x = es->x; |
| 420 | shsurf->saved_y = es->y; |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 421 | es->x = (output->current->width - es->width) / 2; |
| 422 | es->y = (output->current->height - es->height) / 2; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 423 | es->fullscreen_output = output; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 424 | weston_surface_damage(es); |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 425 | shsurf->type = SHELL_SURFACE_FULLSCREEN; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 426 | } |
| 427 | |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 428 | static void |
| 429 | popup_grab_focus(struct wl_grab *grab, uint32_t time, |
| 430 | struct wl_surface *surface, int32_t x, int32_t y) |
| 431 | { |
| 432 | struct wl_input_device *device = grab->input_device; |
| 433 | struct shell_surface *priv = |
| 434 | container_of(grab, struct shell_surface, popup.grab); |
| 435 | struct wl_client *client = priv->surface->surface.resource.client; |
| 436 | |
| 437 | if (surface->resource.client == client) { |
| 438 | wl_input_device_set_pointer_focus(device, surface, time, |
| 439 | device->x, device->y, x, y); |
| 440 | grab->focus = surface; |
| 441 | } else { |
| 442 | wl_input_device_set_pointer_focus(device, NULL, |
| 443 | time, 0, 0, 0, 0); |
| 444 | grab->focus = NULL; |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | static void |
| 449 | popup_grab_motion(struct wl_grab *grab, |
| 450 | uint32_t time, int32_t x, int32_t y) |
| 451 | { |
| 452 | struct wl_input_device *device = grab->input_device; |
| 453 | struct wl_resource *resource; |
| 454 | |
| 455 | resource = grab->input_device->pointer_focus_resource; |
| 456 | if (resource) |
| 457 | wl_resource_post_event(resource, WL_INPUT_DEVICE_MOTION, |
| 458 | time, device->x, device->y, x, y); |
| 459 | } |
| 460 | |
| 461 | static void |
| 462 | popup_grab_button(struct wl_grab *grab, |
| 463 | uint32_t time, int32_t button, int32_t state) |
| 464 | { |
| 465 | struct wl_resource *resource; |
| 466 | struct shell_surface *shsurf = |
| 467 | container_of(grab, struct shell_surface, popup.grab); |
| 468 | |
| 469 | resource = grab->input_device->pointer_focus_resource; |
| 470 | if (resource) { |
| 471 | wl_resource_post_event(resource, WL_INPUT_DEVICE_BUTTON, |
| 472 | time, button, state); |
| 473 | } else if (state == 0 && |
| 474 | (shsurf->popup.initial_up || |
| 475 | time - shsurf->popup.time > 500)) { |
| 476 | wl_resource_post_event(&shsurf->resource, |
| 477 | WL_SHELL_SURFACE_POPUP_DONE); |
| 478 | wl_input_device_end_grab(grab->input_device, time); |
| 479 | shsurf->popup.grab.input_device = NULL; |
| 480 | } |
| 481 | |
| 482 | if (state == 0) |
| 483 | shsurf->popup.initial_up = 1; |
| 484 | } |
| 485 | |
| 486 | static const struct wl_grab_interface popup_grab_interface = { |
| 487 | popup_grab_focus, |
| 488 | popup_grab_motion, |
| 489 | popup_grab_button, |
| 490 | }; |
| 491 | |
| 492 | static void |
| 493 | shell_map_popup(struct shell_surface *shsurf, uint32_t time) |
| 494 | { |
| 495 | struct wl_input_device *device; |
| 496 | struct weston_surface *es = shsurf->surface; |
| 497 | struct weston_surface *parent = shsurf->parent->surface; |
| 498 | |
| 499 | es->output = parent->output; |
| 500 | |
| 501 | shsurf->popup.grab.interface = &popup_grab_interface; |
| 502 | device = es->compositor->input_device; |
| 503 | |
| 504 | es->x = shsurf->parent->surface->x + shsurf->popup.x; |
| 505 | es->y = shsurf->parent->surface->y + shsurf->popup.y; |
| 506 | |
| 507 | shsurf->popup.grab.input_device = device; |
| 508 | shsurf->popup.time = device->grab_time; |
| 509 | shsurf->popup.initial_up = 0; |
| 510 | |
| 511 | wl_input_device_start_grab(shsurf->popup.grab.input_device, |
| 512 | &shsurf->popup.grab, shsurf->popup.time); |
| 513 | } |
| 514 | |
| 515 | static void |
| 516 | shell_surface_set_popup(struct wl_client *client, |
| 517 | struct wl_resource *resource, |
| 518 | struct wl_resource *input_device_resource, |
| 519 | uint32_t time, |
| 520 | struct wl_resource *parent_resource, |
| 521 | int32_t x, int32_t y, uint32_t flags) |
| 522 | { |
| 523 | struct shell_surface *shsurf = resource->data; |
| 524 | struct weston_surface *es = shsurf->surface; |
| 525 | |
| 526 | weston_surface_damage(es); |
| 527 | shsurf->type = SHELL_SURFACE_POPUP; |
| 528 | shsurf->parent = parent_resource->data; |
| 529 | shsurf->popup.x = x; |
| 530 | shsurf->popup.y = y; |
| 531 | } |
| 532 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 533 | static const struct wl_shell_surface_interface shell_surface_implementation = { |
| 534 | shell_surface_move, |
| 535 | shell_surface_resize, |
| 536 | shell_surface_set_toplevel, |
| 537 | shell_surface_set_transient, |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 538 | shell_surface_set_fullscreen, |
| 539 | shell_surface_set_popup |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 540 | }; |
| 541 | |
| 542 | static void |
| 543 | destroy_shell_surface(struct wl_resource *resource) |
| 544 | { |
| 545 | struct shell_surface *shsurf = resource->data; |
| 546 | |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 547 | if (shsurf->popup.grab.input_device) |
| 548 | wl_input_device_end_grab(shsurf->popup.grab.input_device, 0); |
| 549 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 550 | /* in case cleaning up a dead client destroys shell_surface first */ |
| 551 | if (shsurf->surface) |
| 552 | wl_list_remove(&shsurf->surface_destroy_listener.link); |
| 553 | |
| 554 | wl_list_remove(&shsurf->link); |
| 555 | free(shsurf); |
| 556 | } |
| 557 | |
| 558 | static void |
| 559 | shell_handle_surface_destroy(struct wl_listener *listener, |
| 560 | struct wl_resource *resource, uint32_t time) |
| 561 | { |
| 562 | struct shell_surface *shsurf = container_of(listener, |
| 563 | struct shell_surface, |
| 564 | surface_destroy_listener); |
| 565 | |
| 566 | shsurf->surface = NULL; |
| 567 | wl_resource_destroy(&shsurf->resource, time); |
| 568 | } |
| 569 | |
Pekka Paalanen | ec2b32f | 2011-11-28 15:12:34 +0200 | [diff] [blame] | 570 | static struct shell_surface * |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 571 | get_shell_surface(struct weston_surface *surface) |
Pekka Paalanen | ec2b32f | 2011-11-28 15:12:34 +0200 | [diff] [blame] | 572 | { |
| 573 | struct wl_list *lst = &surface->surface.resource.destroy_listener_list; |
| 574 | struct wl_listener *listener; |
| 575 | |
| 576 | /* search the destroy listener list for our callback */ |
| 577 | wl_list_for_each(listener, lst, link) { |
| 578 | if (listener->func == shell_handle_surface_destroy) { |
| 579 | return container_of(listener, struct shell_surface, |
| 580 | surface_destroy_listener); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | return NULL; |
| 585 | } |
| 586 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 587 | static void |
Pekka Paalanen | 4622967 | 2011-11-29 15:49:31 +0200 | [diff] [blame] | 588 | shell_get_shell_surface(struct wl_client *client, |
| 589 | struct wl_resource *resource, |
| 590 | uint32_t id, |
| 591 | struct wl_resource *surface_resource) |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 592 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 593 | struct weston_surface *surface = surface_resource->data; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 594 | struct shell_surface *shsurf; |
| 595 | |
Pekka Paalanen | f32f1fc | 2011-11-29 16:05:28 +0200 | [diff] [blame] | 596 | if (get_shell_surface(surface)) { |
| 597 | wl_resource_post_error(surface_resource, |
| 598 | WL_DISPLAY_ERROR_INVALID_OBJECT, |
| 599 | "wl_shell::get_shell_surface already requested"); |
| 600 | return; |
| 601 | } |
| 602 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 603 | shsurf = calloc(1, sizeof *shsurf); |
| 604 | if (!shsurf) { |
| 605 | wl_resource_post_no_memory(resource); |
| 606 | return; |
| 607 | } |
| 608 | |
| 609 | shsurf->resource.destroy = destroy_shell_surface; |
| 610 | shsurf->resource.object.id = id; |
| 611 | shsurf->resource.object.interface = &wl_shell_surface_interface; |
| 612 | shsurf->resource.object.implementation = |
| 613 | (void (**)(void)) &shell_surface_implementation; |
| 614 | shsurf->resource.data = shsurf; |
| 615 | |
| 616 | shsurf->surface = surface; |
| 617 | shsurf->surface_destroy_listener.func = shell_handle_surface_destroy; |
| 618 | wl_list_insert(surface->surface.resource.destroy_listener_list.prev, |
| 619 | &shsurf->surface_destroy_listener.link); |
| 620 | |
| 621 | /* init link so its safe to always remove it in destroy_shell_surface */ |
| 622 | wl_list_init(&shsurf->link); |
| 623 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 624 | shsurf->type = SHELL_SURFACE_NONE; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 625 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 626 | wl_client_add_resource(client, &shsurf->resource); |
| 627 | } |
| 628 | |
| 629 | static const struct wl_shell_interface shell_implementation = { |
Pekka Paalanen | 4622967 | 2011-11-29 15:49:31 +0200 | [diff] [blame] | 630 | shell_get_shell_surface |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 631 | }; |
| 632 | |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 633 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 634 | handle_screensaver_sigchld(struct weston_process *proc, int status) |
Pekka Paalanen | 18027e5 | 2011-12-02 16:31:49 +0200 | [diff] [blame] | 635 | { |
| 636 | proc->pid = 0; |
| 637 | } |
| 638 | |
| 639 | static void |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 640 | launch_screensaver(struct wl_shell *shell) |
| 641 | { |
| 642 | if (shell->screensaver.binding) |
| 643 | return; |
| 644 | |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 645 | if (!shell->screensaver.path) |
| 646 | return; |
| 647 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 648 | weston_client_launch(shell->compositor, |
Pekka Paalanen | 18027e5 | 2011-12-02 16:31:49 +0200 | [diff] [blame] | 649 | &shell->screensaver.process, |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 650 | shell->screensaver.path, |
Pekka Paalanen | 18027e5 | 2011-12-02 16:31:49 +0200 | [diff] [blame] | 651 | handle_screensaver_sigchld); |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | static void |
| 655 | terminate_screensaver(struct wl_shell *shell) |
| 656 | { |
Pekka Paalanen | 18027e5 | 2011-12-02 16:31:49 +0200 | [diff] [blame] | 657 | if (shell->screensaver.process.pid == 0) |
| 658 | return; |
| 659 | |
| 660 | kill(shell->screensaver.process.pid, SIGTERM); |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | static void |
| 664 | show_screensaver(struct wl_shell *shell, struct shell_surface *surface) |
| 665 | { |
| 666 | struct wl_list *list; |
| 667 | |
| 668 | if (shell->lock_surface) |
| 669 | list = &shell->lock_surface->surface->link; |
| 670 | else |
| 671 | list = &shell->compositor->surface_list; |
| 672 | |
| 673 | wl_list_remove(&surface->surface->link); |
| 674 | wl_list_insert(list, &surface->surface->link); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 675 | weston_surface_configure(surface->surface, |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 676 | surface->surface->x, |
| 677 | surface->surface->y, |
| 678 | surface->surface->width, |
| 679 | surface->surface->height); |
| 680 | surface->surface->output = surface->output; |
| 681 | } |
| 682 | |
| 683 | static void |
| 684 | hide_screensaver(struct wl_shell *shell, struct shell_surface *surface) |
| 685 | { |
| 686 | wl_list_remove(&surface->surface->link); |
| 687 | wl_list_init(&surface->surface->link); |
| 688 | surface->surface->output = NULL; |
| 689 | } |
| 690 | |
| 691 | static void |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 692 | desktop_shell_set_background(struct wl_client *client, |
| 693 | struct wl_resource *resource, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 694 | struct wl_resource *output_resource, |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 695 | struct wl_resource *surface_resource) |
| 696 | { |
| 697 | struct wl_shell *shell = resource->data; |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 698 | struct shell_surface *shsurf = surface_resource->data; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 699 | struct weston_surface *surface = shsurf->surface; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 700 | struct shell_surface *priv; |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 701 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 702 | if (reset_shell_surface_type(shsurf)) |
| 703 | return; |
| 704 | |
Benjamin Franzke | f02bb64 | 2011-11-23 20:46:40 +0100 | [diff] [blame] | 705 | wl_list_for_each(priv, &shell->backgrounds, link) { |
| 706 | if (priv->output == output_resource->data) { |
| 707 | priv->surface->output = NULL; |
| 708 | wl_list_remove(&priv->surface->link); |
| 709 | wl_list_remove(&priv->link); |
| 710 | break; |
| 711 | } |
| 712 | } |
| 713 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 714 | shsurf->type = SHELL_SURFACE_BACKGROUND; |
| 715 | shsurf->output = output_resource->data; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 716 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 717 | wl_list_insert(&shell->backgrounds, &shsurf->link); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 718 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 719 | surface->x = shsurf->output->x; |
| 720 | surface->y = shsurf->output->y; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 721 | |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 722 | wl_resource_post_event(resource, |
| 723 | DESKTOP_SHELL_CONFIGURE, |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 724 | weston_compositor_get_time(), 0, surface_resource, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 725 | shsurf->output->current->width, |
| 726 | shsurf->output->current->height); |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | static void |
| 730 | desktop_shell_set_panel(struct wl_client *client, |
| 731 | struct wl_resource *resource, |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 732 | struct wl_resource *output_resource, |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 733 | struct wl_resource *surface_resource) |
| 734 | { |
| 735 | struct wl_shell *shell = resource->data; |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 736 | struct shell_surface *shsurf = surface_resource->data; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 737 | struct weston_surface *surface = shsurf->surface; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 738 | struct shell_surface *priv; |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 739 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 740 | if (reset_shell_surface_type(shsurf)) |
| 741 | return; |
| 742 | |
Benjamin Franzke | f02bb64 | 2011-11-23 20:46:40 +0100 | [diff] [blame] | 743 | wl_list_for_each(priv, &shell->panels, link) { |
| 744 | if (priv->output == output_resource->data) { |
| 745 | priv->surface->output = NULL; |
| 746 | wl_list_remove(&priv->surface->link); |
| 747 | wl_list_remove(&priv->link); |
| 748 | break; |
| 749 | } |
| 750 | } |
| 751 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 752 | shsurf->type = SHELL_SURFACE_PANEL; |
| 753 | shsurf->output = output_resource->data; |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 754 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 755 | wl_list_insert(&shell->panels, &shsurf->link); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 756 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 757 | surface->x = shsurf->output->x; |
| 758 | surface->y = shsurf->output->y; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 759 | |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 760 | wl_resource_post_event(resource, |
| 761 | DESKTOP_SHELL_CONFIGURE, |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 762 | weston_compositor_get_time(), 0, surface_resource, |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 763 | shsurf->output->current->width, |
| 764 | shsurf->output->current->height); |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 765 | } |
| 766 | |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 767 | static void |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 768 | handle_lock_surface_destroy(struct wl_listener *listener, |
| 769 | struct wl_resource *resource, uint32_t time) |
| 770 | { |
| 771 | struct wl_shell *shell = |
Pekka Paalanen | 2ca8630 | 2011-11-16 13:47:35 +0200 | [diff] [blame] | 772 | container_of(listener, struct wl_shell, lock_surface_listener); |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 773 | |
| 774 | fprintf(stderr, "lock surface gone\n"); |
| 775 | shell->lock_surface = NULL; |
| 776 | } |
| 777 | |
| 778 | static void |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 779 | desktop_shell_set_lock_surface(struct wl_client *client, |
| 780 | struct wl_resource *resource, |
| 781 | struct wl_resource *surface_resource) |
| 782 | { |
Kristian Høgsberg | af867cc | 2011-11-15 13:34:49 +0200 | [diff] [blame] | 783 | struct wl_shell *shell = resource->data; |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 784 | struct shell_surface *surface = surface_resource->data; |
| 785 | |
| 786 | if (reset_shell_surface_type(surface)) |
| 787 | return; |
Kristian Høgsberg | af867cc | 2011-11-15 13:34:49 +0200 | [diff] [blame] | 788 | |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 789 | shell->prepare_event_sent = false; |
Kristian Høgsberg | af867cc | 2011-11-15 13:34:49 +0200 | [diff] [blame] | 790 | |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 791 | if (!shell->locked) |
| 792 | return; |
| 793 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 794 | shell->lock_surface = surface; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 795 | |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 796 | shell->lock_surface_listener.func = handle_lock_surface_destroy; |
| 797 | wl_list_insert(&surface_resource->destroy_listener_list, |
| 798 | &shell->lock_surface_listener.link); |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 799 | |
Pekka Paalanen | 068ae94 | 2011-11-28 14:11:15 +0200 | [diff] [blame] | 800 | shell->lock_surface->type = SHELL_SURFACE_LOCK; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | static void |
| 804 | resume_desktop(struct wl_shell *shell) |
| 805 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 806 | struct weston_surface *surface; |
Pekka Paalanen | fe34083 | 2011-11-25 16:07:52 +0200 | [diff] [blame] | 807 | struct wl_list *list; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 808 | struct shell_surface *tmp; |
| 809 | |
| 810 | wl_list_for_each(tmp, &shell->screensaver.surfaces, link) |
| 811 | hide_screensaver(shell, tmp); |
| 812 | |
| 813 | terminate_screensaver(shell); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 814 | |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 815 | wl_list_for_each(surface, &shell->hidden_surface_list, link) |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 816 | weston_surface_configure(surface, surface->x, surface->y, |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 817 | surface->width, surface->height); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 818 | |
Pekka Paalanen | fe34083 | 2011-11-25 16:07:52 +0200 | [diff] [blame] | 819 | if (wl_list_empty(&shell->backgrounds)) { |
| 820 | list = &shell->compositor->surface_list; |
| 821 | } else { |
| 822 | struct shell_surface *background; |
| 823 | background = container_of(shell->backgrounds.prev, |
| 824 | struct shell_surface, link); |
| 825 | list = background->surface->link.prev; |
| 826 | } |
| 827 | |
| 828 | if (!wl_list_empty(&shell->hidden_surface_list)) |
| 829 | wl_list_insert_list(list, &shell->hidden_surface_list); |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 830 | wl_list_init(&shell->hidden_surface_list); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 831 | |
| 832 | shell->locked = false; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 833 | weston_compositor_repick(shell->compositor); |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 834 | shell->compositor->idle_time = shell->compositor->option_idle_time; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 835 | weston_compositor_wake(shell->compositor); |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | static void |
| 839 | desktop_shell_unlock(struct wl_client *client, |
| 840 | struct wl_resource *resource) |
| 841 | { |
| 842 | struct wl_shell *shell = resource->data; |
| 843 | |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 844 | shell->prepare_event_sent = false; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 845 | |
| 846 | if (shell->locked) |
| 847 | resume_desktop(shell); |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 848 | } |
| 849 | |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 850 | static const struct desktop_shell_interface desktop_shell_implementation = { |
| 851 | desktop_shell_set_background, |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 852 | desktop_shell_set_panel, |
| 853 | desktop_shell_set_lock_surface, |
| 854 | desktop_shell_unlock |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 855 | }; |
| 856 | |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 857 | static enum shell_surface_type |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 858 | get_shell_surface_type(struct weston_surface *surface) |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 859 | { |
| 860 | struct shell_surface *shsurf; |
| 861 | |
| 862 | shsurf = get_shell_surface(surface); |
| 863 | if (!shsurf) |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 864 | return SHELL_SURFACE_NONE; |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 865 | return shsurf->type; |
| 866 | } |
| 867 | |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 868 | static void |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 869 | move_binding(struct wl_input_device *device, uint32_t time, |
| 870 | uint32_t key, uint32_t button, uint32_t state, void *data) |
| 871 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 872 | struct weston_surface *surface = |
| 873 | (struct weston_surface *) device->pointer_focus; |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 874 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 875 | if (surface == NULL) |
| 876 | return; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 877 | |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 878 | switch (get_shell_surface_type(surface)) { |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 879 | case SHELL_SURFACE_PANEL: |
| 880 | case SHELL_SURFACE_BACKGROUND: |
| 881 | case SHELL_SURFACE_FULLSCREEN: |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 882 | case SHELL_SURFACE_SCREENSAVER: |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 883 | return; |
| 884 | default: |
| 885 | break; |
| 886 | } |
Kristian Høgsberg | 10f097e | 2011-04-13 11:52:54 -0400 | [diff] [blame] | 887 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 888 | weston_surface_move(surface, (struct weston_input_device *) device, time); |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | static void |
| 892 | resize_binding(struct wl_input_device *device, uint32_t time, |
| 893 | uint32_t key, uint32_t button, uint32_t state, void *data) |
| 894 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 895 | struct weston_surface *surface = |
| 896 | (struct weston_surface *) device->pointer_focus; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 897 | uint32_t edges = 0; |
| 898 | int32_t x, y; |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 899 | struct shell_surface *shsurf; |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 900 | |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 901 | if (surface == NULL) |
| 902 | return; |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 903 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 904 | shsurf = get_shell_surface(surface); |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 905 | if (!shsurf) |
| 906 | return; |
| 907 | |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 908 | switch (shsurf->type) { |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 909 | case SHELL_SURFACE_PANEL: |
| 910 | case SHELL_SURFACE_BACKGROUND: |
| 911 | case SHELL_SURFACE_FULLSCREEN: |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 912 | case SHELL_SURFACE_SCREENSAVER: |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 913 | return; |
| 914 | default: |
| 915 | break; |
| 916 | } |
Kristian Høgsberg | 10f097e | 2011-04-13 11:52:54 -0400 | [diff] [blame] | 917 | |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 918 | x = device->grab_x - surface->x; |
| 919 | y = device->grab_y - surface->y; |
| 920 | |
| 921 | if (x < surface->width / 3) |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 922 | edges |= WL_SHELL_SURFACE_RESIZE_LEFT; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 923 | else if (x < 2 * surface->width / 3) |
| 924 | edges |= 0; |
| 925 | else |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 926 | edges |= WL_SHELL_SURFACE_RESIZE_RIGHT; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 927 | |
| 928 | if (y < surface->height / 3) |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 929 | edges |= WL_SHELL_SURFACE_RESIZE_TOP; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 930 | else if (y < 2 * surface->height / 3) |
| 931 | edges |= 0; |
| 932 | else |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 933 | edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 934 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 935 | weston_surface_resize(shsurf, (struct weston_input_device *) device, |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 936 | time, edges); |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | static void |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 940 | terminate_binding(struct wl_input_device *device, uint32_t time, |
| 941 | uint32_t key, uint32_t button, uint32_t state, void *data) |
| 942 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 943 | struct weston_compositor *compositor = data; |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 944 | |
| 945 | if (state) |
| 946 | wl_display_terminate(compositor->wl_display); |
| 947 | } |
| 948 | |
| 949 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 950 | activate(struct weston_shell *base, struct weston_surface *es, |
| 951 | struct weston_input_device *device, uint32_t time) |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 952 | { |
| 953 | struct wl_shell *shell = container_of(base, struct wl_shell, shell); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 954 | struct weston_compositor *compositor = shell->compositor; |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 955 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 956 | weston_surface_activate(es, device, time); |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 957 | |
Kristian Høgsberg | d6e5525 | 2011-10-11 23:41:17 -0400 | [diff] [blame] | 958 | if (compositor->wxs) |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 959 | weston_xserver_surface_activate(es); |
Kristian Høgsberg | d6e5525 | 2011-10-11 23:41:17 -0400 | [diff] [blame] | 960 | |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 961 | switch (get_shell_surface_type(es)) { |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 962 | case SHELL_SURFACE_BACKGROUND: |
| 963 | /* put background back to bottom */ |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 964 | wl_list_remove(&es->link); |
| 965 | wl_list_insert(compositor->surface_list.prev, &es->link); |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 966 | break; |
| 967 | case SHELL_SURFACE_PANEL: |
| 968 | /* already put on top */ |
| 969 | break; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 970 | case SHELL_SURFACE_SCREENSAVER: |
| 971 | /* always below lock surface */ |
| 972 | if (shell->lock_surface) { |
| 973 | wl_list_remove(&es->link); |
| 974 | wl_list_insert(&shell->lock_surface->surface->link, |
| 975 | &es->link); |
| 976 | } |
| 977 | break; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 978 | default: |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 979 | if (!shell->locked) { |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 980 | /* bring panel back to top */ |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 981 | struct shell_surface *panel; |
| 982 | wl_list_for_each(panel, &shell->panels, link) { |
| 983 | wl_list_remove(&panel->surface->link); |
| 984 | wl_list_insert(&compositor->surface_list, |
| 985 | &panel->surface->link); |
| 986 | } |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 987 | } |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 988 | } |
| 989 | } |
| 990 | |
| 991 | static void |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 992 | click_to_activate_binding(struct wl_input_device *device, |
| 993 | uint32_t time, uint32_t key, |
| 994 | uint32_t button, uint32_t state, void *data) |
| 995 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 996 | struct weston_input_device *wd = (struct weston_input_device *) device; |
| 997 | struct weston_compositor *compositor = data; |
| 998 | struct weston_surface *focus; |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 999 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1000 | focus = (struct weston_surface *) device->pointer_focus; |
Kristian Høgsberg | 9ddb826 | 2012-01-04 21:30:29 -0500 | [diff] [blame] | 1001 | if (state && focus && device->grab == &device->default_grab) |
Kristian Høgsberg | 2a25cd4 | 2011-12-19 15:19:54 -0500 | [diff] [blame] | 1002 | activate(compositor->shell, focus, wd, time); |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1006 | lock(struct weston_shell *base) |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1007 | { |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1008 | struct wl_shell *shell = container_of(base, struct wl_shell, shell); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1009 | struct wl_list *surface_list = &shell->compositor->surface_list; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1010 | struct weston_surface *cur; |
| 1011 | struct weston_surface *tmp; |
| 1012 | struct weston_input_device *device; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1013 | struct shell_surface *shsurf; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1014 | uint32_t time; |
| 1015 | |
| 1016 | if (shell->locked) |
| 1017 | return; |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1018 | |
| 1019 | shell->locked = true; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1020 | |
| 1021 | /* Move all surfaces from compositor's list to our hidden list, |
| 1022 | * except the background. This way nothing else can show or |
| 1023 | * receive input events while we are locked. */ |
| 1024 | |
| 1025 | if (!wl_list_empty(&shell->hidden_surface_list)) { |
| 1026 | fprintf(stderr, |
| 1027 | "%s: Assertion failed: hidden_surface_list is not empty.\n", |
| 1028 | __func__); |
| 1029 | } |
| 1030 | |
| 1031 | wl_list_for_each_safe(cur, tmp, surface_list, link) { |
| 1032 | /* skip input device sprites, cur->surface is uninitialised */ |
| 1033 | if (cur->surface.resource.client == NULL) |
| 1034 | continue; |
| 1035 | |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 1036 | if (get_shell_surface_type(cur) == SHELL_SURFACE_BACKGROUND) |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1037 | continue; |
| 1038 | |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1039 | cur->output = NULL; |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1040 | wl_list_remove(&cur->link); |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1041 | wl_list_insert(shell->hidden_surface_list.prev, &cur->link); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1042 | } |
| 1043 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1044 | launch_screensaver(shell); |
| 1045 | |
| 1046 | wl_list_for_each(shsurf, &shell->screensaver.surfaces, link) |
| 1047 | show_screensaver(shell, shsurf); |
| 1048 | |
Pekka Paalanen | bce2d3f | 2011-12-02 13:07:27 +0200 | [diff] [blame] | 1049 | if (!wl_list_empty(&shell->screensaver.surfaces)) { |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 1050 | shell->compositor->idle_time = shell->screensaver.duration; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1051 | weston_compositor_wake(shell->compositor); |
| 1052 | shell->compositor->state = WESTON_COMPOSITOR_IDLE; |
Pekka Paalanen | bce2d3f | 2011-12-02 13:07:27 +0200 | [diff] [blame] | 1053 | } |
Pekka Paalanen | baeb6a1 | 2011-12-01 16:23:57 +0200 | [diff] [blame] | 1054 | |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1055 | /* reset pointer foci */ |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1056 | weston_compositor_repick(shell->compositor); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1057 | |
| 1058 | /* reset keyboard foci */ |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1059 | time = weston_compositor_get_time(); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1060 | wl_list_for_each(device, &shell->compositor->input_device_list, link) { |
| 1061 | wl_input_device_set_keyboard_focus(&device->input_device, |
| 1062 | NULL, time); |
| 1063 | } |
| 1064 | |
| 1065 | /* TODO: disable bindings that should not work while locked. */ |
| 1066 | |
| 1067 | /* All this must be undone in resume_desktop(). */ |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1071 | unlock(struct weston_shell *base) |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1072 | { |
| 1073 | struct wl_shell *shell = container_of(base, struct wl_shell, shell); |
| 1074 | |
Pekka Paalanen | d81c216 | 2011-11-16 13:47:34 +0200 | [diff] [blame] | 1075 | if (!shell->locked || shell->lock_surface) { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1076 | weston_compositor_wake(shell->compositor); |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1077 | return; |
| 1078 | } |
| 1079 | |
| 1080 | /* If desktop-shell client has gone away, unlock immediately. */ |
| 1081 | if (!shell->child.desktop_shell) { |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1082 | resume_desktop(shell); |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1083 | return; |
| 1084 | } |
| 1085 | |
| 1086 | if (shell->prepare_event_sent) |
| 1087 | return; |
| 1088 | |
| 1089 | wl_resource_post_event(shell->child.desktop_shell, |
| 1090 | DESKTOP_SHELL_PREPARE_LOCK_SURFACE); |
| 1091 | shell->prepare_event_sent = true; |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1095 | center_on_output(struct weston_surface *surface, struct weston_output *output) |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1096 | { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1097 | struct weston_mode *mode = output->current; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1098 | |
| 1099 | surface->x = output->x + (mode->width - surface->width) / 2; |
| 1100 | surface->y = output->y + (mode->height - surface->height) / 2; |
| 1101 | } |
| 1102 | |
| 1103 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1104 | map(struct weston_shell *base, |
| 1105 | struct weston_surface *surface, int32_t width, int32_t height) |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1106 | { |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1107 | struct wl_shell *shell = container_of(base, struct wl_shell, shell); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1108 | struct weston_compositor *compositor = shell->compositor; |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1109 | struct wl_list *list; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1110 | struct shell_surface *shsurf; |
| 1111 | enum shell_surface_type surface_type = SHELL_SURFACE_NONE; |
| 1112 | int do_configure; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 1113 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1114 | shsurf = get_shell_surface(surface); |
| 1115 | if (shsurf) |
| 1116 | surface_type = shsurf->type; |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1117 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1118 | if (shell->locked) { |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1119 | list = &shell->hidden_surface_list; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1120 | do_configure = 0; |
| 1121 | } else { |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1122 | list = &compositor->surface_list; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1123 | do_configure = 1; |
| 1124 | } |
| 1125 | |
| 1126 | surface->width = width; |
| 1127 | surface->height = height; |
| 1128 | |
| 1129 | /* initial positioning, see also configure() */ |
| 1130 | switch (surface_type) { |
| 1131 | case SHELL_SURFACE_TOPLEVEL: |
| 1132 | surface->x = 10 + random() % 400; |
| 1133 | surface->y = 10 + random() % 400; |
| 1134 | break; |
| 1135 | case SHELL_SURFACE_SCREENSAVER: |
| 1136 | case SHELL_SURFACE_FULLSCREEN: |
| 1137 | center_on_output(surface, surface->fullscreen_output); |
| 1138 | break; |
Pekka Paalanen | af0e34c | 2011-12-02 10:59:17 +0200 | [diff] [blame] | 1139 | case SHELL_SURFACE_LOCK: |
| 1140 | center_on_output(surface, get_default_output(compositor)); |
| 1141 | break; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1142 | default: |
| 1143 | ; |
| 1144 | } |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1145 | |
Pekka Paalanen | d3dd6e1 | 2011-11-16 13:47:33 +0200 | [diff] [blame] | 1146 | /* surface stacking order, see also activate() */ |
Pekka Paalanen | 92a0dc4 | 2011-11-28 15:34:13 +0200 | [diff] [blame] | 1147 | switch (surface_type) { |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 1148 | case SHELL_SURFACE_BACKGROUND: |
Pekka Paalanen | d3dd6e1 | 2011-11-16 13:47:33 +0200 | [diff] [blame] | 1149 | /* background always visible, at the bottom */ |
Kristian Høgsberg | 32e24cc | 2011-11-09 12:07:35 -0500 | [diff] [blame] | 1150 | wl_list_insert(compositor->surface_list.prev, &surface->link); |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1151 | do_configure = 1; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 1152 | break; |
| 1153 | case SHELL_SURFACE_PANEL: |
Pekka Paalanen | d3dd6e1 | 2011-11-16 13:47:33 +0200 | [diff] [blame] | 1154 | /* panel always on top, hidden while locked */ |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1155 | wl_list_insert(list, &surface->link); |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 1156 | break; |
| 1157 | case SHELL_SURFACE_LOCK: |
Pekka Paalanen | d3dd6e1 | 2011-11-16 13:47:33 +0200 | [diff] [blame] | 1158 | /* lock surface always visible, on top */ |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1159 | wl_list_insert(&compositor->surface_list, &surface->link); |
Pekka Paalanen | d3dd6e1 | 2011-11-16 13:47:33 +0200 | [diff] [blame] | 1160 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1161 | weston_compositor_repick(compositor); |
| 1162 | weston_compositor_wake(compositor); |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1163 | do_configure = 1; |
| 1164 | break; |
| 1165 | case SHELL_SURFACE_SCREENSAVER: |
| 1166 | /* If locked, show it. */ |
Pekka Paalanen | baeb6a1 | 2011-12-01 16:23:57 +0200 | [diff] [blame] | 1167 | if (shell->locked) { |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1168 | show_screensaver(shell, shsurf); |
Pekka Paalanen | 7296e79 | 2011-12-07 16:22:00 +0200 | [diff] [blame] | 1169 | compositor->idle_time = shell->screensaver.duration; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1170 | weston_compositor_wake(compositor); |
Pekka Paalanen | bce2d3f | 2011-12-02 13:07:27 +0200 | [diff] [blame] | 1171 | if (!shell->lock_surface) |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1172 | compositor->state = WESTON_COMPOSITOR_IDLE; |
Pekka Paalanen | baeb6a1 | 2011-12-01 16:23:57 +0200 | [diff] [blame] | 1173 | } |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1174 | do_configure = 0; |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 1175 | break; |
| 1176 | default: |
Pekka Paalanen | d3dd6e1 | 2011-11-16 13:47:33 +0200 | [diff] [blame] | 1177 | /* everything else just below the panel */ |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1178 | if (!wl_list_empty(&shell->panels)) { |
| 1179 | struct shell_surface *panel = |
| 1180 | container_of(shell->panels.prev, |
| 1181 | struct shell_surface, link); |
| 1182 | wl_list_insert(&panel->surface->link, &surface->link); |
| 1183 | } else { |
Pekka Paalanen | 57da4a8 | 2011-11-23 16:42:16 +0200 | [diff] [blame] | 1184 | wl_list_insert(list, &surface->link); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1185 | } |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1186 | } |
| 1187 | |
Kristian Høgsberg | b3cca0a | 2012-01-04 22:19:14 -0500 | [diff] [blame^] | 1188 | switch (surface_type) { |
| 1189 | case SHELL_SURFACE_TOPLEVEL: |
| 1190 | surface->x = 10 + random() % 400; |
| 1191 | surface->y = 10 + random() % 400; |
| 1192 | break; |
| 1193 | case SHELL_SURFACE_POPUP: |
| 1194 | shell_map_popup(shsurf, shsurf->popup.time); |
| 1195 | break; |
| 1196 | default: |
| 1197 | break; |
| 1198 | } |
| 1199 | |
| 1200 | surface->width = width; |
| 1201 | surface->height = height; |
| 1202 | if (do_configure) { |
| 1203 | weston_surface_configure(surface, surface->x, surface->y, |
| 1204 | width, height); |
| 1205 | weston_compositor_repick(compositor); |
| 1206 | } |
Kristian Høgsberg | 2f88a40 | 2011-12-04 15:32:59 -0500 | [diff] [blame] | 1207 | |
Juan Zhao | 7bb92f0 | 2011-12-15 11:31:51 -0500 | [diff] [blame] | 1208 | switch (surface_type) { |
| 1209 | case SHELL_SURFACE_TOPLEVEL: |
| 1210 | case SHELL_SURFACE_TRANSIENT: |
| 1211 | case SHELL_SURFACE_FULLSCREEN: |
| 1212 | if (!shell->locked) |
| 1213 | activate(base, surface, |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1214 | (struct weston_input_device *) |
Juan Zhao | 7bb92f0 | 2011-12-15 11:31:51 -0500 | [diff] [blame] | 1215 | compositor->input_device, |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1216 | weston_compositor_get_time()); |
Juan Zhao | 7bb92f0 | 2011-12-15 11:31:51 -0500 | [diff] [blame] | 1217 | break; |
| 1218 | default: |
| 1219 | break; |
| 1220 | } |
| 1221 | |
Kristian Høgsberg | 2f88a40 | 2011-12-04 15:32:59 -0500 | [diff] [blame] | 1222 | if (surface_type == SHELL_SURFACE_TOPLEVEL) |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1223 | weston_zoom_run(surface, 0.8, 1.0, NULL, NULL); |
Kristian Høgsberg | 32e24cc | 2011-11-09 12:07:35 -0500 | [diff] [blame] | 1224 | } |
| 1225 | |
| 1226 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1227 | configure(struct weston_shell *base, struct weston_surface *surface, |
Kristian Høgsberg | 32e24cc | 2011-11-09 12:07:35 -0500 | [diff] [blame] | 1228 | int32_t x, int32_t y, int32_t width, int32_t height) |
| 1229 | { |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1230 | struct wl_shell *shell = container_of(base, struct wl_shell, shell); |
| 1231 | int do_configure = !shell->locked; |
| 1232 | enum shell_surface_type surface_type = SHELL_SURFACE_NONE; |
| 1233 | struct shell_surface *shsurf; |
Kristian Høgsberg | 32e24cc | 2011-11-09 12:07:35 -0500 | [diff] [blame] | 1234 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1235 | shsurf = get_shell_surface(surface); |
| 1236 | if (shsurf) |
| 1237 | surface_type = shsurf->type; |
| 1238 | |
| 1239 | surface->width = width; |
| 1240 | surface->height = height; |
| 1241 | |
| 1242 | switch (surface_type) { |
| 1243 | case SHELL_SURFACE_SCREENSAVER: |
| 1244 | do_configure = !do_configure; |
| 1245 | /* fall through */ |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 1246 | case SHELL_SURFACE_FULLSCREEN: |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1247 | center_on_output(surface, surface->fullscreen_output); |
Kristian Høgsberg | d2abb83 | 2011-11-23 10:52:40 -0500 | [diff] [blame] | 1248 | break; |
| 1249 | default: |
| 1250 | break; |
Kristian Høgsberg | 7a5c979 | 2011-06-18 06:12:54 -0400 | [diff] [blame] | 1251 | } |
Kristian Høgsberg | 32e24cc | 2011-11-09 12:07:35 -0500 | [diff] [blame] | 1252 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1253 | /* |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1254 | * weston_surface_configure() will assign an output, which means |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1255 | * the surface is supposed to be in compositor->surface_list. |
| 1256 | * Be careful with that, and make sure we stay on the right output. |
| 1257 | * XXX: would a fullscreen surface need the same handling? |
| 1258 | */ |
| 1259 | if (do_configure) { |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1260 | weston_surface_configure(surface, x, y, width, height); |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1261 | |
| 1262 | if (surface_type == SHELL_SURFACE_SCREENSAVER) |
| 1263 | surface->output = shsurf->output; |
| 1264 | } |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 1265 | } |
| 1266 | |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 1267 | static void |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1268 | desktop_shell_sigchld(struct weston_process *process, int status) |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 1269 | { |
| 1270 | struct wl_shell *shell = |
| 1271 | container_of(process, struct wl_shell, child.process); |
| 1272 | |
| 1273 | shell->child.process.pid = 0; |
| 1274 | shell->child.client = NULL; /* already destroyed by wayland */ |
| 1275 | } |
| 1276 | |
| 1277 | static int |
| 1278 | launch_desktop_shell_process(struct wl_shell *shell) |
| 1279 | { |
Kristian Høgsberg | 9724b51 | 2012-01-03 14:35:49 -0500 | [diff] [blame] | 1280 | const char *shell_exe = LIBEXECDIR "/weston-desktop-shell"; |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 1281 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1282 | shell->child.client = weston_client_launch(shell->compositor, |
Pekka Paalanen | 409ef0a | 2011-12-02 15:30:21 +0200 | [diff] [blame] | 1283 | &shell->child.process, |
| 1284 | shell_exe, |
| 1285 | desktop_shell_sigchld); |
| 1286 | |
| 1287 | if (!shell->child.client) |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 1288 | return -1; |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 1289 | return 0; |
| 1290 | } |
| 1291 | |
| 1292 | static void |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 1293 | bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id) |
| 1294 | { |
| 1295 | struct wl_shell *shell = data; |
| 1296 | |
| 1297 | wl_client_add_object(client, &wl_shell_interface, |
Pekka Paalanen | 9d1613e | 2011-11-25 12:09:16 +0200 | [diff] [blame] | 1298 | &shell_implementation, id, shell); |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 1299 | } |
| 1300 | |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1301 | static void |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1302 | unbind_desktop_shell(struct wl_resource *resource) |
| 1303 | { |
| 1304 | struct wl_shell *shell = resource->data; |
Kristian Høgsberg | 1ec0c31 | 2011-11-15 16:39:55 -0500 | [diff] [blame] | 1305 | |
| 1306 | if (shell->locked) |
| 1307 | resume_desktop(shell); |
| 1308 | |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1309 | shell->child.desktop_shell = NULL; |
| 1310 | shell->prepare_event_sent = false; |
| 1311 | free(resource); |
| 1312 | } |
| 1313 | |
| 1314 | static void |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1315 | bind_desktop_shell(struct wl_client *client, |
| 1316 | void *data, uint32_t version, uint32_t id) |
| 1317 | { |
| 1318 | struct wl_shell *shell = data; |
Pekka Paalanen | bbe6052 | 2011-11-03 14:11:33 +0200 | [diff] [blame] | 1319 | struct wl_resource *resource; |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1320 | |
Pekka Paalanen | bbe6052 | 2011-11-03 14:11:33 +0200 | [diff] [blame] | 1321 | resource = wl_client_add_object(client, &desktop_shell_interface, |
| 1322 | &desktop_shell_implementation, |
| 1323 | id, shell); |
| 1324 | |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1325 | if (client == shell->child.client) { |
| 1326 | resource->destroy = unbind_desktop_shell; |
| 1327 | shell->child.desktop_shell = resource; |
Pekka Paalanen | bbe6052 | 2011-11-03 14:11:33 +0200 | [diff] [blame] | 1328 | return; |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1329 | } |
Pekka Paalanen | bbe6052 | 2011-11-03 14:11:33 +0200 | [diff] [blame] | 1330 | |
| 1331 | wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, |
| 1332 | "permission to bind desktop_shell denied"); |
| 1333 | wl_resource_destroy(resource, 0); |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1334 | } |
| 1335 | |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1336 | static void |
| 1337 | screensaver_set_surface(struct wl_client *client, |
| 1338 | struct wl_resource *resource, |
| 1339 | struct wl_resource *shell_surface_resource, |
| 1340 | struct wl_resource *output_resource) |
| 1341 | { |
| 1342 | struct wl_shell *shell = resource->data; |
| 1343 | struct shell_surface *surface = shell_surface_resource->data; |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1344 | struct weston_output *output = output_resource->data; |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1345 | |
Pekka Paalanen | 9826223 | 2011-12-01 10:42:22 +0200 | [diff] [blame] | 1346 | if (reset_shell_surface_type(surface)) |
| 1347 | return; |
| 1348 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1349 | surface->type = SHELL_SURFACE_SCREENSAVER; |
| 1350 | |
| 1351 | surface->surface->fullscreen_output = output; |
| 1352 | surface->output = output; |
| 1353 | wl_list_insert(shell->screensaver.surfaces.prev, &surface->link); |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | static const struct screensaver_interface screensaver_implementation = { |
| 1357 | screensaver_set_surface |
| 1358 | }; |
| 1359 | |
| 1360 | static void |
| 1361 | unbind_screensaver(struct wl_resource *resource) |
| 1362 | { |
| 1363 | struct wl_shell *shell = resource->data; |
| 1364 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1365 | shell->screensaver.binding = NULL; |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1366 | free(resource); |
| 1367 | } |
| 1368 | |
| 1369 | static void |
| 1370 | bind_screensaver(struct wl_client *client, |
| 1371 | void *data, uint32_t version, uint32_t id) |
| 1372 | { |
| 1373 | struct wl_shell *shell = data; |
| 1374 | struct wl_resource *resource; |
| 1375 | |
| 1376 | resource = wl_client_add_object(client, &screensaver_interface, |
| 1377 | &screensaver_implementation, |
| 1378 | id, shell); |
| 1379 | |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1380 | if (shell->screensaver.binding == NULL) { |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1381 | resource->destroy = unbind_screensaver; |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1382 | shell->screensaver.binding = resource; |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1383 | return; |
| 1384 | } |
| 1385 | |
| 1386 | wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, |
| 1387 | "interface object already bound"); |
| 1388 | wl_resource_destroy(resource, 0); |
| 1389 | } |
| 1390 | |
Pekka Paalanen | 3c64723 | 2011-12-22 13:43:43 +0200 | [diff] [blame] | 1391 | static void |
Kristian Høgsberg | 3466bc8 | 2012-01-03 11:29:15 -0500 | [diff] [blame] | 1392 | shell_destroy(struct weston_shell *base) |
Pekka Paalanen | 3c64723 | 2011-12-22 13:43:43 +0200 | [diff] [blame] | 1393 | { |
| 1394 | struct wl_shell *shell = container_of(base, struct wl_shell, shell); |
| 1395 | |
Pekka Paalanen | 9cf5cc8 | 2012-01-02 16:00:24 +0200 | [diff] [blame] | 1396 | if (shell->child.client) |
| 1397 | wl_client_destroy(shell->child.client); |
| 1398 | |
Pekka Paalanen | 3c64723 | 2011-12-22 13:43:43 +0200 | [diff] [blame] | 1399 | free(shell->screensaver.path); |
| 1400 | free(shell); |
| 1401 | } |
| 1402 | |
Kristian Høgsberg | 6c709a3 | 2011-05-06 14:52:41 -0400 | [diff] [blame] | 1403 | int |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1404 | shell_init(struct weston_compositor *ec); |
Kristian Høgsberg | 6c709a3 | 2011-05-06 14:52:41 -0400 | [diff] [blame] | 1405 | |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 1406 | WL_EXPORT int |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1407 | shell_init(struct weston_compositor *ec) |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 1408 | { |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1409 | struct wl_shell *shell; |
| 1410 | |
| 1411 | shell = malloc(sizeof *shell); |
| 1412 | if (shell == NULL) |
| 1413 | return -1; |
| 1414 | |
Kristian Høgsberg | f0d9116 | 2011-10-11 22:44:23 -0400 | [diff] [blame] | 1415 | memset(shell, 0, sizeof *shell); |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1416 | shell->compositor = ec; |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1417 | shell->shell.lock = lock; |
Pekka Paalanen | 9ef3e01 | 2011-11-15 13:34:48 +0200 | [diff] [blame] | 1418 | shell->shell.unlock = unlock; |
Kristian Høgsberg | 32e24cc | 2011-11-09 12:07:35 -0500 | [diff] [blame] | 1419 | shell->shell.map = map; |
| 1420 | shell->shell.configure = configure; |
Pekka Paalanen | 3c64723 | 2011-12-22 13:43:43 +0200 | [diff] [blame] | 1421 | shell->shell.destroy = shell_destroy; |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 1422 | |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1423 | wl_list_init(&shell->hidden_surface_list); |
Benjamin Franzke | d0f79ab | 2011-11-22 12:43:52 +0100 | [diff] [blame] | 1424 | wl_list_init(&shell->backgrounds); |
| 1425 | wl_list_init(&shell->panels); |
Pekka Paalanen | 77346a6 | 2011-11-30 16:26:35 +0200 | [diff] [blame] | 1426 | wl_list_init(&shell->screensaver.surfaces); |
Pekka Paalanen | f0fc70d | 2011-11-15 13:34:54 +0200 | [diff] [blame] | 1427 | |
Pekka Paalanen | e955f1e | 2011-12-07 11:49:52 +0200 | [diff] [blame] | 1428 | if (shell_configuration(shell) < 0) |
| 1429 | return -1; |
| 1430 | |
Kristian Høgsberg | 97d44aa | 2011-08-26 17:21:20 -0400 | [diff] [blame] | 1431 | if (wl_display_add_global(ec->wl_display, &wl_shell_interface, |
| 1432 | shell, bind_shell) == NULL) |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 1433 | return -1; |
| 1434 | |
Kristian Høgsberg | 7584062 | 2011-09-06 13:48:16 -0400 | [diff] [blame] | 1435 | if (wl_display_add_global(ec->wl_display, |
| 1436 | &desktop_shell_interface, |
| 1437 | shell, bind_desktop_shell) == NULL) |
| 1438 | return -1; |
| 1439 | |
Pekka Paalanen | 6e16811 | 2011-11-24 11:34:05 +0200 | [diff] [blame] | 1440 | if (wl_display_add_global(ec->wl_display, &screensaver_interface, |
| 1441 | shell, bind_screensaver) == NULL) |
| 1442 | return -1; |
| 1443 | |
Pekka Paalanen | 6cd281a | 2011-11-03 14:11:32 +0200 | [diff] [blame] | 1444 | if (launch_desktop_shell_process(shell) != 0) |
| 1445 | return -1; |
| 1446 | |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1447 | weston_compositor_add_binding(ec, 0, BTN_LEFT, MODIFIER_SUPER, |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1448 | move_binding, shell); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1449 | weston_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER, |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1450 | resize_binding, shell); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1451 | weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 1452 | MODIFIER_CTRL | MODIFIER_ALT, |
| 1453 | terminate_binding, ec); |
Kristian Høgsberg | 8334bc1 | 2012-01-03 10:29:47 -0500 | [diff] [blame] | 1454 | weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, |
Kristian Høgsberg | e1a850e | 2011-12-19 15:18:05 -0500 | [diff] [blame] | 1455 | click_to_activate_binding, ec); |
| 1456 | |
Kristian Høgsberg | 02ec0a5 | 2011-04-23 13:04:11 -0400 | [diff] [blame] | 1457 | ec->shell = &shell->shell; |
Kristian Høgsberg | 0793756 | 2011-04-12 17:25:42 -0400 | [diff] [blame] | 1458 | |
Kristian Høgsberg | 4cca349 | 2011-01-18 07:53:49 -0500 | [diff] [blame] | 1459 | return 0; |
| 1460 | } |