blob: 4d4f00ab2dbe9ce97b6712fc389b0c50990db012 [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>
26
27#include "compositor.h"
28
29enum animation_type {
30 ANIMATION_NONE,
31
32 ANIMATION_ZOOM,
33 ANIMATION_FADE,
34 ANIMATION_DIM_LAYER,
35};
36
37enum fade_type {
38 FADE_IN,
39 FADE_OUT
40};
41
42enum exposay_target_state {
43 EXPOSAY_TARGET_OVERVIEW, /* show all windows */
44 EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
45 EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
46};
47
48enum exposay_layout_state {
49 EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
50 EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
51 EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
52 EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
53};
54
55struct focus_surface {
56 struct weston_surface *surface;
57 struct weston_view *view;
58 struct weston_transform workspace_transform;
59};
60
61struct workspace {
62 struct weston_layer layer;
63
64 struct wl_list focus_list;
65 struct wl_listener seat_destroyed_listener;
66
67 struct focus_surface *fsurf_front;
68 struct focus_surface *fsurf_back;
69 struct weston_view_animation *focus_animation;
70};
71
72struct desktop_shell {
73 struct weston_compositor *compositor;
74
75 struct wl_listener idle_listener;
76 struct wl_listener wake_listener;
77 struct wl_listener destroy_listener;
78 struct wl_listener show_input_panel_listener;
79 struct wl_listener hide_input_panel_listener;
80 struct wl_listener update_input_panel_listener;
81
82 struct weston_layer fullscreen_layer;
83 struct weston_layer panel_layer;
84 struct weston_layer background_layer;
85 struct weston_layer lock_layer;
86 struct weston_layer input_panel_layer;
87
88 struct wl_listener pointer_focus_listener;
89 struct weston_surface *grab_surface;
90
91 struct {
92 struct weston_process process;
93 struct wl_client *client;
94 struct wl_resource *desktop_shell;
Ander Conselvan de Oliveira312ea4c2013-12-20 21:07:01 +020095 struct wl_listener client_destroy_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080096
97 unsigned deathcount;
98 uint32_t deathstamp;
99 } child;
100
101 bool locked;
102 bool showing_input_panels;
103 bool prepare_event_sent;
104
105 struct {
106 struct weston_surface *surface;
107 pixman_box32_t cursor_rectangle;
108 } text_input;
109
110 struct weston_surface *lock_surface;
111 struct wl_listener lock_surface_listener;
112
113 struct {
114 struct wl_array array;
115 unsigned int current;
116 unsigned int num;
117
118 struct wl_list client_list;
119
120 struct weston_animation animation;
121 struct wl_list anim_sticky_list;
122 int anim_dir;
123 uint32_t anim_timestamp;
124 double anim_current;
125 struct workspace *anim_from;
126 struct workspace *anim_to;
127 } workspaces;
128
129 struct {
130 char *path;
131 int duration;
132 struct wl_resource *binding;
133 struct weston_process process;
134 struct wl_event_source *timer;
135 } screensaver;
136
137 struct {
138 struct wl_resource *binding;
139 struct wl_list surfaces;
140 } input_panel;
141
142 struct {
143 struct weston_view *view;
144 struct weston_view_animation *animation;
145 enum fade_type type;
146 struct wl_event_source *startup_timer;
147 } fade;
148
149 struct exposay {
150 /* XXX: Make these exposay_surfaces. */
151 struct weston_view *focus_prev;
152 struct weston_view *focus_current;
153 struct weston_view *clicked;
154 struct workspace *workspace;
155 struct weston_seat *seat;
156 struct wl_list surface_list;
157
158 struct weston_keyboard_grab grab_kbd;
159 struct weston_pointer_grab grab_ptr;
160
161 enum exposay_target_state state_target;
162 enum exposay_layout_state state_cur;
163 int in_flight; /* number of animations still running */
164
165 int num_surfaces;
166 int grid_size;
167 int surface_size;
168
169 int hpadding_outer;
170 int vpadding_outer;
171 int padding_inner;
172
173 int row_current;
174 int column_current;
175
176 bool mod_pressed;
177 bool mod_invalid;
178 } exposay;
179
180 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800181 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800182 enum animation_type win_animation_type;
183 enum animation_type startup_animation_type;
184 enum animation_type focus_animation_type;
185
186 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200187 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800188 struct wl_list output_list;
189
190 char *client;
191};
192
Emilio Pozuelo Monfort1a26f1b2014-01-07 16:41:40 +0100193void
194set_alpha_if_fullscreen(struct shell_surface *shsurf);
195
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800196struct weston_output *
197get_default_output(struct weston_compositor *compositor);
198
199struct weston_view *
200get_default_view(struct weston_surface *surface);
201
202struct shell_surface *
203get_shell_surface(struct weston_surface *surface);
204
205struct workspace *
206get_current_workspace(struct desktop_shell *shell);
207
208void
209lower_fullscreen_layer(struct desktop_shell *shell);
210
211void
212activate(struct desktop_shell *shell, struct weston_surface *es,
213 struct weston_seat *seat);
214
215void
216exposay_binding(struct weston_seat *seat,
217 enum weston_keyboard_modifier modifier,
218 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800219int
220input_panel_setup(struct desktop_shell *shell);
221void
222input_panel_destroy(struct desktop_shell *shell);