Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2010-2012 Intel Corporation |
| 3 | * Copyright © 2011-2012 Collabora, Ltd. |
| 4 | * Copyright © 2013 Raspberry Pi Foundation |
| 5 | * |
Bryce Harrington | af637c2 | 2015-06-11 12:55:55 -0700 | [diff] [blame] | 6 | * 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øgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 12 | * |
Bryce Harrington | af637c2 | 2015-06-11 12:55:55 -0700 | [diff] [blame] | 13 | * 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øgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include <stdbool.h> |
Pekka Paalanen | 2e62e4a | 2014-08-28 11:41:26 +0300 | [diff] [blame] | 27 | #include <time.h> |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 28 | |
| 29 | #include "compositor.h" |
| 30 | |
Jonny Lamb | 765760d | 2014-08-20 15:53:19 +0200 | [diff] [blame] | 31 | #include "desktop-shell-server-protocol.h" |
| 32 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 33 | enum animation_type { |
| 34 | ANIMATION_NONE, |
| 35 | |
| 36 | ANIMATION_ZOOM, |
| 37 | ANIMATION_FADE, |
| 38 | ANIMATION_DIM_LAYER, |
| 39 | }; |
| 40 | |
| 41 | enum fade_type { |
| 42 | FADE_IN, |
| 43 | FADE_OUT |
| 44 | }; |
| 45 | |
| 46 | enum 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 | |
| 52 | enum 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 Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 59 | struct 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 | |
| 69 | struct 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øgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 94 | struct focus_surface { |
| 95 | struct weston_surface *surface; |
| 96 | struct weston_view *view; |
| 97 | struct weston_transform workspace_transform; |
| 98 | }; |
| 99 | |
| 100 | struct 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 Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 111 | struct 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; |
| 117 | }; |
| 118 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 119 | struct desktop_shell { |
| 120 | struct weston_compositor *compositor; |
| 121 | |
| 122 | struct wl_listener idle_listener; |
| 123 | struct wl_listener wake_listener; |
| 124 | struct wl_listener destroy_listener; |
| 125 | struct wl_listener show_input_panel_listener; |
| 126 | struct wl_listener hide_input_panel_listener; |
| 127 | struct wl_listener update_input_panel_listener; |
| 128 | |
| 129 | struct weston_layer fullscreen_layer; |
| 130 | struct weston_layer panel_layer; |
| 131 | struct weston_layer background_layer; |
| 132 | struct weston_layer lock_layer; |
| 133 | struct weston_layer input_panel_layer; |
| 134 | |
| 135 | struct wl_listener pointer_focus_listener; |
| 136 | struct weston_surface *grab_surface; |
| 137 | |
| 138 | struct { |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 139 | struct wl_client *client; |
| 140 | struct wl_resource *desktop_shell; |
Ander Conselvan de Oliveira | 312ea4c | 2013-12-20 21:07:01 +0200 | [diff] [blame] | 141 | struct wl_listener client_destroy_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 142 | |
| 143 | unsigned deathcount; |
| 144 | uint32_t deathstamp; |
| 145 | } child; |
| 146 | |
| 147 | bool locked; |
| 148 | bool showing_input_panels; |
| 149 | bool prepare_event_sent; |
| 150 | |
Pekka Paalanen | aa9536a | 2015-06-24 16:09:17 +0300 | [diff] [blame] | 151 | struct text_backend *text_backend; |
| 152 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 153 | struct { |
| 154 | struct weston_surface *surface; |
| 155 | pixman_box32_t cursor_rectangle; |
| 156 | } text_input; |
| 157 | |
| 158 | struct weston_surface *lock_surface; |
| 159 | struct wl_listener lock_surface_listener; |
| 160 | |
| 161 | struct { |
| 162 | struct wl_array array; |
| 163 | unsigned int current; |
| 164 | unsigned int num; |
| 165 | |
| 166 | struct wl_list client_list; |
| 167 | |
| 168 | struct weston_animation animation; |
| 169 | struct wl_list anim_sticky_list; |
| 170 | int anim_dir; |
| 171 | uint32_t anim_timestamp; |
| 172 | double anim_current; |
| 173 | struct workspace *anim_from; |
| 174 | struct workspace *anim_to; |
| 175 | } workspaces; |
| 176 | |
| 177 | struct { |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 178 | struct wl_resource *binding; |
| 179 | struct wl_list surfaces; |
| 180 | } input_panel; |
| 181 | |
| 182 | struct { |
| 183 | struct weston_view *view; |
| 184 | struct weston_view_animation *animation; |
| 185 | enum fade_type type; |
| 186 | struct wl_event_source *startup_timer; |
| 187 | } fade; |
| 188 | |
Emilio Pozuelo Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 189 | struct exposay exposay; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 190 | |
| 191 | uint32_t binding_modifier; |
Kristian Høgsberg | d56ab4e | 2014-01-16 16:51:52 -0800 | [diff] [blame] | 192 | uint32_t exposay_modifier; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 193 | enum animation_type win_animation_type; |
Jonny Lamb | f322f8e | 2014-08-12 15:13:30 +0200 | [diff] [blame] | 194 | enum animation_type win_close_animation_type; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 195 | enum animation_type startup_animation_type; |
| 196 | enum animation_type focus_animation_type; |
| 197 | |
Manuel Bachmann | 50c87db | 2014-02-26 15:52:13 +0100 | [diff] [blame] | 198 | struct weston_layer minimized_layer; |
| 199 | |
Jason Ekstrand | 024177c | 2014-04-21 19:42:58 -0500 | [diff] [blame] | 200 | struct wl_listener seat_create_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 201 | struct wl_listener output_create_listener; |
Ander Conselvan de Oliveira | a8a9baf | 2014-01-29 18:47:52 +0200 | [diff] [blame] | 202 | struct wl_listener output_move_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 203 | struct wl_list output_list; |
| 204 | |
Jonny Lamb | 765760d | 2014-08-20 15:53:19 +0200 | [diff] [blame] | 205 | enum desktop_shell_panel_position panel_position; |
| 206 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 207 | char *client; |
Pekka Paalanen | 2e62e4a | 2014-08-28 11:41:26 +0300 | [diff] [blame] | 208 | |
| 209 | struct timespec startup_time; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | struct weston_output * |
| 213 | get_default_output(struct weston_compositor *compositor); |
| 214 | |
| 215 | struct weston_view * |
| 216 | get_default_view(struct weston_surface *surface); |
| 217 | |
| 218 | struct shell_surface * |
| 219 | get_shell_surface(struct weston_surface *surface); |
| 220 | |
| 221 | struct workspace * |
| 222 | get_current_workspace(struct desktop_shell *shell); |
| 223 | |
| 224 | void |
Mario Kleiner | 9f4d655 | 2015-06-21 21:25:08 +0200 | [diff] [blame] | 225 | lower_fullscreen_layer(struct desktop_shell *shell, |
| 226 | struct weston_output *lowering_output); |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 227 | |
| 228 | void |
| 229 | activate(struct desktop_shell *shell, struct weston_surface *es, |
Emilio Pozuelo Monfort | 9e7c759 | 2014-01-30 14:01:10 +0100 | [diff] [blame] | 230 | struct weston_seat *seat, bool configure); |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 231 | |
| 232 | void |
Derek Foreman | 8ae2db5 | 2015-07-15 13:00:36 -0500 | [diff] [blame] | 233 | exposay_binding(struct weston_keyboard *keyboard, |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 234 | enum weston_keyboard_modifier modifier, |
| 235 | void *data); |
Kristian Høgsberg | 677a5f5 | 2013-12-04 11:00:19 -0800 | [diff] [blame] | 236 | int |
| 237 | input_panel_setup(struct desktop_shell *shell); |
| 238 | void |
| 239 | input_panel_destroy(struct desktop_shell *shell); |
Ander Conselvan de Oliveira | 304996d | 2014-04-11 13:57:15 +0300 | [diff] [blame] | 240 | |
| 241 | typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *, |
| 242 | struct weston_layer *, void *); |
| 243 | |
| 244 | void |
| 245 | shell_for_each_layer(struct desktop_shell *shell, |
| 246 | shell_for_each_layer_func_t func, |
| 247 | void *data); |