blob: 17419e35920ea1b9acb439525e294e60d58defe2 [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;
95
96 unsigned deathcount;
97 uint32_t deathstamp;
98 } child;
99
100 bool locked;
101 bool showing_input_panels;
102 bool prepare_event_sent;
103
104 struct {
105 struct weston_surface *surface;
106 pixman_box32_t cursor_rectangle;
107 } text_input;
108
109 struct weston_surface *lock_surface;
110 struct wl_listener lock_surface_listener;
111
112 struct {
113 struct wl_array array;
114 unsigned int current;
115 unsigned int num;
116
117 struct wl_list client_list;
118
119 struct weston_animation animation;
120 struct wl_list anim_sticky_list;
121 int anim_dir;
122 uint32_t anim_timestamp;
123 double anim_current;
124 struct workspace *anim_from;
125 struct workspace *anim_to;
126 } workspaces;
127
128 struct {
129 char *path;
130 int duration;
131 struct wl_resource *binding;
132 struct weston_process process;
133 struct wl_event_source *timer;
134 } screensaver;
135
136 struct {
137 struct wl_resource *binding;
138 struct wl_list surfaces;
139 } input_panel;
140
141 struct {
142 struct weston_view *view;
143 struct weston_view_animation *animation;
144 enum fade_type type;
145 struct wl_event_source *startup_timer;
146 } fade;
147
148 struct exposay {
149 /* XXX: Make these exposay_surfaces. */
150 struct weston_view *focus_prev;
151 struct weston_view *focus_current;
152 struct weston_view *clicked;
153 struct workspace *workspace;
154 struct weston_seat *seat;
155 struct wl_list surface_list;
156
157 struct weston_keyboard_grab grab_kbd;
158 struct weston_pointer_grab grab_ptr;
159
160 enum exposay_target_state state_target;
161 enum exposay_layout_state state_cur;
162 int in_flight; /* number of animations still running */
163
164 int num_surfaces;
165 int grid_size;
166 int surface_size;
167
168 int hpadding_outer;
169 int vpadding_outer;
170 int padding_inner;
171
172 int row_current;
173 int column_current;
174
175 bool mod_pressed;
176 bool mod_invalid;
177 } exposay;
178
179 uint32_t binding_modifier;
180 enum animation_type win_animation_type;
181 enum animation_type startup_animation_type;
182 enum animation_type focus_animation_type;
183
184 struct wl_listener output_create_listener;
185 struct wl_list output_list;
186
187 char *client;
188};
189
190struct weston_output *
191get_default_output(struct weston_compositor *compositor);
192
193struct weston_view *
194get_default_view(struct weston_surface *surface);
195
196struct shell_surface *
197get_shell_surface(struct weston_surface *surface);
198
199struct workspace *
200get_current_workspace(struct desktop_shell *shell);
201
202void
203lower_fullscreen_layer(struct desktop_shell *shell);
204
205void
206activate(struct desktop_shell *shell, struct weston_surface *es,
207 struct weston_seat *seat);
208
209void
210exposay_binding(struct weston_seat *seat,
211 enum weston_keyboard_modifier modifier,
212 void *data);