fe437b833ef9f960cdcf5f7dbdd4375976f78d67
[profile/ivi/ico-uxf-weston-plugin.git] / src / ico_ivi_shell.h
1 /*
2  * Copyright © 2010-2012 Intel Corporation
3  * Copyright © 2011-2012 Collabora, Ltd.
4  * Copyright © 2013 Raspberry Pi Foundation
5  * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION.
6  *
7  * Permission to use, copy, modify, distribute, and sell this software and
8  * its documentation for any purpose is hereby granted without fee, provided
9  * that the above copyright notice appear in all copies and that both that
10  * copyright notice and this permission notice appear in supporting
11  * documentation, and that the name of the copyright holders not be used in
12  * advertising or publicity pertaining to distribution of the software
13  * without specific, written prior permission.  The copyright holders make
14  * no representations about the suitability of this software for any
15  * purpose.  It is provided "as is" without express or implied warranty.
16  *
17  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
18  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
21  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
22  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24  */
25
26 #include <stdbool.h>
27
28 #include <weston/compositor.h>
29
30 enum animation_type {
31     ANIMATION_NONE,
32
33     ANIMATION_ZOOM,
34     ANIMATION_FADE,
35     ANIMATION_DIM_LAYER,
36 };
37
38 enum fade_type {
39     FADE_IN,
40     FADE_OUT
41 };
42
43 enum exposay_target_state {
44     EXPOSAY_TARGET_OVERVIEW, /* show all windows */
45     EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
46     EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
47 };
48
49 enum exposay_layout_state {
50     EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
51     EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
52     EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
53     EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
54 };
55
56 struct focus_surface {
57     struct weston_surface *surface;
58     struct weston_view *view;
59     struct weston_transform workspace_transform;
60 };
61
62 struct workspace {
63     struct weston_layer layer;
64
65     struct wl_list focus_list;
66     struct wl_listener seat_destroyed_listener;
67
68     struct focus_surface *fsurf_front;
69     struct focus_surface *fsurf_back;
70     struct weston_view_animation *focus_animation;
71 };
72
73 struct desktop_shell {
74     struct weston_compositor *compositor;
75
76     struct wl_listener idle_listener;
77     struct wl_listener wake_listener;
78     struct wl_listener destroy_listener;
79     struct wl_listener show_input_panel_listener;
80     struct wl_listener hide_input_panel_listener;
81     struct wl_listener update_input_panel_listener;
82
83     struct weston_layer fullscreen_layer;
84     struct weston_layer panel_layer;
85     struct weston_layer background_layer;
86     struct weston_layer lock_layer;
87     struct weston_layer input_panel_layer;
88
89     struct wl_listener pointer_focus_listener;
90     struct weston_surface *grab_surface;
91
92     struct {
93         struct weston_process process;
94         struct wl_client *client;
95         struct wl_resource *desktop_shell;
96         struct wl_listener client_destroy_listener;
97
98         unsigned deathcount;
99         uint32_t deathstamp;
100     } child;
101
102     bool locked;
103     bool showing_input_panels;
104     bool prepare_event_sent;
105
106     struct {
107         struct weston_surface *surface;
108         pixman_box32_t cursor_rectangle;
109     } text_input;
110
111     struct weston_surface *lock_surface;
112     struct wl_listener lock_surface_listener;
113
114     struct {
115         struct wl_array array;
116         unsigned int current;
117         unsigned int num;
118
119         struct wl_list client_list;
120
121         struct weston_animation animation;
122         struct wl_list anim_sticky_list;
123         int anim_dir;
124         uint32_t anim_timestamp;
125         double anim_current;
126         struct workspace *anim_from;
127         struct workspace *anim_to;
128     } workspaces;
129
130     struct {
131         char *path;
132         int duration;
133         struct wl_resource *binding;
134         struct weston_process process;
135         struct wl_event_source *timer;
136     } screensaver;
137
138     struct {
139         struct wl_resource *binding;
140         struct wl_list surfaces;
141     } input_panel;
142
143     struct {
144         struct weston_view *view;
145         struct weston_view_animation *animation;
146         enum fade_type type;
147         struct wl_event_source *startup_timer;
148     } fade;
149
150     struct exposay {
151         /* XXX: Make these exposay_surfaces. */
152         struct weston_view *focus_prev;
153         struct weston_view *focus_current;
154         struct weston_view *clicked;
155         struct workspace *workspace;
156         struct weston_seat *seat;
157         struct wl_list surface_list;
158
159         struct weston_keyboard_grab grab_kbd;
160         struct weston_pointer_grab grab_ptr;
161
162                 enum exposay_target_state state_target;
163                 enum exposay_layout_state state_cur;
164         int in_flight; /* number of animations still running */
165
166         int num_surfaces;
167         int grid_size;
168         int surface_size;
169
170         int hpadding_outer;
171         int vpadding_outer;
172         int padding_inner;
173
174         int row_current;
175         int column_current;
176
177         bool mod_pressed;
178         bool mod_invalid;
179     } exposay;
180
181     uint32_t binding_modifier;
182     uint32_t exposay_modifier;
183     enum animation_type win_animation_type;
184     enum animation_type startup_animation_type;
185     enum animation_type focus_animation_type;
186
187     struct wl_listener output_create_listener;
188     struct wl_list output_list;
189
190     char *client;
191 };
192
193 void
194 set_alpha_if_fullscreen(struct shell_surface *shsurf);
195
196 struct weston_output *
197 get_default_output(struct weston_compositor *compositor);
198
199 struct weston_view *
200 get_default_view(struct weston_surface *surface);
201
202 struct shell_surface *
203 get_shell_surface(struct weston_surface *surface);
204
205 struct workspace *
206 get_current_workspace(struct desktop_shell *shell);
207
208 void
209 lower_fullscreen_layer(struct desktop_shell *shell);
210
211 void
212 activate(struct desktop_shell *shell, struct weston_surface *es,
213      struct weston_seat *seat);
214
215 void
216 exposay_binding(struct weston_seat *seat,
217         enum weston_keyboard_modifier modifier,
218         void *data);
219 int
220 input_panel_setup(struct desktop_shell *shell);
221 void
222 input_panel_destroy(struct desktop_shell *shell);