blob: 4ff5306a4edd0c558b1368e7c4d6e261fc829ba0 [file] [log] [blame]
Kristian Høgsberg4cca3492011-01-18 07:53:49 -05001/*
2 * Copyright © 2010 Intel Corporation
Pekka Paalanen9ef3e012011-11-15 13:34:48 +02003 * Copyright © 2011 Collabora, Ltd.
Kristian Høgsberg4cca3492011-01-18 07:53:49 -05004 *
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øgsberg75840622011-09-06 13:48:16 -040025#include <stdio.h>
Pekka Paalanen9ef3e012011-11-15 13:34:48 +020026#include <stdbool.h>
Kristian Høgsberg4cca3492011-01-18 07:53:49 -050027#include <string.h>
28#include <unistd.h>
Kristian Høgsberg07937562011-04-12 17:25:42 -040029#include <linux/input.h>
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +020030#include <assert.h>
Pekka Paalanen18027e52011-12-02 16:31:49 +020031#include <signal.h>
Kristian Høgsberg4cca3492011-01-18 07:53:49 -050032
Pekka Paalanen50719bc2011-11-22 14:18:50 +020033#include <wayland-server.h>
Kristian Høgsberg4cca3492011-01-18 07:53:49 -050034#include "compositor.h"
Kristian Høgsberg75840622011-09-06 13:48:16 -040035#include "desktop-shell-server-protocol.h"
Pekka Paalanene955f1e2011-12-07 11:49:52 +020036#include "../shared/config-parser.h"
Kristian Høgsberg4cca3492011-01-18 07:53:49 -050037
Pekka Paalanen068ae942011-11-28 14:11:15 +020038struct shell_surface;
39
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -040040struct wl_shell {
Kristian Høgsberg75840622011-09-06 13:48:16 -040041 struct wlsc_compositor *compositor;
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -040042 struct wlsc_shell shell;
Pekka Paalanen6cd281a2011-11-03 14:11:32 +020043
44 struct {
45 struct wlsc_process process;
46 struct wl_client *client;
Pekka Paalanen9ef3e012011-11-15 13:34:48 +020047 struct wl_resource *desktop_shell;
Pekka Paalanen6cd281a2011-11-03 14:11:32 +020048 } child;
Pekka Paalanen9ef3e012011-11-15 13:34:48 +020049
50 bool locked;
51 bool prepare_event_sent;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +020052
Pekka Paalanen068ae942011-11-28 14:11:15 +020053 struct shell_surface *lock_surface;
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -050054 struct wl_listener lock_surface_listener;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +020055 struct wl_list hidden_surface_list;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010056
57 struct wl_list backgrounds;
58 struct wl_list panels;
Pekka Paalanen6e168112011-11-24 11:34:05 +020059
Pekka Paalanen77346a62011-11-30 16:26:35 +020060 struct {
Pekka Paalanen3c647232011-12-22 13:43:43 +020061 char *path;
Pekka Paalanen7296e792011-12-07 16:22:00 +020062 int duration;
Pekka Paalanen77346a62011-11-30 16:26:35 +020063 struct wl_resource *binding;
64 struct wl_list surfaces;
Pekka Paalanen18027e52011-12-02 16:31:49 +020065 struct wlsc_process process;
Pekka Paalanen77346a62011-11-30 16:26:35 +020066 } screensaver;
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -040067};
68
Kristian Høgsbergd2abb832011-11-23 10:52:40 -050069enum shell_surface_type {
Pekka Paalanen98262232011-12-01 10:42:22 +020070 SHELL_SURFACE_NONE,
Kristian Høgsbergd2abb832011-11-23 10:52:40 -050071
Pekka Paalanen57da4a82011-11-23 16:42:16 +020072 SHELL_SURFACE_PANEL,
73 SHELL_SURFACE_BACKGROUND,
74 SHELL_SURFACE_LOCK,
Pekka Paalanen77346a62011-11-30 16:26:35 +020075 SHELL_SURFACE_SCREENSAVER,
Kristian Høgsbergd2abb832011-11-23 10:52:40 -050076
77 SHELL_SURFACE_TOPLEVEL,
78 SHELL_SURFACE_TRANSIENT,
79 SHELL_SURFACE_FULLSCREEN
Pekka Paalanen57da4a82011-11-23 16:42:16 +020080};
81
Pekka Paalanen56cdea92011-11-23 16:14:12 +020082struct shell_surface {
Pekka Paalanen9d1613e2011-11-25 12:09:16 +020083 struct wl_resource resource;
84
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010085 struct wlsc_surface *surface;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +020086 struct wl_listener surface_destroy_listener;
Pekka Paalanen57da4a82011-11-23 16:42:16 +020087
Kristian Høgsbergd2abb832011-11-23 10:52:40 -050088 enum shell_surface_type type;
89 int32_t saved_x, saved_y;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +010090
91 struct wlsc_output *output;
92 struct wl_list link;
Pekka Paalanen56cdea92011-11-23 16:14:12 +020093};
94
Kristian Høgsberg4cca3492011-01-18 07:53:49 -050095struct wlsc_move_grab {
96 struct wl_grab grab;
Kristian Høgsbergdd4046a2011-01-21 17:00:09 -050097 struct wlsc_surface *surface;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -050098 int32_t dx, dy;
99};
100
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200101static int
102shell_configuration(struct wl_shell *shell)
103{
104 int ret;
105 char *config_file;
Pekka Paalanen7296e792011-12-07 16:22:00 +0200106 char *path = NULL;
107 int duration = 60;
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200108
109 struct config_key saver_keys[] = {
Pekka Paalanen7296e792011-12-07 16:22:00 +0200110 { "path", CONFIG_KEY_STRING, &path },
111 { "duration", CONFIG_KEY_INTEGER, &duration },
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200112 };
113
114 struct config_section cs[] = {
115 { "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },
116 };
117
118 config_file = config_file_path("wayland-desktop-shell.ini");
119 ret = parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
120 free(config_file);
121
Pekka Paalanen7296e792011-12-07 16:22:00 +0200122 shell->screensaver.path = path;
123 shell->screensaver.duration = duration;
124
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200125 return ret;
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200126}
127
Pekka Paalanen56cdea92011-11-23 16:14:12 +0200128static void
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500129move_grab_motion(struct wl_grab *grab,
130 uint32_t time, int32_t x, int32_t y)
131{
132 struct wlsc_move_grab *move = (struct wlsc_move_grab *) grab;
Kristian Høgsbergdd4046a2011-01-21 17:00:09 -0500133 struct wlsc_surface *es = move->surface;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500134
Kristian Høgsberga691aee2011-06-23 21:43:50 -0400135 wlsc_surface_configure(es, x + move->dx, y + move->dy,
136 es->width, es->height);
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500137}
138
139static void
140move_grab_button(struct wl_grab *grab,
141 uint32_t time, int32_t button, int32_t state)
142{
143}
144
145static void
146move_grab_end(struct wl_grab *grab, uint32_t time)
147{
148 free(grab);
149}
150
151static const struct wl_grab_interface move_grab_interface = {
152 move_grab_motion,
153 move_grab_button,
154 move_grab_end
155};
156
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400157static int
158wlsc_surface_move(struct wlsc_surface *es,
159 struct wlsc_input_device *wd, uint32_t time)
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500160{
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500161 struct wlsc_move_grab *move;
162
163 move = malloc(sizeof *move);
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400164 if (!move)
165 return -1;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500166
167 move->grab.interface = &move_grab_interface;
168 move->dx = es->x - wd->input_device.grab_x;
169 move->dy = es->y - wd->input_device.grab_y;
Kristian Høgsbergdd4046a2011-01-21 17:00:09 -0500170 move->surface = es;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500171
172 if (wl_input_device_update_grab(&wd->input_device,
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400173 &move->grab, &es->surface, time) < 0)
174 return 0;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500175
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400176 wl_input_device_set_pointer_focus(&wd->input_device,
177 NULL, time, 0, 0, 0, 0);
178
179 return 0;
180}
181
182static void
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200183shell_surface_move(struct wl_client *client, struct wl_resource *resource,
184 struct wl_resource *input_resource, uint32_t time)
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400185{
186 struct wlsc_input_device *wd = input_resource->data;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200187 struct shell_surface *shsurf = resource->data;
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400188
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200189 if (wlsc_surface_move(shsurf->surface, wd, time) < 0)
Kristian Høgsberg9ebcf942011-09-01 09:54:57 -0400190 wl_resource_post_no_memory(resource);
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500191}
192
193struct wlsc_resize_grab {
194 struct wl_grab grab;
195 uint32_t edges;
196 int32_t dx, dy, width, height;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200197 struct shell_surface *shsurf;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500198};
199
200static void
201resize_grab_motion(struct wl_grab *grab,
202 uint32_t time, int32_t x, int32_t y)
203{
204 struct wlsc_resize_grab *resize = (struct wlsc_resize_grab *) grab;
205 struct wl_input_device *device = grab->input_device;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500206 int32_t width, height;
207
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200208 if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500209 width = device->grab_x - x + resize->width;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200210 } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) {
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500211 width = x - device->grab_x + resize->width;
212 } else {
213 width = resize->width;
214 }
215
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200216 if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) {
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500217 height = device->grab_y - y + resize->height;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200218 } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) {
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500219 height = y - device->grab_y + resize->height;
220 } else {
221 height = resize->height;
222 }
223
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200224 wl_resource_post_event(&resize->shsurf->resource,
225 WL_SHELL_SURFACE_CONFIGURE, time, resize->edges,
226 width, height);
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500227}
228
229static void
230resize_grab_button(struct wl_grab *grab,
231 uint32_t time, int32_t button, int32_t state)
232{
233}
234
235static void
236resize_grab_end(struct wl_grab *grab, uint32_t time)
237{
238 free(grab);
239}
240
241static const struct wl_grab_interface resize_grab_interface = {
242 resize_grab_motion,
243 resize_grab_button,
244 resize_grab_end
245};
246
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400247static int
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200248wlsc_surface_resize(struct shell_surface *shsurf,
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400249 struct wlsc_input_device *wd,
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200250 uint32_t time, uint32_t edges)
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500251{
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500252 struct wlsc_resize_grab *resize;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200253 struct wlsc_surface *es = shsurf->surface;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500254
Kristian Høgsberg0ce24572011-01-28 15:18:33 -0500255 /* FIXME: Reject if fullscreen */
256
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500257 resize = malloc(sizeof *resize);
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400258 if (!resize)
259 return -1;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500260
261 resize->grab.interface = &resize_grab_interface;
262 resize->edges = edges;
263 resize->dx = es->x - wd->input_device.grab_x;
264 resize->dy = es->y - wd->input_device.grab_y;
265 resize->width = es->width;
266 resize->height = es->height;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200267 resize->shsurf = shsurf;
Kristian Høgsberg904055a2011-08-18 17:55:30 -0400268
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500269 if (edges == 0 || edges > 15 ||
270 (edges & 3) == 3 || (edges & 12) == 12)
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400271 return 0;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500272
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500273 if (wl_input_device_update_grab(&wd->input_device,
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400274 &resize->grab, &es->surface, time) < 0)
275 return 0;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500276
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400277 wl_input_device_set_pointer_focus(&wd->input_device,
278 NULL, time, 0, 0, 0, 0);
279
280 return 0;
281}
282
283static void
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200284shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
285 struct wl_resource *input_resource, uint32_t time,
286 uint32_t edges)
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400287{
288 struct wlsc_input_device *wd = input_resource->data;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200289 struct shell_surface *shsurf = resource->data;
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400290
291 /* FIXME: Reject if fullscreen */
292
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200293 if (wlsc_surface_resize(shsurf, wd, time, edges) < 0)
Kristian Høgsberg9ebcf942011-09-01 09:54:57 -0400294 wl_resource_post_no_memory(resource);
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500295}
296
Pekka Paalanen98262232011-12-01 10:42:22 +0200297static int
298reset_shell_surface_type(struct shell_surface *surface)
299{
300 switch (surface->type) {
301 case SHELL_SURFACE_FULLSCREEN:
302 surface->surface->x = surface->saved_x;
303 surface->surface->y = surface->saved_y;
304 surface->surface->fullscreen_output = NULL;
305 break;
306 case SHELL_SURFACE_PANEL:
307 case SHELL_SURFACE_BACKGROUND:
308 wl_list_remove(&surface->link);
309 wl_list_init(&surface->link);
310 break;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200311 case SHELL_SURFACE_SCREENSAVER:
Pekka Paalanen98262232011-12-01 10:42:22 +0200312 case SHELL_SURFACE_LOCK:
313 wl_resource_post_error(&surface->resource,
314 WL_DISPLAY_ERROR_INVALID_METHOD,
Pekka Paalanen77346a62011-11-30 16:26:35 +0200315 "cannot reassign surface type");
Pekka Paalanen98262232011-12-01 10:42:22 +0200316 return -1;
317 case SHELL_SURFACE_NONE:
318 case SHELL_SURFACE_TOPLEVEL:
319 case SHELL_SURFACE_TRANSIENT:
320 break;
321 }
322
323 surface->type = SHELL_SURFACE_NONE;
324 return 0;
325}
326
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500327static void
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200328shell_surface_set_toplevel(struct wl_client *client,
329 struct wl_resource *resource)
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400330
331{
Pekka Paalanen98262232011-12-01 10:42:22 +0200332 struct shell_surface *surface = resource->data;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400333
Pekka Paalanen98262232011-12-01 10:42:22 +0200334 if (reset_shell_surface_type(surface))
335 return;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400336
Pekka Paalanen98262232011-12-01 10:42:22 +0200337 wlsc_surface_damage(surface->surface);
338 surface->type = SHELL_SURFACE_TOPLEVEL;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400339}
340
341static void
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200342shell_surface_set_transient(struct wl_client *client,
343 struct wl_resource *resource,
344 struct wl_resource *parent_resource,
345 int x, int y, uint32_t flags)
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400346{
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200347 struct shell_surface *shsurf = resource->data;
348 struct wlsc_surface *es = shsurf->surface;
Pekka Paalanen01e7b002011-12-08 16:42:33 +0200349 struct shell_surface *pshsurf = parent_resource->data;
350 struct wlsc_surface *pes = pshsurf->surface;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400351
Pekka Paalanen98262232011-12-01 10:42:22 +0200352 if (reset_shell_surface_type(shsurf))
353 return;
354
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400355 /* assign to parents output */
356 es->output = pes->output;
357
358 es->x = pes->x + x;
359 es->y = pes->y + y;
360
361 wlsc_surface_damage(es);
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200362 shsurf->type = SHELL_SURFACE_TRANSIENT;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400363}
364
Pekka Paalanenaf0e34c2011-12-02 10:59:17 +0200365static struct wlsc_output *
366get_default_output(struct wlsc_compositor *compositor)
367{
368 return container_of(compositor->output_list.next,
369 struct wlsc_output, link);
370}
371
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400372static void
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200373shell_surface_set_fullscreen(struct wl_client *client,
374 struct wl_resource *resource)
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400375
376{
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200377 struct shell_surface *shsurf = resource->data;
378 struct wlsc_surface *es = shsurf->surface;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400379 struct wlsc_output *output;
380
Pekka Paalanen98262232011-12-01 10:42:22 +0200381 if (reset_shell_surface_type(shsurf))
382 return;
383
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400384 /* FIXME: Fullscreen on first output */
385 /* FIXME: Handle output going away */
Pekka Paalanenaf0e34c2011-12-02 10:59:17 +0200386 output = get_default_output(es->compositor);
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400387 es->output = output;
388
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200389 shsurf->saved_x = es->x;
390 shsurf->saved_y = es->y;
Kristian Høgsberg8f0ce052011-06-21 11:16:58 -0400391 es->x = (output->current->width - es->width) / 2;
392 es->y = (output->current->height - es->height) / 2;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400393 es->fullscreen_output = output;
394 wlsc_surface_damage(es);
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200395 shsurf->type = SHELL_SURFACE_FULLSCREEN;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400396}
397
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200398static const struct wl_shell_surface_interface shell_surface_implementation = {
399 shell_surface_move,
400 shell_surface_resize,
401 shell_surface_set_toplevel,
402 shell_surface_set_transient,
403 shell_surface_set_fullscreen
404};
405
406static void
407destroy_shell_surface(struct wl_resource *resource)
408{
409 struct shell_surface *shsurf = resource->data;
410
411 /* in case cleaning up a dead client destroys shell_surface first */
412 if (shsurf->surface)
413 wl_list_remove(&shsurf->surface_destroy_listener.link);
414
415 wl_list_remove(&shsurf->link);
416 free(shsurf);
417}
418
419static void
420shell_handle_surface_destroy(struct wl_listener *listener,
421 struct wl_resource *resource, uint32_t time)
422{
423 struct shell_surface *shsurf = container_of(listener,
424 struct shell_surface,
425 surface_destroy_listener);
426
427 shsurf->surface = NULL;
428 wl_resource_destroy(&shsurf->resource, time);
429}
430
Pekka Paalanenec2b32f2011-11-28 15:12:34 +0200431static struct shell_surface *
432get_shell_surface(struct wlsc_surface *surface)
433{
434 struct wl_list *lst = &surface->surface.resource.destroy_listener_list;
435 struct wl_listener *listener;
436
437 /* search the destroy listener list for our callback */
438 wl_list_for_each(listener, lst, link) {
439 if (listener->func == shell_handle_surface_destroy) {
440 return container_of(listener, struct shell_surface,
441 surface_destroy_listener);
442 }
443 }
444
445 return NULL;
446}
447
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200448static void
Pekka Paalanen46229672011-11-29 15:49:31 +0200449shell_get_shell_surface(struct wl_client *client,
450 struct wl_resource *resource,
451 uint32_t id,
452 struct wl_resource *surface_resource)
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200453{
454 struct wlsc_surface *surface = surface_resource->data;
455 struct shell_surface *shsurf;
456
Pekka Paalanenf32f1fc2011-11-29 16:05:28 +0200457 if (get_shell_surface(surface)) {
458 wl_resource_post_error(surface_resource,
459 WL_DISPLAY_ERROR_INVALID_OBJECT,
460 "wl_shell::get_shell_surface already requested");
461 return;
462 }
463
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200464 shsurf = calloc(1, sizeof *shsurf);
465 if (!shsurf) {
466 wl_resource_post_no_memory(resource);
467 return;
468 }
469
470 shsurf->resource.destroy = destroy_shell_surface;
471 shsurf->resource.object.id = id;
472 shsurf->resource.object.interface = &wl_shell_surface_interface;
473 shsurf->resource.object.implementation =
474 (void (**)(void)) &shell_surface_implementation;
475 shsurf->resource.data = shsurf;
476
477 shsurf->surface = surface;
478 shsurf->surface_destroy_listener.func = shell_handle_surface_destroy;
479 wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
480 &shsurf->surface_destroy_listener.link);
481
482 /* init link so its safe to always remove it in destroy_shell_surface */
483 wl_list_init(&shsurf->link);
484
Pekka Paalanen98262232011-12-01 10:42:22 +0200485 shsurf->type = SHELL_SURFACE_NONE;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200486
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200487 wl_client_add_resource(client, &shsurf->resource);
488}
489
490static const struct wl_shell_interface shell_implementation = {
Pekka Paalanen46229672011-11-29 15:49:31 +0200491 shell_get_shell_surface
Kristian Høgsberg4cca3492011-01-18 07:53:49 -0500492};
493
Kristian Høgsberg07937562011-04-12 17:25:42 -0400494static void
Pekka Paalanen18027e52011-12-02 16:31:49 +0200495handle_screensaver_sigchld(struct wlsc_process *proc, int status)
496{
497 proc->pid = 0;
498}
499
500static void
Pekka Paalanen77346a62011-11-30 16:26:35 +0200501launch_screensaver(struct wl_shell *shell)
502{
503 if (shell->screensaver.binding)
504 return;
505
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200506 if (!shell->screensaver.path)
507 return;
508
Pekka Paalanen18027e52011-12-02 16:31:49 +0200509 wlsc_client_launch(shell->compositor,
510 &shell->screensaver.process,
Pekka Paalanene955f1e2011-12-07 11:49:52 +0200511 shell->screensaver.path,
Pekka Paalanen18027e52011-12-02 16:31:49 +0200512 handle_screensaver_sigchld);
Pekka Paalanen77346a62011-11-30 16:26:35 +0200513}
514
515static void
516terminate_screensaver(struct wl_shell *shell)
517{
Pekka Paalanen18027e52011-12-02 16:31:49 +0200518 if (shell->screensaver.process.pid == 0)
519 return;
520
521 kill(shell->screensaver.process.pid, SIGTERM);
Pekka Paalanen77346a62011-11-30 16:26:35 +0200522}
523
524static void
525show_screensaver(struct wl_shell *shell, struct shell_surface *surface)
526{
527 struct wl_list *list;
528
529 if (shell->lock_surface)
530 list = &shell->lock_surface->surface->link;
531 else
532 list = &shell->compositor->surface_list;
533
534 wl_list_remove(&surface->surface->link);
535 wl_list_insert(list, &surface->surface->link);
536 wlsc_surface_configure(surface->surface,
537 surface->surface->x,
538 surface->surface->y,
539 surface->surface->width,
540 surface->surface->height);
541 surface->surface->output = surface->output;
542}
543
544static void
545hide_screensaver(struct wl_shell *shell, struct shell_surface *surface)
546{
547 wl_list_remove(&surface->surface->link);
548 wl_list_init(&surface->surface->link);
549 surface->surface->output = NULL;
550}
551
552static void
Kristian Høgsberg75840622011-09-06 13:48:16 -0400553desktop_shell_set_background(struct wl_client *client,
554 struct wl_resource *resource,
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100555 struct wl_resource *output_resource,
Kristian Høgsberg75840622011-09-06 13:48:16 -0400556 struct wl_resource *surface_resource)
557{
558 struct wl_shell *shell = resource->data;
Pekka Paalanen068ae942011-11-28 14:11:15 +0200559 struct shell_surface *shsurf = surface_resource->data;
560 struct wlsc_surface *surface = shsurf->surface;
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200561 struct shell_surface *priv;
Kristian Høgsberg75840622011-09-06 13:48:16 -0400562
Pekka Paalanen98262232011-12-01 10:42:22 +0200563 if (reset_shell_surface_type(shsurf))
564 return;
565
Benjamin Franzkef02bb642011-11-23 20:46:40 +0100566 wl_list_for_each(priv, &shell->backgrounds, link) {
567 if (priv->output == output_resource->data) {
568 priv->surface->output = NULL;
569 wl_list_remove(&priv->surface->link);
570 wl_list_remove(&priv->link);
571 break;
572 }
573 }
574
Pekka Paalanen068ae942011-11-28 14:11:15 +0200575 shsurf->type = SHELL_SURFACE_BACKGROUND;
576 shsurf->output = output_resource->data;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100577
Pekka Paalanen068ae942011-11-28 14:11:15 +0200578 wl_list_insert(&shell->backgrounds, &shsurf->link);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100579
Pekka Paalanen068ae942011-11-28 14:11:15 +0200580 surface->x = shsurf->output->x;
581 surface->y = shsurf->output->y;
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200582
Kristian Høgsberg75840622011-09-06 13:48:16 -0400583 wl_resource_post_event(resource,
584 DESKTOP_SHELL_CONFIGURE,
Pekka Paalanen068ae942011-11-28 14:11:15 +0200585 wlsc_compositor_get_time(), 0, surface_resource,
586 shsurf->output->current->width,
587 shsurf->output->current->height);
Kristian Høgsberg75840622011-09-06 13:48:16 -0400588}
589
590static void
591desktop_shell_set_panel(struct wl_client *client,
592 struct wl_resource *resource,
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100593 struct wl_resource *output_resource,
Kristian Høgsberg75840622011-09-06 13:48:16 -0400594 struct wl_resource *surface_resource)
595{
596 struct wl_shell *shell = resource->data;
Pekka Paalanen068ae942011-11-28 14:11:15 +0200597 struct shell_surface *shsurf = surface_resource->data;
598 struct wlsc_surface *surface = shsurf->surface;
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200599 struct shell_surface *priv;
Kristian Høgsberg75840622011-09-06 13:48:16 -0400600
Pekka Paalanen98262232011-12-01 10:42:22 +0200601 if (reset_shell_surface_type(shsurf))
602 return;
603
Benjamin Franzkef02bb642011-11-23 20:46:40 +0100604 wl_list_for_each(priv, &shell->panels, link) {
605 if (priv->output == output_resource->data) {
606 priv->surface->output = NULL;
607 wl_list_remove(&priv->surface->link);
608 wl_list_remove(&priv->link);
609 break;
610 }
611 }
612
Pekka Paalanen068ae942011-11-28 14:11:15 +0200613 shsurf->type = SHELL_SURFACE_PANEL;
614 shsurf->output = output_resource->data;
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100615
Pekka Paalanen068ae942011-11-28 14:11:15 +0200616 wl_list_insert(&shell->panels, &shsurf->link);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100617
Pekka Paalanen068ae942011-11-28 14:11:15 +0200618 surface->x = shsurf->output->x;
619 surface->y = shsurf->output->y;
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200620
Kristian Høgsberg75840622011-09-06 13:48:16 -0400621 wl_resource_post_event(resource,
622 DESKTOP_SHELL_CONFIGURE,
623 wlsc_compositor_get_time(), 0, surface_resource,
Pekka Paalanen068ae942011-11-28 14:11:15 +0200624 shsurf->output->current->width,
625 shsurf->output->current->height);
Kristian Høgsberg75840622011-09-06 13:48:16 -0400626}
627
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200628static void
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500629handle_lock_surface_destroy(struct wl_listener *listener,
630 struct wl_resource *resource, uint32_t time)
631{
632 struct wl_shell *shell =
Pekka Paalanen2ca86302011-11-16 13:47:35 +0200633 container_of(listener, struct wl_shell, lock_surface_listener);
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500634
635 fprintf(stderr, "lock surface gone\n");
636 shell->lock_surface = NULL;
637}
638
639static void
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200640desktop_shell_set_lock_surface(struct wl_client *client,
641 struct wl_resource *resource,
642 struct wl_resource *surface_resource)
643{
Kristian Høgsbergaf867cc2011-11-15 13:34:49 +0200644 struct wl_shell *shell = resource->data;
Pekka Paalanen98262232011-12-01 10:42:22 +0200645 struct shell_surface *surface = surface_resource->data;
646
647 if (reset_shell_surface_type(surface))
648 return;
Kristian Høgsbergaf867cc2011-11-15 13:34:49 +0200649
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200650 shell->prepare_event_sent = false;
Kristian Høgsbergaf867cc2011-11-15 13:34:49 +0200651
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200652 if (!shell->locked)
653 return;
654
Pekka Paalanen98262232011-12-01 10:42:22 +0200655 shell->lock_surface = surface;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200656
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500657 shell->lock_surface_listener.func = handle_lock_surface_destroy;
658 wl_list_insert(&surface_resource->destroy_listener_list,
659 &shell->lock_surface_listener.link);
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200660
Pekka Paalanen068ae942011-11-28 14:11:15 +0200661 shell->lock_surface->type = SHELL_SURFACE_LOCK;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200662}
663
664static void
665resume_desktop(struct wl_shell *shell)
666{
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500667 struct wlsc_surface *surface;
Pekka Paalanenfe340832011-11-25 16:07:52 +0200668 struct wl_list *list;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200669 struct shell_surface *tmp;
670
671 wl_list_for_each(tmp, &shell->screensaver.surfaces, link)
672 hide_screensaver(shell, tmp);
673
674 terminate_screensaver(shell);
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200675
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500676 wl_list_for_each(surface, &shell->hidden_surface_list, link)
677 wlsc_surface_configure(surface, surface->x, surface->y,
678 surface->width, surface->height);
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200679
Pekka Paalanenfe340832011-11-25 16:07:52 +0200680 if (wl_list_empty(&shell->backgrounds)) {
681 list = &shell->compositor->surface_list;
682 } else {
683 struct shell_surface *background;
684 background = container_of(shell->backgrounds.prev,
685 struct shell_surface, link);
686 list = background->surface->link.prev;
687 }
688
689 if (!wl_list_empty(&shell->hidden_surface_list))
690 wl_list_insert_list(list, &shell->hidden_surface_list);
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500691 wl_list_init(&shell->hidden_surface_list);
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200692
693 shell->locked = false;
694 wlsc_compositor_repick(shell->compositor);
Pekka Paalanen7296e792011-12-07 16:22:00 +0200695 shell->compositor->idle_time = shell->compositor->option_idle_time;
Kristian Høgsbergaf867cc2011-11-15 13:34:49 +0200696 wlsc_compositor_wake(shell->compositor);
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200697}
698
699static void
700desktop_shell_unlock(struct wl_client *client,
701 struct wl_resource *resource)
702{
703 struct wl_shell *shell = resource->data;
704
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200705 shell->prepare_event_sent = false;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200706
707 if (shell->locked)
708 resume_desktop(shell);
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200709}
710
Kristian Høgsberg75840622011-09-06 13:48:16 -0400711static const struct desktop_shell_interface desktop_shell_implementation = {
712 desktop_shell_set_background,
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200713 desktop_shell_set_panel,
714 desktop_shell_set_lock_surface,
715 desktop_shell_unlock
Kristian Høgsberg75840622011-09-06 13:48:16 -0400716};
717
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200718static enum shell_surface_type
719get_shell_surface_type(struct wlsc_surface *surface)
720{
721 struct shell_surface *shsurf;
722
723 shsurf = get_shell_surface(surface);
724 if (!shsurf)
Pekka Paalanen98262232011-12-01 10:42:22 +0200725 return SHELL_SURFACE_NONE;
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200726 return shsurf->type;
727}
728
Kristian Høgsberg75840622011-09-06 13:48:16 -0400729static void
Kristian Høgsberg07937562011-04-12 17:25:42 -0400730move_binding(struct wl_input_device *device, uint32_t time,
731 uint32_t key, uint32_t button, uint32_t state, void *data)
732{
Kristian Høgsberg07937562011-04-12 17:25:42 -0400733 struct wlsc_surface *surface =
734 (struct wlsc_surface *) device->pointer_focus;
Kristian Høgsbergd2abb832011-11-23 10:52:40 -0500735
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100736 if (surface == NULL)
737 return;
Kristian Høgsberg07937562011-04-12 17:25:42 -0400738
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200739 switch (get_shell_surface_type(surface)) {
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100740 case SHELL_SURFACE_PANEL:
741 case SHELL_SURFACE_BACKGROUND:
742 case SHELL_SURFACE_FULLSCREEN:
Pekka Paalanen77346a62011-11-30 16:26:35 +0200743 case SHELL_SURFACE_SCREENSAVER:
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100744 return;
745 default:
746 break;
747 }
Kristian Høgsberg10f097e2011-04-13 11:52:54 -0400748
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -0400749 wlsc_surface_move(surface, (struct wlsc_input_device *) device, time);
Kristian Høgsberg07937562011-04-12 17:25:42 -0400750}
751
752static void
753resize_binding(struct wl_input_device *device, uint32_t time,
754 uint32_t key, uint32_t button, uint32_t state, void *data)
755{
Kristian Høgsberg07937562011-04-12 17:25:42 -0400756 struct wlsc_surface *surface =
757 (struct wlsc_surface *) device->pointer_focus;
758 uint32_t edges = 0;
759 int32_t x, y;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200760 struct shell_surface *shsurf;
Kristian Høgsbergd2abb832011-11-23 10:52:40 -0500761
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100762 if (surface == NULL)
763 return;
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200764
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200765 shsurf = get_shell_surface(surface);
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200766 if (!shsurf)
767 return;
768
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200769 switch (shsurf->type) {
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100770 case SHELL_SURFACE_PANEL:
771 case SHELL_SURFACE_BACKGROUND:
772 case SHELL_SURFACE_FULLSCREEN:
Pekka Paalanen77346a62011-11-30 16:26:35 +0200773 case SHELL_SURFACE_SCREENSAVER:
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100774 return;
775 default:
776 break;
777 }
Kristian Høgsberg10f097e2011-04-13 11:52:54 -0400778
Kristian Høgsberg07937562011-04-12 17:25:42 -0400779 x = device->grab_x - surface->x;
780 y = device->grab_y - surface->y;
781
782 if (x < surface->width / 3)
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200783 edges |= WL_SHELL_SURFACE_RESIZE_LEFT;
Kristian Høgsberg07937562011-04-12 17:25:42 -0400784 else if (x < 2 * surface->width / 3)
785 edges |= 0;
786 else
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200787 edges |= WL_SHELL_SURFACE_RESIZE_RIGHT;
Kristian Høgsberg07937562011-04-12 17:25:42 -0400788
789 if (y < surface->height / 3)
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200790 edges |= WL_SHELL_SURFACE_RESIZE_TOP;
Kristian Høgsberg07937562011-04-12 17:25:42 -0400791 else if (y < 2 * surface->height / 3)
792 edges |= 0;
793 else
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200794 edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
Kristian Høgsberg07937562011-04-12 17:25:42 -0400795
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200796 wlsc_surface_resize(shsurf, (struct wlsc_input_device *) device,
797 time, edges);
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -0400798}
799
800static void
Kristian Høgsberge1a850e2011-12-19 15:18:05 -0500801terminate_binding(struct wl_input_device *device, uint32_t time,
802 uint32_t key, uint32_t button, uint32_t state, void *data)
803{
804 struct wlsc_compositor *compositor = data;
805
806 if (state)
807 wl_display_terminate(compositor->wl_display);
808}
809
810static void
Kristian Høgsberg75840622011-09-06 13:48:16 -0400811activate(struct wlsc_shell *base, struct wlsc_surface *es,
812 struct wlsc_input_device *device, uint32_t time)
813{
814 struct wl_shell *shell = container_of(base, struct wl_shell, shell);
815 struct wlsc_compositor *compositor = shell->compositor;
816
817 wlsc_surface_activate(es, device, time);
818
Kristian Høgsbergd6e55252011-10-11 23:41:17 -0400819 if (compositor->wxs)
820 wlsc_xserver_surface_activate(es);
821
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200822 switch (get_shell_surface_type(es)) {
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200823 case SHELL_SURFACE_BACKGROUND:
824 /* put background back to bottom */
Kristian Høgsberg75840622011-09-06 13:48:16 -0400825 wl_list_remove(&es->link);
826 wl_list_insert(compositor->surface_list.prev, &es->link);
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200827 break;
828 case SHELL_SURFACE_PANEL:
829 /* already put on top */
830 break;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200831 case SHELL_SURFACE_SCREENSAVER:
832 /* always below lock surface */
833 if (shell->lock_surface) {
834 wl_list_remove(&es->link);
835 wl_list_insert(&shell->lock_surface->surface->link,
836 &es->link);
837 }
838 break;
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200839 default:
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100840 if (!shell->locked) {
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200841 /* bring panel back to top */
Benjamin Franzked0f79ab2011-11-22 12:43:52 +0100842 struct shell_surface *panel;
843 wl_list_for_each(panel, &shell->panels, link) {
844 wl_list_remove(&panel->surface->link);
845 wl_list_insert(&compositor->surface_list,
846 &panel->surface->link);
847 }
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200848 }
Kristian Høgsberg75840622011-09-06 13:48:16 -0400849 }
850}
851
852static void
Kristian Høgsberge1a850e2011-12-19 15:18:05 -0500853click_to_activate_binding(struct wl_input_device *device,
854 uint32_t time, uint32_t key,
855 uint32_t button, uint32_t state, void *data)
856{
857 struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
858 struct wlsc_compositor *compositor = data;
859 struct wlsc_surface *focus;
860
861 focus = (struct wlsc_surface *) device->pointer_focus;
862 if (state && focus && device->grab == NULL)
Kristian Høgsberg2a25cd42011-12-19 15:19:54 -0500863 activate(compositor->shell, focus, wd, time);
Kristian Høgsberge1a850e2011-12-19 15:18:05 -0500864}
865
866static void
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200867lock(struct wlsc_shell *base)
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -0400868{
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200869 struct wl_shell *shell = container_of(base, struct wl_shell, shell);
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200870 struct wl_list *surface_list = &shell->compositor->surface_list;
871 struct wlsc_surface *cur;
872 struct wlsc_surface *tmp;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200873 struct wlsc_input_device *device;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200874 struct shell_surface *shsurf;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200875 uint32_t time;
876
877 if (shell->locked)
878 return;
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200879
880 shell->locked = true;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200881
882 /* Move all surfaces from compositor's list to our hidden list,
883 * except the background. This way nothing else can show or
884 * receive input events while we are locked. */
885
886 if (!wl_list_empty(&shell->hidden_surface_list)) {
887 fprintf(stderr,
888 "%s: Assertion failed: hidden_surface_list is not empty.\n",
889 __func__);
890 }
891
892 wl_list_for_each_safe(cur, tmp, surface_list, link) {
893 /* skip input device sprites, cur->surface is uninitialised */
894 if (cur->surface.resource.client == NULL)
895 continue;
896
Pekka Paalanen92a0dc42011-11-28 15:34:13 +0200897 if (get_shell_surface_type(cur) == SHELL_SURFACE_BACKGROUND)
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200898 continue;
899
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500900 cur->output = NULL;
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200901 wl_list_remove(&cur->link);
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500902 wl_list_insert(shell->hidden_surface_list.prev, &cur->link);
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200903 }
904
Pekka Paalanen77346a62011-11-30 16:26:35 +0200905 launch_screensaver(shell);
906
907 wl_list_for_each(shsurf, &shell->screensaver.surfaces, link)
908 show_screensaver(shell, shsurf);
909
Pekka Paalanenbce2d3f2011-12-02 13:07:27 +0200910 if (!wl_list_empty(&shell->screensaver.surfaces)) {
Pekka Paalanen7296e792011-12-07 16:22:00 +0200911 shell->compositor->idle_time = shell->screensaver.duration;
Pekka Paalanenbaeb6a12011-12-01 16:23:57 +0200912 wlsc_compositor_wake(shell->compositor);
Pekka Paalanenbce2d3f2011-12-02 13:07:27 +0200913 shell->compositor->state = WLSC_COMPOSITOR_IDLE;
914 }
Pekka Paalanenbaeb6a12011-12-01 16:23:57 +0200915
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200916 /* reset pointer foci */
917 wlsc_compositor_repick(shell->compositor);
918
919 /* reset keyboard foci */
920 time = wlsc_compositor_get_time();
921 wl_list_for_each(device, &shell->compositor->input_device_list, link) {
922 wl_input_device_set_keyboard_focus(&device->input_device,
923 NULL, time);
924 }
925
926 /* TODO: disable bindings that should not work while locked. */
927
928 /* All this must be undone in resume_desktop(). */
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200929}
930
931static void
932unlock(struct wlsc_shell *base)
933{
934 struct wl_shell *shell = container_of(base, struct wl_shell, shell);
935
Pekka Paalanend81c2162011-11-16 13:47:34 +0200936 if (!shell->locked || shell->lock_surface) {
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200937 wlsc_compositor_wake(shell->compositor);
938 return;
939 }
940
941 /* If desktop-shell client has gone away, unlock immediately. */
942 if (!shell->child.desktop_shell) {
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +0200943 resume_desktop(shell);
Pekka Paalanen9ef3e012011-11-15 13:34:48 +0200944 return;
945 }
946
947 if (shell->prepare_event_sent)
948 return;
949
950 wl_resource_post_event(shell->child.desktop_shell,
951 DESKTOP_SHELL_PREPARE_LOCK_SURFACE);
952 shell->prepare_event_sent = true;
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -0400953}
954
955static void
Pekka Paalanen77346a62011-11-30 16:26:35 +0200956center_on_output(struct wlsc_surface *surface, struct wlsc_output *output)
957{
958 struct wlsc_mode *mode = output->current;
959
960 surface->x = output->x + (mode->width - surface->width) / 2;
961 surface->y = output->y + (mode->height - surface->height) / 2;
962}
963
964static void
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -0500965map(struct wlsc_shell *base,
966 struct wlsc_surface *surface, int32_t width, int32_t height)
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -0400967{
Kristian Høgsberg75840622011-09-06 13:48:16 -0400968 struct wl_shell *shell = container_of(base, struct wl_shell, shell);
969 struct wlsc_compositor *compositor = shell->compositor;
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500970 struct wl_list *list;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200971 struct shell_surface *shsurf;
972 enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
973 int do_configure;
Pekka Paalanen57da4a82011-11-23 16:42:16 +0200974
Pekka Paalanen77346a62011-11-30 16:26:35 +0200975 shsurf = get_shell_surface(surface);
976 if (shsurf)
977 surface_type = shsurf->type;
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500978
Pekka Paalanen77346a62011-11-30 16:26:35 +0200979 if (shell->locked) {
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500980 list = &shell->hidden_surface_list;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200981 do_configure = 0;
982 } else {
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -0500983 list = &compositor->surface_list;
Pekka Paalanen77346a62011-11-30 16:26:35 +0200984 do_configure = 1;
985 }
986
987 surface->width = width;
988 surface->height = height;
989
990 /* initial positioning, see also configure() */
991 switch (surface_type) {
992 case SHELL_SURFACE_TOPLEVEL:
993 surface->x = 10 + random() % 400;
994 surface->y = 10 + random() % 400;
995 break;
996 case SHELL_SURFACE_SCREENSAVER:
997 case SHELL_SURFACE_FULLSCREEN:
998 center_on_output(surface, surface->fullscreen_output);
999 break;
Pekka Paalanenaf0e34c2011-12-02 10:59:17 +02001000 case SHELL_SURFACE_LOCK:
1001 center_on_output(surface, get_default_output(compositor));
1002 break;
Pekka Paalanen77346a62011-11-30 16:26:35 +02001003 default:
1004 ;
1005 }
Kristian Høgsberg75840622011-09-06 13:48:16 -04001006
Pekka Paalanend3dd6e12011-11-16 13:47:33 +02001007 /* surface stacking order, see also activate() */
Pekka Paalanen92a0dc42011-11-28 15:34:13 +02001008 switch (surface_type) {
Pekka Paalanen57da4a82011-11-23 16:42:16 +02001009 case SHELL_SURFACE_BACKGROUND:
Pekka Paalanend3dd6e12011-11-16 13:47:33 +02001010 /* background always visible, at the bottom */
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -05001011 wl_list_insert(compositor->surface_list.prev, &surface->link);
Pekka Paalanen77346a62011-11-30 16:26:35 +02001012 do_configure = 1;
Pekka Paalanen57da4a82011-11-23 16:42:16 +02001013 break;
1014 case SHELL_SURFACE_PANEL:
Pekka Paalanend3dd6e12011-11-16 13:47:33 +02001015 /* panel always on top, hidden while locked */
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -05001016 wl_list_insert(list, &surface->link);
Pekka Paalanen57da4a82011-11-23 16:42:16 +02001017 break;
1018 case SHELL_SURFACE_LOCK:
Pekka Paalanend3dd6e12011-11-16 13:47:33 +02001019 /* lock surface always visible, on top */
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -05001020 wl_list_insert(&compositor->surface_list, &surface->link);
Pekka Paalanend3dd6e12011-11-16 13:47:33 +02001021
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -05001022 wlsc_compositor_repick(compositor);
Pekka Paalanen57da4a82011-11-23 16:42:16 +02001023 wlsc_compositor_wake(compositor);
Pekka Paalanen77346a62011-11-30 16:26:35 +02001024 do_configure = 1;
1025 break;
1026 case SHELL_SURFACE_SCREENSAVER:
1027 /* If locked, show it. */
Pekka Paalanenbaeb6a12011-12-01 16:23:57 +02001028 if (shell->locked) {
Pekka Paalanen77346a62011-11-30 16:26:35 +02001029 show_screensaver(shell, shsurf);
Pekka Paalanen7296e792011-12-07 16:22:00 +02001030 compositor->idle_time = shell->screensaver.duration;
Pekka Paalanenbaeb6a12011-12-01 16:23:57 +02001031 wlsc_compositor_wake(compositor);
Pekka Paalanenbce2d3f2011-12-02 13:07:27 +02001032 if (!shell->lock_surface)
1033 compositor->state = WLSC_COMPOSITOR_IDLE;
Pekka Paalanenbaeb6a12011-12-01 16:23:57 +02001034 }
Pekka Paalanen77346a62011-11-30 16:26:35 +02001035 do_configure = 0;
Pekka Paalanen57da4a82011-11-23 16:42:16 +02001036 break;
1037 default:
Pekka Paalanend3dd6e12011-11-16 13:47:33 +02001038 /* everything else just below the panel */
Benjamin Franzked0f79ab2011-11-22 12:43:52 +01001039 if (!wl_list_empty(&shell->panels)) {
1040 struct shell_surface *panel =
1041 container_of(shell->panels.prev,
1042 struct shell_surface, link);
1043 wl_list_insert(&panel->surface->link, &surface->link);
1044 } else {
Pekka Paalanen57da4a82011-11-23 16:42:16 +02001045 wl_list_insert(list, &surface->link);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +01001046 }
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +02001047 }
1048
Pekka Paalanen77346a62011-11-30 16:26:35 +02001049 if (do_configure)
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -05001050 wlsc_surface_configure(surface,
1051 surface->x, surface->y, width, height);
Kristian Høgsberg2f88a402011-12-04 15:32:59 -05001052
Juan Zhao7bb92f02011-12-15 11:31:51 -05001053 switch (surface_type) {
1054 case SHELL_SURFACE_TOPLEVEL:
1055 case SHELL_SURFACE_TRANSIENT:
1056 case SHELL_SURFACE_FULLSCREEN:
1057 if (!shell->locked)
1058 activate(base, surface,
1059 (struct wlsc_input_device *)
1060 compositor->input_device,
1061 wlsc_compositor_get_time());
1062 break;
1063 default:
1064 break;
1065 }
1066
Kristian Høgsberg2f88a402011-12-04 15:32:59 -05001067 if (surface_type == SHELL_SURFACE_TOPLEVEL)
1068 wlsc_zoom_run(surface, 0.8, 1.0, NULL, NULL);
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -05001069}
1070
1071static void
Pekka Paalanen77346a62011-11-30 16:26:35 +02001072configure(struct wlsc_shell *base, struct wlsc_surface *surface,
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -05001073 int32_t x, int32_t y, int32_t width, int32_t height)
1074{
Pekka Paalanen77346a62011-11-30 16:26:35 +02001075 struct wl_shell *shell = container_of(base, struct wl_shell, shell);
1076 int do_configure = !shell->locked;
1077 enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
1078 struct shell_surface *shsurf;
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -05001079
Pekka Paalanen77346a62011-11-30 16:26:35 +02001080 shsurf = get_shell_surface(surface);
1081 if (shsurf)
1082 surface_type = shsurf->type;
1083
1084 surface->width = width;
1085 surface->height = height;
1086
1087 switch (surface_type) {
1088 case SHELL_SURFACE_SCREENSAVER:
1089 do_configure = !do_configure;
1090 /* fall through */
Kristian Høgsbergd2abb832011-11-23 10:52:40 -05001091 case SHELL_SURFACE_FULLSCREEN:
Pekka Paalanen77346a62011-11-30 16:26:35 +02001092 center_on_output(surface, surface->fullscreen_output);
Kristian Høgsbergd2abb832011-11-23 10:52:40 -05001093 break;
1094 default:
1095 break;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -04001096 }
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -05001097
Pekka Paalanen77346a62011-11-30 16:26:35 +02001098 /*
1099 * wlsc_surface_configure() will assign an output, which means
1100 * the surface is supposed to be in compositor->surface_list.
1101 * Be careful with that, and make sure we stay on the right output.
1102 * XXX: would a fullscreen surface need the same handling?
1103 */
1104 if (do_configure) {
1105 wlsc_surface_configure(surface, x, y, width, height);
1106
1107 if (surface_type == SHELL_SURFACE_SCREENSAVER)
1108 surface->output = shsurf->output;
1109 }
Kristian Høgsberg07937562011-04-12 17:25:42 -04001110}
1111
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -04001112static void
Pekka Paalanen6cd281a2011-11-03 14:11:32 +02001113desktop_shell_sigchld(struct wlsc_process *process, int status)
1114{
1115 struct wl_shell *shell =
1116 container_of(process, struct wl_shell, child.process);
1117
1118 shell->child.process.pid = 0;
1119 shell->child.client = NULL; /* already destroyed by wayland */
1120}
1121
1122static int
1123launch_desktop_shell_process(struct wl_shell *shell)
1124{
Kristian Høgsbergc4693c42011-11-14 14:57:17 -05001125 const char *shell_exe = LIBEXECDIR "/wayland-desktop-shell";
Pekka Paalanen6cd281a2011-11-03 14:11:32 +02001126
Pekka Paalanen409ef0a2011-12-02 15:30:21 +02001127 shell->child.client = wlsc_client_launch(shell->compositor,
1128 &shell->child.process,
1129 shell_exe,
1130 desktop_shell_sigchld);
1131
1132 if (!shell->child.client)
Pekka Paalanen6cd281a2011-11-03 14:11:32 +02001133 return -1;
Pekka Paalanen6cd281a2011-11-03 14:11:32 +02001134 return 0;
1135}
1136
1137static void
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -04001138bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
1139{
1140 struct wl_shell *shell = data;
1141
1142 wl_client_add_object(client, &wl_shell_interface,
Pekka Paalanen9d1613e2011-11-25 12:09:16 +02001143 &shell_implementation, id, shell);
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -04001144}
1145
Kristian Høgsberg75840622011-09-06 13:48:16 -04001146static void
Pekka Paalanen9ef3e012011-11-15 13:34:48 +02001147unbind_desktop_shell(struct wl_resource *resource)
1148{
1149 struct wl_shell *shell = resource->data;
Kristian Høgsberg1ec0c312011-11-15 16:39:55 -05001150
1151 if (shell->locked)
1152 resume_desktop(shell);
1153
Pekka Paalanen9ef3e012011-11-15 13:34:48 +02001154 shell->child.desktop_shell = NULL;
1155 shell->prepare_event_sent = false;
1156 free(resource);
1157}
1158
1159static void
Kristian Høgsberg75840622011-09-06 13:48:16 -04001160bind_desktop_shell(struct wl_client *client,
1161 void *data, uint32_t version, uint32_t id)
1162{
1163 struct wl_shell *shell = data;
Pekka Paalanenbbe60522011-11-03 14:11:33 +02001164 struct wl_resource *resource;
Kristian Høgsberg75840622011-09-06 13:48:16 -04001165
Pekka Paalanenbbe60522011-11-03 14:11:33 +02001166 resource = wl_client_add_object(client, &desktop_shell_interface,
1167 &desktop_shell_implementation,
1168 id, shell);
1169
Pekka Paalanen9ef3e012011-11-15 13:34:48 +02001170 if (client == shell->child.client) {
1171 resource->destroy = unbind_desktop_shell;
1172 shell->child.desktop_shell = resource;
Pekka Paalanenbbe60522011-11-03 14:11:33 +02001173 return;
Pekka Paalanen9ef3e012011-11-15 13:34:48 +02001174 }
Pekka Paalanenbbe60522011-11-03 14:11:33 +02001175
1176 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
1177 "permission to bind desktop_shell denied");
1178 wl_resource_destroy(resource, 0);
Kristian Høgsberg75840622011-09-06 13:48:16 -04001179}
1180
Pekka Paalanen6e168112011-11-24 11:34:05 +02001181static void
1182screensaver_set_surface(struct wl_client *client,
1183 struct wl_resource *resource,
1184 struct wl_resource *shell_surface_resource,
1185 struct wl_resource *output_resource)
1186{
1187 struct wl_shell *shell = resource->data;
1188 struct shell_surface *surface = shell_surface_resource->data;
1189 struct wlsc_output *output = output_resource->data;
1190
Pekka Paalanen98262232011-12-01 10:42:22 +02001191 if (reset_shell_surface_type(surface))
1192 return;
1193
Pekka Paalanen77346a62011-11-30 16:26:35 +02001194 surface->type = SHELL_SURFACE_SCREENSAVER;
1195
1196 surface->surface->fullscreen_output = output;
1197 surface->output = output;
1198 wl_list_insert(shell->screensaver.surfaces.prev, &surface->link);
Pekka Paalanen6e168112011-11-24 11:34:05 +02001199}
1200
1201static const struct screensaver_interface screensaver_implementation = {
1202 screensaver_set_surface
1203};
1204
1205static void
1206unbind_screensaver(struct wl_resource *resource)
1207{
1208 struct wl_shell *shell = resource->data;
1209
Pekka Paalanen77346a62011-11-30 16:26:35 +02001210 shell->screensaver.binding = NULL;
Pekka Paalanen6e168112011-11-24 11:34:05 +02001211 free(resource);
1212}
1213
1214static void
1215bind_screensaver(struct wl_client *client,
1216 void *data, uint32_t version, uint32_t id)
1217{
1218 struct wl_shell *shell = data;
1219 struct wl_resource *resource;
1220
1221 resource = wl_client_add_object(client, &screensaver_interface,
1222 &screensaver_implementation,
1223 id, shell);
1224
Pekka Paalanen77346a62011-11-30 16:26:35 +02001225 if (shell->screensaver.binding == NULL) {
Pekka Paalanen6e168112011-11-24 11:34:05 +02001226 resource->destroy = unbind_screensaver;
Pekka Paalanen77346a62011-11-30 16:26:35 +02001227 shell->screensaver.binding = resource;
Pekka Paalanen6e168112011-11-24 11:34:05 +02001228 return;
1229 }
1230
1231 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
1232 "interface object already bound");
1233 wl_resource_destroy(resource, 0);
1234}
1235
Pekka Paalanen3c647232011-12-22 13:43:43 +02001236static void
1237shell_destroy(struct wlsc_shell *base)
1238{
1239 struct wl_shell *shell = container_of(base, struct wl_shell, shell);
1240
Pekka Paalanen9cf5cc82012-01-02 16:00:24 +02001241 if (shell->child.client)
1242 wl_client_destroy(shell->child.client);
1243
Pekka Paalanen3c647232011-12-22 13:43:43 +02001244 free(shell->screensaver.path);
1245 free(shell);
1246}
1247
Kristian Høgsberg6c709a32011-05-06 14:52:41 -04001248int
1249shell_init(struct wlsc_compositor *ec);
1250
Kristian Høgsberg1c562182011-05-02 22:09:20 -04001251WL_EXPORT int
1252shell_init(struct wlsc_compositor *ec)
Kristian Høgsberg4cca3492011-01-18 07:53:49 -05001253{
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -04001254 struct wl_shell *shell;
1255
1256 shell = malloc(sizeof *shell);
1257 if (shell == NULL)
1258 return -1;
1259
Kristian Høgsbergf0d91162011-10-11 22:44:23 -04001260 memset(shell, 0, sizeof *shell);
Kristian Høgsberg75840622011-09-06 13:48:16 -04001261 shell->compositor = ec;
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -04001262 shell->shell.lock = lock;
Pekka Paalanen9ef3e012011-11-15 13:34:48 +02001263 shell->shell.unlock = unlock;
Kristian Høgsberg32e24cc2011-11-09 12:07:35 -05001264 shell->shell.map = map;
1265 shell->shell.configure = configure;
Pekka Paalanen3c647232011-12-22 13:43:43 +02001266 shell->shell.destroy = shell_destroy;
Kristian Høgsberg4cca3492011-01-18 07:53:49 -05001267
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +02001268 wl_list_init(&shell->hidden_surface_list);
Benjamin Franzked0f79ab2011-11-22 12:43:52 +01001269 wl_list_init(&shell->backgrounds);
1270 wl_list_init(&shell->panels);
Pekka Paalanen77346a62011-11-30 16:26:35 +02001271 wl_list_init(&shell->screensaver.surfaces);
Pekka Paalanenf0fc70d2011-11-15 13:34:54 +02001272
Pekka Paalanene955f1e2011-12-07 11:49:52 +02001273 if (shell_configuration(shell) < 0)
1274 return -1;
1275
Kristian Høgsberg97d44aa2011-08-26 17:21:20 -04001276 if (wl_display_add_global(ec->wl_display, &wl_shell_interface,
1277 shell, bind_shell) == NULL)
Kristian Høgsberg4cca3492011-01-18 07:53:49 -05001278 return -1;
1279
Kristian Høgsberg75840622011-09-06 13:48:16 -04001280 if (wl_display_add_global(ec->wl_display,
1281 &desktop_shell_interface,
1282 shell, bind_desktop_shell) == NULL)
1283 return -1;
1284
Pekka Paalanen6e168112011-11-24 11:34:05 +02001285 if (wl_display_add_global(ec->wl_display, &screensaver_interface,
1286 shell, bind_screensaver) == NULL)
1287 return -1;
1288
Pekka Paalanen6cd281a2011-11-03 14:11:32 +02001289 if (launch_desktop_shell_process(shell) != 0)
1290 return -1;
1291
Kristian Høgsberg07937562011-04-12 17:25:42 -04001292 wlsc_compositor_add_binding(ec, 0, BTN_LEFT, MODIFIER_SUPER,
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -04001293 move_binding, shell);
Kristian Høgsberg07937562011-04-12 17:25:42 -04001294 wlsc_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER,
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -04001295 resize_binding, shell);
Kristian Høgsberge1a850e2011-12-19 15:18:05 -05001296 wlsc_compositor_add_binding(ec, KEY_BACKSPACE, 0,
1297 MODIFIER_CTRL | MODIFIER_ALT,
1298 terminate_binding, ec);
1299 wlsc_compositor_add_binding(ec, 0, BTN_LEFT, 0,
1300 click_to_activate_binding, ec);
1301
Kristian Høgsberg02ec0a52011-04-23 13:04:11 -04001302 ec->shell = &shell->shell;
Kristian Høgsberg07937562011-04-12 17:25:42 -04001303
Kristian Høgsberg4cca3492011-01-18 07:53:49 -05001304 return 0;
1305}