blob: 041ecd8ee97e30fa21d67a19bb2a40991d8bc222 [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
Pekka Paalanenaa9536a2015-06-24 16:09:17 +0300151 struct text_backend *text_backend;
152
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800153 struct {
154 struct weston_surface *surface;
155 pixman_box32_t cursor_rectangle;
156 } text_input;
157
158 struct weston_surface *lock_surface;
159 struct wl_listener lock_surface_listener;
160
161 struct {
162 struct wl_array array;
163 unsigned int current;
164 unsigned int num;
165
166 struct wl_list client_list;
167
168 struct weston_animation animation;
169 struct wl_list anim_sticky_list;
170 int anim_dir;
171 uint32_t anim_timestamp;
172 double anim_current;
173 struct workspace *anim_from;
174 struct workspace *anim_to;
175 } workspaces;
176
177 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800178 struct wl_resource *binding;
179 struct wl_list surfaces;
180 } input_panel;
181
182 struct {
183 struct weston_view *view;
184 struct weston_view_animation *animation;
185 enum fade_type type;
186 struct wl_event_source *startup_timer;
187 } fade;
188
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100189 struct exposay exposay;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800190
191 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800192 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800193 enum animation_type win_animation_type;
Jonny Lambf322f8e2014-08-12 15:13:30 +0200194 enum animation_type win_close_animation_type;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800195 enum animation_type startup_animation_type;
196 enum animation_type focus_animation_type;
197
Manuel Bachmann50c87db2014-02-26 15:52:13 +0100198 struct weston_layer minimized_layer;
199
Jason Ekstrand024177c2014-04-21 19:42:58 -0500200 struct wl_listener seat_create_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800201 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200202 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800203 struct wl_list output_list;
204
Jonny Lamb765760d2014-08-20 15:53:19 +0200205 enum desktop_shell_panel_position panel_position;
206
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800207 char *client;
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +0300208
209 struct timespec startup_time;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800210};
211
212struct weston_output *
213get_default_output(struct weston_compositor *compositor);
214
215struct weston_view *
216get_default_view(struct weston_surface *surface);
217
218struct shell_surface *
219get_shell_surface(struct weston_surface *surface);
220
221struct workspace *
222get_current_workspace(struct desktop_shell *shell);
223
224void
Mario Kleiner9f4d6552015-06-21 21:25:08 +0200225lower_fullscreen_layer(struct desktop_shell *shell,
226 struct weston_output *lowering_output);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800227
228void
229activate(struct desktop_shell *shell, struct weston_surface *es,
Emilio Pozuelo Monfort9e7c7592014-01-30 14:01:10 +0100230 struct weston_seat *seat, bool configure);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800231
232void
Derek Foreman8ae2db52015-07-15 13:00:36 -0500233exposay_binding(struct weston_keyboard *keyboard,
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800234 enum weston_keyboard_modifier modifier,
235 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800236int
237input_panel_setup(struct desktop_shell *shell);
238void
239input_panel_destroy(struct desktop_shell *shell);
Ander Conselvan de Oliveira304996d2014-04-11 13:57:15 +0300240
241typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
242 struct weston_layer *, void *);
243
244void
245shell_for_each_layer(struct desktop_shell *shell,
246 shell_for_each_layer_func_t func,
247 void *data);