blob: f76f1810a50d493c49b60a22130793e612dd1326 [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 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -07006 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080012 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -070013 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080024 */
25
26#include <stdbool.h>
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +030027#include <time.h>
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080028
29#include "compositor.h"
30
Jonny Lamb765760d2014-08-20 15:53:19 +020031#include "desktop-shell-server-protocol.h"
32
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080033enum animation_type {
34 ANIMATION_NONE,
35
36 ANIMATION_ZOOM,
37 ANIMATION_FADE,
38 ANIMATION_DIM_LAYER,
39};
40
41enum fade_type {
42 FADE_IN,
43 FADE_OUT
44};
45
46enum exposay_target_state {
47 EXPOSAY_TARGET_OVERVIEW, /* show all windows */
48 EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
49 EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
50};
51
52enum exposay_layout_state {
53 EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
54 EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
55 EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
56 EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
57};
58
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +010059struct exposay_output {
60 int num_surfaces;
61 int grid_size;
62 int surface_size;
63
64 int hpadding_outer;
65 int vpadding_outer;
66 int padding_inner;
67};
68
69struct exposay {
70 /* XXX: Make these exposay_surfaces. */
71 struct weston_view *focus_prev;
72 struct weston_view *focus_current;
73 struct weston_view *clicked;
74 struct workspace *workspace;
75 struct weston_seat *seat;
76
77 struct wl_list surface_list;
78
79 struct weston_keyboard_grab grab_kbd;
80 struct weston_pointer_grab grab_ptr;
81
82 enum exposay_target_state state_target;
83 enum exposay_layout_state state_cur;
84 int in_flight; /* number of animations still running */
85
86 int row_current;
87 int column_current;
88 struct exposay_output *cur_output;
89
90 bool mod_pressed;
91 bool mod_invalid;
92};
93
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080094struct focus_surface {
95 struct weston_surface *surface;
96 struct weston_view *view;
97 struct weston_transform workspace_transform;
98};
99
100struct workspace {
101 struct weston_layer layer;
102
103 struct wl_list focus_list;
104 struct wl_listener seat_destroyed_listener;
105
106 struct focus_surface *fsurf_front;
107 struct focus_surface *fsurf_back;
108 struct weston_view_animation *focus_animation;
109};
110
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100111struct shell_output {
112 struct desktop_shell *shell;
113 struct weston_output *output;
114 struct exposay_output eoutput;
115 struct wl_listener destroy_listener;
116 struct wl_list link;
117};
118
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800119struct desktop_shell {
120 struct weston_compositor *compositor;
121
122 struct wl_listener idle_listener;
123 struct wl_listener wake_listener;
124 struct wl_listener destroy_listener;
125 struct wl_listener show_input_panel_listener;
126 struct wl_listener hide_input_panel_listener;
127 struct wl_listener update_input_panel_listener;
128
129 struct weston_layer fullscreen_layer;
130 struct weston_layer panel_layer;
131 struct weston_layer background_layer;
132 struct weston_layer lock_layer;
133 struct weston_layer input_panel_layer;
134
135 struct wl_listener pointer_focus_listener;
136 struct weston_surface *grab_surface;
137
138 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800139 struct wl_client *client;
140 struct wl_resource *desktop_shell;
Ander Conselvan de Oliveira312ea4c2013-12-20 21:07:01 +0200141 struct wl_listener client_destroy_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800142
143 unsigned deathcount;
144 uint32_t deathstamp;
145 } child;
146
147 bool locked;
148 bool showing_input_panels;
149 bool prepare_event_sent;
150
151 struct {
152 struct weston_surface *surface;
153 pixman_box32_t cursor_rectangle;
154 } text_input;
155
156 struct weston_surface *lock_surface;
157 struct wl_listener lock_surface_listener;
158
159 struct {
160 struct wl_array array;
161 unsigned int current;
162 unsigned int num;
163
164 struct wl_list client_list;
165
166 struct weston_animation animation;
167 struct wl_list anim_sticky_list;
168 int anim_dir;
169 uint32_t anim_timestamp;
170 double anim_current;
171 struct workspace *anim_from;
172 struct workspace *anim_to;
173 } workspaces;
174
175 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800176 struct wl_resource *binding;
177 struct wl_list surfaces;
178 } input_panel;
179
180 struct {
181 struct weston_view *view;
182 struct weston_view_animation *animation;
183 enum fade_type type;
184 struct wl_event_source *startup_timer;
185 } fade;
186
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100187 struct exposay exposay;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800188
189 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800190 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800191 enum animation_type win_animation_type;
Jonny Lambf322f8e2014-08-12 15:13:30 +0200192 enum animation_type win_close_animation_type;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800193 enum animation_type startup_animation_type;
194 enum animation_type focus_animation_type;
195
Manuel Bachmann50c87db2014-02-26 15:52:13 +0100196 struct weston_layer minimized_layer;
197
Jason Ekstrand024177c2014-04-21 19:42:58 -0500198 struct wl_listener seat_create_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800199 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200200 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800201 struct wl_list output_list;
202
Jonny Lamb765760d2014-08-20 15:53:19 +0200203 enum desktop_shell_panel_position panel_position;
204
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800205 char *client;
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +0300206
207 struct timespec startup_time;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800208};
209
210struct weston_output *
211get_default_output(struct weston_compositor *compositor);
212
213struct weston_view *
214get_default_view(struct weston_surface *surface);
215
216struct shell_surface *
217get_shell_surface(struct weston_surface *surface);
218
219struct workspace *
220get_current_workspace(struct desktop_shell *shell);
221
222void
223lower_fullscreen_layer(struct desktop_shell *shell);
224
225void
226activate(struct desktop_shell *shell, struct weston_surface *es,
Emilio Pozuelo Monfort9e7c7592014-01-30 14:01:10 +0100227 struct weston_seat *seat, bool configure);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800228
229void
230exposay_binding(struct weston_seat *seat,
231 enum weston_keyboard_modifier modifier,
232 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800233int
234input_panel_setup(struct desktop_shell *shell);
235void
236input_panel_destroy(struct desktop_shell *shell);
Ander Conselvan de Oliveira304996d2014-04-11 13:57:15 +0300237
238typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
239 struct weston_layer *, void *);
240
241void
242shell_for_each_layer(struct desktop_shell *shell,
243 shell_for_each_layer_func_t func,
244 void *data);