shell.h 6.72 KB
Newer Older
1 2 3 4 5
/*
 * Copyright © 2010-2012 Intel Corporation
 * Copyright © 2011-2012 Collabora, Ltd.
 * Copyright © 2013 Raspberry Pi Foundation
 *
6 7 8 9 10 11
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
12
 *
13 14 15 16 17 18 19 20 21 22 23
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
24 25 26
 */

#include <stdbool.h>
27
#include <stdint.h>
28
#include <time.h>
29 30

#include "compositor.h"
31
#include "xwayland/xwayland-api.h"
32

33
#include "weston-desktop-shell-server-protocol.h"
34

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
enum animation_type {
	ANIMATION_NONE,

	ANIMATION_ZOOM,
	ANIMATION_FADE,
	ANIMATION_DIM_LAYER,
};

enum fade_type {
	FADE_IN,
	FADE_OUT
};

enum exposay_target_state {
	EXPOSAY_TARGET_OVERVIEW, /* show all windows */
	EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
	EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
};

enum exposay_layout_state {
	EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
	EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
	EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
	EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
};

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
struct exposay_output {
	int num_surfaces;
	int grid_size;
	int surface_size;

	int hpadding_outer;
	int vpadding_outer;
	int padding_inner;
};

struct exposay {
	/* XXX: Make these exposay_surfaces. */
	struct weston_view *focus_prev;
	struct weston_view *focus_current;
	struct weston_view *clicked;
	struct workspace *workspace;
	struct weston_seat *seat;

	struct wl_list surface_list;

	struct weston_keyboard_grab grab_kbd;
	struct weston_pointer_grab grab_ptr;

	enum exposay_target_state state_target;
	enum exposay_layout_state state_cur;
	int in_flight; /* number of animations still running */

	int row_current;
	int column_current;
	struct exposay_output *cur_output;

	bool mod_pressed;
	bool mod_invalid;
};

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
struct focus_surface {
	struct weston_surface *surface;
	struct weston_view *view;
	struct weston_transform workspace_transform;
};

struct workspace {
	struct weston_layer layer;

	struct wl_list focus_list;
	struct wl_listener seat_destroyed_listener;

	struct focus_surface *fsurf_front;
	struct focus_surface *fsurf_back;
	struct weston_view_animation *focus_animation;
};

113 114 115 116 117 118
struct shell_output {
	struct desktop_shell  *shell;
	struct weston_output  *output;
	struct exposay_output eoutput;
	struct wl_listener    destroy_listener;
	struct wl_list        link;
119 120 121 122 123 124

	struct weston_surface *panel_surface;
	struct wl_listener panel_surface_listener;

	struct weston_surface *background_surface;
	struct wl_listener background_surface_listener;
125 126 127 128 129 130 131

	struct {
		struct weston_view *view;
		struct weston_view_animation *animation;
		enum fade_type type;
		struct wl_event_source *startup_timer;
	} fade;
132 133
};

134
struct weston_desktop;
135 136
struct desktop_shell {
	struct weston_compositor *compositor;
137 138
	struct weston_desktop *desktop;
	const struct weston_xwayland_surface_api *xwayland_surface_api;
139 140 141

	struct wl_listener idle_listener;
	struct wl_listener wake_listener;
142
	struct wl_listener transform_listener;
143
	struct wl_listener resized_listener;
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
	struct wl_listener destroy_listener;
	struct wl_listener show_input_panel_listener;
	struct wl_listener hide_input_panel_listener;
	struct wl_listener update_input_panel_listener;

	struct weston_layer fullscreen_layer;
	struct weston_layer panel_layer;
	struct weston_layer background_layer;
	struct weston_layer lock_layer;
	struct weston_layer input_panel_layer;

	struct wl_listener pointer_focus_listener;
	struct weston_surface *grab_surface;

	struct {
		struct wl_client *client;
		struct wl_resource *desktop_shell;
161
		struct wl_listener client_destroy_listener;
162 163

		unsigned deathcount;
164
		struct timespec deathstamp;
165 166 167 168 169 170
	} child;

	bool locked;
	bool showing_input_panels;
	bool prepare_event_sent;

171 172
	struct text_backend *text_backend;

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
	struct {
		struct weston_surface *surface;
		pixman_box32_t cursor_rectangle;
	} text_input;

	struct weston_surface *lock_surface;
	struct wl_listener lock_surface_listener;

	struct {
		struct wl_array array;
		unsigned int current;
		unsigned int num;

		struct wl_list client_list;

		struct weston_animation animation;
		struct wl_list anim_sticky_list;
		int anim_dir;
191
		struct timespec anim_timestamp;
192 193 194 195 196 197 198 199 200 201
		double anim_current;
		struct workspace *anim_from;
		struct workspace *anim_to;
	} workspaces;

	struct {
		struct wl_resource *binding;
		struct wl_list surfaces;
	} input_panel;

202
	struct exposay exposay;
203

204
	bool allow_zap;
205
	uint32_t binding_modifier;
206
	uint32_t exposay_modifier;
207
	enum animation_type win_animation_type;
208
	enum animation_type win_close_animation_type;
209 210 211
	enum animation_type startup_animation_type;
	enum animation_type focus_animation_type;

212 213
	struct weston_layer minimized_layer;

214
	struct wl_listener seat_create_listener;
215
	struct wl_listener output_create_listener;
216
	struct wl_listener output_move_listener;
217 218
	struct wl_list output_list;

219
	enum weston_desktop_shell_panel_position panel_position;
220

221
	char *client;
222 223

	struct timespec startup_time;
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
};

struct weston_output *
get_default_output(struct weston_compositor *compositor);

struct weston_view *
get_default_view(struct weston_surface *surface);

struct shell_surface *
get_shell_surface(struct weston_surface *surface);

struct workspace *
get_current_workspace(struct desktop_shell *shell);

void
239 240
lower_fullscreen_layer(struct desktop_shell *shell,
		       struct weston_output *lowering_output);
241 242

void
243
activate(struct desktop_shell *shell, struct weston_view *view,
244
	 struct weston_seat *seat, uint32_t flags);
245 246

void
247
exposay_binding(struct weston_keyboard *keyboard,
248 249
		enum weston_keyboard_modifier modifier,
		void *data);
250 251 252 253
int
input_panel_setup(struct desktop_shell *shell);
void
input_panel_destroy(struct desktop_shell *shell);
254 255 256 257 258 259 260 261

typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
					    struct weston_layer *, void *);

void
shell_for_each_layer(struct desktop_shell *shell,
		     shell_for_each_layer_func_t func,
		     void *data);