blob: f73cae5f96028b3faa4f3a08d1840ee5e0a0d6f7 [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>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030027#include <stdint.h>
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +030028#include <time.h>
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080029
30#include "compositor.h"
31
Jonas Ådahl6d6fb612015-11-17 16:00:33 +080032#include "weston-desktop-shell-server-protocol.h"
Jonny Lamb765760d2014-08-20 15:53:19 +020033
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080034enum animation_type {
35 ANIMATION_NONE,
36
37 ANIMATION_ZOOM,
38 ANIMATION_FADE,
39 ANIMATION_DIM_LAYER,
40};
41
42enum fade_type {
43 FADE_IN,
44 FADE_OUT
45};
46
47enum exposay_target_state {
48 EXPOSAY_TARGET_OVERVIEW, /* show all windows */
49 EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
50 EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
51};
52
53enum exposay_layout_state {
54 EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
55 EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
56 EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
57 EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
58};
59
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +010060struct exposay_output {
61 int num_surfaces;
62 int grid_size;
63 int surface_size;
64
65 int hpadding_outer;
66 int vpadding_outer;
67 int padding_inner;
68};
69
70struct exposay {
71 /* XXX: Make these exposay_surfaces. */
72 struct weston_view *focus_prev;
73 struct weston_view *focus_current;
74 struct weston_view *clicked;
75 struct workspace *workspace;
76 struct weston_seat *seat;
77
78 struct wl_list surface_list;
79
80 struct weston_keyboard_grab grab_kbd;
81 struct weston_pointer_grab grab_ptr;
82
83 enum exposay_target_state state_target;
84 enum exposay_layout_state state_cur;
85 int in_flight; /* number of animations still running */
86
87 int row_current;
88 int column_current;
89 struct exposay_output *cur_output;
90
91 bool mod_pressed;
92 bool mod_invalid;
93};
94
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080095struct focus_surface {
96 struct weston_surface *surface;
97 struct weston_view *view;
98 struct weston_transform workspace_transform;
99};
100
101struct workspace {
102 struct weston_layer layer;
103
104 struct wl_list focus_list;
105 struct wl_listener seat_destroyed_listener;
106
107 struct focus_surface *fsurf_front;
108 struct focus_surface *fsurf_back;
109 struct weston_view_animation *focus_animation;
110};
111
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100112struct shell_output {
113 struct desktop_shell *shell;
114 struct weston_output *output;
115 struct exposay_output eoutput;
116 struct wl_listener destroy_listener;
117 struct wl_list link;
David Fort50d962f2016-06-09 17:55:52 +0200118
119 struct weston_surface *panel_surface;
120 struct wl_listener panel_surface_listener;
121
122 struct weston_surface *background_surface;
123 struct wl_listener background_surface_listener;
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100124};
125
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800126struct desktop_shell {
127 struct weston_compositor *compositor;
128
129 struct wl_listener idle_listener;
130 struct wl_listener wake_listener;
Giulio Camuffof05d18f2015-12-11 20:57:05 +0200131 struct wl_listener transform_listener;
David Fort50d962f2016-06-09 17:55:52 +0200132 struct wl_listener resized_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800133 struct wl_listener destroy_listener;
134 struct wl_listener show_input_panel_listener;
135 struct wl_listener hide_input_panel_listener;
136 struct wl_listener update_input_panel_listener;
137
138 struct weston_layer fullscreen_layer;
139 struct weston_layer panel_layer;
140 struct weston_layer background_layer;
141 struct weston_layer lock_layer;
142 struct weston_layer input_panel_layer;
143
144 struct wl_listener pointer_focus_listener;
145 struct weston_surface *grab_surface;
146
147 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800148 struct wl_client *client;
149 struct wl_resource *desktop_shell;
Ander Conselvan de Oliveira312ea4c2013-12-20 21:07:01 +0200150 struct wl_listener client_destroy_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800151
152 unsigned deathcount;
153 uint32_t deathstamp;
154 } child;
155
156 bool locked;
157 bool showing_input_panels;
158 bool prepare_event_sent;
159
Pekka Paalanenaa9536a2015-06-24 16:09:17 +0300160 struct text_backend *text_backend;
161
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800162 struct {
163 struct weston_surface *surface;
164 pixman_box32_t cursor_rectangle;
165 } text_input;
166
167 struct weston_surface *lock_surface;
168 struct wl_listener lock_surface_listener;
169
170 struct {
171 struct wl_array array;
172 unsigned int current;
173 unsigned int num;
174
175 struct wl_list client_list;
176
177 struct weston_animation animation;
178 struct wl_list anim_sticky_list;
179 int anim_dir;
180 uint32_t anim_timestamp;
181 double anim_current;
182 struct workspace *anim_from;
183 struct workspace *anim_to;
184 } workspaces;
185
186 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800187 struct wl_resource *binding;
188 struct wl_list surfaces;
189 } input_panel;
190
191 struct {
192 struct weston_view *view;
193 struct weston_view_animation *animation;
194 enum fade_type type;
195 struct wl_event_source *startup_timer;
196 } fade;
197
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100198 struct exposay exposay;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800199
Bob Ham744e6532016-01-12 10:21:48 +0000200 bool allow_zap;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800201 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800202 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800203 enum animation_type win_animation_type;
Jonny Lambf322f8e2014-08-12 15:13:30 +0200204 enum animation_type win_close_animation_type;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800205 enum animation_type startup_animation_type;
206 enum animation_type focus_animation_type;
207
Manuel Bachmann50c87db2014-02-26 15:52:13 +0100208 struct weston_layer minimized_layer;
209
Jason Ekstrand024177c2014-04-21 19:42:58 -0500210 struct wl_listener seat_create_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800211 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200212 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800213 struct wl_list output_list;
214
Jonas Ådahl6d6fb612015-11-17 16:00:33 +0800215 enum weston_desktop_shell_panel_position panel_position;
Jonny Lamb765760d2014-08-20 15:53:19 +0200216
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800217 char *client;
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +0300218
219 struct timespec startup_time;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800220};
221
222struct weston_output *
223get_default_output(struct weston_compositor *compositor);
224
225struct weston_view *
226get_default_view(struct weston_surface *surface);
227
228struct shell_surface *
229get_shell_surface(struct weston_surface *surface);
230
231struct workspace *
232get_current_workspace(struct desktop_shell *shell);
233
234void
Mario Kleiner9f4d6552015-06-21 21:25:08 +0200235lower_fullscreen_layer(struct desktop_shell *shell,
236 struct weston_output *lowering_output);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800237
238void
Jonas Ådahl1fa6ded2014-10-18 13:24:53 +0200239activate(struct desktop_shell *shell, struct weston_view *view,
Jonas Ådahl4361b4e2014-10-18 18:20:16 +0200240 struct weston_seat *seat, uint32_t flags);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800241
242void
Derek Foreman8ae2db52015-07-15 13:00:36 -0500243exposay_binding(struct weston_keyboard *keyboard,
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800244 enum weston_keyboard_modifier modifier,
245 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800246int
247input_panel_setup(struct desktop_shell *shell);
248void
249input_panel_destroy(struct desktop_shell *shell);
Ander Conselvan de Oliveira304996d2014-04-11 13:57:15 +0300250
251typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
252 struct weston_layer *, void *);
253
254void
255shell_for_each_layer(struct desktop_shell *shell,
256 shell_for_each_layer_func_t func,
257 void *data);