blob: a5fe194337c13911be53280367ea200bb91cdd25 [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
Jonas Ådahl6d6fb612015-11-17 16:00:33 +080031#include "weston-desktop-shell-server-protocol.h"
Jonny Lamb765760d2014-08-20 15:53:19 +020032
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;
David Fort50d962f2016-06-09 17:55:52 +0200117
118 struct weston_surface *panel_surface;
119 struct wl_listener panel_surface_listener;
120
121 struct weston_surface *background_surface;
122 struct wl_listener background_surface_listener;
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100123};
124
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800125struct desktop_shell {
126 struct weston_compositor *compositor;
127
128 struct wl_listener idle_listener;
129 struct wl_listener wake_listener;
Giulio Camuffof05d18f2015-12-11 20:57:05 +0200130 struct wl_listener transform_listener;
David Fort50d962f2016-06-09 17:55:52 +0200131 struct wl_listener resized_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800132 struct wl_listener destroy_listener;
133 struct wl_listener show_input_panel_listener;
134 struct wl_listener hide_input_panel_listener;
135 struct wl_listener update_input_panel_listener;
136
137 struct weston_layer fullscreen_layer;
138 struct weston_layer panel_layer;
139 struct weston_layer background_layer;
140 struct weston_layer lock_layer;
141 struct weston_layer input_panel_layer;
142
143 struct wl_listener pointer_focus_listener;
144 struct weston_surface *grab_surface;
145
146 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800147 struct wl_client *client;
148 struct wl_resource *desktop_shell;
Ander Conselvan de Oliveira312ea4c2013-12-20 21:07:01 +0200149 struct wl_listener client_destroy_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800150
151 unsigned deathcount;
152 uint32_t deathstamp;
153 } child;
154
155 bool locked;
156 bool showing_input_panels;
157 bool prepare_event_sent;
158
Pekka Paalanenaa9536a2015-06-24 16:09:17 +0300159 struct text_backend *text_backend;
160
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800161 struct {
162 struct weston_surface *surface;
163 pixman_box32_t cursor_rectangle;
164 } text_input;
165
166 struct weston_surface *lock_surface;
167 struct wl_listener lock_surface_listener;
168
169 struct {
170 struct wl_array array;
171 unsigned int current;
172 unsigned int num;
173
174 struct wl_list client_list;
175
176 struct weston_animation animation;
177 struct wl_list anim_sticky_list;
178 int anim_dir;
179 uint32_t anim_timestamp;
180 double anim_current;
181 struct workspace *anim_from;
182 struct workspace *anim_to;
183 } workspaces;
184
185 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800186 struct wl_resource *binding;
187 struct wl_list surfaces;
188 } input_panel;
189
190 struct {
191 struct weston_view *view;
192 struct weston_view_animation *animation;
193 enum fade_type type;
194 struct wl_event_source *startup_timer;
195 } fade;
196
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100197 struct exposay exposay;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800198
Bob Ham744e6532016-01-12 10:21:48 +0000199 bool allow_zap;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800200 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800201 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800202 enum animation_type win_animation_type;
Jonny Lambf322f8e2014-08-12 15:13:30 +0200203 enum animation_type win_close_animation_type;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800204 enum animation_type startup_animation_type;
205 enum animation_type focus_animation_type;
206
Manuel Bachmann50c87db2014-02-26 15:52:13 +0100207 struct weston_layer minimized_layer;
208
Jason Ekstrand024177c2014-04-21 19:42:58 -0500209 struct wl_listener seat_create_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800210 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200211 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800212 struct wl_list output_list;
213
Jonas Ådahl6d6fb612015-11-17 16:00:33 +0800214 enum weston_desktop_shell_panel_position panel_position;
Jonny Lamb765760d2014-08-20 15:53:19 +0200215
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800216 char *client;
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +0300217
218 struct timespec startup_time;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800219};
220
221struct weston_output *
222get_default_output(struct weston_compositor *compositor);
223
224struct weston_view *
225get_default_view(struct weston_surface *surface);
226
227struct shell_surface *
228get_shell_surface(struct weston_surface *surface);
229
230struct workspace *
231get_current_workspace(struct desktop_shell *shell);
232
233void
Mario Kleiner9f4d6552015-06-21 21:25:08 +0200234lower_fullscreen_layer(struct desktop_shell *shell,
235 struct weston_output *lowering_output);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800236
237void
238activate(struct desktop_shell *shell, struct weston_surface *es,
Emilio Pozuelo Monfort9e7c7592014-01-30 14:01:10 +0100239 struct weston_seat *seat, bool configure);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800240
241void
Derek Foreman8ae2db52015-07-15 13:00:36 -0500242exposay_binding(struct weston_keyboard *keyboard,
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800243 enum weston_keyboard_modifier modifier,
244 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800245int
246input_panel_setup(struct desktop_shell *shell);
247void
248input_panel_destroy(struct desktop_shell *shell);
Ander Conselvan de Oliveira304996d2014-04-11 13:57:15 +0300249
250typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
251 struct weston_layer *, void *);
252
253void
254shell_for_each_layer(struct desktop_shell *shell,
255 shell_for_each_layer_func_t func,
256 void *data);