blob: 2cfd1d62b50d05a204e834215e3ac480681eb09f [file] [log] [blame]
Kristian Høgsberg1ef23132013-12-04 00:20:01 -08001/*
2 * Copyright © 2010-2012 Intel Corporation
3 * Copyright © 2011-2012 Collabora, Ltd.
4 * Copyright © 2013 Raspberry Pi Foundation
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
15 *
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#include <stdbool.h>
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +030026#include <time.h>
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080027
28#include "compositor.h"
29
Jonny Lamb765760d2014-08-20 15:53:19 +020030#include "desktop-shell-server-protocol.h"
31
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080032enum animation_type {
33 ANIMATION_NONE,
34
35 ANIMATION_ZOOM,
36 ANIMATION_FADE,
37 ANIMATION_DIM_LAYER,
38};
39
40enum fade_type {
41 FADE_IN,
42 FADE_OUT
43};
44
45enum exposay_target_state {
46 EXPOSAY_TARGET_OVERVIEW, /* show all windows */
47 EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
48 EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
49};
50
51enum exposay_layout_state {
52 EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
53 EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
54 EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
55 EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
56};
57
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +010058struct exposay_output {
59 int num_surfaces;
60 int grid_size;
61 int surface_size;
62
63 int hpadding_outer;
64 int vpadding_outer;
65 int padding_inner;
66};
67
68struct exposay {
69 /* XXX: Make these exposay_surfaces. */
70 struct weston_view *focus_prev;
71 struct weston_view *focus_current;
72 struct weston_view *clicked;
73 struct workspace *workspace;
74 struct weston_seat *seat;
75
76 struct wl_list surface_list;
77
78 struct weston_keyboard_grab grab_kbd;
79 struct weston_pointer_grab grab_ptr;
80
81 enum exposay_target_state state_target;
82 enum exposay_layout_state state_cur;
83 int in_flight; /* number of animations still running */
84
85 int row_current;
86 int column_current;
87 struct exposay_output *cur_output;
88
89 bool mod_pressed;
90 bool mod_invalid;
91};
92
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080093struct focus_surface {
94 struct weston_surface *surface;
95 struct weston_view *view;
96 struct weston_transform workspace_transform;
97};
98
99struct workspace {
100 struct weston_layer layer;
101
102 struct wl_list focus_list;
103 struct wl_listener seat_destroyed_listener;
104
105 struct focus_surface *fsurf_front;
106 struct focus_surface *fsurf_back;
107 struct weston_view_animation *focus_animation;
108};
109
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100110struct shell_output {
111 struct desktop_shell *shell;
112 struct weston_output *output;
113 struct exposay_output eoutput;
114 struct wl_listener destroy_listener;
115 struct wl_list link;
116};
117
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800118struct desktop_shell {
119 struct weston_compositor *compositor;
120
121 struct wl_listener idle_listener;
122 struct wl_listener wake_listener;
123 struct wl_listener destroy_listener;
124 struct wl_listener show_input_panel_listener;
125 struct wl_listener hide_input_panel_listener;
126 struct wl_listener update_input_panel_listener;
127
128 struct weston_layer fullscreen_layer;
129 struct weston_layer panel_layer;
130 struct weston_layer background_layer;
131 struct weston_layer lock_layer;
132 struct weston_layer input_panel_layer;
133
134 struct wl_listener pointer_focus_listener;
135 struct weston_surface *grab_surface;
136
137 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800138 struct wl_client *client;
139 struct wl_resource *desktop_shell;
Ander Conselvan de Oliveira312ea4c2013-12-20 21:07:01 +0200140 struct wl_listener client_destroy_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800141
142 unsigned deathcount;
143 uint32_t deathstamp;
144 } child;
145
146 bool locked;
147 bool showing_input_panels;
148 bool prepare_event_sent;
149
150 struct {
151 struct weston_surface *surface;
152 pixman_box32_t cursor_rectangle;
153 } text_input;
154
155 struct weston_surface *lock_surface;
156 struct wl_listener lock_surface_listener;
157
158 struct {
159 struct wl_array array;
160 unsigned int current;
161 unsigned int num;
162
163 struct wl_list client_list;
164
165 struct weston_animation animation;
166 struct wl_list anim_sticky_list;
167 int anim_dir;
168 uint32_t anim_timestamp;
169 double anim_current;
170 struct workspace *anim_from;
171 struct workspace *anim_to;
172 } workspaces;
173
174 struct {
175 char *path;
176 int duration;
177 struct wl_resource *binding;
178 struct weston_process process;
179 struct wl_event_source *timer;
180 } screensaver;
181
182 struct {
183 struct wl_resource *binding;
184 struct wl_list surfaces;
185 } input_panel;
186
187 struct {
188 struct weston_view *view;
189 struct weston_view_animation *animation;
190 enum fade_type type;
191 struct wl_event_source *startup_timer;
192 } fade;
193
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100194 struct exposay exposay;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800195
196 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800197 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800198 enum animation_type win_animation_type;
Jonny Lambf322f8e2014-08-12 15:13:30 +0200199 enum animation_type win_close_animation_type;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800200 enum animation_type startup_animation_type;
201 enum animation_type focus_animation_type;
202
Manuel Bachmann50c87db2014-02-26 15:52:13 +0100203 struct weston_layer minimized_layer;
204
Jason Ekstrand024177c2014-04-21 19:42:58 -0500205 struct wl_listener seat_create_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800206 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200207 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800208 struct wl_list output_list;
209
Jonny Lamb765760d2014-08-20 15:53:19 +0200210 enum desktop_shell_panel_position panel_position;
211
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800212 char *client;
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +0300213
214 struct timespec startup_time;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800215};
216
217struct weston_output *
218get_default_output(struct weston_compositor *compositor);
219
220struct weston_view *
221get_default_view(struct weston_surface *surface);
222
223struct shell_surface *
224get_shell_surface(struct weston_surface *surface);
225
226struct workspace *
227get_current_workspace(struct desktop_shell *shell);
228
229void
230lower_fullscreen_layer(struct desktop_shell *shell);
231
232void
233activate(struct desktop_shell *shell, struct weston_surface *es,
Emilio Pozuelo Monfort9e7c7592014-01-30 14:01:10 +0100234 struct weston_seat *seat, bool configure);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800235
236void
237exposay_binding(struct weston_seat *seat,
238 enum weston_keyboard_modifier modifier,
239 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800240int
241input_panel_setup(struct desktop_shell *shell);
242void
243input_panel_destroy(struct desktop_shell *shell);
Ander Conselvan de Oliveira304996d2014-04-11 13:57:15 +0300244
245typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
246 struct weston_layer *, void *);
247
248void
249shell_for_each_layer(struct desktop_shell *shell,
250 shell_for_each_layer_func_t func,
251 void *data);