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 | * |
| 6 | * Permission to use, copy, modify, distribute, and sell this software and |
| 7 | * its documentation for any purpose is hereby granted without fee, provided |
| 8 | * that the above copyright notice appear in all copies and that both that |
| 9 | * copyright notice and this permission notice appear in supporting |
| 10 | * documentation, and that the name of the copyright holders not be used in |
| 11 | * advertising or publicity pertaining to distribution of the software |
| 12 | * without specific, written prior permission. The copyright holders make |
| 13 | * no representations about the suitability of this software for any |
| 14 | * purpose. It is provided "as is" without express or implied warranty. |
| 15 | * |
| 16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 21 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 22 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <stdbool.h> |
| 26 | |
| 27 | #include "compositor.h" |
| 28 | |
Jonny Lamb | 765760d | 2014-08-20 15:53:19 +0200 | [diff] [blame] | 29 | #include "desktop-shell-server-protocol.h" |
| 30 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 31 | enum animation_type { |
| 32 | ANIMATION_NONE, |
| 33 | |
| 34 | ANIMATION_ZOOM, |
| 35 | ANIMATION_FADE, |
| 36 | ANIMATION_DIM_LAYER, |
| 37 | }; |
| 38 | |
| 39 | enum fade_type { |
| 40 | FADE_IN, |
| 41 | FADE_OUT |
| 42 | }; |
| 43 | |
| 44 | enum exposay_target_state { |
| 45 | EXPOSAY_TARGET_OVERVIEW, /* show all windows */ |
| 46 | EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */ |
| 47 | EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */ |
| 48 | }; |
| 49 | |
| 50 | enum exposay_layout_state { |
| 51 | EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */ |
| 52 | EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */ |
| 53 | EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */ |
| 54 | EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */ |
| 55 | }; |
| 56 | |
Emilio Pozuelo Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 57 | struct exposay_output { |
| 58 | int num_surfaces; |
| 59 | int grid_size; |
| 60 | int surface_size; |
| 61 | |
| 62 | int hpadding_outer; |
| 63 | int vpadding_outer; |
| 64 | int padding_inner; |
| 65 | }; |
| 66 | |
| 67 | struct exposay { |
| 68 | /* XXX: Make these exposay_surfaces. */ |
| 69 | struct weston_view *focus_prev; |
| 70 | struct weston_view *focus_current; |
| 71 | struct weston_view *clicked; |
| 72 | struct workspace *workspace; |
| 73 | struct weston_seat *seat; |
| 74 | |
| 75 | struct wl_list surface_list; |
| 76 | |
| 77 | struct weston_keyboard_grab grab_kbd; |
| 78 | struct weston_pointer_grab grab_ptr; |
| 79 | |
| 80 | enum exposay_target_state state_target; |
| 81 | enum exposay_layout_state state_cur; |
| 82 | int in_flight; /* number of animations still running */ |
| 83 | |
| 84 | int row_current; |
| 85 | int column_current; |
| 86 | struct exposay_output *cur_output; |
| 87 | |
| 88 | bool mod_pressed; |
| 89 | bool mod_invalid; |
| 90 | }; |
| 91 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 92 | struct focus_surface { |
| 93 | struct weston_surface *surface; |
| 94 | struct weston_view *view; |
| 95 | struct weston_transform workspace_transform; |
| 96 | }; |
| 97 | |
| 98 | struct workspace { |
| 99 | struct weston_layer layer; |
| 100 | |
| 101 | struct wl_list focus_list; |
| 102 | struct wl_listener seat_destroyed_listener; |
| 103 | |
| 104 | struct focus_surface *fsurf_front; |
| 105 | struct focus_surface *fsurf_back; |
| 106 | struct weston_view_animation *focus_animation; |
| 107 | }; |
| 108 | |
Emilio Pozuelo Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 109 | struct shell_output { |
| 110 | struct desktop_shell *shell; |
| 111 | struct weston_output *output; |
| 112 | struct exposay_output eoutput; |
| 113 | struct wl_listener destroy_listener; |
| 114 | struct wl_list link; |
| 115 | }; |
| 116 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 117 | struct desktop_shell { |
| 118 | struct weston_compositor *compositor; |
| 119 | |
| 120 | struct wl_listener idle_listener; |
| 121 | struct wl_listener wake_listener; |
| 122 | struct wl_listener destroy_listener; |
| 123 | struct wl_listener show_input_panel_listener; |
| 124 | struct wl_listener hide_input_panel_listener; |
| 125 | struct wl_listener update_input_panel_listener; |
| 126 | |
| 127 | struct weston_layer fullscreen_layer; |
| 128 | struct weston_layer panel_layer; |
| 129 | struct weston_layer background_layer; |
| 130 | struct weston_layer lock_layer; |
| 131 | struct weston_layer input_panel_layer; |
| 132 | |
| 133 | struct wl_listener pointer_focus_listener; |
| 134 | struct weston_surface *grab_surface; |
| 135 | |
| 136 | struct { |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 137 | struct wl_client *client; |
| 138 | struct wl_resource *desktop_shell; |
Ander Conselvan de Oliveira | 312ea4c | 2013-12-20 21:07:01 +0200 | [diff] [blame] | 139 | struct wl_listener client_destroy_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 140 | |
| 141 | unsigned deathcount; |
| 142 | uint32_t deathstamp; |
| 143 | } child; |
| 144 | |
| 145 | bool locked; |
| 146 | bool showing_input_panels; |
| 147 | bool prepare_event_sent; |
| 148 | |
| 149 | struct { |
| 150 | struct weston_surface *surface; |
| 151 | pixman_box32_t cursor_rectangle; |
| 152 | } text_input; |
| 153 | |
| 154 | struct weston_surface *lock_surface; |
| 155 | struct wl_listener lock_surface_listener; |
| 156 | |
| 157 | struct { |
| 158 | struct wl_array array; |
| 159 | unsigned int current; |
| 160 | unsigned int num; |
| 161 | |
| 162 | struct wl_list client_list; |
| 163 | |
| 164 | struct weston_animation animation; |
| 165 | struct wl_list anim_sticky_list; |
| 166 | int anim_dir; |
| 167 | uint32_t anim_timestamp; |
| 168 | double anim_current; |
| 169 | struct workspace *anim_from; |
| 170 | struct workspace *anim_to; |
| 171 | } workspaces; |
| 172 | |
| 173 | struct { |
| 174 | char *path; |
| 175 | int duration; |
| 176 | struct wl_resource *binding; |
| 177 | struct weston_process process; |
| 178 | struct wl_event_source *timer; |
| 179 | } screensaver; |
| 180 | |
| 181 | struct { |
| 182 | struct wl_resource *binding; |
| 183 | struct wl_list surfaces; |
| 184 | } input_panel; |
| 185 | |
| 186 | struct { |
| 187 | struct weston_view *view; |
| 188 | struct weston_view_animation *animation; |
| 189 | enum fade_type type; |
| 190 | struct wl_event_source *startup_timer; |
| 191 | } fade; |
| 192 | |
Emilio Pozuelo Monfort | 3b6e68e | 2014-02-10 13:22:32 +0100 | [diff] [blame] | 193 | struct exposay exposay; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 194 | |
| 195 | uint32_t binding_modifier; |
Kristian Høgsberg | d56ab4e | 2014-01-16 16:51:52 -0800 | [diff] [blame] | 196 | uint32_t exposay_modifier; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 197 | enum animation_type win_animation_type; |
Jonny Lamb | f322f8e | 2014-08-12 15:13:30 +0200 | [diff] [blame] | 198 | enum animation_type win_close_animation_type; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 199 | enum animation_type startup_animation_type; |
| 200 | enum animation_type focus_animation_type; |
| 201 | |
Manuel Bachmann | 50c87db | 2014-02-26 15:52:13 +0100 | [diff] [blame] | 202 | struct weston_layer minimized_layer; |
| 203 | |
Jason Ekstrand | 024177c | 2014-04-21 19:42:58 -0500 | [diff] [blame] | 204 | struct wl_listener seat_create_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 205 | struct wl_listener output_create_listener; |
Ander Conselvan de Oliveira | a8a9baf | 2014-01-29 18:47:52 +0200 | [diff] [blame] | 206 | struct wl_listener output_move_listener; |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 207 | struct wl_list output_list; |
| 208 | |
Jonny Lamb | 765760d | 2014-08-20 15:53:19 +0200 | [diff] [blame] | 209 | enum desktop_shell_panel_position panel_position; |
| 210 | |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 211 | char *client; |
| 212 | }; |
| 213 | |
| 214 | struct weston_output * |
| 215 | get_default_output(struct weston_compositor *compositor); |
| 216 | |
| 217 | struct weston_view * |
| 218 | get_default_view(struct weston_surface *surface); |
| 219 | |
| 220 | struct shell_surface * |
| 221 | get_shell_surface(struct weston_surface *surface); |
| 222 | |
| 223 | struct workspace * |
| 224 | get_current_workspace(struct desktop_shell *shell); |
| 225 | |
| 226 | void |
| 227 | lower_fullscreen_layer(struct desktop_shell *shell); |
| 228 | |
| 229 | void |
| 230 | activate(struct desktop_shell *shell, struct weston_surface *es, |
Emilio Pozuelo Monfort | 9e7c759 | 2014-01-30 14:01:10 +0100 | [diff] [blame] | 231 | struct weston_seat *seat, bool configure); |
Kristian Høgsberg | 1ef2313 | 2013-12-04 00:20:01 -0800 | [diff] [blame] | 232 | |
| 233 | void |
| 234 | exposay_binding(struct weston_seat *seat, |
| 235 | enum weston_keyboard_modifier modifier, |
| 236 | void *data); |
Kristian Høgsberg | 677a5f5 | 2013-12-04 11:00:19 -0800 | [diff] [blame] | 237 | int |
| 238 | input_panel_setup(struct desktop_shell *shell); |
| 239 | void |
| 240 | input_panel_destroy(struct desktop_shell *shell); |
Ander Conselvan de Oliveira | 304996d | 2014-04-11 13:57:15 +0300 | [diff] [blame] | 241 | |
| 242 | typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *, |
| 243 | struct weston_layer *, void *); |
| 244 | |
| 245 | void |
| 246 | shell_for_each_layer(struct desktop_shell *shell, |
| 247 | shell_for_each_layer_func_t func, |
| 248 | void *data); |