blob: 063641d2178f7fd9dbb561416bec38b5dd54e744 [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"
Quentin Glidic8f9d90a2016-08-12 10:41:36 +020031#include "xwayland/xwayland-api.h"
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080032
Jonas Ådahl6d6fb612015-11-17 16:00:33 +080033#include "weston-desktop-shell-server-protocol.h"
Jonny Lamb765760d2014-08-20 15:53:19 +020034
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080035enum animation_type {
36 ANIMATION_NONE,
37
38 ANIMATION_ZOOM,
39 ANIMATION_FADE,
40 ANIMATION_DIM_LAYER,
41};
42
43enum fade_type {
44 FADE_IN,
45 FADE_OUT
46};
47
48enum exposay_target_state {
49 EXPOSAY_TARGET_OVERVIEW, /* show all windows */
50 EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
51 EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
52};
53
54enum exposay_layout_state {
55 EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
56 EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
57 EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
58 EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
59};
60
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +010061struct exposay_output {
62 int num_surfaces;
63 int grid_size;
64 int surface_size;
65
66 int hpadding_outer;
67 int vpadding_outer;
68 int padding_inner;
69};
70
71struct exposay {
72 /* XXX: Make these exposay_surfaces. */
73 struct weston_view *focus_prev;
74 struct weston_view *focus_current;
75 struct weston_view *clicked;
76 struct workspace *workspace;
77 struct weston_seat *seat;
78
79 struct wl_list surface_list;
80
81 struct weston_keyboard_grab grab_kbd;
82 struct weston_pointer_grab grab_ptr;
83
84 enum exposay_target_state state_target;
85 enum exposay_layout_state state_cur;
86 int in_flight; /* number of animations still running */
87
88 int row_current;
89 int column_current;
90 struct exposay_output *cur_output;
91
92 bool mod_pressed;
93 bool mod_invalid;
94};
95
Kristian Høgsberg1ef23132013-12-04 00:20:01 -080096struct focus_surface {
97 struct weston_surface *surface;
98 struct weston_view *view;
99 struct weston_transform workspace_transform;
100};
101
102struct workspace {
103 struct weston_layer layer;
104
105 struct wl_list focus_list;
106 struct wl_listener seat_destroyed_listener;
107
108 struct focus_surface *fsurf_front;
109 struct focus_surface *fsurf_back;
110 struct weston_view_animation *focus_animation;
111};
112
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100113struct shell_output {
114 struct desktop_shell *shell;
115 struct weston_output *output;
116 struct exposay_output eoutput;
117 struct wl_listener destroy_listener;
118 struct wl_list link;
David Fort50d962f2016-06-09 17:55:52 +0200119
120 struct weston_surface *panel_surface;
121 struct wl_listener panel_surface_listener;
122
123 struct weston_surface *background_surface;
124 struct wl_listener background_surface_listener;
Bryce Harrington9ad4de12016-09-09 13:16:02 -0700125
126 struct {
127 struct weston_view *view;
128 struct weston_view_animation *animation;
129 enum fade_type type;
130 struct wl_event_source *startup_timer;
131 } fade;
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100132};
133
Quentin Glidic8f9d90a2016-08-12 10:41:36 +0200134struct weston_desktop;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800135struct desktop_shell {
136 struct weston_compositor *compositor;
Quentin Glidic8f9d90a2016-08-12 10:41:36 +0200137 struct weston_desktop *desktop;
138 const struct weston_xwayland_surface_api *xwayland_surface_api;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800139
140 struct wl_listener idle_listener;
141 struct wl_listener wake_listener;
Giulio Camuffof05d18f2015-12-11 20:57:05 +0200142 struct wl_listener transform_listener;
David Fort50d962f2016-06-09 17:55:52 +0200143 struct wl_listener resized_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800144 struct wl_listener destroy_listener;
145 struct wl_listener show_input_panel_listener;
146 struct wl_listener hide_input_panel_listener;
147 struct wl_listener update_input_panel_listener;
148
149 struct weston_layer fullscreen_layer;
150 struct weston_layer panel_layer;
151 struct weston_layer background_layer;
152 struct weston_layer lock_layer;
153 struct weston_layer input_panel_layer;
154
155 struct wl_listener pointer_focus_listener;
156 struct weston_surface *grab_surface;
157
158 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800159 struct wl_client *client;
160 struct wl_resource *desktop_shell;
Ander Conselvan de Oliveira312ea4c2013-12-20 21:07:01 +0200161 struct wl_listener client_destroy_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800162
163 unsigned deathcount;
164 uint32_t deathstamp;
165 } child;
166
167 bool locked;
168 bool showing_input_panels;
169 bool prepare_event_sent;
170
Pekka Paalanenaa9536a2015-06-24 16:09:17 +0300171 struct text_backend *text_backend;
172
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800173 struct {
174 struct weston_surface *surface;
175 pixman_box32_t cursor_rectangle;
176 } text_input;
177
178 struct weston_surface *lock_surface;
179 struct wl_listener lock_surface_listener;
180
181 struct {
182 struct wl_array array;
183 unsigned int current;
184 unsigned int num;
185
186 struct wl_list client_list;
187
188 struct weston_animation animation;
189 struct wl_list anim_sticky_list;
190 int anim_dir;
191 uint32_t anim_timestamp;
192 double anim_current;
193 struct workspace *anim_from;
194 struct workspace *anim_to;
195 } workspaces;
196
197 struct {
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800198 struct wl_resource *binding;
199 struct wl_list surfaces;
200 } input_panel;
201
Emilio Pozuelo Monfort3b6e68e2014-02-10 13:22:32 +0100202 struct exposay exposay;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800203
Bob Ham744e6532016-01-12 10:21:48 +0000204 bool allow_zap;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800205 uint32_t binding_modifier;
Kristian Høgsbergd56ab4e2014-01-16 16:51:52 -0800206 uint32_t exposay_modifier;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800207 enum animation_type win_animation_type;
Jonny Lambf322f8e2014-08-12 15:13:30 +0200208 enum animation_type win_close_animation_type;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800209 enum animation_type startup_animation_type;
210 enum animation_type focus_animation_type;
211
Manuel Bachmann50c87db2014-02-26 15:52:13 +0100212 struct weston_layer minimized_layer;
213
Jason Ekstrand024177c2014-04-21 19:42:58 -0500214 struct wl_listener seat_create_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800215 struct wl_listener output_create_listener;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200216 struct wl_listener output_move_listener;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800217 struct wl_list output_list;
218
Jonas Ådahl6d6fb612015-11-17 16:00:33 +0800219 enum weston_desktop_shell_panel_position panel_position;
Jonny Lamb765760d2014-08-20 15:53:19 +0200220
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800221 char *client;
Pekka Paalanen2e62e4a2014-08-28 11:41:26 +0300222
223 struct timespec startup_time;
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800224};
225
226struct weston_output *
227get_default_output(struct weston_compositor *compositor);
228
229struct weston_view *
230get_default_view(struct weston_surface *surface);
231
232struct shell_surface *
233get_shell_surface(struct weston_surface *surface);
234
235struct workspace *
236get_current_workspace(struct desktop_shell *shell);
237
238void
Mario Kleiner9f4d6552015-06-21 21:25:08 +0200239lower_fullscreen_layer(struct desktop_shell *shell,
240 struct weston_output *lowering_output);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800241
242void
Jonas Ådahl1fa6ded2014-10-18 13:24:53 +0200243activate(struct desktop_shell *shell, struct weston_view *view,
Jonas Ådahl4361b4e2014-10-18 18:20:16 +0200244 struct weston_seat *seat, uint32_t flags);
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800245
246void
Derek Foreman8ae2db52015-07-15 13:00:36 -0500247exposay_binding(struct weston_keyboard *keyboard,
Kristian Høgsberg1ef23132013-12-04 00:20:01 -0800248 enum weston_keyboard_modifier modifier,
249 void *data);
Kristian Høgsberg677a5f52013-12-04 11:00:19 -0800250int
251input_panel_setup(struct desktop_shell *shell);
252void
253input_panel_destroy(struct desktop_shell *shell);
Ander Conselvan de Oliveira304996d2014-04-11 13:57:15 +0300254
255typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
256 struct weston_layer *, void *);
257
258void
259shell_for_each_layer(struct desktop_shell *shell,
260 shell_for_each_layer_func_t func,
261 void *data);