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> |
Jussi Kukkonen | 649bbce | 2016-07-19 14:16:27 +0300 | [diff] [blame] | 27 | #include <stdint.h> |
Pekka Paalanen | 2e62e4a | 2014-08-28 11:41:26 +0300 | [diff] [blame] | 28 | #include <time.h> |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 29 | |
| 30 | #include "compositor.h" |
Quentin Glidic | 8f9d90a | 2016-08-12 10:41:36 +0200 | [diff] [blame] | 31 | #include "xwayland/xwayland-api.h" |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 32 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 33 | #include "weston-desktop-shell-server-protocol.h" |
Jonny Lamb | 765760d | 2014-08-20 15:53:19 +0200 | [diff] [blame] | 34 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 35 | enum animation_type { |
| 36 | ANIMATION_NONE, |
| 37 | |
| 38 | ANIMATION_ZOOM, |
| 39 | ANIMATION_FADE, |
| 40 | ANIMATION_DIM_LAYER, |
| 41 | }; |
| 42 | |
| 43 | enum fade_type { |
| 44 | FADE_IN, |
| 45 | FADE_OUT |
| 46 | }; |
| 47 | |
| 48 | enum 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 | |
| 54 | enum 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 Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 61 | struct 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 | |
| 71 | struct 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øgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 96 | struct focus_surface { |
| 97 | struct weston_surface *surface; |
| 98 | struct weston_view *view; |
| 99 | struct weston_transform workspace_transform; |
| 100 | }; |
| 101 | |
| 102 | struct 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 Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 113 | struct 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 Fort | 50d962f | 2016-06-09 17:55:52 +0200 | [diff] [blame] | 119 | |
| 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 Harrington | 9ad4de1 | 2016-09-09 13:16:02 -0700 | [diff] [blame] | 125 | |
| 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 Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 132 | }; |
| 133 | |
Quentin Glidic | 8f9d90a | 2016-08-12 10:41:36 +0200 | [diff] [blame] | 134 | struct weston_desktop; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 135 | struct desktop_shell { |
| 136 | struct weston_compositor *compositor; |
Quentin Glidic | 8f9d90a | 2016-08-12 10:41:36 +0200 | [diff] [blame] | 137 | struct weston_desktop *desktop; |
| 138 | const struct weston_xwayland_surface_api *xwayland_surface_api; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 139 | |
| 140 | struct wl_listener idle_listener; |
| 141 | struct wl_listener wake_listener; |
Giulio Camuffo | f05d18f | 2015-12-11 20:57:05 +0200 | [diff] [blame] | 142 | struct wl_listener transform_listener; |
David Fort | 50d962f | 2016-06-09 17:55:52 +0200 | [diff] [blame] | 143 | struct wl_listener resized_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 144 | 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øgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 159 | struct wl_client *client; |
| 160 | struct wl_resource *desktop_shell; |
Ander Conselvan de Oliveira | 312ea4c | 2013-12-20 21:07:01 +0200 | [diff] [blame] | 161 | struct wl_listener client_destroy_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 162 | |
| 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 Paalanen | aa9536a | 2015-06-24 16:09:17 +0300 | [diff] [blame] | 171 | struct text_backend *text_backend; |
| 172 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 173 | 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øgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 198 | struct wl_resource *binding; |
| 199 | struct wl_list surfaces; |
| 200 | } input_panel; |
| 201 | |
Emilio Pozuelo Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 202 | struct exposay exposay; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 203 | |
Bob Ham | 744e653 | 2016-01-12 10:21:48 +0000 | [diff] [blame] | 204 | bool allow_zap; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 205 | uint32_t binding_modifier; |
Kristian Høgsberg | d56ab4e | 2014-01-16 16:51:52 -0800 | [diff] [blame] | 206 | uint32_t exposay_modifier; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 207 | enum animation_type win_animation_type; |
Jonny Lamb | f322f8e | 2014-08-12 15:13:30 +0200 | [diff] [blame] | 208 | enum animation_type win_close_animation_type; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 209 | enum animation_type startup_animation_type; |
| 210 | enum animation_type focus_animation_type; |
| 211 | |
Manuel Bachmann | 50c87db | 2014-02-26 15:52:13 +0100 | [diff] [blame] | 212 | struct weston_layer minimized_layer; |
| 213 | |
Jason Ekstrand | 024177c | 2014-04-21 19:42:58 -0500 | [diff] [blame] | 214 | struct wl_listener seat_create_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 215 | struct wl_listener output_create_listener; |
Ander Conselvan de Oliveira | a8a9baf | 2014-01-29 18:47:52 +0200 | [diff] [blame] | 216 | struct wl_listener output_move_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 217 | struct wl_list output_list; |
| 218 | |
Jonas Ådahl | 6d6fb61 | 2015-11-17 16:00:33 +0800 | [diff] [blame] | 219 | enum weston_desktop_shell_panel_position panel_position; |
Jonny Lamb | 765760d | 2014-08-20 15:53:19 +0200 | [diff] [blame] | 220 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 221 | char *client; |
Pekka Paalanen | 2e62e4a | 2014-08-28 11:41:26 +0300 | [diff] [blame] | 222 | |
| 223 | struct timespec startup_time; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 224 | }; |
| 225 | |
| 226 | struct weston_output * |
| 227 | get_default_output(struct weston_compositor *compositor); |
| 228 | |
| 229 | struct weston_view * |
| 230 | get_default_view(struct weston_surface *surface); |
| 231 | |
| 232 | struct shell_surface * |
| 233 | get_shell_surface(struct weston_surface *surface); |
| 234 | |
| 235 | struct workspace * |
| 236 | get_current_workspace(struct desktop_shell *shell); |
| 237 | |
| 238 | void |
Mario Kleiner | 9f4d655 | 2015-06-21 21:25:08 +0200 | [diff] [blame] | 239 | lower_fullscreen_layer(struct desktop_shell *shell, |
| 240 | struct weston_output *lowering_output); |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 241 | |
| 242 | void |
Jonas Ådahl | 1fa6ded | 2014-10-18 13:24:53 +0200 | [diff] [blame] | 243 | activate(struct desktop_shell *shell, struct weston_view *view, |
Jonas Ådahl | 4361b4e | 2014-10-18 18:20:16 +0200 | [diff] [blame] | 244 | struct weston_seat *seat, uint32_t flags); |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 245 | |
| 246 | void |
Derek Foreman | 8ae2db5 | 2015-07-15 13:00:36 -0500 | [diff] [blame] | 247 | exposay_binding(struct weston_keyboard *keyboard, |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 248 | enum weston_keyboard_modifier modifier, |
| 249 | void *data); |
Kristian Høgsberg | 677a5f5 | 2013-12-04 11:00:19 -0800 | [diff] [blame] | 250 | int |
| 251 | input_panel_setup(struct desktop_shell *shell); |
| 252 | void |
| 253 | input_panel_destroy(struct desktop_shell *shell); |
Ander Conselvan de Oliveira | 304996d | 2014-04-11 13:57:15 +0300 | [diff] [blame] | 254 | |
| 255 | typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *, |
| 256 | struct weston_layer *, void *); |
| 257 | |
| 258 | void |
| 259 | shell_for_each_layer(struct desktop_shell *shell, |
| 260 | shell_for_each_layer_func_t func, |
| 261 | void *data); |