blob: 869740df5f7f335415a12bc618b9aac88e336a9c [file] [log] [blame]
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
Pekka Paalanend581a8f2012-01-27 16:25:16 +02003 * Copyright © 2012 Collabora, Ltd.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05004 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -07005 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050012 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -070013 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050025 */
26
27#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
28#define _WAYLAND_SYSTEM_COMPOSITOR_H_
29
Giulio Camuffo7fe01b12013-03-28 18:02:42 +010030#ifdef __cplusplus
31extern "C" {
32#endif
33
Derek Foreman280e7dd2014-10-03 13:13:42 -050034#include <stdbool.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030035#include <stdint.h>
Pekka Paalanenb5eedad2014-09-23 22:08:45 -040036#include <time.h>
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050037#include <pixman.h>
Daniel Stone855028f2012-05-01 20:37:10 +010038#include <xkbcommon/xkbcommon.h>
Kristian Høgsberg3c179332013-08-06 19:27:04 -070039
40#define WL_HIDE_DEPRECATED
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050041#include <wayland-server.h>
42
Kristian Høgsbergaf4f2aa2013-02-15 20:53:20 -050043#include "matrix.h"
44#include "config-parser.h"
Peter Huttererb1bc4a62013-08-08 11:57:04 +100045#include "zalloc.h"
Pekka Paalanenb5026542014-11-12 15:09:24 +020046#include "timeline-object.h"
Pekka Paalanen2eaa11e2012-03-30 15:45:40 +030047
Quentin Glidic248dd102016-08-12 10:41:34 +020048struct weston_geometry {
49 int32_t x, y;
50 int32_t width, height;
51};
52
53struct weston_position {
54 int32_t x, y;
55};
56
57struct weston_size {
58 int32_t width, height;
59};
60
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050061struct weston_transform {
62 struct weston_matrix matrix;
Pekka Paalanenc61eca62012-01-06 14:10:06 +020063 struct wl_list link;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050064};
65
66struct weston_surface;
Jason Ekstrand6bd62942013-06-20 20:38:23 -050067struct weston_buffer;
Tiago Vignattibc052c92012-04-19 16:18:18 +030068struct shell_surface;
Daniel Stone37816df2012-05-16 18:45:18 +010069struct weston_seat;
Scott Moreau062be7e2012-04-20 13:37:33 -060070struct weston_output;
Jan Arne Petersene829adc2012-08-10 16:47:22 +020071struct input_method;
Derek Foremane4d6c832015-08-05 14:48:11 -050072struct weston_pointer;
Pekka Paalanen230f3b12014-09-29 14:18:40 -040073struct linux_dmabuf_buffer;
Giulio Camuffo26f62d42016-06-02 21:48:09 +030074struct weston_recorder;
Jonas Ådahld3414f22016-07-22 17:56:31 +080075struct weston_pointer_constraint;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050076
Daniel Stone496ca172012-05-30 16:31:42 +010077enum weston_keyboard_modifier {
78 MODIFIER_CTRL = (1 << 0),
79 MODIFIER_ALT = (1 << 1),
80 MODIFIER_SUPER = (1 << 2),
Kristian Høgsberg73694c82012-06-28 14:13:10 -040081 MODIFIER_SHIFT = (1 << 3),
Daniel Stone496ca172012-05-30 16:31:42 +010082};
83
Giulio Camuffo6ef444d2014-08-28 19:44:09 +030084enum weston_keyboard_locks {
85 WESTON_NUM_LOCK = (1 << 0),
86 WESTON_CAPS_LOCK = (1 << 1),
87};
88
Daniel Stone8c8164f2012-05-30 16:31:45 +010089enum weston_led {
90 LED_NUM_LOCK = (1 << 0),
91 LED_CAPS_LOCK = (1 << 1),
92 LED_SCROLL_LOCK = (1 << 2),
93};
94
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050095struct weston_mode {
96 uint32_t flags;
97 int32_t width, height;
98 uint32_t refresh;
99 struct wl_list link;
100};
101
Scott Moreaue6603982012-06-11 13:07:51 -0600102struct weston_animation {
103 void (*frame)(struct weston_animation *animation,
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200104 struct weston_output *output,
105 const struct timespec *time);
Scott Moreaue6603982012-06-11 13:07:51 -0600106 int frame_counter;
107 struct wl_list link;
108};
109
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400110enum {
111 WESTON_SPRING_OVERSHOOT,
112 WESTON_SPRING_CLAMP,
113 WESTON_SPRING_BOUNCE
114};
115
Scott Moreaue6603982012-06-11 13:07:51 -0600116struct weston_spring {
117 double k;
118 double friction;
119 double current;
120 double target;
121 double previous;
Kristian Høgsberg091b0962013-06-17 09:23:14 -0400122 double min, max;
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200123 struct timespec timestamp;
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400124 uint32_t clip;
Scott Moreaue6603982012-06-11 13:07:51 -0600125};
126
Scott Moreauccbf29d2012-02-22 14:21:41 -0700127struct weston_output_zoom {
Derek Foremana36eb502015-07-23 14:55:12 -0500128 bool active;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700129 float increment;
130 float level;
Scott Moreaue6603982012-06-11 13:07:51 -0600131 float max_level;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700132 float trans_x, trans_y;
Giulio Camuffo6850e7b2015-10-07 20:14:18 +0300133 struct {
134 double x, y;
135 } current;
Derek Foreman22276a52015-07-23 14:55:15 -0500136 struct weston_seat *seat;
Scott Moreaue6603982012-06-11 13:07:51 -0600137 struct weston_animation animation_z;
138 struct weston_spring spring_z;
Giulio Camuffo412b0242013-11-14 23:42:51 +0100139 struct wl_listener motion_listener;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700140};
141
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200142/* bit compatible with drm definitions. */
143enum dpms_enum {
144 WESTON_DPMS_ON,
145 WESTON_DPMS_STANDBY,
146 WESTON_DPMS_SUSPEND,
147 WESTON_DPMS_OFF
148};
149
Pekka Paalanen01f60212017-03-24 15:39:24 +0200150/** Represents a monitor
151 *
152 * This object represents a monitor (hardware backends like DRM) or a window
153 * (windowed nested backends).
154 */
155struct weston_head {
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300156 struct weston_compositor *compositor; /**< owning compositor */
157 struct wl_list compositor_link; /**< in weston_compositor::head_list */
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +0300158 struct wl_signal destroy_signal; /**< destroy callbacks */
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300159
Pekka Paalanen05347622017-03-27 12:24:34 +0300160 struct weston_output *output; /**< the output driving this head */
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300161 struct wl_list output_link; /**< in weston_output::head_list */
Pekka Paalanen05347622017-03-27 12:24:34 +0300162
Pekka Paalanen1b9bf592017-03-27 12:15:38 +0300163 struct wl_list resource_list; /**< wl_output protocol objects */
164 struct wl_global *global; /**< wl_output global */
165
Pekka Paalanen01f60212017-03-24 15:39:24 +0200166 int32_t mm_width; /**< physical image width in mm */
167 int32_t mm_height; /**< physical image height in mm */
168 char *make; /**< monitor manufacturer (PNP ID) */
169 char *model; /**< monitor model */
170 char *serial_number; /**< monitor serial */
171 uint32_t subpixel; /**< enum wl_output_subpixel */
172 bool connection_internal; /**< embedded monitor (e.g. laptop) */
Pekka Paalanene19970f2017-08-28 14:11:02 +0300173 bool device_changed; /**< monitor information has changed */
Pekka Paalanen9b02e472017-08-14 14:43:13 +0300174
175 char *name; /**< head name, e.g. connector name */
Pekka Paalanen7fe858b2017-08-14 15:45:14 +0300176 bool connected; /**< is physically connected */
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300177
178 struct weston_output *allocator_output; /**< XXX: to be removed */
Pekka Paalanen01f60212017-03-24 15:39:24 +0200179};
180
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500181struct weston_output {
Casey Dahlin58ba1372012-04-19 22:50:08 -0400182 uint32_t id;
Richard Hughesafe690c2013-05-02 10:10:04 +0100183 char *name;
Casey Dahlin58ba1372012-04-19 22:50:08 -0400184
John Kåre Alsaker94659272012-11-13 19:10:18 +0100185 void *renderer_state;
186
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500187 struct wl_list link;
188 struct weston_compositor *compositor;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500189
190 /** From global to output buffer coordinates. */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500191 struct weston_matrix matrix;
Derek Foremanc0023212015-03-24 11:36:13 -0500192 /** From output buffer to global coordinates. */
193 struct weston_matrix inverse_matrix;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500194
Scott Moreau9d1b1122012-06-08 19:40:53 -0600195 struct wl_list animation_list;
Scott Moreau1bad5db2012-08-18 01:04:05 -0600196 int32_t x, y, width, height;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200197
198 /** Output area in global coordinates, simple rect */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500199 pixman_region32_t region;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200200
Ander Conselvan de Oliveirab8fcca92012-11-16 17:23:52 +0200201 pixman_region32_t previous_damage;
Daniel Stone09a97e22017-03-01 11:34:06 +0000202
203 /** True if damage has occurred since the last repaint for this output;
204 * if set, a repaint will eventually occur. */
205 bool repaint_needed;
Daniel Stone05df8c12017-03-03 16:59:42 +0000206
207 /** State of the repaint loop */
208 enum {
209 REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */
210 REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */
211 REPAINT_SCHEDULED, /**< repaint is scheduled to occur */
212 REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
213 } repaint_status;
214
Daniel Stone6847b852017-03-01 11:34:08 +0000215 /** If repaint_status is REPAINT_SCHEDULED, contains the time the
216 * next repaint should be run */
217 struct timespec next_repaint;
218
Pekka Paalanendcbcfc72017-10-26 14:33:59 +0300219 /** For cancelling the idle_repaint callback on output destruction. */
220 struct wl_event_source *idle_repaint_source;
221
Scott Moreauccbf29d2012-02-22 14:21:41 -0700222 struct weston_output_zoom zoom;
223 int dirty;
Kristian Høgsberg5fb70bf2012-05-24 12:29:46 -0400224 struct wl_signal frame_signal;
Richard Hughes64ddde12013-05-01 21:52:10 +0100225 struct wl_signal destroy_signal;
Zhang, Xiong Yf3012412013-12-13 22:10:53 +0200226 int move_x, move_y;
Alexandros Frantzise6ac2af2017-11-16 18:20:53 +0200227 struct timespec frame_time; /* presentation timestamp */
Pekka Paalanen641307c2014-09-23 22:08:47 -0400228 uint64_t msc; /* media stream counter */
Kristian Høgsberg79af73e2012-08-03 15:45:23 -0400229 int disable_planes;
Ander Conselvan de Oliveirae1e23522013-12-13 22:10:55 +0200230 int destroying;
Pekka Paalanen133e4392014-09-23 22:08:46 -0400231 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500232
Kristian Høgsberg05890dc2012-08-10 10:09:20 -0400233 uint32_t transform;
Hardening57388e42013-09-18 23:56:36 +0200234 int32_t native_scale;
Hardeningff39efa2013-09-18 23:56:35 +0200235 int32_t current_scale;
Hardening57388e42013-09-18 23:56:36 +0200236 int32_t original_scale;
Alexander Larsson4ea95522013-05-22 14:41:37 +0200237
Hardening57388e42013-09-18 23:56:36 +0200238 struct weston_mode *native_mode;
Hardeningff39efa2013-09-18 23:56:35 +0200239 struct weston_mode *current_mode;
240 struct weston_mode *original_mode;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500241 struct wl_list mode_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500242
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300243 struct weston_head head; /**< head for unconverted backends */
244 struct wl_list head_list; /**< List of driven weston_heads */
Pekka Paalanen01f60212017-03-24 15:39:24 +0200245
Jonas Ådahle5a12252013-04-05 23:07:11 +0200246 void (*start_repaint_loop)(struct weston_output *output);
David Herrmann1edf44c2013-10-22 17:11:26 +0200247 int (*repaint)(struct weston_output *output,
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000248 pixman_region32_t *damage,
249 void *repaint_data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500250 void (*destroy)(struct weston_output *output);
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000251 void (*assign_planes)(struct weston_output *output, void *repaint_data);
Alex Wu2dda6042012-04-17 17:20:47 +0800252 int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200253
Tiago Vignatti5ab91ad2012-03-12 19:40:09 -0300254 /* backlight values are on 0-255 range, where higher is brighter */
Kristian Høgsberg7c609122013-05-23 20:30:26 -0400255 int32_t backlight_current;
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200256 void (*set_backlight)(struct weston_output *output, uint32_t value);
257 void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
Richard Hughese7299962013-05-01 21:52:12 +0100258
259 uint16_t gamma_size;
260 void (*set_gamma)(struct weston_output *output,
261 uint16_t size,
262 uint16_t *r,
263 uint16_t *g,
264 uint16_t *b);
Pekka Paalanenb5026542014-11-12 15:09:24 +0200265
266 struct weston_timeline_object timeline;
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200267
Pekka Paalanen7f340ff2017-03-30 14:56:22 +0300268 bool enabled; /**< is in the output_list, not pending list */
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200269 int scale;
270
271 int (*enable)(struct weston_output *output);
272 int (*disable)(struct weston_output *output);
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300273
274 /** Attach a head in the backend
275 *
276 * @param output The output to attach to.
277 * @param head The head to attach.
278 * @return 0 on success, -1 on failure.
279 *
280 * Do anything necessary to account for a new head being attached to
281 * the output, and check any conditions possible. On failure, both
282 * the head and the output must be left as before the call.
283 *
284 * Libweston core will add the head to the head_list after a successful
285 * call.
286 */
287 int (*attach_head)(struct weston_output *output,
288 struct weston_head *head);
289
290 /** Detach a head in the backend
291 *
292 * @param output The output to detach from.
293 * @param head The head to detach.
294 *
295 * Do any clean-up necessary to detach this head from the output.
296 * The head has already been removed from the output's head_list.
297 */
298 void (*detach_head)(struct weston_output *output,
299 struct weston_head *head);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500300};
301
Jonas Ådahld2510102014-10-05 21:39:14 +0200302enum weston_pointer_motion_mask {
303 WESTON_POINTER_MOTION_ABS = 1 << 0,
304 WESTON_POINTER_MOTION_REL = 1 << 1,
Jonas Ådahl3845b322014-10-21 23:51:29 +0200305 WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2,
Jonas Ådahld2510102014-10-05 21:39:14 +0200306};
307
308struct weston_pointer_motion_event {
309 uint32_t mask;
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200310 struct timespec time;
Jonas Ådahld2510102014-10-05 21:39:14 +0200311 double x;
312 double y;
313 double dx;
314 double dy;
Jonas Ådahl3845b322014-10-21 23:51:29 +0200315 double dx_unaccel;
316 double dy_unaccel;
Jonas Ådahld2510102014-10-05 21:39:14 +0200317};
318
Peter Hutterer89b6a492016-01-18 15:58:17 +1000319struct weston_pointer_axis_event {
320 uint32_t axis;
Giulio Camuffo90a6fc62016-03-22 17:44:54 +0200321 double value;
Peter Hutterer87743e92016-01-18 16:38:22 +1000322 bool has_discrete;
323 int32_t discrete;
Peter Hutterer89b6a492016-01-18 15:58:17 +1000324};
325
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400326struct weston_pointer_grab;
327struct weston_pointer_grab_interface {
Kristian Høgsberg6848c252013-05-08 22:02:59 -0400328 void (*focus)(struct weston_pointer_grab *grab);
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200329 void (*motion)(struct weston_pointer_grab *grab,
330 const struct timespec *time,
Jonas Ådahld2510102014-10-05 21:39:14 +0200331 struct weston_pointer_motion_event *event);
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400332 void (*button)(struct weston_pointer_grab *grab,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200333 const struct timespec *time,
334 uint32_t button, uint32_t state);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200335 void (*axis)(struct weston_pointer_grab *grab,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200336 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000337 struct weston_pointer_axis_event *event);
Peter Hutterer87743e92016-01-18 16:38:22 +1000338 void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
339 void (*frame)(struct weston_pointer_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200340 void (*cancel)(struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400341};
342
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400343struct weston_pointer_grab {
344 const struct weston_pointer_grab_interface *interface;
345 struct weston_pointer *pointer;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400346};
347
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400348struct weston_keyboard_grab;
349struct weston_keyboard_grab_interface {
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200350 void (*key)(struct weston_keyboard_grab *grab,
351 const struct timespec *time, uint32_t key, uint32_t state);
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400352 void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400353 uint32_t mods_depressed, uint32_t mods_latched,
354 uint32_t mods_locked, uint32_t group);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200355 void (*cancel)(struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400356};
357
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400358struct weston_keyboard_grab {
359 const struct weston_keyboard_grab_interface *interface;
360 struct weston_keyboard *keyboard;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400361};
362
Kristian Høgsberge329f362013-05-06 22:19:57 -0400363struct weston_touch_grab;
364struct weston_touch_grab_interface {
365 void (*down)(struct weston_touch_grab *grab,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200366 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400367 int touch_id,
368 wl_fixed_t sx,
369 wl_fixed_t sy);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400370 void (*up)(struct weston_touch_grab *grab,
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200371 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400372 int touch_id);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400373 void (*motion)(struct weston_touch_grab *grab,
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200374 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400375 int touch_id,
376 wl_fixed_t sx,
377 wl_fixed_t sy);
Jonas Ådahl1679f232014-04-12 09:39:51 +0200378 void (*frame)(struct weston_touch_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200379 void (*cancel)(struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400380};
381
Kristian Høgsberge329f362013-05-06 22:19:57 -0400382struct weston_touch_grab {
383 const struct weston_touch_grab_interface *interface;
384 struct weston_touch *touch;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400385};
386
Kristian Høgsberg5e76a492013-07-25 16:09:37 -0700387struct weston_data_offer {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500388 struct wl_resource *resource;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700389 struct weston_data_source *source;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400390 struct wl_listener source_destroy_listener;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100391 uint32_t dnd_actions;
392 enum wl_data_device_manager_dnd_action preferred_dnd_action;
393 bool in_ask;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400394};
395
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700396struct weston_data_source {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500397 struct wl_resource *resource;
398 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400399 struct wl_array mime_types;
Carlos Garnacho78d4bf92016-01-15 21:14:23 +0100400 struct weston_data_offer *offer;
401 struct weston_seat *seat;
402 bool accepted;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100403 bool actions_set;
404 uint32_t dnd_actions;
405 enum wl_data_device_manager_dnd_action current_dnd_action;
Carlos Garnachob2889882016-01-15 21:14:26 +0100406 enum wl_data_device_manager_dnd_action compositor_action;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400407
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700408 void (*accept)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400409 uint32_t serial, const char *mime_type);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700410 void (*send)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400411 const char *mime_type, int32_t fd);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700412 void (*cancel)(struct weston_data_source *source);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400413};
414
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800415struct weston_pointer_client {
416 struct wl_list link;
417 struct wl_client *client;
418 struct wl_list pointer_resources;
Jonas Ådahl30d61d82014-10-22 21:21:17 +0200419 struct wl_list relative_pointer_resources;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800420};
421
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400422struct weston_pointer {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400423 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400424
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800425 struct wl_list pointer_clients;
426
Jason Ekstranda7af7042013-10-12 22:38:11 -0500427 struct weston_view *focus;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800428 struct weston_pointer_client *focus_client;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400429 uint32_t focus_serial;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100430 struct wl_listener focus_view_listener;
431 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400432 struct wl_signal focus_signal;
Giulio Camuffo6fcb3782013-11-14 23:42:50 +0100433 struct wl_signal motion_signal;
Jonas Ådahl3eb4ddd2016-07-22 17:52:58 +0800434 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400435
Jason Ekstranda7af7042013-10-12 22:38:11 -0500436 struct weston_view *sprite;
Kristian Høgsberg195b8692013-05-08 15:02:05 -0400437 struct wl_listener sprite_destroy_listener;
438 int32_t hotspot_x, hotspot_y;
439
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400440 struct weston_pointer_grab *grab;
441 struct weston_pointer_grab default_grab;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400442 wl_fixed_t grab_x, grab_y;
443 uint32_t grab_button;
444 uint32_t grab_serial;
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200445 struct timespec grab_time;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400446
447 wl_fixed_t x, y;
Kristian Høgsbergdb1fccb2014-02-05 17:14:42 -0800448 wl_fixed_t sx, sy;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400449 uint32_t button_count;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +0200450
451 struct wl_listener output_destroy_listener;
Alexandros Frantzisdb907b72018-02-20 14:06:26 +0200452
453 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400454};
455
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400456
Kristian Høgsberge329f362013-05-06 22:19:57 -0400457struct weston_touch {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400458 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400459
460 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100461 struct wl_list focus_resource_list;
Jason Ekstranda7af7042013-10-12 22:38:11 -0500462 struct weston_view *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100463 struct wl_listener focus_view_listener;
464 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400465 uint32_t focus_serial;
466 struct wl_signal focus_signal;
467
Jonas Ådahl9484b692013-12-02 22:05:03 +0100468 uint32_t num_tp;
469
Kristian Høgsberge329f362013-05-06 22:19:57 -0400470 struct weston_touch_grab *grab;
471 struct weston_touch_grab default_grab;
Neil Roberts306fe082013-10-03 16:43:06 +0100472 int grab_touch_id;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400473 wl_fixed_t grab_x, grab_y;
474 uint32_t grab_serial;
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200475 struct timespec grab_time;
Alexandros Frantzisd7157842018-02-20 14:07:03 +0200476
477 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400478};
479
Jonas Ådahld2510102014-10-05 21:39:14 +0200480void
481weston_pointer_motion_to_abs(struct weston_pointer *pointer,
482 struct weston_pointer_motion_event *event,
483 wl_fixed_t *x, wl_fixed_t *y);
484
Kristian Høgsberga4036bb2013-05-07 23:52:07 -0400485struct weston_pointer *
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100486weston_pointer_create(struct weston_seat *seat);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400487void
Kristian Høgsberga4036bb2013-05-07 23:52:07 -0400488weston_pointer_destroy(struct weston_pointer *pointer);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400489void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200490weston_pointer_send_motion(struct weston_pointer *pointer,
491 const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200492 struct weston_pointer_motion_event *event);
493bool
494weston_pointer_has_focus_resource(struct weston_pointer *pointer);
495void
496weston_pointer_send_button(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200497 const struct timespec *time,
498 uint32_t button, uint32_t state_w);
Quentin Glidiccde13452016-08-12 10:41:32 +0200499void
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200500weston_pointer_send_axis(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200501 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000502 struct weston_pointer_axis_event *event);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200503void
Peter Hutterer87743e92016-01-18 16:38:22 +1000504weston_pointer_send_axis_source(struct weston_pointer *pointer,
505 uint32_t source);
506void
507weston_pointer_send_frame(struct weston_pointer *pointer);
508
509void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400510weston_pointer_set_focus(struct weston_pointer *pointer,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500511 struct weston_view *view,
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400512 wl_fixed_t sx, wl_fixed_t sy);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400513void
Derek Foremanf9318d12015-05-11 15:40:11 -0500514weston_pointer_clear_focus(struct weston_pointer *pointer);
515void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400516weston_pointer_start_grab(struct weston_pointer *pointer,
517 struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400518void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400519weston_pointer_end_grab(struct weston_pointer *pointer);
Rob Bradford806d8c02013-06-25 18:56:41 +0100520void
521weston_pointer_clamp(struct weston_pointer *pointer,
522 wl_fixed_t *fx, wl_fixed_t *fy);
Giulio Camuffo1959ab82013-11-14 23:42:52 +0100523void
524weston_pointer_move(struct weston_pointer *pointer,
Jonas Ådahld2510102014-10-05 21:39:14 +0200525 struct weston_pointer_motion_event *event);
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100526void
527weston_pointer_set_default_grab(struct weston_pointer *pointer,
528 const struct weston_pointer_grab_interface *interface);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400529
Jonas Ådahld3414f22016-07-22 17:56:31 +0800530void
531weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
532
Kristian Høgsberga4036bb2013-05-07 23:52:07 -0400533struct weston_keyboard *
534weston_keyboard_create(void);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400535void
Kristian Høgsberga4036bb2013-05-07 23:52:07 -0400536weston_keyboard_destroy(struct weston_keyboard *keyboard);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400537void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400538weston_keyboard_set_focus(struct weston_keyboard *keyboard,
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400539 struct weston_surface *surface);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400540void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400541weston_keyboard_start_grab(struct weston_keyboard *device,
542 struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400543void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400544weston_keyboard_end_grab(struct weston_keyboard *keyboard);
Giulio Camuffo6ef444d2014-08-28 19:44:09 +0300545int
546/*
547 * 'mask' and 'value' should be a bitwise mask of one or more
548 * valued of the weston_keyboard_locks enum.
549 */
550weston_keyboard_set_locks(struct weston_keyboard *keyboard,
551 uint32_t mask, uint32_t value);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400552
Quentin Glidiccde13452016-08-12 10:41:32 +0200553bool
554weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
555void
556weston_keyboard_send_key(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200557 const struct timespec *time, uint32_t key,
Quentin Glidiccde13452016-08-12 10:41:32 +0200558 enum wl_keyboard_key_state state);
559void
560weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
561 uint32_t serial, uint32_t mods_depressed,
562 uint32_t mods_latched,
563 uint32_t mods_locked, uint32_t group);
564
Kristian Høgsberga4036bb2013-05-07 23:52:07 -0400565struct weston_touch *
566weston_touch_create(void);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400567void
Kristian Høgsberga4036bb2013-05-07 23:52:07 -0400568weston_touch_destroy(struct weston_touch *touch);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400569void
Derek Foreman4c93c082015-04-30 16:45:41 -0500570weston_touch_set_focus(struct weston_touch *touch,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500571 struct weston_view *view);
Michael Fua2bb7912013-07-23 15:51:06 +0800572void
Kristian Høgsberge329f362013-05-06 22:19:57 -0400573weston_touch_start_grab(struct weston_touch *device,
574 struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400575void
Kristian Høgsberge329f362013-05-06 22:19:57 -0400576weston_touch_end_grab(struct weston_touch *touch);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400577
Quentin Glidiccde13452016-08-12 10:41:32 +0200578bool
579weston_touch_has_focus_resource(struct weston_touch *touch);
580void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200581weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200582 int touch_id, wl_fixed_t x, wl_fixed_t y);
583void
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200584weston_touch_send_up(struct weston_touch *touch, const struct timespec *time,
585 int touch_id);
Quentin Glidiccde13452016-08-12 10:41:32 +0200586void
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200587weston_touch_send_motion(struct weston_touch *touch,
588 const struct timespec *time, int touch_id,
589 wl_fixed_t x, wl_fixed_t y);
Quentin Glidiccde13452016-08-12 10:41:32 +0200590void
591weston_touch_send_frame(struct weston_touch *touch);
592
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400593void
Kristian Høgsberge3148752013-05-06 23:19:49 -0400594wl_data_device_set_keyboard_focus(struct weston_seat *seat);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400595
596int
597wl_data_device_manager_init(struct wl_display *display);
598
599
600void
Kristian Høgsberge3148752013-05-06 23:19:49 -0400601weston_seat_set_selection(struct weston_seat *seat,
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700602 struct weston_data_source *source, uint32_t serial);
Giulio Camuffodddf9e62015-05-01 12:59:35 +0300603void
604weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
605
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700606int
Xiong Zhangfd51e7b2013-11-25 18:42:49 +0800607weston_pointer_start_drag(struct weston_pointer *pointer,
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700608 struct weston_data_source *source,
609 struct weston_surface *icon,
610 struct wl_client *client);
Xiong Zhangfd51e7b2013-11-25 18:42:49 +0800611int
612weston_touch_start_drag(struct weston_touch *touch,
613 struct weston_data_source *source,
614 struct weston_surface *icon,
615 struct wl_client *client);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400616
Daniel Stoned65b9092012-05-30 16:32:05 +0100617struct weston_xkb_info {
618 struct xkb_keymap *keymap;
Daniel Stoneb7452fe2012-06-01 12:14:06 +0100619 int keymap_fd;
620 size_t keymap_size;
621 char *keymap_area;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +0000622 int32_t ref_count;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100623 xkb_mod_index_t shift_mod;
624 xkb_mod_index_t caps_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100625 xkb_mod_index_t ctrl_mod;
626 xkb_mod_index_t alt_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100627 xkb_mod_index_t mod2_mod;
628 xkb_mod_index_t mod3_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100629 xkb_mod_index_t super_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100630 xkb_mod_index_t mod5_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100631 xkb_led_index_t num_led;
632 xkb_led_index_t caps_led;
633 xkb_led_index_t scroll_led;
634};
635
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100636struct weston_keyboard {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400637 struct weston_seat *seat;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100638
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400639 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100640 struct wl_list focus_resource_list;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400641 struct weston_surface *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100642 struct wl_listener focus_resource_listener;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400643 uint32_t focus_serial;
644 struct wl_signal focus_signal;
645
646 struct weston_keyboard_grab *grab;
647 struct weston_keyboard_grab default_grab;
648 uint32_t grab_key;
649 uint32_t grab_serial;
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200650 struct timespec grab_time;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400651
652 struct wl_array keys;
653
654 struct {
655 uint32_t mods_depressed;
656 uint32_t mods_latched;
657 uint32_t mods_locked;
658 uint32_t group;
659 } modifiers;
660
661 struct weston_keyboard_grab input_method_grab;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100662 struct wl_resource *input_method_resource;
Jonas Ådahl7395ea02013-12-03 09:14:26 +0100663
664 struct weston_xkb_info *xkb_info;
665 struct {
666 struct xkb_state *state;
667 enum weston_led leds;
668 } xkb_state;
669 struct xkb_keymap *pending_keymap;
Alexandros Frantzis2b442482018-02-20 14:05:50 +0200670
671 struct wl_list timestamps_list;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100672};
673
Daniel Stone37816df2012-05-16 18:45:18 +0100674struct weston_seat {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400675 struct wl_list base_resource_list;
676
Kristian Høgsbergaaadc772013-07-08 16:20:31 -0400677 struct wl_global *global;
Derek Foreman1281a362015-07-31 16:55:32 -0500678 struct weston_pointer *pointer_state;
679 struct weston_keyboard *keyboard_state;
680 struct weston_touch *touch_state;
Jonas Ådahld6e1c342013-10-17 23:04:05 +0200681 int pointer_device_count;
682 int keyboard_device_count;
683 int touch_device_count;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400684
Rob Bradford66bd9f52013-06-25 18:56:42 +0100685 struct weston_output *output; /* constraint */
686
Giulio Camuffo5085a752013-03-25 21:42:45 +0100687 struct wl_signal destroy_signal;
Jason Ekstranda4ab5422014-04-02 19:53:45 -0500688 struct wl_signal updated_caps_signal;
Daniel Stone74419a22012-05-30 16:32:02 +0100689
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500690 struct weston_compositor *compositor;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500691 struct wl_list link;
Daniel Stone496ca172012-05-30 16:31:42 +0100692 enum weston_keyboard_modifier modifier_state;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400693 struct weston_surface *saved_kbd_focus;
Ander Conselvan de Oliveira71b1d0c2012-03-16 17:25:11 +0200694 struct wl_listener saved_kbd_focus_listener;
Kristian Høgsberg054c50a2013-05-08 15:27:47 -0400695 struct wl_list drag_resource_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500696
Kristian Høgsberge3148752013-05-06 23:19:49 -0400697 uint32_t selection_serial;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700698 struct weston_data_source *selection_data_source;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400699 struct wl_listener selection_data_source_listener;
700 struct wl_signal selection_signal;
701
Daniel Stone8c8164f2012-05-30 16:31:45 +0100702 void (*led_update)(struct weston_seat *ws, enum weston_led leds);
703
Jan Arne Petersene829adc2012-08-10 16:47:22 +0200704 struct input_method *input_method;
Rob Bradford9af5f9e2013-05-31 18:09:50 +0100705 char *seat_name;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500706};
707
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500708enum {
Bryce Harringtonc2be8572015-12-11 13:11:37 -0800709 WESTON_COMPOSITOR_ACTIVE, /* normal rendering and events */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500710 WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */
Philipp Brüschweiler57edf7f2013-03-29 13:01:56 +0100711 WESTON_COMPOSITOR_OFFSCREEN, /* no rendering, no frame events */
Bryce Harrington873a3f82016-08-30 12:05:01 -0700712 WESTON_COMPOSITOR_SLEEPING /* same as offscreen, but also set dpms
713 * to off */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500714};
715
Giulio Camuffo412e6a52014-07-09 22:12:56 +0300716struct weston_layer_entry {
717 struct wl_list link;
718 struct weston_layer *layer;
719};
720
Quentin Glidic82681572016-12-17 13:40:51 +0100721/**
722 * Higher value means higher in the stack.
723 *
724 * These values are based on well-known concepts in a classic desktop
725 * environment. Third-party modules based on libweston are encouraged to use
726 * them to integrate better with other projects.
727 *
728 * A fully integrated environment can use any value, based on these or not,
729 * at their discretion.
730 */
731enum weston_layer_position {
732 /*
733 * Special value to make the layer invisible and still rendered.
734 * This is used by compositors wanting e.g. minimized surfaces to still
735 * receive frame callbacks.
736 */
737 WESTON_LAYER_POSITION_HIDDEN = 0x00000000,
738
739 /*
740 * There should always be a background layer with a surface covering
741 * the visible area.
742 *
743 * If the compositor handles the background itself, it should use
744 * BACKGROUND.
745 *
746 * If the compositor supports runtime-loadable modules to set the
747 * background, it should put a solid color surface at (BACKGROUND - 1)
748 * and modules must use BACKGROUND.
749 */
750 WESTON_LAYER_POSITION_BACKGROUND = 0x00000002,
751
752 /* For "desktop widgets" and applications like conky. */
753 WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000,
754
755 /* For regular applications, only one layer should have this value
756 * to ensure proper stacking control. */
757 WESTON_LAYER_POSITION_NORMAL = 0x50000000,
758
759 /* For desktop UI, like panels. */
760 WESTON_LAYER_POSITION_UI = 0x80000000,
761
762 /* For fullscreen applications that should cover UI. */
763 WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000,
764
765 /* For special UI like on-screen keyboard that fullscreen applications
766 * will need. */
767 WESTON_LAYER_POSITION_TOP_UI = 0xe0000000,
768
769 /* For the lock surface. */
770 WESTON_LAYER_POSITION_LOCK = 0xffff0000,
771
772 /* Values reserved for libweston internal usage */
773 WESTON_LAYER_POSITION_CURSOR = 0xfffffffe,
774 WESTON_LAYER_POSITION_FADE = 0xffffffff,
775};
776
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500777struct weston_layer {
Quentin Glidic82681572016-12-17 13:40:51 +0100778 struct weston_compositor *compositor;
779 struct wl_list link; /* weston_compositor::layer_list */
780 enum weston_layer_position position;
Giulio Camuffo95ec0f92014-07-09 22:12:57 +0300781 pixman_box32_t mask;
Quentin Glidic82681572016-12-17 13:40:51 +0100782 struct weston_layer_entry view_list;
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500783};
784
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400785struct weston_plane {
Xiong Zhang97116532013-10-23 13:58:31 +0800786 struct weston_compositor *compositor;
Pekka Paalanen502f5e02015-02-23 14:08:25 +0200787 pixman_region32_t damage; /**< in global coords */
Ander Conselvan de Oliveirae1bd5a02013-03-05 17:30:29 +0200788 pixman_region32_t clip;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400789 int32_t x, y;
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +0200790 struct wl_list link;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400791};
792
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400793struct weston_renderer {
John Kåre Alsakera95b2d62012-11-13 19:10:21 +0100794 int (*read_pixels)(struct weston_output *output,
795 pixman_format_code_t format, void *pixels,
796 uint32_t x, uint32_t y,
797 uint32_t width, uint32_t height);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400798 void (*repaint_output)(struct weston_output *output,
799 pixman_region32_t *output_damage);
800 void (*flush_damage)(struct weston_surface *surface);
Jason Ekstrand6bd62942013-06-20 20:38:23 -0500801 void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
John Kåre Alsaker878f4492012-11-13 19:10:23 +0100802 void (*surface_set_color)(struct weston_surface *surface,
803 float red, float green,
804 float blue, float alpha);
Vasily Khoruzhick52cfd612013-01-08 19:09:01 +0300805 void (*destroy)(struct weston_compositor *ec);
Pekka Paalanenc647ed72015-02-09 13:16:57 +0200806
807
808 /** See weston_surface_get_content_size() */
809 void (*surface_get_content_size)(struct weston_surface *surface,
810 int *width, int *height);
811
812 /** See weston_surface_copy_content() */
813 int (*surface_copy_content)(struct weston_surface *surface,
814 void *target, size_t size,
815 int src_x, int src_y,
816 int width, int height);
Pekka Paalanen230f3b12014-09-29 14:18:40 -0400817
818 /** See weston_compositor_import_dmabuf() */
819 bool (*import_dmabuf)(struct weston_compositor *ec,
820 struct linux_dmabuf_buffer *buffer);
Varad Gautam0775cd12016-11-23 14:03:20 +0530821
Emil Velikovfbf165f2017-12-05 14:26:16 +0000822 /** On error sets num_formats to zero */
823 void (*query_dmabuf_formats)(struct weston_compositor *ec,
Varad Gautam0775cd12016-11-23 14:03:20 +0530824 int **formats, int *num_formats);
825
Emil Velikovfbf165f2017-12-05 14:26:16 +0000826 /** On error sets num_modifiers to zero */
827 void (*query_dmabuf_modifiers)(struct weston_compositor *ec,
Varad Gautam0775cd12016-11-23 14:03:20 +0530828 int format, uint64_t **modifiers,
829 int *num_modifiers);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400830};
831
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300832enum weston_capability {
833 /* backend/renderer supports arbitrary rotation */
834 WESTON_CAP_ROTATION_ANY = 0x0001,
Pekka Paalanen4fc5dd02013-05-22 18:03:05 +0300835
836 /* screencaptures need to be y-flipped */
837 WESTON_CAP_CAPTURE_YFLIP = 0x0002,
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500838
Bryce Harringtona86c3ee2015-03-18 18:42:00 -0700839 /* backend/renderer has a separate cursor plane */
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500840 WESTON_CAP_CURSOR_PLANE = 0x0004,
841
842 /* backend supports setting arbitrary resolutions */
843 WESTON_CAP_ARBITRARY_MODES = 0x0008,
Pekka Paalanen380adf52015-02-16 14:39:11 +0200844
845 /* renderer supports weston_view_set_mask() clipping */
846 WESTON_CAP_VIEW_CLIP_MASK = 0x0010,
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300847};
848
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300849/* Configuration struct for a backend.
850 *
851 * This struct carries the configuration for a backend, and it's
852 * passed to the backend's init entry point. The backend will
853 * likely want to subclass this in order to handle backend specific
854 * data.
Bryce Harrington20b66c32016-04-15 20:28:29 -0700855 *
856 * NOTE: Alternate designs were proposed (Feb 2016) for using opaque
857 * structures[1] and for section+key/value getter/setters[2]. The rationale
858 * for selecting the transparent structure design is based on several
859 * assumptions[3] which may require re-evaluating the design choice if they
860 * fail to hold.
861 *
862 * 1: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html
863 * 2: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html
864 * 3: https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300865 */
866struct weston_backend_config {
Bryce Harrington20b66c32016-04-15 20:28:29 -0700867 /** Major version for the backend-specific config struct
868 *
869 * This version must match exactly what the backend expects, otherwise
870 * the struct is incompatible.
871 */
872 uint32_t struct_version;
873
874 /** Minor version of the backend-specific config struct
875 *
876 * This must be set to sizeof(struct backend-specific config).
877 * If the value here is smaller than what the backend expects, the
878 * extra config members will assume their default values.
879 *
880 * A value greater than what the backend expects is incompatible.
881 */
882 size_t struct_size;
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300883};
884
Giulio Camuffo954f1832014-10-11 18:27:30 +0300885struct weston_backend {
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300886 void (*destroy)(struct weston_compositor *compositor);
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000887
888 /** Begin a repaint sequence
889 *
890 * Provides the backend with explicit markers around repaint
891 * sequences, which may allow the backend to aggregate state
892 * application. This call will be bracketed by the repaint_flush (on
893 * success), or repaint_cancel (when any output in the grouping fails
894 * repaint).
895 *
896 * Returns an opaque pointer, which the backend may use as private
897 * data referring to the repaint cycle.
898 */
899 void * (*repaint_begin)(struct weston_compositor *compositor);
900
901 /** Cancel a repaint sequence
902 *
903 * Cancels a repaint sequence, when an error has occurred during
904 * one output's repaint; see repaint_begin.
905 *
906 * @param repaint_data Data returned by repaint_begin
907 */
908 void (*repaint_cancel)(struct weston_compositor *compositor,
909 void *repaint_data);
910
911 /** Conclude a repaint sequence
912 *
913 * Called on successful completion of a repaint sequence; see
914 * repaint_begin.
915 *
916 * @param repaint_data Data returned by repaint_begin
917 */
918 void (*repaint_flush)(struct weston_compositor *compositor,
919 void *repaint_data);
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300920
921 /** Allocate a new output
922 *
923 * @param compositor The compositor.
924 * @param name Name for the new output.
925 *
926 * Allocates a new output structure that embeds a weston_output,
927 * initializes it, and returns the pointer to the weston_output
928 * member.
929 *
930 * Must set weston_output members @c destroy, @c enable and @c disable.
931 */
932 struct weston_output *
933 (*create_output)(struct weston_compositor *compositor,
934 const char *name);
Giulio Camuffo954f1832014-10-11 18:27:30 +0300935};
936
Quentin Glidic955cec02016-08-12 10:41:35 +0200937struct weston_desktop_xwayland;
938struct weston_desktop_xwayland_interface;
939
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500940struct weston_compositor {
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -0400941 struct wl_signal destroy_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500942
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500943 struct wl_display *wl_display;
Quentin Glidic955cec02016-08-12 10:41:35 +0200944 struct weston_desktop_xwayland *xwayland;
945 const struct weston_desktop_xwayland_interface *xwayland_interface;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500946
Tiago Vignattifb2adba2013-06-12 15:43:21 -0300947 /* surface signals */
Kristian Høgsbergf03a04a2014-04-06 22:04:50 -0700948 struct wl_signal create_surface_signal;
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -0400949 struct wl_signal activate_signal;
Tiago Vignattifb2adba2013-06-12 15:43:21 -0300950 struct wl_signal transform_signal;
951
Tiago Vignatti1d01b012012-09-27 17:48:36 +0300952 struct wl_signal kill_signal;
Ander Conselvan de Oliveiraa4575632013-02-21 18:35:23 +0200953 struct wl_signal idle_signal;
954 struct wl_signal wake_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500955
Jan Arne Petersen42feced2012-06-21 21:52:17 +0200956 struct wl_signal show_input_panel_signal;
957 struct wl_signal hide_input_panel_signal;
Jan Arne Petersen14da96b2013-04-18 16:47:28 +0200958 struct wl_signal update_input_panel_signal;
Jan Arne Petersen42feced2012-06-21 21:52:17 +0200959
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +0100960 struct wl_signal seat_created_signal;
Richard Hughes59d5da72013-05-01 21:52:11 +0100961 struct wl_signal output_created_signal;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +0200962 struct wl_signal output_destroyed_signal;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200963 struct wl_signal output_moved_signal;
David Fort0de859e2016-05-27 23:22:57 +0200964 struct wl_signal output_resized_signal; /* callback argument: resized output */
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +0100965
Kristian Høgsberg61741a22013-09-17 16:02:57 -0700966 struct wl_signal session_signal;
967 int session_active;
968
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500969 struct weston_layer fade_layer;
970 struct weston_layer cursor_layer;
971
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200972 struct wl_list pending_output_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500973 struct wl_list output_list;
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300974 struct wl_list head_list; /* struct weston_head::compositor_link */
Daniel Stone37816df2012-05-16 18:45:18 +0100975 struct wl_list seat_list;
Quentin Glidic82681572016-12-17 13:40:51 +0100976 struct wl_list layer_list; /* struct weston_layer::link */
Pekka Paalanen20c7e552016-03-30 14:08:24 +0300977 struct wl_list view_list; /* struct weston_view::link */
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +0200978 struct wl_list plane_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +0100979 struct wl_list key_binding_list;
Daniel Stone96d47c02013-11-19 11:37:12 +0100980 struct wl_list modifier_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +0100981 struct wl_list button_binding_list;
Neil Robertsa28c6932013-10-03 16:43:04 +0100982 struct wl_list touch_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +0100983 struct wl_list axis_binding_list;
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +0200984 struct wl_list debug_binding_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500985
986 uint32_t state;
987 struct wl_event_source *idle_source;
988 uint32_t idle_inhibit;
Philipp Brüschweiler4b409c32013-03-10 14:37:04 +0100989 int idle_time; /* timeout, s */
Daniel Stone6847b852017-03-01 11:34:08 +0000990 struct wl_event_source *repaint_timer;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500991
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100992 const struct weston_pointer_grab_interface *default_pointer_grab;
993
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500994 /* Repaint state. */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400995 struct weston_plane primary_plane;
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300996 uint32_t capabilities; /* combination of enum weston_capability */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500997
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400998 struct weston_renderer *renderer;
999
John Kåre Alsakerf9e710b2012-11-13 19:10:22 +01001000 pixman_format_code_t read_format;
Pekka Paalanen52bfbaa2012-04-11 16:19:37 +03001001
Giulio Camuffo954f1832014-10-11 18:27:30 +03001002 struct weston_backend *backend;
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001003
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -07001004 struct weston_launcher *launcher;
Casey Dahlin58ba1372012-04-19 22:50:08 -04001005
Pekka Paalanen827b5d22016-06-29 11:54:26 +02001006 struct wl_list plugin_api_list; /* struct weston_plugin_api::link */
1007
Casey Dahlin58ba1372012-04-19 22:50:08 -04001008 uint32_t output_id_pool;
Daniel Stone855028f2012-05-01 20:37:10 +01001009
Daniel Stonee379da92012-05-30 16:32:04 +01001010 struct xkb_rule_names xkb_names;
1011 struct xkb_context *xkb_context;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +00001012 struct weston_xkb_info *xkb_info;
Matt Roper01a92732013-06-24 16:52:44 +01001013
Jonny Lamb66a41a02014-08-12 14:58:25 +02001014 int32_t kb_repeat_rate;
1015 int32_t kb_repeat_delay;
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001016
Bob Ham91880f12016-01-12 10:21:47 +00001017 bool vt_switching;
1018
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001019 clockid_t presentation_clock;
Pekka Paalanen0513a952014-05-21 16:17:27 +03001020 int32_t repaint_msec;
Frederic Plourdec336f062014-10-29 14:44:33 -04001021
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001022 unsigned int activate_serial;
1023
Jonas Ådahld3414f22016-07-22 17:56:31 +08001024 struct wl_global *pointer_constraints;
1025
Frederic Plourdec336f062014-10-29 14:44:33 -04001026 int exit_code;
Giulio Camuffo459137b2014-10-11 23:56:24 +03001027
1028 void *user_data;
1029 void (*exit)(struct weston_compositor *c);
Daniel Díaz75b71972016-10-21 14:03:13 -05001030
1031 /* Whether to let the compositor run without any input device. */
1032 bool require_input;
1033
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03001034 struct wl_signal heads_changed_signal;
1035 struct wl_event_source *heads_changed_source;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001036};
1037
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001038struct weston_buffer {
1039 struct wl_resource *resource;
1040 struct wl_signal destroy_signal;
1041 struct wl_listener destroy_listener;
1042
1043 union {
1044 struct wl_shm_buffer *shm_buffer;
Jason Ekstranda85118c2013-06-27 20:17:02 -05001045 void *legacy_buffer;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001046 };
1047 int32_t width, height;
1048 uint32_t busy_count;
Stanislav Vorobiovbfbb8e52013-08-29 11:36:44 +04001049 int y_inverted;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001050};
1051
Pekka Paalanende685b82012-12-04 15:58:12 +02001052struct weston_buffer_reference {
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001053 struct weston_buffer *buffer;
Pekka Paalanende685b82012-12-04 15:58:12 +02001054 struct wl_listener destroy_listener;
1055};
1056
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001057struct weston_buffer_viewport {
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001058 struct {
1059 /* wl_surface.set_buffer_transform */
1060 uint32_t transform;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001061
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001062 /* wl_surface.set_scaling_factor */
1063 int32_t scale;
Jonny Lamb74130762013-11-26 18:19:46 +01001064
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001065 /*
1066 * If src_width != wl_fixed_from_int(-1),
1067 * then and only then src_* are used.
1068 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001069 wl_fixed_t src_x, src_y;
1070 wl_fixed_t src_width, src_height;
1071 } buffer;
1072
1073 struct {
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001074 /*
1075 * If width == -1, the size is inferred from the buffer.
1076 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001077 int32_t width, height;
1078 } surface;
George Kiagiadakis8f9e87f2014-06-13 18:14:20 +02001079
1080 int changed;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001081};
1082
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001083struct weston_region {
Jason Ekstrand8895efc2013-06-14 10:07:56 -05001084 struct wl_resource *resource;
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001085 pixman_region32_t region;
1086};
1087
Jason Ekstranda7af7042013-10-12 22:38:11 -05001088/* Using weston_view transformations
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001089 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001090 * To add a transformation to a view, create a struct weston_transform, and
1091 * add it to the list view->geometry.transformation_list. Whenever you
1092 * change the list, anything under view->geometry, or anything in the
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001093 * weston_transforms linked into the list, you must call
Jason Ekstranda7af7042013-10-12 22:38:11 -05001094 * weston_view_geometry_dirty().
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001095 *
1096 * The order in the list defines the order of transformations. Let the list
1097 * contain the transformation matrices M1, ..., Mn as head to tail. The
Jason Ekstranda7af7042013-10-12 22:38:11 -05001098 * transformation is applied to view-local coordinate vector p as
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001099 * P = Mn * ... * M2 * M1 * p
1100 * to produce the global coordinate vector P. The total transform
1101 * Mn * ... * M2 * M1
Jason Ekstranda7af7042013-10-12 22:38:11 -05001102 * is cached in view->transform.matrix, and the inverse of it in
1103 * view->transform.inverse.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001104 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001105 * The list always contains view->transform.position transformation, which
1106 * is the translation by view->geometry.x and y.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001107 *
1108 * If you want to apply a transformation in local coordinates, add your
1109 * weston_transform to the head of the list. If you want to apply a
1110 * transformation in global coordinates, add it to the tail of the list.
Pekka Paalanen483243f2013-03-08 14:56:50 +02001111 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001112 * If view->geometry.parent is set, the total transformation of this
1113 * view will be the parent's total transformation and this transformation
Pekka Paalanen483243f2013-03-08 14:56:50 +02001114 * combined:
1115 * Mparent * Mn * ... * M2 * M1
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001116 */
1117
Jason Ekstranda7af7042013-10-12 22:38:11 -05001118struct weston_view {
1119 struct weston_surface *surface;
1120 struct wl_list surface_link;
Jason Ekstrand26ed73c2013-06-06 22:34:41 -05001121 struct wl_signal destroy_signal;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001122
Pekka Paalanen20c7e552016-03-30 14:08:24 +03001123 struct wl_list link; /* weston_compositor::view_list */
Pekka Paalanen8844bf22015-02-18 16:30:47 +02001124 struct weston_layer_entry layer_link; /* part of geometry */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001125 struct weston_plane *plane;
Pekka Paalanen2d6e5512015-02-18 16:06:46 +02001126
1127 /* For weston_layer inheritance from another view */
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001128 struct weston_view *parent_view;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001129
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001130 unsigned int click_to_activate_serial;
1131
Pekka Paalanen51723d52015-02-17 13:10:01 +02001132 pixman_region32_t clip; /* See weston_view_damage_below() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001133 float alpha; /* part of geometry, see below */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001134
John Kåre Alsaker878f4492012-11-13 19:10:23 +01001135 void *renderer_state;
1136
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001137 /* Surface geometry state, mutable.
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001138 * If you change anything, call weston_surface_geometry_dirty().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001139 * That includes the transformations referenced from the list.
1140 */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001141 struct {
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001142 float x, y; /* surface translation on display */
Pekka Paalanenba3cf952012-01-25 16:22:05 +02001143
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001144 /* struct weston_transform */
1145 struct wl_list transformation_list;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001146
1147 /* managed by weston_surface_set_transform_parent() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001148 struct weston_view *parent;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001149 struct wl_listener parent_destroy_listener;
1150 struct wl_list child_list; /* geometry.parent_link */
1151 struct wl_list parent_link;
Pekka Paalanen380adf52015-02-16 14:39:11 +02001152
1153 /* managed by weston_view_set_mask() */
1154 bool scissor_enabled;
1155 pixman_region32_t scissor; /* always a simple rect */
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001156 } geometry;
1157
1158 /* State derived from geometry state, read-only.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001159 * This is updated by weston_view_update_transform().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001160 */
1161 struct {
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001162 int dirty;
1163
Pekka Paalanenfbd00f12015-02-19 11:49:18 +02001164 /* Approximations in global coordinates:
1165 * - boundingbox is guaranteed to include the whole view in
1166 * the smallest possible single rectangle.
1167 * - opaque is guaranteed to be fully opaque, though not
1168 * necessarily include all opaque areas.
1169 */
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001170 pixman_region32_t boundingbox;
Pekka Paalanen730d87e2012-02-09 16:39:38 +02001171 pixman_region32_t opaque;
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001172
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001173 /* matrix and inverse are used only if enabled = 1.
1174 * If enabled = 0, use x, y, width, height directly.
1175 */
1176 int enabled;
Pekka Paalanen061b7472012-01-12 15:00:57 +02001177 struct weston_matrix matrix;
Pekka Paalanend1f0ab62012-01-20 10:47:57 +02001178 struct weston_matrix inverse;
Pekka Paalanencd403622012-01-25 13:37:39 +02001179
1180 struct weston_transform position; /* matrix from x, y */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001181 } transform;
1182
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001183 /*
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001184 * The primary output for this view.
1185 * Used for picking the output for driving internal animations on the
1186 * view, inheriting the primary output for related views in shells, etc.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001187 */
1188 struct weston_output *output;
1189
Casey Dahlin9074db52012-04-19 22:50:09 -04001190 /*
1191 * A more complete representation of all outputs this surface is
1192 * displayed on.
1193 */
1194 uint32_t output_mask;
Pekka Paalanenbf0e0312014-12-17 16:20:41 +02001195
1196 /* Per-surface Presentation feedback flags, controlled by backend. */
1197 uint32_t psf_flags;
Armin Krezovićf8486c32016-06-30 06:04:28 +02001198
1199 bool is_mapped;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001200};
1201
Jason Ekstrand7b982072014-05-20 14:33:03 -05001202struct weston_surface_state {
1203 /* wl_surface.attach */
1204 int newly_attached;
1205 struct weston_buffer *buffer;
1206 struct wl_listener buffer_destroy_listener;
1207 int32_t sx;
1208 int32_t sy;
1209
1210 /* wl_surface.damage */
Derek Foreman152254b2015-11-26 14:17:48 -06001211 pixman_region32_t damage_surface;
1212 /* wl_surface.damage_buffer */
1213 pixman_region32_t damage_buffer;
Jason Ekstrand7b982072014-05-20 14:33:03 -05001214
1215 /* wl_surface.set_opaque_region */
1216 pixman_region32_t opaque;
1217
1218 /* wl_surface.set_input_region */
1219 pixman_region32_t input;
1220
1221 /* wl_surface.frame */
1222 struct wl_list frame_callback_list;
1223
Pekka Paalanen133e4392014-09-23 22:08:46 -04001224 /* presentation.feedback */
1225 struct wl_list feedback_list;
1226
Jason Ekstrand7b982072014-05-20 14:33:03 -05001227 /* wl_surface.set_buffer_transform */
1228 /* wl_surface.set_scaling_factor */
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001229 /* wp_viewport.set_source */
1230 /* wp_viewport.set_destination */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001231 struct weston_buffer_viewport buffer_viewport;
1232};
1233
Jonas Ådahlf7deb6a2016-07-22 17:50:26 +08001234struct weston_surface_activation_data {
1235 struct weston_surface *surface;
1236 struct weston_seat *seat;
1237};
1238
Jonas Ådahld3414f22016-07-22 17:56:31 +08001239struct weston_pointer_constraint {
1240 struct wl_list link;
1241
1242 struct weston_surface *surface;
1243 struct weston_view *view;
1244 struct wl_resource *resource;
1245 struct weston_pointer_grab grab;
1246 struct weston_pointer *pointer;
1247 uint32_t lifetime;
1248
1249 pixman_region32_t region;
1250 pixman_region32_t region_pending;
1251 bool region_is_pending;
1252
1253 wl_fixed_t hint_x;
1254 wl_fixed_t hint_y;
1255 wl_fixed_t hint_x_pending;
1256 wl_fixed_t hint_y_pending;
1257 bool hint_is_pending;
1258
1259 struct wl_listener pointer_destroy_listener;
1260 struct wl_listener surface_destroy_listener;
1261 struct wl_listener surface_commit_listener;
1262 struct wl_listener surface_activate_listener;
1263};
1264
Jason Ekstranda7af7042013-10-12 22:38:11 -05001265struct weston_surface {
1266 struct wl_resource *resource;
Pekka Paalanenca790762015-04-17 14:23:38 +03001267 struct wl_signal destroy_signal; /* callback argument: this surface */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001268 struct weston_compositor *compositor;
Jonas Ådahl5d9ca272016-07-22 17:48:03 +08001269 struct wl_signal commit_signal;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001270
1271 /** Damage in local coordinates from the client, for tex upload. */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001272 pixman_region32_t damage;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001273
Jason Ekstranda7af7042013-10-12 22:38:11 -05001274 pixman_region32_t opaque; /* part of geometry, see below */
1275 pixman_region32_t input;
1276 int32_t width, height;
1277 int32_t ref_count;
1278
1279 /* Not for long-term storage. This exists for book-keeping while
1280 * iterating over surfaces and views
1281 */
Derek Foreman060cf112015-11-18 16:32:26 -06001282 bool touched;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001283
1284 void *renderer_state;
1285
1286 struct wl_list views;
1287
1288 /*
1289 * Which output to vsync this surface to.
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001290 * Used to determine whether to send or queue frame events, and for
1291 * other client-visible syncing/throttling tied to the output
1292 * repaint cycle.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001293 */
1294 struct weston_output *output;
1295
1296 /*
1297 * A more complete representation of all outputs this surface is
1298 * displayed on.
1299 */
1300 uint32_t output_mask;
Casey Dahlin9074db52012-04-19 22:50:09 -04001301
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001302 struct wl_list frame_callback_list;
Pekka Paalanen133e4392014-09-23 22:08:46 -04001303 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001304
Pekka Paalanende685b82012-12-04 15:58:12 +02001305 struct weston_buffer_reference buffer_ref;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001306 struct weston_buffer_viewport buffer_viewport;
Pekka Paalanen0b4c5352014-03-14 14:38:17 +02001307 int32_t width_from_buffer; /* before applying viewport */
1308 int32_t height_from_buffer;
Derek Foreman0fd6d4e2014-10-10 09:36:45 -05001309 bool keep_buffer; /* for backends to prevent early release */
Alex Wu8811bf92012-02-28 18:07:54 +08001310
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001311 /* wp_viewport resource for this surface */
Pekka Paalanenb0420ae2014-01-08 15:39:17 +02001312 struct wl_resource *viewport_resource;
Jonny Lamb74130762013-11-26 18:19:46 +01001313
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001314 /* All the pending state, that wl_surface.commit will apply. */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001315 struct weston_surface_state pending;
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001316
Jason Ekstrand1e059042014-10-16 10:55:19 -05001317 /* Matrices representating of the full transformation between
1318 * buffer and surface coordinates. These matrices are updated
1319 * using the weston_surface_build_buffer_matrix function. */
1320 struct weston_matrix buffer_to_surface_matrix;
1321 struct weston_matrix surface_to_buffer_matrix;
1322
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001323 /*
Jasper St. Pierred67b52a2014-04-28 11:19:27 -04001324 * If non-NULL, this function will be called on
1325 * wl_surface::commit after a new buffer has been set up for
1326 * this surface. The integer params are the sx and sy
1327 * parameters supplied to wl_surface::attach.
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001328 */
Quentin Glidic2edc3d52016-08-12 10:41:33 +02001329 void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
1330 void *committed_private;
Pekka Paalanen8274d902014-08-06 19:36:51 +03001331 int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
Pekka Paalanene67858b2013-04-25 13:57:42 +03001332
1333 /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
1334 * Contains also the parent itself as a dummy weston_subsurface,
1335 * if the list is not empty.
1336 */
1337 struct wl_list subsurface_list; /* weston_subsurface::parent_link */
1338 struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
Pekka Paalanen50b67472014-10-01 15:02:41 +03001339
1340 /*
1341 * For tracking protocol role assignments. Different roles may
1342 * have the same configure hook, e.g. in shell.c. Configure hook
1343 * may get reset, this will not.
1344 * XXX: map configure functions 1:1 to roles, and never reset it,
1345 * and replace role_name with configure.
1346 */
1347 const char *role_name;
Pekka Paalanenb5026542014-11-12 15:09:24 +02001348
1349 struct weston_timeline_object timeline;
Armin Krezovićf8486c32016-06-30 06:04:28 +02001350
1351 bool is_mapped;
Jonas Ådahld3414f22016-07-22 17:56:31 +08001352
1353 /* An list of per seat pointer constraints. */
1354 struct wl_list pointer_constraints;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001355};
1356
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001357struct weston_subsurface {
1358 struct wl_resource *resource;
1359
1360 /* guaranteed to be valid and non-NULL */
1361 struct weston_surface *surface;
1362 struct wl_listener surface_destroy_listener;
1363
1364 /* can be NULL */
1365 struct weston_surface *parent;
1366 struct wl_listener parent_destroy_listener;
1367 struct wl_list parent_link;
1368 struct wl_list parent_link_pending;
1369
1370 struct {
1371 int32_t x;
1372 int32_t y;
1373 int set;
1374 } position;
1375
Jason Ekstrand7b982072014-05-20 14:33:03 -05001376 int has_cached_data;
1377 struct weston_surface_state cached;
1378 struct weston_buffer_reference cached_buffer_ref;
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001379
Emilio Pozuelo Monfort4f3cad72017-01-27 17:30:29 +01001380 /* Sub-surface has been reordered; need to apply damage. */
1381 bool reordered;
1382
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001383 int synchronized;
1384
1385 /* Used for constructing the view tree */
1386 struct wl_list unused_views;
1387};
1388
Daniel Stoned6da09e2012-06-22 13:21:29 +01001389enum weston_key_state_update {
1390 STATE_UPDATE_AUTOMATIC,
1391 STATE_UPDATE_NONE,
1392};
1393
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001394enum weston_activate_flag {
1395 WESTON_ACTIVATE_FLAG_NONE = 0,
1396 WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001397 WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001398};
1399
Kristian Høgsberg9ddb8262012-01-04 21:30:29 -05001400void
Kristian Høgsbergaf4f2aa2013-02-15 20:53:20 -05001401weston_version(int *major, int *minor, int *micro);
1402
1403void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001404weston_view_update_transform(struct weston_view *view);
Pekka Paalanen460099f2012-01-20 16:48:25 +02001405
1406void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001407weston_view_geometry_dirty(struct weston_view *view);
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001408
1409void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001410weston_view_to_global_fixed(struct weston_view *view,
1411 wl_fixed_t sx, wl_fixed_t sy,
1412 wl_fixed_t *x, wl_fixed_t *y);
Daniel Stonebd3489b2012-05-08 17:17:53 +01001413void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001414weston_view_to_global_float(struct weston_view *view,
1415 float sx, float sy, float *x, float *y);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001416
1417void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001418weston_view_from_global_float(struct weston_view *view,
1419 float x, float y, float *vx, float *vy);
Kristian Høgsbergecf6ede2012-09-05 21:59:35 -04001420void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001421weston_view_from_global(struct weston_view *view,
1422 int32_t x, int32_t y, int32_t *vx, int32_t *vy);
Daniel Stonebd3489b2012-05-08 17:17:53 +01001423void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001424weston_view_from_global_fixed(struct weston_view *view,
1425 wl_fixed_t x, wl_fixed_t y,
1426 wl_fixed_t *vx, wl_fixed_t *vy);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001427
Derek Foremand1be3122014-09-18 16:46:49 -05001428void
Ander Conselvan de Oliveira0396ba22012-11-28 17:10:26 +02001429weston_surface_to_buffer_float(struct weston_surface *surface,
1430 float x, float y, float *bx, float *by);
1431pixman_box32_t
1432weston_surface_to_buffer_rect(struct weston_surface *surface,
1433 pixman_box32_t rect);
1434
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001435void
Pekka Paalanene54e31c2015-03-04 14:23:28 +02001436weston_surface_to_buffer_region(struct weston_surface *surface,
1437 pixman_region32_t *surface_region,
1438 pixman_region32_t *buffer_region);
1439
1440void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001441weston_spring_init(struct weston_spring *spring,
1442 double k, double current, double target);
1443void
Alexandros Frantzis8250a612017-11-16 18:20:52 +02001444weston_spring_update(struct weston_spring *spring, const struct timespec *time);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001445int
1446weston_spring_done(struct weston_spring *spring);
1447
1448void
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001449weston_view_activate(struct weston_view *view,
1450 struct weston_seat *seat,
1451 uint32_t flags);
1452
1453void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +02001454notify_motion(struct weston_seat *seat, const struct timespec *time,
Jonas Ådahld2510102014-10-05 21:39:14 +02001455 struct weston_pointer_motion_event *event);
Rob Bradfordc088e2c2013-03-27 15:59:43 +00001456void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +02001457notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
Giulio Camuffo90a6fc62016-03-22 17:44:54 +02001458 double x, double y);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001459void
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001460notify_button(struct weston_seat *seat, const struct timespec *time,
1461 int32_t button, enum wl_pointer_button_state state);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001462void
Alexandros Frantzis80321942017-11-16 18:20:56 +02001463notify_axis(struct weston_seat *seat, const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001464 struct weston_pointer_axis_event *event);
Scott Moreau210d0792012-03-22 10:47:01 -06001465void
Peter Hutterer87743e92016-01-18 16:38:22 +10001466notify_axis_source(struct weston_seat *seat, uint32_t source);
1467
1468void
1469notify_pointer_frame(struct weston_seat *seat);
1470
1471void
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001472notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
Daniel Stone1b4e11f2012-06-22 13:21:37 +01001473 enum wl_keyboard_key_state state,
1474 enum weston_key_state_update update_state);
Daniel Stone05d58682012-06-22 13:21:38 +01001475void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001476notify_modifiers(struct weston_seat *seat, uint32_t serial);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001477
1478void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001479notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
Giulio Camuffo90a6fc62016-03-22 17:44:54 +02001480 double x, double y);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001481
1482void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001483notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
Daniel Stoned6da09e2012-06-22 13:21:29 +01001484 enum weston_key_state_update update_state);
1485void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001486notify_keyboard_focus_out(struct weston_seat *seat);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001487
1488void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001489notify_touch(struct weston_seat *seat, const struct timespec *time,
1490 int touch_id, double x, double y, int touch_type);
Jonas Ådahl1679f232014-04-12 09:39:51 +02001491void
1492notify_touch_frame(struct weston_seat *seat);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001493
1494void
Derek Foreman3cc004a2015-11-06 15:56:09 -06001495notify_touch_cancel(struct weston_seat *seat);
1496
1497void
Giulio Camuffo412e6a52014-07-09 22:12:56 +03001498weston_layer_entry_insert(struct weston_layer_entry *list,
1499 struct weston_layer_entry *entry);
1500void
1501weston_layer_entry_remove(struct weston_layer_entry *entry);
1502void
Quentin Glidic82681572016-12-17 13:40:51 +01001503weston_layer_init(struct weston_layer *layer,
1504 struct weston_compositor *compositor);
1505void
1506weston_layer_set_position(struct weston_layer *layer,
1507 enum weston_layer_position position);
1508void
1509weston_layer_unset_position(struct weston_layer *layer);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001510
1511void
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001512weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
1513
1514void
1515weston_layer_set_mask_infinite(struct weston_layer *layer);
1516
1517void
Xiong Zhang97116532013-10-23 13:58:31 +08001518weston_plane_init(struct weston_plane *plane,
1519 struct weston_compositor *ec,
1520 int32_t x, int32_t y);
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001521void
1522weston_plane_release(struct weston_plane *plane);
1523
1524void
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001525weston_compositor_stack_plane(struct weston_compositor *ec,
1526 struct weston_plane *plane,
1527 struct weston_plane *above);
1528
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001529/* An invalid flag in presented_flags to catch logic errors. */
Pekka Paalanenb00c79b2016-02-18 16:53:27 +02001530#define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31)
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001531
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001532void
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001533weston_output_finish_frame(struct weston_output *output,
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001534 const struct timespec *stamp,
1535 uint32_t presented_flags);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001536void
Kristian Høgsberg49952d12012-06-20 00:35:59 -04001537weston_output_schedule_repaint(struct weston_output *output);
1538void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001539weston_output_damage(struct weston_output *output);
1540void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001541weston_compositor_schedule_repaint(struct weston_compositor *compositor);
1542void
1543weston_compositor_fade(struct weston_compositor *compositor, float tint);
1544void
1545weston_compositor_damage_all(struct weston_compositor *compositor);
1546void
1547weston_compositor_unlock(struct weston_compositor *compositor);
1548void
1549weston_compositor_wake(struct weston_compositor *compositor);
1550void
Philipp Brüschweiler57edf7f2013-03-29 13:01:56 +01001551weston_compositor_offscreen(struct weston_compositor *compositor);
1552void
Ander Conselvan de Oliveira87524b62013-02-21 18:35:22 +02001553weston_compositor_sleep(struct weston_compositor *compositor);
Jason Ekstranda7af7042013-10-12 22:38:11 -05001554struct weston_view *
1555weston_compositor_pick_view(struct weston_compositor *compositor,
1556 wl_fixed_t x, wl_fixed_t y,
1557 wl_fixed_t *sx, wl_fixed_t *sy);
Ander Conselvan de Oliveira30eebc72012-02-15 17:02:57 +02001558
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001559
1560struct weston_binding;
Derek Foreman8ae2db52015-07-15 13:00:36 -05001561typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001562 const struct timespec *time,
1563 uint32_t key,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001564 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001565struct weston_binding *
Daniel Stone325fc2d2012-05-30 16:31:58 +01001566weston_compositor_add_key_binding(struct weston_compositor *compositor,
1567 uint32_t key,
1568 enum weston_keyboard_modifier modifier,
1569 weston_key_binding_handler_t binding,
1570 void *data);
1571
Derek Foreman8ae2db52015-07-15 13:00:36 -05001572typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
Daniel Stone96d47c02013-11-19 11:37:12 +01001573 enum weston_keyboard_modifier modifier,
1574 void *data);
1575struct weston_binding *
1576weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
1577 enum weston_keyboard_modifier modifier,
1578 weston_modifier_binding_handler_t binding,
1579 void *data);
1580
Derek Foreman8ae2db52015-07-15 13:00:36 -05001581typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001582 const struct timespec *time,
1583 uint32_t button,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001584 void *data);
1585struct weston_binding *
1586weston_compositor_add_button_binding(struct weston_compositor *compositor,
1587 uint32_t button,
1588 enum weston_keyboard_modifier modifier,
1589 weston_button_binding_handler_t binding,
1590 void *data);
1591
Derek Foreman8ae2db52015-07-15 13:00:36 -05001592typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001593 const struct timespec *time,
Neil Robertsa28c6932013-10-03 16:43:04 +01001594 void *data);
1595struct weston_binding *
1596weston_compositor_add_touch_binding(struct weston_compositor *compositor,
1597 enum weston_keyboard_modifier modifier,
1598 weston_touch_binding_handler_t binding,
1599 void *data);
1600
Derek Foreman8ae2db52015-07-15 13:00:36 -05001601typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +02001602 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001603 struct weston_pointer_axis_event *event,
1604 void *data);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001605struct weston_binding *
1606weston_compositor_add_axis_binding(struct weston_compositor *compositor,
1607 uint32_t axis,
1608 enum weston_keyboard_modifier modifier,
1609 weston_axis_binding_handler_t binding,
1610 void *data);
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001611struct weston_binding *
1612weston_compositor_add_debug_binding(struct weston_compositor *compositor,
1613 uint32_t key,
1614 weston_key_binding_handler_t binding,
1615 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001616void
1617weston_binding_destroy(struct weston_binding *binding);
1618
1619void
Pekka Paalanen2829f7c2015-02-19 17:02:13 +02001620weston_install_debug_key_binding(struct weston_compositor *compositor,
1621 uint32_t mod);
1622
1623void
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001624weston_binding_list_destroy_all(struct wl_list *list);
1625
Pekka Paalanen86b53962014-11-19 13:43:32 +02001626void
Daniel Stone325fc2d2012-05-30 16:31:58 +01001627weston_compositor_run_key_binding(struct weston_compositor *compositor,
Derek Foreman99a6a2d2015-07-15 13:00:43 -05001628 struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001629 const struct timespec *time,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001630 uint32_t key,
1631 enum wl_keyboard_key_state state);
Daniel Stone96d47c02013-11-19 11:37:12 +01001632
1633void
1634weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
Derek Foreman99a6a2d2015-07-15 13:00:43 -05001635 struct weston_keyboard *keyboard,
Daniel Stone96d47c02013-11-19 11:37:12 +01001636 enum weston_keyboard_modifier modifier,
1637 enum wl_keyboard_key_state state);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001638void
1639weston_compositor_run_button_binding(struct weston_compositor *compositor,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001640 struct weston_pointer *pointer,
1641 const struct timespec *time,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001642 uint32_t button,
1643 enum wl_pointer_button_state value);
Neil Robertsa28c6932013-10-03 16:43:04 +01001644void
1645weston_compositor_run_touch_binding(struct weston_compositor *compositor,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001646 struct weston_touch *touch,
1647 const struct timespec *time,
Neil Robertsa28c6932013-10-03 16:43:04 +01001648 int touch_type);
Rune K. Svendsen14b2fe72013-03-07 21:50:00 +01001649int
Daniel Stone325fc2d2012-05-30 16:31:58 +01001650weston_compositor_run_axis_binding(struct weston_compositor *compositor,
Alexandros Frantzis80321942017-11-16 18:20:56 +02001651 struct weston_pointer *pointer,
1652 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001653 struct weston_pointer_axis_event *event);
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001654int
1655weston_compositor_run_debug_binding(struct weston_compositor *compositor,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001656 struct weston_keyboard *keyboard,
1657 const struct timespec *time,
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001658 uint32_t key,
1659 enum wl_keyboard_key_state state);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001660
Giulio Camuffocdb4d292013-11-14 23:42:53 +01001661void
1662weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
1663 const struct weston_pointer_grab_interface *interface);
1664
Benjamin Franzkebfeda132012-01-30 14:04:04 +01001665int
1666weston_environment_get_fd(const char *env);
1667
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001668struct weston_surface *
Kristian Høgsberg18c93002012-01-27 11:58:31 -05001669weston_surface_create(struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001670
Jason Ekstranda7af7042013-10-12 22:38:11 -05001671struct weston_view *
1672weston_view_create(struct weston_surface *surface);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001673
1674void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001675weston_view_destroy(struct weston_view *view);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001676
1677void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001678weston_view_set_position(struct weston_view *view,
1679 float x, float y);
1680
1681void
1682weston_view_set_transform_parent(struct weston_view *view,
1683 struct weston_view *parent);
1684
Pekka Paalanen380adf52015-02-16 14:39:11 +02001685void
1686weston_view_set_mask(struct weston_view *view,
1687 int x, int y, int width, int height);
1688
1689void
1690weston_view_set_mask_infinite(struct weston_view *view);
1691
Derek Foreman280e7dd2014-10-03 13:13:42 -05001692bool
Jason Ekstranda7af7042013-10-12 22:38:11 -05001693weston_view_is_mapped(struct weston_view *view);
1694
1695void
1696weston_view_schedule_repaint(struct weston_view *view);
Pekka Paalanen483243f2013-03-08 14:56:50 +02001697
Derek Foreman280e7dd2014-10-03 13:13:42 -05001698bool
Ander Conselvan de Oliveirab8ab14f2012-03-27 17:36:36 +03001699weston_surface_is_mapped(struct weston_surface *surface);
1700
Derek Foremand1be3122014-09-18 16:46:49 -05001701void
Jason Ekstrand5c11a332013-12-04 20:32:03 -06001702weston_surface_set_size(struct weston_surface *surface,
1703 int32_t width, int32_t height);
1704
Pekka Paalanen8fb8d3b2012-02-13 13:03:59 +02001705void
Kristian Høgsberg98238702012-08-03 16:29:12 -04001706weston_surface_schedule_repaint(struct weston_surface *surface);
1707
1708void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001709weston_surface_damage(struct weston_surface *surface);
1710
1711void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001712weston_view_damage_below(struct weston_view *view);
Kristian Høgsbergd8bf90c2012-02-23 23:03:14 -05001713
1714void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001715weston_view_move_to_plane(struct weston_view *view,
1716 struct weston_plane *plane);
1717void
1718weston_view_unmap(struct weston_view *view);
1719
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001720void
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001721weston_surface_unmap(struct weston_surface *surface);
1722
Pekka Paalanen01388e22013-04-25 13:57:44 +03001723struct weston_surface *
1724weston_surface_get_main_surface(struct weston_surface *surface);
1725
Pekka Paalanen50b67472014-10-01 15:02:41 +03001726int
1727weston_surface_set_role(struct weston_surface *surface,
1728 const char *role_name,
1729 struct wl_resource *error_resource,
1730 uint32_t error_code);
Quentin Glidic9c5dd7e2016-08-12 10:41:37 +02001731const char *
1732weston_surface_get_role(struct weston_surface *surface);
Pekka Paalanen50b67472014-10-01 15:02:41 +03001733
Pekka Paalanen8274d902014-08-06 19:36:51 +03001734void
1735weston_surface_set_label_func(struct weston_surface *surface,
1736 int (*desc)(struct weston_surface *,
1737 char *, size_t));
1738
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001739void
1740weston_surface_get_content_size(struct weston_surface *surface,
1741 int *width, int *height);
1742
Quentin Glidic248dd102016-08-12 10:41:34 +02001743struct weston_geometry
1744weston_surface_get_bounding_box(struct weston_surface *surface);
1745
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001746int
1747weston_surface_copy_content(struct weston_surface *surface,
1748 void *target, size_t size,
1749 int src_x, int src_y,
1750 int width, int height);
1751
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001752struct weston_buffer *
1753weston_buffer_from_resource(struct wl_resource *resource);
1754
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001755void
Pekka Paalanende685b82012-12-04 15:58:12 +02001756weston_buffer_reference(struct weston_buffer_reference *ref,
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001757 struct weston_buffer *buffer);
Pekka Paalanende685b82012-12-04 15:58:12 +02001758
Alexandros Frantzis409b01f2017-11-16 18:21:01 +02001759void
1760weston_compositor_get_time(struct timespec *time);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001761
Giulio Camuffo459137b2014-10-11 23:56:24 +03001762void
1763weston_compositor_destroy(struct weston_compositor *ec);
1764struct weston_compositor *
1765weston_compositor_create(struct wl_display *display, void *user_data);
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001766
1767enum weston_compositor_backend {
1768 WESTON_BACKEND_DRM,
1769 WESTON_BACKEND_FBDEV,
1770 WESTON_BACKEND_HEADLESS,
1771 WESTON_BACKEND_RDP,
1772 WESTON_BACKEND_WAYLAND,
1773 WESTON_BACKEND_X11,
1774};
1775
Pekka Paalanendd186732016-06-03 14:49:54 +03001776int
1777weston_compositor_load_backend(struct weston_compositor *compositor,
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001778 enum weston_compositor_backend backend,
Pekka Paalanendd186732016-06-03 14:49:54 +03001779 struct weston_backend_config *config_base);
Giulio Camuffo459137b2014-10-11 23:56:24 +03001780void
1781weston_compositor_exit(struct weston_compositor *ec);
1782void *
1783weston_compositor_get_user_data(struct weston_compositor *compositor);
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001784int
1785weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
1786 clockid_t clk_id);
1787int
1788weston_compositor_set_presentation_clock_software(
1789 struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001790void
Pekka Paalanen662f3842015-03-18 12:17:26 +02001791weston_compositor_read_presentation_clock(
1792 const struct weston_compositor *compositor,
1793 struct timespec *ts);
1794
Pekka Paalanen230f3b12014-09-29 14:18:40 -04001795bool
1796weston_compositor_import_dmabuf(struct weston_compositor *compositor,
1797 struct linux_dmabuf_buffer *buffer);
1798
Pekka Paalanen662f3842015-03-18 12:17:26 +02001799void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001800weston_compositor_shutdown(struct weston_compositor *ec);
1801void
Frederic Plourdec336f062014-10-29 14:44:33 -04001802weston_compositor_exit_with_code(struct weston_compositor *compositor,
1803 int exit_code);
1804void
Scott Moreau429490d2012-06-17 18:10:59 -06001805weston_output_init_zoom(struct weston_output *output);
1806void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001807weston_output_update_zoom(struct weston_output *output);
Scott Moreauccbf29d2012-02-22 14:21:41 -07001808void
Derek Foreman22276a52015-07-23 14:55:15 -05001809weston_output_activate_zoom(struct weston_output *output,
1810 struct weston_seat *seat);
Giulio Camuffo412b0242013-11-14 23:42:51 +01001811void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001812weston_output_move(struct weston_output *output, int x, int y);
Armin Krezović40087402016-09-30 14:11:12 +02001813
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001814void
Pekka Paalanenae6d35d2017-08-16 12:07:14 +03001815weston_output_release(struct weston_output *output);
Kristian Høgsberg98c774f2013-07-22 14:33:42 -07001816void
Jason Ekstrandb6a3cc72013-10-27 22:25:00 -05001817weston_output_transform_coordinate(struct weston_output *output,
Giulio Camuffo90a6fc62016-03-22 17:44:54 +02001818 double device_x, double device_y,
1819 double *x, double *y);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001820
1821void
Rob Bradford9af5f9e2013-05-31 18:09:50 +01001822weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
1823 const char *seat_name);
Daniel Stone74419a22012-05-30 16:32:02 +01001824void
1825weston_seat_init_pointer(struct weston_seat *seat);
Jonas Ådahld6e1c342013-10-17 23:04:05 +02001826void
1827weston_seat_release_pointer(struct weston_seat *seat);
Kristian Høgsberg2f07ef62013-02-16 14:29:24 -05001828int
Daniel Stonebb1df6a2012-05-30 16:32:06 +01001829weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
Daniel Stone74419a22012-05-30 16:32:02 +01001830void
Jonas Ådahld6e1c342013-10-17 23:04:05 +02001831weston_seat_release_keyboard(struct weston_seat *seat);
1832void
Daniel Stone74419a22012-05-30 16:32:02 +01001833weston_seat_init_touch(struct weston_seat *seat);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001834void
Jonas Ådahld6e1c342013-10-17 23:04:05 +02001835weston_seat_release_touch(struct weston_seat *seat);
1836void
Kristian Høgsberga71e8b22013-05-06 21:51:21 -04001837weston_seat_repick(struct weston_seat *seat);
Rui Matos65196bc2013-10-10 19:44:19 +02001838void
1839weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001840
1841void
Daniel Stone37816df2012-05-16 18:45:18 +01001842weston_seat_release(struct weston_seat *seat);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001843int
Giulio Camuffo0358af42016-06-02 21:48:08 +03001844weston_compositor_set_xkb_rule_names(struct weston_compositor *ec,
1845 struct xkb_rule_names *names);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001846void
1847weston_compositor_xkb_destroy(struct weston_compositor *ec);
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001848
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001849/* String literal of spaces, the same width as the timestamp. */
1850#define STAMP_SPACE " "
1851
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001852typedef int (*log_func_t)(const char *fmt, va_list ap);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001853void
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001854weston_log_set_handler(log_func_t log, log_func_t cont);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001855int
Kristian Høgsberg082d58c2013-06-18 01:00:27 -04001856weston_vlog(const char *fmt, va_list ap);
1857int
1858weston_vlog_continue(const char *fmt, va_list ap);
1859int
Pekka Paalanend525b562012-08-06 14:57:04 +03001860weston_log(const char *fmt, ...)
1861 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001862int
Pekka Paalanend525b562012-08-06 14:57:04 +03001863weston_log_continue(const char *fmt, ...)
1864 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001865
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001866enum {
1867 TTY_ENTER_VT,
1868 TTY_LEAVE_VT
1869};
1870
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001871struct tty *
Kristian Høgsberg61741a22013-09-17 16:02:57 -07001872tty_create(struct weston_compositor *compositor, int tty_nr);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001873
1874void
1875tty_destroy(struct tty *tty);
1876
Kristian Høgsberg7b884bc2012-07-31 14:32:01 -04001877void
1878tty_reset(struct tty *tty);
1879
Kristian Høgsberg5d1c0c52012-04-10 00:11:50 -04001880int
1881tty_activate_vt(struct tty *tty, int vt);
1882
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001883enum weston_screenshooter_outcome {
1884 WESTON_SCREENSHOOTER_SUCCESS,
1885 WESTON_SCREENSHOOTER_NO_MEMORY,
1886 WESTON_SCREENSHOOTER_BAD_BUFFER
1887};
1888
1889typedef void (*weston_screenshooter_done_func_t)(void *data,
1890 enum weston_screenshooter_outcome outcome);
1891int
1892weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
1893 weston_screenshooter_done_func_t done, void *data);
Giulio Camuffo26f62d42016-06-02 21:48:09 +03001894struct weston_recorder *
1895weston_recorder_start(struct weston_output *output, const char *filename);
1896void
1897weston_recorder_stop(struct weston_recorder *recorder);
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001898
Kristian Høgsberga7ceaff2012-06-03 10:20:13 -04001899struct clipboard *
1900clipboard_create(struct weston_seat *seat);
1901
Jason Ekstranda7af7042013-10-12 22:38:11 -05001902struct weston_view_animation;
1903typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001904
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001905void
1906weston_view_animation_destroy(struct weston_view_animation *animation);
1907
Jason Ekstranda7af7042013-10-12 22:38:11 -05001908struct weston_view_animation *
1909weston_zoom_run(struct weston_view *view, float start, float stop,
1910 weston_view_animation_done_func_t done, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001911
Jason Ekstranda7af7042013-10-12 22:38:11 -05001912struct weston_view_animation *
1913weston_fade_run(struct weston_view *view,
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001914 float start, float end, float k,
Jason Ekstranda7af7042013-10-12 22:38:11 -05001915 weston_view_animation_done_func_t done, void *data);
Daniel Stonea67e6b92013-11-19 11:37:13 +01001916
1917struct weston_view_animation *
1918weston_move_scale_run(struct weston_view *view, int dx, int dy,
Quentin Glidic24d306c2016-08-10 15:53:33 +02001919 float start, float end, bool reverse,
Daniel Stonea67e6b92013-11-19 11:37:13 +01001920 weston_view_animation_done_func_t done, void *data);
1921
Quentin Glidic24d306c2016-08-10 15:53:33 +02001922struct weston_view_animation *
1923weston_move_run(struct weston_view *view, int dx, int dy,
1924 float start, float end, bool reverse,
1925 weston_view_animation_done_func_t done, void *data);
1926
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001927void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001928weston_fade_update(struct weston_view_animation *fade, float target);
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001929
Jason Ekstranda7af7042013-10-12 22:38:11 -05001930struct weston_view_animation *
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001931weston_stable_fade_run(struct weston_view *front_view, float start,
1932 struct weston_view *back_view, float end,
1933 weston_view_animation_done_func_t done, void *data);
1934
1935struct weston_view_animation *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001936weston_slide_run(struct weston_view *view, float start, float stop,
1937 weston_view_animation_done_func_t done, void *data);
Juan Zhaoe10d2792012-04-25 19:09:52 +08001938
Alex Wu8811bf92012-02-28 18:07:54 +08001939void
1940weston_surface_set_color(struct weston_surface *surface,
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001941 float red, float green, float blue, float alpha);
Alex Wu8811bf92012-02-28 18:07:54 +08001942
1943void
1944weston_surface_destroy(struct weston_surface *surface);
1945
Alex Wu2dda6042012-04-17 17:20:47 +08001946int
Derek Foreman6ae7bc92014-11-04 10:47:33 -06001947weston_output_mode_set_native(struct weston_output *output,
1948 struct weston_mode *mode,
1949 int32_t scale);
1950int
1951weston_output_mode_switch_to_temporary(struct weston_output *output,
1952 struct weston_mode *mode,
1953 int32_t scale);
1954int
1955weston_output_mode_switch_to_native(struct weston_output *output);
Alex Wu2dda6042012-04-17 17:20:47 +08001956
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001957int
1958noop_renderer_init(struct weston_compositor *ec);
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001959
Giulio Camuffo954f1832014-10-11 18:27:30 +03001960int
Jonas Ådahl30d61d82014-10-22 21:21:17 +02001961weston_input_init(struct weston_compositor *compositor);
1962
1963int
Quentin Glidic23e1d6f2016-12-02 14:08:44 +01001964weston_backend_init(struct weston_compositor *c,
1965 struct weston_backend_config *config_base);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001966int
Quentin Glidic3d7ca3b2016-12-02 14:20:35 +01001967weston_module_init(struct weston_compositor *compositor);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001968
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001969void
1970weston_transformed_coord(int width, int height,
1971 enum wl_output_transform transform,
Alexander Larssonedddbd12013-05-24 13:09:43 +02001972 int32_t scale,
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001973 float sx, float sy, float *bx, float *by);
1974pixman_box32_t
1975weston_transformed_rect(int width, int height,
1976 enum wl_output_transform transform,
Alexander Larssonedddbd12013-05-24 13:09:43 +02001977 int32_t scale,
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001978 pixman_box32_t rect);
Jason Ekstrand33ff6362013-10-27 22:25:01 -05001979void
Derek Foremanbc9a61c2015-11-18 16:32:30 -06001980weston_matrix_transform_region(pixman_region32_t *dest,
1981 struct weston_matrix *matrix,
1982 pixman_region32_t *src);
1983void
Jason Ekstrand33ff6362013-10-27 22:25:01 -05001984weston_transformed_region(int width, int height,
1985 enum wl_output_transform transform,
1986 int32_t scale,
1987 pixman_region32_t *src, pixman_region32_t *dest);
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001988
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +03001989void *
1990weston_load_module(const char *name, const char *entrypoint);
1991
Derek Foreman64a3df02014-10-23 12:24:18 -05001992int
1993weston_parse_transform(const char *transform, uint32_t *out);
1994
1995const char *
1996weston_transform_to_string(uint32_t output_transform);
1997
Derek Foreman1281a362015-07-31 16:55:32 -05001998struct weston_keyboard *
1999weston_seat_get_keyboard(struct weston_seat *seat);
2000
2001struct weston_pointer *
2002weston_seat_get_pointer(struct weston_seat *seat);
2003
2004struct weston_touch *
2005weston_seat_get_touch(struct weston_seat *seat);
2006
Bryce Harrington24f917e2016-06-29 19:04:07 -07002007void
2008weston_seat_set_keyboard_focus(struct weston_seat *seat,
2009 struct weston_surface *surface);
2010
Giulio Camuffo9c764df2016-06-29 11:54:27 +02002011int
2012weston_compositor_load_xwayland(struct weston_compositor *compositor);
2013
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002014void
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002015weston_head_init(struct weston_head *head, const char *name);
2016
2017void
2018weston_head_release(struct weston_head *head);
2019
2020void
2021weston_compositor_add_head(struct weston_compositor *compositor,
2022 struct weston_head *head);
2023
2024void
Pekka Paalanen01f60212017-03-24 15:39:24 +02002025weston_head_set_monitor_strings(struct weston_head *head,
2026 const char *make,
2027 const char *model,
2028 const char *serialno);
2029
2030void
2031weston_head_set_physical_size(struct weston_head *head,
2032 int32_t mm_width, int32_t mm_height);
2033
2034void
2035weston_head_set_subpixel(struct weston_head *head,
2036 enum wl_output_subpixel sp);
2037
2038void
Pekka Paalanen7fe858b2017-08-14 15:45:14 +03002039weston_head_set_connection_status(struct weston_head *head, bool connected);
2040
2041void
Pekka Paalanen01f60212017-03-24 15:39:24 +02002042weston_head_set_internal(struct weston_head *head);
2043
Pekka Paalanen7fe858b2017-08-14 15:45:14 +03002044bool
2045weston_head_is_connected(struct weston_head *head);
2046
Pekka Paalanen8e552fd2018-02-15 15:18:20 +02002047bool
2048weston_head_is_enabled(struct weston_head *head);
2049
Pekka Paalanene19970f2017-08-28 14:11:02 +03002050bool
2051weston_head_is_device_changed(struct weston_head *head);
2052
2053void
2054weston_head_reset_device_changed(struct weston_head *head);
2055
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002056const char *
2057weston_head_get_name(struct weston_head *head);
2058
2059struct weston_output *
2060weston_head_get_output(struct weston_head *head);
2061
2062void
2063weston_head_detach(struct weston_head *head);
2064
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +03002065void
2066weston_head_add_destroy_listener(struct weston_head *head,
2067 struct wl_listener *listener);
2068
2069struct wl_listener *
2070weston_head_get_destroy_listener(struct weston_head *head,
2071 wl_notify_func_t notify);
2072
Pekka Paalanen1adcbac2017-08-14 16:05:35 +03002073struct weston_head *
2074weston_compositor_iterate_heads(struct weston_compositor *compositor,
2075 struct weston_head *iter);
2076
Pekka Paalanen01f60212017-03-24 15:39:24 +02002077void
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002078weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor,
2079 struct wl_listener *listener);
2080
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002081struct weston_output *
2082weston_compositor_create_output_with_head(struct weston_compositor *compositor,
2083 struct weston_head *head);
2084
2085void
2086weston_output_destroy(struct weston_output *output);
2087
2088int
2089weston_output_attach_head(struct weston_output *output,
2090 struct weston_head *head);
2091
2092struct weston_head *
2093weston_output_iterate_heads(struct weston_output *output,
2094 struct weston_head *iter);
2095
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002096void
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002097weston_output_set_scale(struct weston_output *output,
2098 int32_t scale);
2099
2100void
2101weston_output_set_transform(struct weston_output *output,
2102 uint32_t transform);
2103
2104void
Armin Krezović40087402016-09-30 14:11:12 +02002105weston_output_init(struct weston_output *output,
Pekka Paalanen26ac2e12017-04-03 13:18:13 +03002106 struct weston_compositor *compositor,
2107 const char *name);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002108
2109void
2110weston_compositor_add_pending_output(struct weston_output *output,
2111 struct weston_compositor *compositor);
2112
2113int
2114weston_output_enable(struct weston_output *output);
2115
2116void
2117weston_output_disable(struct weston_output *output);
2118
2119void
Pekka Paalanen8a8dcac2017-08-17 17:29:36 +03002120weston_compositor_flush_heads_changed(struct weston_compositor *compositor);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002121
Pekka Paalanen055c1132017-03-27 16:31:25 +03002122struct weston_head *
2123weston_head_from_resource(struct wl_resource *resource);
Pekka Paalanen9ffb2502017-03-27 15:14:32 +03002124
Pekka Paalanencf0a4762017-04-04 16:36:07 +03002125struct weston_head *
2126weston_output_get_first_head(struct weston_output *output);
2127
Giulio Camuffo7fe01b12013-03-28 18:02:42 +01002128#ifdef __cplusplus
2129}
2130#endif
2131
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05002132#endif