blob: d036c5bba49fbe262a3519184a97d49a8e722e8a [file] [log] [blame]
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
Pekka Paalanen925788f2018-04-19 14:20:01 +03003 * Copyright © 2012, 2017, 2018 Collabora, Ltd.
4 * Copyright © 2017, 2018 General Electric Company
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05005 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -07006 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050013 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -070014 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050026 */
27
28#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
29#define _WAYLAND_SYSTEM_COMPOSITOR_H_
30
Giulio Camuffo7fe01b12013-03-28 18:02:42 +010031#ifdef __cplusplus
32extern "C" {
33#endif
34
Derek Foreman280e7dd2014-10-03 13:13:42 -050035#include <stdbool.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030036#include <stdint.h>
Pekka Paalanenb5eedad2014-09-23 22:08:45 -040037#include <time.h>
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050038#include <pixman.h>
Daniel Stone855028f2012-05-01 20:37:10 +010039#include <xkbcommon/xkbcommon.h>
Kristian Høgsberg3c179332013-08-06 19:27:04 -070040
41#define WL_HIDE_DEPRECATED
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050042#include <wayland-server.h>
43
Pekka Paalanen96dc4492019-04-04 13:47:40 +030044#include <libweston/matrix.h>
Pekka Paalanenecbdcfd2019-04-04 14:46:00 +030045#include <libweston/zalloc.h>
Pekka Paalanen2eaa11e2012-03-30 15:45:40 +030046
Quentin Glidic248dd102016-08-12 10:41:34 +020047struct weston_geometry {
48 int32_t x, y;
49 int32_t width, height;
50};
51
52struct weston_position {
53 int32_t x, y;
54};
55
56struct weston_size {
57 int32_t width, height;
58};
59
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050060struct weston_transform {
61 struct weston_matrix matrix;
Pekka Paalanenc61eca62012-01-06 14:10:06 +020062 struct wl_list link;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050063};
64
Pekka Paalanenf4062532018-02-26 16:18:29 +020065/** 2D device coordinates normalized to [0, 1] range */
66struct weston_point2d_device_normalized {
67 double x;
68 double y;
69};
70
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050071struct weston_surface;
Jason Ekstrand6bd62942013-06-20 20:38:23 -050072struct weston_buffer;
Tiago Vignattibc052c92012-04-19 16:18:18 +030073struct shell_surface;
Daniel Stone37816df2012-05-16 18:45:18 +010074struct weston_seat;
Scott Moreau062be7e2012-04-20 13:37:33 -060075struct weston_output;
Jan Arne Petersene829adc2012-08-10 16:47:22 +020076struct input_method;
Derek Foremane4d6c832015-08-05 14:48:11 -050077struct weston_pointer;
Pekka Paalanen230f3b12014-09-29 14:18:40 -040078struct linux_dmabuf_buffer;
Giulio Camuffo26f62d42016-06-02 21:48:09 +030079struct weston_recorder;
Jonas Ådahld3414f22016-07-22 17:56:31 +080080struct weston_pointer_constraint;
Sebastian Wickabec5122019-11-01 02:38:45 +010081struct ro_anonymous_file;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050082
Daniel Stone496ca172012-05-30 16:31:42 +010083enum weston_keyboard_modifier {
84 MODIFIER_CTRL = (1 << 0),
85 MODIFIER_ALT = (1 << 1),
86 MODIFIER_SUPER = (1 << 2),
Kristian Høgsberg73694c82012-06-28 14:13:10 -040087 MODIFIER_SHIFT = (1 << 3),
Daniel Stone496ca172012-05-30 16:31:42 +010088};
89
Giulio Camuffo6ef444d2014-08-28 19:44:09 +030090enum weston_keyboard_locks {
91 WESTON_NUM_LOCK = (1 << 0),
92 WESTON_CAPS_LOCK = (1 << 1),
93};
94
Daniel Stone8c8164f2012-05-30 16:31:45 +010095enum weston_led {
96 LED_NUM_LOCK = (1 << 0),
97 LED_CAPS_LOCK = (1 << 1),
98 LED_SCROLL_LOCK = (1 << 2),
99};
100
Ankit Nautiyala21c3932097-03-19 00:24:57 +0530101enum weston_mode_aspect_ratio {
102 /** The picture aspect ratio values, for the aspect_ratio field of
103 * weston_mode. The values here, are taken from
104 * DRM_MODE_PICTURE_ASPECT_* from drm_mode.h.
105 */
106 WESTON_MODE_PIC_AR_NONE = 0, /* DRM_MODE_PICTURE_ASPECT_NONE */
107 WESTON_MODE_PIC_AR_4_3 = 1, /* DRM_MODE_PICTURE_ASPECT_4_3 */
108 WESTON_MODE_PIC_AR_16_9 = 2, /* DRM_MODE_PICTURE_ASPECT_16_9 */
109 WESTON_MODE_PIC_AR_64_27 = 3, /* DRM_MODE_PICTURE_ASPECT_64_27 */
110 WESTON_MODE_PIC_AR_256_135 = 4, /* DRM_MODE_PICTURE_ASPECT_256_135*/
111};
112
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +0530113enum weston_surface_protection_mode {
114 WESTON_SURFACE_PROTECTION_MODE_RELAXED,
115 WESTON_SURFACE_PROTECTION_MODE_ENFORCED
116};
Ankit Nautiyala21c3932097-03-19 00:24:57 +0530117
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500118struct weston_mode {
119 uint32_t flags;
Ankit Nautiyala21c3932097-03-19 00:24:57 +0530120 enum weston_mode_aspect_ratio aspect_ratio;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500121 int32_t width, height;
122 uint32_t refresh;
123 struct wl_list link;
124};
125
Scott Moreaue6603982012-06-11 13:07:51 -0600126struct weston_animation {
127 void (*frame)(struct weston_animation *animation,
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200128 struct weston_output *output,
129 const struct timespec *time);
Scott Moreaue6603982012-06-11 13:07:51 -0600130 int frame_counter;
131 struct wl_list link;
132};
133
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400134enum {
135 WESTON_SPRING_OVERSHOOT,
136 WESTON_SPRING_CLAMP,
137 WESTON_SPRING_BOUNCE
138};
139
Scott Moreaue6603982012-06-11 13:07:51 -0600140struct weston_spring {
141 double k;
142 double friction;
143 double current;
144 double target;
145 double previous;
Kristian Høgsberg091b0962013-06-17 09:23:14 -0400146 double min, max;
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200147 struct timespec timestamp;
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400148 uint32_t clip;
Scott Moreaue6603982012-06-11 13:07:51 -0600149};
150
Scott Moreauccbf29d2012-02-22 14:21:41 -0700151struct weston_output_zoom {
Derek Foremana36eb502015-07-23 14:55:12 -0500152 bool active;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700153 float increment;
154 float level;
Scott Moreaue6603982012-06-11 13:07:51 -0600155 float max_level;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700156 float trans_x, trans_y;
Giulio Camuffo6850e7b2015-10-07 20:14:18 +0300157 struct {
158 double x, y;
159 } current;
Derek Foreman22276a52015-07-23 14:55:15 -0500160 struct weston_seat *seat;
Scott Moreaue6603982012-06-11 13:07:51 -0600161 struct weston_animation animation_z;
162 struct weston_spring spring_z;
Giulio Camuffo412b0242013-11-14 23:42:51 +0100163 struct wl_listener motion_listener;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700164};
165
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200166/* bit compatible with drm definitions. */
167enum dpms_enum {
168 WESTON_DPMS_ON,
169 WESTON_DPMS_STANDBY,
170 WESTON_DPMS_SUSPEND,
171 WESTON_DPMS_OFF
172};
173
Ankit Nautiyal2690a772019-03-25 17:57:59 +0530174/* enum for content protection requests/status
175 *
176 * This enum represents the content protection requests and statuses in
177 * libweston and its enum values correspond to those of 'type' enum defined in
178 * weston-content-protection protocol. The values should exactly match to the
179 * values of the 'type' enum of the protocol.
180 */
181
182enum weston_hdcp_protection {
183 WESTON_HDCP_DISABLE = 0,
184 WESTON_HDCP_ENABLE_TYPE_0,
185 WESTON_HDCP_ENABLE_TYPE_1
186};
187
Pekka Paalanen9dccfd12020-01-16 17:44:51 +0200188/** Represents a head, usually a display connector
Pekka Paalanen01f60212017-03-24 15:39:24 +0200189 *
Pekka Paalanen9dccfd12020-01-16 17:44:51 +0200190 * \rst
191 See :ref:`libweston-head`. \endrst
Marius Vlad78984ee2019-06-11 00:05:08 +0300192 *
193 * \ingroup head
Pekka Paalanen01f60212017-03-24 15:39:24 +0200194 */
195struct weston_head {
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300196 struct weston_compositor *compositor; /**< owning compositor */
197 struct wl_list compositor_link; /**< in weston_compositor::head_list */
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +0300198 struct wl_signal destroy_signal; /**< destroy callbacks */
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300199
Pekka Paalanen05347622017-03-27 12:24:34 +0300200 struct weston_output *output; /**< the output driving this head */
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300201 struct wl_list output_link; /**< in weston_output::head_list */
Pekka Paalanen05347622017-03-27 12:24:34 +0300202
Pekka Paalanen1b9bf592017-03-27 12:15:38 +0300203 struct wl_list resource_list; /**< wl_output protocol objects */
204 struct wl_global *global; /**< wl_output global */
205
Roman Gilge97391c2019-03-29 13:01:06 +0100206 struct wl_list xdg_output_resource_list; /**< xdg_output protocol objects */
207
Pekka Paalanen01f60212017-03-24 15:39:24 +0200208 int32_t mm_width; /**< physical image width in mm */
209 int32_t mm_height; /**< physical image height in mm */
Lucas Stacha69cb712019-11-25 23:29:31 +0000210
211 /** WL_OUTPUT_TRANSFORM enum to apply to match native orientation */
212 uint32_t transform;
213
Pekka Paalanen01f60212017-03-24 15:39:24 +0200214 char *make; /**< monitor manufacturer (PNP ID) */
215 char *model; /**< monitor model */
216 char *serial_number; /**< monitor serial */
217 uint32_t subpixel; /**< enum wl_output_subpixel */
218 bool connection_internal; /**< embedded monitor (e.g. laptop) */
Pekka Paalanene19970f2017-08-28 14:11:02 +0300219 bool device_changed; /**< monitor information has changed */
Pekka Paalanen9b02e472017-08-14 14:43:13 +0300220
221 char *name; /**< head name, e.g. connector name */
Pekka Paalanen7fe858b2017-08-14 15:45:14 +0300222 bool connected; /**< is physically connected */
Philipp Zabelc18ffd32018-08-30 17:38:03 +0200223 bool non_desktop; /**< non-desktop display, e.g. HMD */
Ankit Nautiyal4f64ff82019-04-03 18:44:35 +0530224
225 /** Current content protection status */
226 enum weston_hdcp_protection current_protection;
Pekka Paalanen01f60212017-03-24 15:39:24 +0200227};
228
Pekka Paalanen9dccfd12020-01-16 17:44:51 +0200229/** Content producer for heads
230 *
231 * \rst
232 See :ref:`libweston-output`. \endrst
Marius Vlad55d87362019-06-11 01:15:35 +0300233 *
234 * \ingroup output
235 */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500236struct weston_output {
Casey Dahlin58ba1372012-04-19 22:50:08 -0400237 uint32_t id;
Richard Hughesafe690c2013-05-02 10:10:04 +0100238 char *name;
Casey Dahlin58ba1372012-04-19 22:50:08 -0400239
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +0200240 /** Matches the lifetime from the user perspective */
241 struct wl_signal user_destroy_signal;
242
John Kåre Alsaker94659272012-11-13 19:10:18 +0100243 void *renderer_state;
244
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500245 struct wl_list link;
246 struct weston_compositor *compositor;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500247
248 /** From global to output buffer coordinates. */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500249 struct weston_matrix matrix;
Derek Foremanc0023212015-03-24 11:36:13 -0500250 /** From output buffer to global coordinates. */
251 struct weston_matrix inverse_matrix;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500252
Scott Moreau9d1b1122012-06-08 19:40:53 -0600253 struct wl_list animation_list;
Scott Moreau1bad5db2012-08-18 01:04:05 -0600254 int32_t x, y, width, height;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200255
256 /** Output area in global coordinates, simple rect */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500257 pixman_region32_t region;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200258
Daniel Stone09a97e22017-03-01 11:34:06 +0000259 /** True if damage has occurred since the last repaint for this output;
260 * if set, a repaint will eventually occur. */
261 bool repaint_needed;
Daniel Stone05df8c12017-03-03 16:59:42 +0000262
Tomohito Esaki7f4d9ff2018-06-05 10:37:06 +0900263 /** Used only between repaint_begin and repaint_cancel. */
264 bool repainted;
265
Daniel Stone05df8c12017-03-03 16:59:42 +0000266 /** State of the repaint loop */
267 enum {
268 REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */
269 REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */
270 REPAINT_SCHEDULED, /**< repaint is scheduled to occur */
271 REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
272 } repaint_status;
273
Daniel Stone6847b852017-03-01 11:34:08 +0000274 /** If repaint_status is REPAINT_SCHEDULED, contains the time the
275 * next repaint should be run */
276 struct timespec next_repaint;
277
Pekka Paalanendcbcfc72017-10-26 14:33:59 +0300278 /** For cancelling the idle_repaint callback on output destruction. */
279 struct wl_event_source *idle_repaint_source;
280
Scott Moreauccbf29d2012-02-22 14:21:41 -0700281 struct weston_output_zoom zoom;
282 int dirty;
Kristian Høgsberg5fb70bf2012-05-24 12:29:46 -0400283 struct wl_signal frame_signal;
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +0200284 struct wl_signal destroy_signal; /**< sent when disabled */
Zhang, Xiong Yf3012412013-12-13 22:10:53 +0200285 int move_x, move_y;
Alexandros Frantzise6ac2af2017-11-16 18:20:53 +0200286 struct timespec frame_time; /* presentation timestamp */
Pekka Paalanen641307c2014-09-23 22:08:47 -0400287 uint64_t msc; /* media stream counter */
Kristian Høgsberg79af73e2012-08-03 15:45:23 -0400288 int disable_planes;
Ander Conselvan de Oliveirae1e23522013-12-13 22:10:55 +0200289 int destroying;
Pekka Paalanen133e4392014-09-23 22:08:46 -0400290 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500291
Kristian Høgsberg05890dc2012-08-10 10:09:20 -0400292 uint32_t transform;
Hardening57388e42013-09-18 23:56:36 +0200293 int32_t native_scale;
Hardeningff39efa2013-09-18 23:56:35 +0200294 int32_t current_scale;
Hardening57388e42013-09-18 23:56:36 +0200295 int32_t original_scale;
Alexander Larsson4ea95522013-05-22 14:41:37 +0200296
Hardening57388e42013-09-18 23:56:36 +0200297 struct weston_mode *native_mode;
Hardeningff39efa2013-09-18 23:56:35 +0200298 struct weston_mode *current_mode;
299 struct weston_mode *original_mode;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500300 struct wl_list mode_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500301
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300302 struct wl_list head_list; /**< List of driven weston_heads */
Pekka Paalanen01f60212017-03-24 15:39:24 +0200303
Ankit Nautiyal2690a772019-03-25 17:57:59 +0530304 enum weston_hdcp_protection desired_protection;
Ankit Nautiyal4f64ff82019-04-03 18:44:35 +0530305 enum weston_hdcp_protection current_protection;
Ankit Nautiyal2844f8e2019-04-03 10:14:59 +0530306 bool allow_protection;
Ankit Nautiyal2690a772019-03-25 17:57:59 +0530307
Antonio Borneoc90fccc2019-06-30 15:51:10 +0200308 int (*start_repaint_loop)(struct weston_output *output);
David Herrmann1edf44c2013-10-22 17:11:26 +0200309 int (*repaint)(struct weston_output *output,
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000310 pixman_region32_t *damage,
311 void *repaint_data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500312 void (*destroy)(struct weston_output *output);
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000313 void (*assign_planes)(struct weston_output *output, void *repaint_data);
Alex Wu2dda6042012-04-17 17:20:47 +0800314 int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200315
Tiago Vignatti5ab91ad2012-03-12 19:40:09 -0300316 /* backlight values are on 0-255 range, where higher is brighter */
Kristian Høgsberg7c609122013-05-23 20:30:26 -0400317 int32_t backlight_current;
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200318 void (*set_backlight)(struct weston_output *output, uint32_t value);
319 void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
Richard Hughese7299962013-05-01 21:52:12 +0100320
321 uint16_t gamma_size;
322 void (*set_gamma)(struct weston_output *output,
323 uint16_t size,
324 uint16_t *r,
325 uint16_t *g,
326 uint16_t *b);
Pekka Paalanenb5026542014-11-12 15:09:24 +0200327
Pekka Paalanen7f340ff2017-03-30 14:56:22 +0300328 bool enabled; /**< is in the output_list, not pending list */
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200329 int scale;
330
331 int (*enable)(struct weston_output *output);
332 int (*disable)(struct weston_output *output);
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300333
334 /** Attach a head in the backend
335 *
336 * @param output The output to attach to.
337 * @param head The head to attach.
338 * @return 0 on success, -1 on failure.
339 *
340 * Do anything necessary to account for a new head being attached to
341 * the output, and check any conditions possible. On failure, both
342 * the head and the output must be left as before the call.
343 *
344 * Libweston core will add the head to the head_list after a successful
345 * call.
346 */
347 int (*attach_head)(struct weston_output *output,
348 struct weston_head *head);
349
350 /** Detach a head in the backend
351 *
352 * @param output The output to detach from.
353 * @param head The head to detach.
354 *
355 * Do any clean-up necessary to detach this head from the output.
356 * The head has already been removed from the output's head_list.
357 */
358 void (*detach_head)(struct weston_output *output,
359 struct weston_head *head);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500360};
361
Jonas Ådahld2510102014-10-05 21:39:14 +0200362enum weston_pointer_motion_mask {
363 WESTON_POINTER_MOTION_ABS = 1 << 0,
364 WESTON_POINTER_MOTION_REL = 1 << 1,
Jonas Ådahl3845b322014-10-21 23:51:29 +0200365 WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2,
Jonas Ådahld2510102014-10-05 21:39:14 +0200366};
367
368struct weston_pointer_motion_event {
369 uint32_t mask;
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200370 struct timespec time;
Jonas Ådahld2510102014-10-05 21:39:14 +0200371 double x;
372 double y;
373 double dx;
374 double dy;
Jonas Ådahl3845b322014-10-21 23:51:29 +0200375 double dx_unaccel;
376 double dy_unaccel;
Jonas Ådahld2510102014-10-05 21:39:14 +0200377};
378
Peter Hutterer89b6a492016-01-18 15:58:17 +1000379struct weston_pointer_axis_event {
380 uint32_t axis;
Giulio Camuffo90a6fc62016-03-22 17:44:54 +0200381 double value;
Peter Hutterer87743e92016-01-18 16:38:22 +1000382 bool has_discrete;
383 int32_t discrete;
Peter Hutterer89b6a492016-01-18 15:58:17 +1000384};
385
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400386struct weston_pointer_grab;
387struct weston_pointer_grab_interface {
Kristian Høgsberg6848c252013-05-08 22:02:59 -0400388 void (*focus)(struct weston_pointer_grab *grab);
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200389 void (*motion)(struct weston_pointer_grab *grab,
390 const struct timespec *time,
Jonas Ådahld2510102014-10-05 21:39:14 +0200391 struct weston_pointer_motion_event *event);
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400392 void (*button)(struct weston_pointer_grab *grab,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200393 const struct timespec *time,
394 uint32_t button, uint32_t state);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200395 void (*axis)(struct weston_pointer_grab *grab,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200396 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000397 struct weston_pointer_axis_event *event);
Peter Hutterer87743e92016-01-18 16:38:22 +1000398 void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
399 void (*frame)(struct weston_pointer_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200400 void (*cancel)(struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400401};
402
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400403struct weston_pointer_grab {
404 const struct weston_pointer_grab_interface *interface;
405 struct weston_pointer *pointer;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400406};
407
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400408struct weston_keyboard_grab;
409struct weston_keyboard_grab_interface {
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200410 void (*key)(struct weston_keyboard_grab *grab,
411 const struct timespec *time, uint32_t key, uint32_t state);
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400412 void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400413 uint32_t mods_depressed, uint32_t mods_latched,
414 uint32_t mods_locked, uint32_t group);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200415 void (*cancel)(struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400416};
417
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400418struct weston_keyboard_grab {
419 const struct weston_keyboard_grab_interface *interface;
420 struct weston_keyboard *keyboard;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400421};
422
Kristian Høgsberge329f362013-05-06 22:19:57 -0400423struct weston_touch_grab;
424struct weston_touch_grab_interface {
425 void (*down)(struct weston_touch_grab *grab,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200426 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400427 int touch_id,
428 wl_fixed_t sx,
429 wl_fixed_t sy);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400430 void (*up)(struct weston_touch_grab *grab,
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200431 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400432 int touch_id);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400433 void (*motion)(struct weston_touch_grab *grab,
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200434 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400435 int touch_id,
436 wl_fixed_t sx,
437 wl_fixed_t sy);
Jonas Ådahl1679f232014-04-12 09:39:51 +0200438 void (*frame)(struct weston_touch_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200439 void (*cancel)(struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400440};
441
Kristian Høgsberge329f362013-05-06 22:19:57 -0400442struct weston_touch_grab {
443 const struct weston_touch_grab_interface *interface;
444 struct weston_touch *touch;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400445};
446
Kristian Høgsberg5e76a492013-07-25 16:09:37 -0700447struct weston_data_offer {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500448 struct wl_resource *resource;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700449 struct weston_data_source *source;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400450 struct wl_listener source_destroy_listener;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100451 uint32_t dnd_actions;
452 enum wl_data_device_manager_dnd_action preferred_dnd_action;
453 bool in_ask;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400454};
455
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700456struct weston_data_source {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500457 struct wl_resource *resource;
458 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400459 struct wl_array mime_types;
Carlos Garnacho78d4bf92016-01-15 21:14:23 +0100460 struct weston_data_offer *offer;
461 struct weston_seat *seat;
462 bool accepted;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100463 bool actions_set;
Harish Krupo737ac0d2019-04-19 22:06:37 +0530464 bool set_selection;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100465 uint32_t dnd_actions;
466 enum wl_data_device_manager_dnd_action current_dnd_action;
Carlos Garnachob2889882016-01-15 21:14:26 +0100467 enum wl_data_device_manager_dnd_action compositor_action;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400468
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700469 void (*accept)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400470 uint32_t serial, const char *mime_type);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700471 void (*send)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400472 const char *mime_type, int32_t fd);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700473 void (*cancel)(struct weston_data_source *source);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400474};
475
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800476struct weston_pointer_client {
477 struct wl_list link;
478 struct wl_client *client;
479 struct wl_list pointer_resources;
Jonas Ådahl30d61d82014-10-22 21:21:17 +0200480 struct wl_list relative_pointer_resources;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800481};
482
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400483struct weston_pointer {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400484 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400485
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800486 struct wl_list pointer_clients;
487
Jason Ekstranda7af7042013-10-12 22:38:11 -0500488 struct weston_view *focus;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800489 struct weston_pointer_client *focus_client;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400490 uint32_t focus_serial;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100491 struct wl_listener focus_view_listener;
492 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400493 struct wl_signal focus_signal;
Giulio Camuffo6fcb3782013-11-14 23:42:50 +0100494 struct wl_signal motion_signal;
Jonas Ådahl3eb4ddd2016-07-22 17:52:58 +0800495 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400496
Jason Ekstranda7af7042013-10-12 22:38:11 -0500497 struct weston_view *sprite;
Kristian Høgsberg195b8692013-05-08 15:02:05 -0400498 struct wl_listener sprite_destroy_listener;
499 int32_t hotspot_x, hotspot_y;
500
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400501 struct weston_pointer_grab *grab;
502 struct weston_pointer_grab default_grab;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400503 wl_fixed_t grab_x, grab_y;
504 uint32_t grab_button;
505 uint32_t grab_serial;
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200506 struct timespec grab_time;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400507
508 wl_fixed_t x, y;
Kristian Høgsbergdb1fccb2014-02-05 17:14:42 -0800509 wl_fixed_t sx, sy;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400510 uint32_t button_count;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +0200511
512 struct wl_listener output_destroy_listener;
Alexandros Frantzisdb907b72018-02-20 14:06:26 +0200513
514 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400515};
516
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500517/** libinput style calibration matrix
518 *
519 * See https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html
520 * and libinput_device_config_calibration_set_matrix().
521 */
522struct weston_touch_device_matrix {
523 float m[6];
524};
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400525
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500526struct weston_touch_device;
527
528/** Operations for a calibratable touchscreen */
529struct weston_touch_device_ops {
530 /** Get the associated output if existing. */
531 struct weston_output *(*get_output)(struct weston_touch_device *device);
532
533 /** Get the name of the associated head if existing. */
534 const char *
535 (*get_calibration_head_name)(struct weston_touch_device *device);
536
537 /** Retrieve the current calibration matrix. */
538 void (*get_calibration)(struct weston_touch_device *device,
539 struct weston_touch_device_matrix *cal);
540
541 /** Set a new calibration matrix. */
542 void (*set_calibration)(struct weston_touch_device *device,
543 const struct weston_touch_device_matrix *cal);
544};
545
Louis-Francis Ratté-Bouliannec4689ff2017-11-28 20:42:47 -0500546enum weston_touch_mode {
547 /** Normal touch event handling */
548 WESTON_TOUCH_MODE_NORMAL,
549
550 /** Prepare moving to WESTON_TOUCH_MODE_CALIB.
551 *
552 * Move to WESTON_TOUCH_MODE_CALIB as soon as no touches are down on
553 * any seat. Until then, all touch events are routed normally.
554 */
555 WESTON_TOUCH_MODE_PREP_CALIB,
556
557 /** Calibration mode
558 *
559 * Only a single weston_touch_device forwards events to the calibrator
560 * all other touch device cause a calibrator "wrong device" event to
561 * be sent.
562 */
563 WESTON_TOUCH_MODE_CALIB,
564
565 /** Prepare moving to WESTON_TOUCH_MODE_NORMAL.
566 *
567 * Move to WESTON_TOUCH_MODE_NORMAL as soon as no touches are down on
568 * any seat. Until then, touch events are routed as in
569 * WESTON_TOUCH_MODE_CALIB except "wrong device" events are not sent.
570 */
571 WESTON_TOUCH_MODE_PREP_NORMAL
572};
573
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500574/** Represents a physical touchscreen input device */
575struct weston_touch_device {
576 char *syspath; /**< unique name */
577
578 struct weston_touch *aggregate; /**< weston_touch this is part of */
579 struct wl_list link; /**< in weston_touch::device_list */
580 struct wl_signal destroy_signal; /**< destroy notifier */
581
582 void *backend_data; /**< backend-specific private */
583
584 const struct weston_touch_device_ops *ops;
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -0500585 struct weston_touch_device_matrix saved_calibration;
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500586};
587
588/** Represents a set of touchscreen devices aggregated under a seat */
Kristian Høgsberge329f362013-05-06 22:19:57 -0400589struct weston_touch {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400590 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400591
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500592 struct wl_list device_list; /* struct weston_touch_device::link */
593
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400594 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100595 struct wl_list focus_resource_list;
Jason Ekstranda7af7042013-10-12 22:38:11 -0500596 struct weston_view *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100597 struct wl_listener focus_view_listener;
598 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400599 uint32_t focus_serial;
600 struct wl_signal focus_signal;
601
Jonas Ådahl9484b692013-12-02 22:05:03 +0100602 uint32_t num_tp;
603
Kristian Høgsberge329f362013-05-06 22:19:57 -0400604 struct weston_touch_grab *grab;
605 struct weston_touch_grab default_grab;
Neil Roberts306fe082013-10-03 16:43:06 +0100606 int grab_touch_id;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400607 wl_fixed_t grab_x, grab_y;
608 uint32_t grab_serial;
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200609 struct timespec grab_time;
Alexandros Frantzisd7157842018-02-20 14:07:03 +0200610
611 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400612};
613
Jonas Ådahld2510102014-10-05 21:39:14 +0200614void
615weston_pointer_motion_to_abs(struct weston_pointer *pointer,
616 struct weston_pointer_motion_event *event,
617 wl_fixed_t *x, wl_fixed_t *y);
618
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400619void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200620weston_pointer_send_motion(struct weston_pointer *pointer,
621 const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200622 struct weston_pointer_motion_event *event);
623bool
624weston_pointer_has_focus_resource(struct weston_pointer *pointer);
625void
626weston_pointer_send_button(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200627 const struct timespec *time,
628 uint32_t button, uint32_t state_w);
Quentin Glidiccde13452016-08-12 10:41:32 +0200629void
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200630weston_pointer_send_axis(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200631 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000632 struct weston_pointer_axis_event *event);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200633void
Peter Hutterer87743e92016-01-18 16:38:22 +1000634weston_pointer_send_axis_source(struct weston_pointer *pointer,
635 uint32_t source);
636void
637weston_pointer_send_frame(struct weston_pointer *pointer);
638
639void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400640weston_pointer_set_focus(struct weston_pointer *pointer,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500641 struct weston_view *view,
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400642 wl_fixed_t sx, wl_fixed_t sy);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400643void
Derek Foremanf9318d12015-05-11 15:40:11 -0500644weston_pointer_clear_focus(struct weston_pointer *pointer);
645void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400646weston_pointer_start_grab(struct weston_pointer *pointer,
647 struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400648void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400649weston_pointer_end_grab(struct weston_pointer *pointer);
Rob Bradford806d8c02013-06-25 18:56:41 +0100650void
Giulio Camuffo1959ab82013-11-14 23:42:52 +0100651weston_pointer_move(struct weston_pointer *pointer,
Jonas Ådahld2510102014-10-05 21:39:14 +0200652 struct weston_pointer_motion_event *event);
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100653void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400654weston_keyboard_set_focus(struct weston_keyboard *keyboard,
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400655 struct weston_surface *surface);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400656void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400657weston_keyboard_start_grab(struct weston_keyboard *device,
658 struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400659void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400660weston_keyboard_end_grab(struct weston_keyboard *keyboard);
Giulio Camuffo6ef444d2014-08-28 19:44:09 +0300661int
662/*
663 * 'mask' and 'value' should be a bitwise mask of one or more
664 * valued of the weston_keyboard_locks enum.
665 */
666weston_keyboard_set_locks(struct weston_keyboard *keyboard,
667 uint32_t mask, uint32_t value);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400668
Quentin Glidiccde13452016-08-12 10:41:32 +0200669void
670weston_keyboard_send_key(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200671 const struct timespec *time, uint32_t key,
Quentin Glidiccde13452016-08-12 10:41:32 +0200672 enum wl_keyboard_key_state state);
673void
674weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
675 uint32_t serial, uint32_t mods_depressed,
676 uint32_t mods_latched,
677 uint32_t mods_locked, uint32_t group);
678
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400679void
Derek Foreman4c93c082015-04-30 16:45:41 -0500680weston_touch_set_focus(struct weston_touch *touch,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500681 struct weston_view *view);
Michael Fua2bb7912013-07-23 15:51:06 +0800682void
Louis-Francis Ratté-Boulianne8549e162017-11-28 20:42:47 -0500683weston_touch_start_grab(struct weston_touch *touch,
Kristian Høgsberge329f362013-05-06 22:19:57 -0400684 struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400685void
Kristian Høgsberge329f362013-05-06 22:19:57 -0400686weston_touch_end_grab(struct weston_touch *touch);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400687
Quentin Glidiccde13452016-08-12 10:41:32 +0200688void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200689weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200690 int touch_id, wl_fixed_t x, wl_fixed_t y);
691void
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200692weston_touch_send_up(struct weston_touch *touch, const struct timespec *time,
693 int touch_id);
Quentin Glidiccde13452016-08-12 10:41:32 +0200694void
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200695weston_touch_send_motion(struct weston_touch *touch,
696 const struct timespec *time, int touch_id,
697 wl_fixed_t x, wl_fixed_t y);
Quentin Glidiccde13452016-08-12 10:41:32 +0200698void
699weston_touch_send_frame(struct weston_touch *touch);
700
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400701
702void
Kristian Høgsberge3148752013-05-06 23:19:49 -0400703weston_seat_set_selection(struct weston_seat *seat,
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700704 struct weston_data_source *source, uint32_t serial);
Giulio Camuffodddf9e62015-05-01 12:59:35 +0300705
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700706int
Xiong Zhangfd51e7b2013-11-25 18:42:49 +0800707weston_pointer_start_drag(struct weston_pointer *pointer,
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700708 struct weston_data_source *source,
709 struct weston_surface *icon,
710 struct wl_client *client);
Daniel Stoned65b9092012-05-30 16:32:05 +0100711struct weston_xkb_info {
712 struct xkb_keymap *keymap;
Sebastian Wickabec5122019-11-01 02:38:45 +0100713 struct ro_anonymous_file *keymap_rofile;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +0000714 int32_t ref_count;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100715 xkb_mod_index_t shift_mod;
716 xkb_mod_index_t caps_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100717 xkb_mod_index_t ctrl_mod;
718 xkb_mod_index_t alt_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100719 xkb_mod_index_t mod2_mod;
720 xkb_mod_index_t mod3_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100721 xkb_mod_index_t super_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100722 xkb_mod_index_t mod5_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100723 xkb_led_index_t num_led;
724 xkb_led_index_t caps_led;
725 xkb_led_index_t scroll_led;
726};
727
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100728struct weston_keyboard {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400729 struct weston_seat *seat;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100730
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400731 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100732 struct wl_list focus_resource_list;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400733 struct weston_surface *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100734 struct wl_listener focus_resource_listener;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400735 uint32_t focus_serial;
736 struct wl_signal focus_signal;
737
738 struct weston_keyboard_grab *grab;
739 struct weston_keyboard_grab default_grab;
740 uint32_t grab_key;
741 uint32_t grab_serial;
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200742 struct timespec grab_time;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400743
744 struct wl_array keys;
745
746 struct {
747 uint32_t mods_depressed;
748 uint32_t mods_latched;
749 uint32_t mods_locked;
750 uint32_t group;
751 } modifiers;
752
753 struct weston_keyboard_grab input_method_grab;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100754 struct wl_resource *input_method_resource;
Jonas Ådahl7395ea02013-12-03 09:14:26 +0100755
756 struct weston_xkb_info *xkb_info;
757 struct {
758 struct xkb_state *state;
759 enum weston_led leds;
760 } xkb_state;
761 struct xkb_keymap *pending_keymap;
Alexandros Frantzis2b442482018-02-20 14:05:50 +0200762
763 struct wl_list timestamps_list;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100764};
765
Daniel Stone37816df2012-05-16 18:45:18 +0100766struct weston_seat {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400767 struct wl_list base_resource_list;
768
Kristian Høgsbergaaadc772013-07-08 16:20:31 -0400769 struct wl_global *global;
Derek Foreman1281a362015-07-31 16:55:32 -0500770 struct weston_pointer *pointer_state;
771 struct weston_keyboard *keyboard_state;
772 struct weston_touch *touch_state;
Jonas Ådahld6e1c342013-10-17 23:04:05 +0200773 int pointer_device_count;
774 int keyboard_device_count;
775 int touch_device_count;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400776
Rob Bradford66bd9f52013-06-25 18:56:42 +0100777 struct weston_output *output; /* constraint */
778
Giulio Camuffo5085a752013-03-25 21:42:45 +0100779 struct wl_signal destroy_signal;
Jason Ekstranda4ab5422014-04-02 19:53:45 -0500780 struct wl_signal updated_caps_signal;
Daniel Stone74419a22012-05-30 16:32:02 +0100781
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500782 struct weston_compositor *compositor;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500783 struct wl_list link;
Daniel Stone496ca172012-05-30 16:31:42 +0100784 enum weston_keyboard_modifier modifier_state;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400785 struct weston_surface *saved_kbd_focus;
Ander Conselvan de Oliveira71b1d0c2012-03-16 17:25:11 +0200786 struct wl_listener saved_kbd_focus_listener;
Kristian Høgsberg054c50a2013-05-08 15:27:47 -0400787 struct wl_list drag_resource_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500788
Kristian Høgsberge3148752013-05-06 23:19:49 -0400789 uint32_t selection_serial;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700790 struct weston_data_source *selection_data_source;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400791 struct wl_listener selection_data_source_listener;
792 struct wl_signal selection_signal;
793
Daniel Stone8c8164f2012-05-30 16:31:45 +0100794 void (*led_update)(struct weston_seat *ws, enum weston_led leds);
795
Jan Arne Petersene829adc2012-08-10 16:47:22 +0200796 struct input_method *input_method;
Rob Bradford9af5f9e2013-05-31 18:09:50 +0100797 char *seat_name;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500798};
799
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500800enum {
Bryce Harringtonc2be8572015-12-11 13:11:37 -0800801 WESTON_COMPOSITOR_ACTIVE, /* normal rendering and events */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500802 WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */
Philipp Brüschweiler57edf7f2013-03-29 13:01:56 +0100803 WESTON_COMPOSITOR_OFFSCREEN, /* no rendering, no frame events */
Bryce Harrington873a3f82016-08-30 12:05:01 -0700804 WESTON_COMPOSITOR_SLEEPING /* same as offscreen, but also set dpms
805 * to off */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500806};
807
Giulio Camuffo412e6a52014-07-09 22:12:56 +0300808struct weston_layer_entry {
809 struct wl_list link;
810 struct weston_layer *layer;
811};
812
Quentin Glidic82681572016-12-17 13:40:51 +0100813/**
814 * Higher value means higher in the stack.
815 *
816 * These values are based on well-known concepts in a classic desktop
817 * environment. Third-party modules based on libweston are encouraged to use
818 * them to integrate better with other projects.
819 *
820 * A fully integrated environment can use any value, based on these or not,
821 * at their discretion.
822 */
823enum weston_layer_position {
824 /*
825 * Special value to make the layer invisible and still rendered.
826 * This is used by compositors wanting e.g. minimized surfaces to still
827 * receive frame callbacks.
828 */
829 WESTON_LAYER_POSITION_HIDDEN = 0x00000000,
830
831 /*
832 * There should always be a background layer with a surface covering
833 * the visible area.
834 *
835 * If the compositor handles the background itself, it should use
836 * BACKGROUND.
837 *
838 * If the compositor supports runtime-loadable modules to set the
839 * background, it should put a solid color surface at (BACKGROUND - 1)
840 * and modules must use BACKGROUND.
841 */
842 WESTON_LAYER_POSITION_BACKGROUND = 0x00000002,
843
844 /* For "desktop widgets" and applications like conky. */
845 WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000,
846
847 /* For regular applications, only one layer should have this value
848 * to ensure proper stacking control. */
849 WESTON_LAYER_POSITION_NORMAL = 0x50000000,
850
851 /* For desktop UI, like panels. */
852 WESTON_LAYER_POSITION_UI = 0x80000000,
853
854 /* For fullscreen applications that should cover UI. */
855 WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000,
856
857 /* For special UI like on-screen keyboard that fullscreen applications
858 * will need. */
859 WESTON_LAYER_POSITION_TOP_UI = 0xe0000000,
860
861 /* For the lock surface. */
862 WESTON_LAYER_POSITION_LOCK = 0xffff0000,
863
864 /* Values reserved for libweston internal usage */
865 WESTON_LAYER_POSITION_CURSOR = 0xfffffffe,
866 WESTON_LAYER_POSITION_FADE = 0xffffffff,
867};
868
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500869struct weston_layer {
Quentin Glidic82681572016-12-17 13:40:51 +0100870 struct weston_compositor *compositor;
871 struct wl_list link; /* weston_compositor::layer_list */
872 enum weston_layer_position position;
Giulio Camuffo95ec0f92014-07-09 22:12:57 +0300873 pixman_box32_t mask;
Quentin Glidic82681572016-12-17 13:40:51 +0100874 struct weston_layer_entry view_list;
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500875};
876
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400877struct weston_plane {
Xiong Zhang97116532013-10-23 13:58:31 +0800878 struct weston_compositor *compositor;
Pekka Paalanen502f5e02015-02-23 14:08:25 +0200879 pixman_region32_t damage; /**< in global coords */
Ander Conselvan de Oliveirae1bd5a02013-03-05 17:30:29 +0200880 pixman_region32_t clip;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400881 int32_t x, y;
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +0200882 struct wl_list link;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400883};
884
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400885struct weston_renderer {
John Kåre Alsakera95b2d62012-11-13 19:10:21 +0100886 int (*read_pixels)(struct weston_output *output,
887 pixman_format_code_t format, void *pixels,
888 uint32_t x, uint32_t y,
889 uint32_t width, uint32_t height);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400890 void (*repaint_output)(struct weston_output *output,
891 pixman_region32_t *output_damage);
892 void (*flush_damage)(struct weston_surface *surface);
Jason Ekstrand6bd62942013-06-20 20:38:23 -0500893 void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
John Kåre Alsaker878f4492012-11-13 19:10:23 +0100894 void (*surface_set_color)(struct weston_surface *surface,
895 float red, float green,
896 float blue, float alpha);
Vasily Khoruzhick52cfd612013-01-08 19:09:01 +0300897 void (*destroy)(struct weston_compositor *ec);
Pekka Paalanenc647ed72015-02-09 13:16:57 +0200898
899
900 /** See weston_surface_get_content_size() */
901 void (*surface_get_content_size)(struct weston_surface *surface,
902 int *width, int *height);
903
904 /** See weston_surface_copy_content() */
905 int (*surface_copy_content)(struct weston_surface *surface,
906 void *target, size_t size,
907 int src_x, int src_y,
908 int width, int height);
Pekka Paalanen230f3b12014-09-29 14:18:40 -0400909
910 /** See weston_compositor_import_dmabuf() */
911 bool (*import_dmabuf)(struct weston_compositor *ec,
912 struct linux_dmabuf_buffer *buffer);
Varad Gautam0775cd12016-11-23 14:03:20 +0530913
Emil Velikovfbf165f2017-12-05 14:26:16 +0000914 /** On error sets num_formats to zero */
915 void (*query_dmabuf_formats)(struct weston_compositor *ec,
Varad Gautam0775cd12016-11-23 14:03:20 +0530916 int **formats, int *num_formats);
917
Emil Velikovfbf165f2017-12-05 14:26:16 +0000918 /** On error sets num_modifiers to zero */
919 void (*query_dmabuf_modifiers)(struct weston_compositor *ec,
Varad Gautam0775cd12016-11-23 14:03:20 +0530920 int format, uint64_t **modifiers,
921 int *num_modifiers);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400922};
923
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300924enum weston_capability {
925 /* backend/renderer supports arbitrary rotation */
926 WESTON_CAP_ROTATION_ANY = 0x0001,
Pekka Paalanen4fc5dd02013-05-22 18:03:05 +0300927
928 /* screencaptures need to be y-flipped */
929 WESTON_CAP_CAPTURE_YFLIP = 0x0002,
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500930
Bryce Harringtona86c3ee2015-03-18 18:42:00 -0700931 /* backend/renderer has a separate cursor plane */
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500932 WESTON_CAP_CURSOR_PLANE = 0x0004,
933
934 /* backend supports setting arbitrary resolutions */
935 WESTON_CAP_ARBITRARY_MODES = 0x0008,
Pekka Paalanen380adf52015-02-16 14:39:11 +0200936
937 /* renderer supports weston_view_set_mask() clipping */
938 WESTON_CAP_VIEW_CLIP_MASK = 0x0010,
Alexandros Frantzisacff29b2018-10-19 12:14:11 +0300939
940 /* renderer supports explicit synchronization */
941 WESTON_CAP_EXPLICIT_SYNC = 0x0020,
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300942};
943
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300944/* Configuration struct for a backend.
945 *
946 * This struct carries the configuration for a backend, and it's
947 * passed to the backend's init entry point. The backend will
948 * likely want to subclass this in order to handle backend specific
949 * data.
Bryce Harrington20b66c32016-04-15 20:28:29 -0700950 *
Marius Vladae263412019-06-06 23:10:49 +0300951 * \rststar
952 * .. note:
Bryce Harrington20b66c32016-04-15 20:28:29 -0700953 *
Marius Vladae263412019-06-06 23:10:49 +0300954 * Alternate designs were proposed (Feb 2016) for using opaque structures[1]
955 * and for section+key/value getter/setters[2]. The rationale for selecting
956 * the transparent structure design is based on several assumptions[3] which
957 * may require re-evaluating the design choice if they fail to hold.
958 *
959 * 1. https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html
960 * 2. https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html
961 * 3. https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html
962 *
963 * \endrststar
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300964 */
965struct weston_backend_config {
Bryce Harrington20b66c32016-04-15 20:28:29 -0700966 /** Major version for the backend-specific config struct
967 *
968 * This version must match exactly what the backend expects, otherwise
969 * the struct is incompatible.
970 */
971 uint32_t struct_version;
972
973 /** Minor version of the backend-specific config struct
974 *
975 * This must be set to sizeof(struct backend-specific config).
976 * If the value here is smaller than what the backend expects, the
977 * extra config members will assume their default values.
978 *
979 * A value greater than what the backend expects is incompatible.
980 */
981 size_t struct_size;
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300982};
983
Pekka Paalanene48bfc72019-07-17 00:09:06 +0300984struct weston_backend;
Giulio Camuffo954f1832014-10-11 18:27:30 +0300985
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -0500986/** Callback for saving calibration
987 *
988 * \param compositor The compositor.
989 * \param device The physical touch device to save for.
990 * \param calibration The new calibration from a client.
991 * \return -1 on failure, 0 on success.
992 *
993 * Failure will prevent taking the new calibration into use.
994 */
995typedef int (*weston_touch_calibration_save_func)(
996 struct weston_compositor *compositor,
997 struct weston_touch_device *device,
998 const struct weston_touch_device_matrix *calibration);
999struct weston_touch_calibrator;
1000
Quentin Glidic955cec02016-08-12 10:41:35 +02001001struct weston_desktop_xwayland;
1002struct weston_desktop_xwayland_interface;
Pekka Paalanena5630ea2017-10-12 13:13:42 +02001003struct weston_debug_compositor;
Quentin Glidic955cec02016-08-12 10:41:35 +02001004
Marius Vlad9fdda7f2019-06-11 16:08:55 +03001005/** Main object, container-like structure which aggregates all other objects.
1006 *
1007 * \ingroup compositor
1008 */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001009struct weston_compositor {
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -04001010 struct wl_signal destroy_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001011
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001012 struct wl_display *wl_display;
Quentin Glidic955cec02016-08-12 10:41:35 +02001013 struct weston_desktop_xwayland *xwayland;
1014 const struct weston_desktop_xwayland_interface *xwayland_interface;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001015
Tiago Vignattifb2adba2013-06-12 15:43:21 -03001016 /* surface signals */
Kristian Høgsbergf03a04a2014-04-06 22:04:50 -07001017 struct wl_signal create_surface_signal;
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -04001018 struct wl_signal activate_signal;
Tiago Vignattifb2adba2013-06-12 15:43:21 -03001019 struct wl_signal transform_signal;
1020
Tiago Vignatti1d01b012012-09-27 17:48:36 +03001021 struct wl_signal kill_signal;
Ander Conselvan de Oliveiraa4575632013-02-21 18:35:23 +02001022 struct wl_signal idle_signal;
1023 struct wl_signal wake_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001024
Jan Arne Petersen42feced2012-06-21 21:52:17 +02001025 struct wl_signal show_input_panel_signal;
1026 struct wl_signal hide_input_panel_signal;
Jan Arne Petersen14da96b2013-04-18 16:47:28 +02001027 struct wl_signal update_input_panel_signal;
Jan Arne Petersen42feced2012-06-21 21:52:17 +02001028
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +01001029 struct wl_signal seat_created_signal;
Richard Hughes59d5da72013-05-01 21:52:11 +01001030 struct wl_signal output_created_signal;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +02001031 struct wl_signal output_destroyed_signal;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +02001032 struct wl_signal output_moved_signal;
David Fort0de859e2016-05-27 23:22:57 +02001033 struct wl_signal output_resized_signal; /* callback argument: resized output */
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +01001034
Pekka Paalanen8dc6db82018-03-20 13:29:40 +02001035 /* Signal for output changes triggered by configuration from frontend
1036 * or head state changes from backend.
1037 */
1038 struct wl_signal output_heads_changed_signal; /* arg: weston_output */
1039
Kristian Høgsberg61741a22013-09-17 16:02:57 -07001040 struct wl_signal session_signal;
Robert Beckettc569bdc2019-07-10 16:40:12 +01001041 bool session_active;
Kristian Høgsberg61741a22013-09-17 16:02:57 -07001042
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001043 struct weston_layer fade_layer;
1044 struct weston_layer cursor_layer;
1045
Armin Krezovića01ab6d2016-09-30 14:11:02 +02001046 struct wl_list pending_output_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001047 struct wl_list output_list;
Pekka Paalanen1adcbac2017-08-14 16:05:35 +03001048 struct wl_list head_list; /* struct weston_head::compositor_link */
Daniel Stone37816df2012-05-16 18:45:18 +01001049 struct wl_list seat_list;
Quentin Glidic82681572016-12-17 13:40:51 +01001050 struct wl_list layer_list; /* struct weston_layer::link */
Pekka Paalanen20c7e552016-03-30 14:08:24 +03001051 struct wl_list view_list; /* struct weston_view::link */
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001052 struct wl_list plane_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +01001053 struct wl_list key_binding_list;
Daniel Stone96d47c02013-11-19 11:37:12 +01001054 struct wl_list modifier_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +01001055 struct wl_list button_binding_list;
Neil Robertsa28c6932013-10-03 16:43:04 +01001056 struct wl_list touch_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +01001057 struct wl_list axis_binding_list;
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001058 struct wl_list debug_binding_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001059
1060 uint32_t state;
1061 struct wl_event_source *idle_source;
1062 uint32_t idle_inhibit;
Philipp Brüschweiler4b409c32013-03-10 14:37:04 +01001063 int idle_time; /* timeout, s */
Daniel Stone6847b852017-03-01 11:34:08 +00001064 struct wl_event_source *repaint_timer;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001065
Giulio Camuffocdb4d292013-11-14 23:42:53 +01001066 const struct weston_pointer_grab_interface *default_pointer_grab;
1067
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001068 /* Repaint state. */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001069 struct weston_plane primary_plane;
Pekka Paalanen7bb65102013-05-22 18:03:04 +03001070 uint32_t capabilities; /* combination of enum weston_capability */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001071
Kristian Høgsbergfa1be022012-09-05 22:49:55 -04001072 struct weston_renderer *renderer;
1073
John Kåre Alsakerf9e710b2012-11-13 19:10:22 +01001074 pixman_format_code_t read_format;
Pekka Paalanen52bfbaa2012-04-11 16:19:37 +03001075
Giulio Camuffo954f1832014-10-11 18:27:30 +03001076 struct weston_backend *backend;
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001077
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -07001078 struct weston_launcher *launcher;
Casey Dahlin58ba1372012-04-19 22:50:08 -04001079
Pekka Paalanen827b5d22016-06-29 11:54:26 +02001080 struct wl_list plugin_api_list; /* struct weston_plugin_api::link */
1081
Casey Dahlin58ba1372012-04-19 22:50:08 -04001082 uint32_t output_id_pool;
Daniel Stone855028f2012-05-01 20:37:10 +01001083
Daniel Stonee379da92012-05-30 16:32:04 +01001084 struct xkb_rule_names xkb_names;
1085 struct xkb_context *xkb_context;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +00001086 struct weston_xkb_info *xkb_info;
Matt Roper01a92732013-06-24 16:52:44 +01001087
Jonny Lamb66a41a02014-08-12 14:58:25 +02001088 int32_t kb_repeat_rate;
1089 int32_t kb_repeat_delay;
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001090
Bob Ham91880f12016-01-12 10:21:47 +00001091 bool vt_switching;
1092
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001093 clockid_t presentation_clock;
Pekka Paalanen0513a952014-05-21 16:17:27 +03001094 int32_t repaint_msec;
Frederic Plourdec336f062014-10-29 14:44:33 -04001095
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001096 unsigned int activate_serial;
1097
Jonas Ådahld3414f22016-07-22 17:56:31 +08001098 struct wl_global *pointer_constraints;
1099
Frederic Plourdec336f062014-10-29 14:44:33 -04001100 int exit_code;
Giulio Camuffo459137b2014-10-11 23:56:24 +03001101
1102 void *user_data;
1103 void (*exit)(struct weston_compositor *c);
Daniel Díaz75b71972016-10-21 14:03:13 -05001104
1105 /* Whether to let the compositor run without any input device. */
1106 bool require_input;
1107
Pekka Paalanen8dc6db82018-03-20 13:29:40 +02001108 /* Signal for a backend to inform a frontend about possible changes
1109 * in head status.
1110 */
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03001111 struct wl_signal heads_changed_signal;
1112 struct wl_event_source *heads_changed_source;
Louis-Francis Ratté-Bouliannec4689ff2017-11-28 20:42:47 -05001113
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05001114 /* Touchscreen calibrator support: */
Louis-Francis Ratté-Bouliannec4689ff2017-11-28 20:42:47 -05001115 enum weston_touch_mode touch_mode;
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05001116 struct wl_global *touch_calibration;
1117 weston_touch_calibration_save_func touch_calibration_save;
1118 struct weston_layer calibrator_layer;
1119 struct weston_touch_calibrator *touch_calibrator;
Pekka Paalanena5630ea2017-10-12 13:13:42 +02001120
Marius Vlad3d7d9782019-04-17 12:35:38 +03001121 struct weston_log_context *weston_log_ctx;
Marius Vlad5d5e3352019-04-17 13:05:38 +03001122 struct weston_log_scope *debug_scene;
Marius Vladda104eb2019-09-05 14:31:01 +03001123 struct weston_log_scope *timeline;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301124
1125 struct content_protection *content_protection;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001126};
1127
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001128struct weston_buffer {
1129 struct wl_resource *resource;
1130 struct wl_signal destroy_signal;
1131 struct wl_listener destroy_listener;
1132
1133 union {
1134 struct wl_shm_buffer *shm_buffer;
Jason Ekstranda85118c2013-06-27 20:17:02 -05001135 void *legacy_buffer;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001136 };
1137 int32_t width, height;
1138 uint32_t busy_count;
Stanislav Vorobiovbfbb8e52013-08-29 11:36:44 +04001139 int y_inverted;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001140};
1141
Pekka Paalanende685b82012-12-04 15:58:12 +02001142struct weston_buffer_reference {
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001143 struct weston_buffer *buffer;
Pekka Paalanende685b82012-12-04 15:58:12 +02001144 struct wl_listener destroy_listener;
1145};
1146
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001147struct weston_buffer_viewport {
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001148 struct {
1149 /* wl_surface.set_buffer_transform */
1150 uint32_t transform;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001151
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001152 /* wl_surface.set_scaling_factor */
1153 int32_t scale;
Jonny Lamb74130762013-11-26 18:19:46 +01001154
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001155 /*
1156 * If src_width != wl_fixed_from_int(-1),
1157 * then and only then src_* are used.
1158 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001159 wl_fixed_t src_x, src_y;
1160 wl_fixed_t src_width, src_height;
1161 } buffer;
1162
1163 struct {
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001164 /*
1165 * If width == -1, the size is inferred from the buffer.
1166 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001167 int32_t width, height;
1168 } surface;
George Kiagiadakis8f9e87f2014-06-13 18:14:20 +02001169
1170 int changed;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001171};
1172
Alexandros Frantzis67629672018-10-19 12:14:11 +03001173struct weston_buffer_release {
1174 /* The associated zwp_linux_buffer_release_v1 resource. */
1175 struct wl_resource *resource;
1176 /* How many weston_buffer_release_reference objects point to this
1177 * object. */
1178 uint32_t ref_count;
1179 /* The fence fd, if any, associated with this release. If the fence fd
1180 * is -1 then this is considered an immediate release. */
1181 int fence_fd;
1182};
1183
1184struct weston_buffer_release_reference {
1185 struct weston_buffer_release *buffer_release;
1186 /* Listener for the destruction of the wl_resource associated with the
1187 * referenced buffer_release object. */
1188 struct wl_listener destroy_listener;
1189};
1190
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001191struct weston_region {
Jason Ekstrand8895efc2013-06-14 10:07:56 -05001192 struct wl_resource *resource;
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001193 pixman_region32_t region;
1194};
1195
Jason Ekstranda7af7042013-10-12 22:38:11 -05001196/* Using weston_view transformations
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001197 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001198 * To add a transformation to a view, create a struct weston_transform, and
1199 * add it to the list view->geometry.transformation_list. Whenever you
1200 * change the list, anything under view->geometry, or anything in the
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001201 * weston_transforms linked into the list, you must call
Jason Ekstranda7af7042013-10-12 22:38:11 -05001202 * weston_view_geometry_dirty().
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001203 *
1204 * The order in the list defines the order of transformations. Let the list
1205 * contain the transformation matrices M1, ..., Mn as head to tail. The
Jason Ekstranda7af7042013-10-12 22:38:11 -05001206 * transformation is applied to view-local coordinate vector p as
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001207 * P = Mn * ... * M2 * M1 * p
1208 * to produce the global coordinate vector P. The total transform
1209 * Mn * ... * M2 * M1
Jason Ekstranda7af7042013-10-12 22:38:11 -05001210 * is cached in view->transform.matrix, and the inverse of it in
1211 * view->transform.inverse.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001212 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001213 * The list always contains view->transform.position transformation, which
1214 * is the translation by view->geometry.x and y.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001215 *
1216 * If you want to apply a transformation in local coordinates, add your
1217 * weston_transform to the head of the list. If you want to apply a
1218 * transformation in global coordinates, add it to the tail of the list.
Pekka Paalanen483243f2013-03-08 14:56:50 +02001219 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001220 * If view->geometry.parent is set, the total transformation of this
1221 * view will be the parent's total transformation and this transformation
Pekka Paalanen483243f2013-03-08 14:56:50 +02001222 * combined:
1223 * Mparent * Mn * ... * M2 * M1
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001224 */
1225
Jason Ekstranda7af7042013-10-12 22:38:11 -05001226struct weston_view {
1227 struct weston_surface *surface;
1228 struct wl_list surface_link;
Jason Ekstrand26ed73c2013-06-06 22:34:41 -05001229 struct wl_signal destroy_signal;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001230
Pekka Paalanen20c7e552016-03-30 14:08:24 +03001231 struct wl_list link; /* weston_compositor::view_list */
Pekka Paalanen8844bf22015-02-18 16:30:47 +02001232 struct weston_layer_entry layer_link; /* part of geometry */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001233 struct weston_plane *plane;
Pekka Paalanen2d6e5512015-02-18 16:06:46 +02001234
1235 /* For weston_layer inheritance from another view */
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001236 struct weston_view *parent_view;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001237
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001238 unsigned int click_to_activate_serial;
1239
Pekka Paalanen51723d52015-02-17 13:10:01 +02001240 pixman_region32_t clip; /* See weston_view_damage_below() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001241 float alpha; /* part of geometry, see below */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001242
John Kåre Alsaker878f4492012-11-13 19:10:23 +01001243 void *renderer_state;
1244
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001245 /* Surface geometry state, mutable.
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001246 * If you change anything, call weston_surface_geometry_dirty().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001247 * That includes the transformations referenced from the list.
1248 */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001249 struct {
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001250 float x, y; /* surface translation on display */
Pekka Paalanenba3cf952012-01-25 16:22:05 +02001251
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001252 /* struct weston_transform */
1253 struct wl_list transformation_list;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001254
1255 /* managed by weston_surface_set_transform_parent() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001256 struct weston_view *parent;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001257 struct wl_listener parent_destroy_listener;
1258 struct wl_list child_list; /* geometry.parent_link */
1259 struct wl_list parent_link;
Pekka Paalanen380adf52015-02-16 14:39:11 +02001260
1261 /* managed by weston_view_set_mask() */
1262 bool scissor_enabled;
1263 pixman_region32_t scissor; /* always a simple rect */
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001264 } geometry;
1265
1266 /* State derived from geometry state, read-only.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001267 * This is updated by weston_view_update_transform().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001268 */
1269 struct {
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001270 int dirty;
1271
Pekka Paalanenfbd00f12015-02-19 11:49:18 +02001272 /* Approximations in global coordinates:
1273 * - boundingbox is guaranteed to include the whole view in
1274 * the smallest possible single rectangle.
1275 * - opaque is guaranteed to be fully opaque, though not
1276 * necessarily include all opaque areas.
1277 */
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001278 pixman_region32_t boundingbox;
Pekka Paalanen730d87e2012-02-09 16:39:38 +02001279 pixman_region32_t opaque;
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001280
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001281 /* matrix and inverse are used only if enabled = 1.
1282 * If enabled = 0, use x, y, width, height directly.
1283 */
1284 int enabled;
Pekka Paalanen061b7472012-01-12 15:00:57 +02001285 struct weston_matrix matrix;
Pekka Paalanend1f0ab62012-01-20 10:47:57 +02001286 struct weston_matrix inverse;
Pekka Paalanencd403622012-01-25 13:37:39 +02001287
1288 struct weston_transform position; /* matrix from x, y */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001289 } transform;
1290
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001291 /*
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001292 * The primary output for this view.
1293 * Used for picking the output for driving internal animations on the
1294 * view, inheriting the primary output for related views in shells, etc.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001295 */
1296 struct weston_output *output;
Semi Malinene7a52fb2018-04-26 11:08:10 +02001297 struct wl_listener output_destroy_listener;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001298
Casey Dahlin9074db52012-04-19 22:50:09 -04001299 /*
1300 * A more complete representation of all outputs this surface is
1301 * displayed on.
1302 */
1303 uint32_t output_mask;
Pekka Paalanenbf0e0312014-12-17 16:20:41 +02001304
1305 /* Per-surface Presentation feedback flags, controlled by backend. */
1306 uint32_t psf_flags;
Armin Krezovićf8486c32016-06-30 06:04:28 +02001307
1308 bool is_mapped;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001309};
1310
Jason Ekstrand7b982072014-05-20 14:33:03 -05001311struct weston_surface_state {
1312 /* wl_surface.attach */
1313 int newly_attached;
1314 struct weston_buffer *buffer;
1315 struct wl_listener buffer_destroy_listener;
1316 int32_t sx;
1317 int32_t sy;
1318
1319 /* wl_surface.damage */
Derek Foreman152254b2015-11-26 14:17:48 -06001320 pixman_region32_t damage_surface;
1321 /* wl_surface.damage_buffer */
1322 pixman_region32_t damage_buffer;
Jason Ekstrand7b982072014-05-20 14:33:03 -05001323
1324 /* wl_surface.set_opaque_region */
1325 pixman_region32_t opaque;
1326
1327 /* wl_surface.set_input_region */
1328 pixman_region32_t input;
1329
1330 /* wl_surface.frame */
1331 struct wl_list frame_callback_list;
1332
Pekka Paalanen133e4392014-09-23 22:08:46 -04001333 /* presentation.feedback */
1334 struct wl_list feedback_list;
1335
Jason Ekstrand7b982072014-05-20 14:33:03 -05001336 /* wl_surface.set_buffer_transform */
1337 /* wl_surface.set_scaling_factor */
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001338 /* wp_viewport.set_source */
1339 /* wp_viewport.set_destination */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001340 struct weston_buffer_viewport buffer_viewport;
Alexandros Frantzisacff29b2018-10-19 12:14:11 +03001341
1342 /* zwp_surface_synchronization_v1.set_acquire_fence */
1343 int acquire_fence_fd;
Alexandros Frantzis67629672018-10-19 12:14:11 +03001344
1345 /* zwp_surface_synchronization_v1.get_release */
1346 struct weston_buffer_release_reference buffer_release_ref;
Ankit Nautiyal4b6e73d2019-03-26 13:37:12 +05301347
1348 /* weston_protected_surface.set_type */
1349 enum weston_hdcp_protection desired_protection;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301350
1351 /* weston_protected_surface.enforced/relaxed */
1352 enum weston_surface_protection_mode protection_mode;
Jason Ekstrand7b982072014-05-20 14:33:03 -05001353};
1354
Jonas Ådahlf7deb6a2016-07-22 17:50:26 +08001355struct weston_surface_activation_data {
1356 struct weston_surface *surface;
1357 struct weston_seat *seat;
1358};
1359
Jonas Ådahld3414f22016-07-22 17:56:31 +08001360struct weston_pointer_constraint {
1361 struct wl_list link;
1362
1363 struct weston_surface *surface;
1364 struct weston_view *view;
1365 struct wl_resource *resource;
1366 struct weston_pointer_grab grab;
1367 struct weston_pointer *pointer;
1368 uint32_t lifetime;
1369
1370 pixman_region32_t region;
1371 pixman_region32_t region_pending;
1372 bool region_is_pending;
1373
1374 wl_fixed_t hint_x;
1375 wl_fixed_t hint_y;
1376 wl_fixed_t hint_x_pending;
1377 wl_fixed_t hint_y_pending;
1378 bool hint_is_pending;
1379
1380 struct wl_listener pointer_destroy_listener;
1381 struct wl_listener surface_destroy_listener;
1382 struct wl_listener surface_commit_listener;
1383 struct wl_listener surface_activate_listener;
1384};
1385
Jason Ekstranda7af7042013-10-12 22:38:11 -05001386struct weston_surface {
1387 struct wl_resource *resource;
Pekka Paalanenca790762015-04-17 14:23:38 +03001388 struct wl_signal destroy_signal; /* callback argument: this surface */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001389 struct weston_compositor *compositor;
Jonas Ådahl5d9ca272016-07-22 17:48:03 +08001390 struct wl_signal commit_signal;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001391
1392 /** Damage in local coordinates from the client, for tex upload. */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001393 pixman_region32_t damage;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001394
Jason Ekstranda7af7042013-10-12 22:38:11 -05001395 pixman_region32_t opaque; /* part of geometry, see below */
1396 pixman_region32_t input;
1397 int32_t width, height;
1398 int32_t ref_count;
1399
1400 /* Not for long-term storage. This exists for book-keeping while
1401 * iterating over surfaces and views
1402 */
Derek Foreman060cf112015-11-18 16:32:26 -06001403 bool touched;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001404
1405 void *renderer_state;
1406
1407 struct wl_list views;
1408
1409 /*
1410 * Which output to vsync this surface to.
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001411 * Used to determine whether to send or queue frame events, and for
1412 * other client-visible syncing/throttling tied to the output
1413 * repaint cycle.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001414 */
1415 struct weston_output *output;
1416
1417 /*
1418 * A more complete representation of all outputs this surface is
1419 * displayed on.
1420 */
1421 uint32_t output_mask;
Casey Dahlin9074db52012-04-19 22:50:09 -04001422
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001423 struct wl_list frame_callback_list;
Pekka Paalanen133e4392014-09-23 22:08:46 -04001424 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001425
Pekka Paalanende685b82012-12-04 15:58:12 +02001426 struct weston_buffer_reference buffer_ref;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001427 struct weston_buffer_viewport buffer_viewport;
Pekka Paalanen0b4c5352014-03-14 14:38:17 +02001428 int32_t width_from_buffer; /* before applying viewport */
1429 int32_t height_from_buffer;
Derek Foreman0fd6d4e2014-10-10 09:36:45 -05001430 bool keep_buffer; /* for backends to prevent early release */
Alex Wu8811bf92012-02-28 18:07:54 +08001431
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001432 /* wp_viewport resource for this surface */
Pekka Paalanenb0420ae2014-01-08 15:39:17 +02001433 struct wl_resource *viewport_resource;
Jonny Lamb74130762013-11-26 18:19:46 +01001434
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001435 /* All the pending state, that wl_surface.commit will apply. */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001436 struct weston_surface_state pending;
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001437
Jason Ekstrand1e059042014-10-16 10:55:19 -05001438 /* Matrices representating of the full transformation between
1439 * buffer and surface coordinates. These matrices are updated
1440 * using the weston_surface_build_buffer_matrix function. */
1441 struct weston_matrix buffer_to_surface_matrix;
1442 struct weston_matrix surface_to_buffer_matrix;
1443
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001444 /*
Jasper St. Pierred67b52a2014-04-28 11:19:27 -04001445 * If non-NULL, this function will be called on
1446 * wl_surface::commit after a new buffer has been set up for
1447 * this surface. The integer params are the sx and sy
1448 * parameters supplied to wl_surface::attach.
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001449 */
Quentin Glidic2edc3d52016-08-12 10:41:33 +02001450 void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
1451 void *committed_private;
Pekka Paalanen8274d902014-08-06 19:36:51 +03001452 int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
Pekka Paalanene67858b2013-04-25 13:57:42 +03001453
1454 /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
1455 * Contains also the parent itself as a dummy weston_subsurface,
1456 * if the list is not empty.
1457 */
1458 struct wl_list subsurface_list; /* weston_subsurface::parent_link */
1459 struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
Pekka Paalanen50b67472014-10-01 15:02:41 +03001460
1461 /*
1462 * For tracking protocol role assignments. Different roles may
1463 * have the same configure hook, e.g. in shell.c. Configure hook
1464 * may get reset, this will not.
1465 * XXX: map configure functions 1:1 to roles, and never reset it,
1466 * and replace role_name with configure.
1467 */
1468 const char *role_name;
Pekka Paalanenb5026542014-11-12 15:09:24 +02001469
Armin Krezovićf8486c32016-06-30 06:04:28 +02001470 bool is_mapped;
Philipp Zabel195dade2018-09-03 19:44:59 +02001471 bool is_opaque;
Jonas Ådahld3414f22016-07-22 17:56:31 +08001472
1473 /* An list of per seat pointer constraints. */
1474 struct wl_list pointer_constraints;
Alexandros Frantzis27d7c392018-10-19 12:14:11 +03001475
1476 /* zwp_surface_synchronization_v1 resource for this surface */
1477 struct wl_resource *synchronization_resource;
Alexandros Frantzisacff29b2018-10-19 12:14:11 +03001478 int acquire_fence_fd;
Alexandros Frantzis67629672018-10-19 12:14:11 +03001479 struct weston_buffer_release_reference buffer_release_ref;
Ankit Nautiyal4b6e73d2019-03-26 13:37:12 +05301480
1481 enum weston_hdcp_protection desired_protection;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301482 enum weston_hdcp_protection current_protection;
1483 enum weston_surface_protection_mode protection_mode;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001484};
1485
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001486struct weston_subsurface {
1487 struct wl_resource *resource;
1488
1489 /* guaranteed to be valid and non-NULL */
1490 struct weston_surface *surface;
1491 struct wl_listener surface_destroy_listener;
1492
1493 /* can be NULL */
1494 struct weston_surface *parent;
1495 struct wl_listener parent_destroy_listener;
1496 struct wl_list parent_link;
1497 struct wl_list parent_link_pending;
1498
1499 struct {
1500 int32_t x;
1501 int32_t y;
1502 int set;
1503 } position;
1504
Jason Ekstrand7b982072014-05-20 14:33:03 -05001505 int has_cached_data;
1506 struct weston_surface_state cached;
1507 struct weston_buffer_reference cached_buffer_ref;
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001508
Emilio Pozuelo Monfort4f3cad72017-01-27 17:30:29 +01001509 /* Sub-surface has been reordered; need to apply damage. */
1510 bool reordered;
1511
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001512 int synchronized;
1513
1514 /* Used for constructing the view tree */
1515 struct wl_list unused_views;
1516};
1517
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301518struct protected_surface {
1519 struct weston_surface *surface;
1520 struct wl_listener surface_destroy_listener;
1521 struct wl_list link;
1522 struct wl_resource *protection_resource;
1523 struct content_protection *cp_backptr;
1524};
1525
1526struct content_protection {
1527 struct weston_compositor *compositor;
1528 struct wl_listener destroy_listener;
1529 struct weston_log_scope *debug;
1530 struct wl_list protected_list;
Ankit Nautiyalf74c35b2019-04-03 19:21:58 +05301531 struct wl_event_source *surface_protection_update;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301532};
1533
1534
Daniel Stoned6da09e2012-06-22 13:21:29 +01001535enum weston_key_state_update {
1536 STATE_UPDATE_AUTOMATIC,
1537 STATE_UPDATE_NONE,
1538};
1539
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001540enum weston_activate_flag {
1541 WESTON_ACTIVATE_FLAG_NONE = 0,
1542 WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001543 WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001544};
1545
Kristian Høgsberg9ddb8262012-01-04 21:30:29 -05001546void
Kristian Høgsbergaf4f2aa2013-02-15 20:53:20 -05001547weston_version(int *major, int *minor, int *micro);
1548
1549void
Semi Malinene7a52fb2018-04-26 11:08:10 +02001550weston_view_set_output(struct weston_view *view, struct weston_output *output);
1551
1552void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001553weston_view_update_transform(struct weston_view *view);
Pekka Paalanen460099f2012-01-20 16:48:25 +02001554
1555void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001556weston_view_geometry_dirty(struct weston_view *view);
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001557
1558void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001559weston_view_to_global_float(struct weston_view *view,
1560 float sx, float sy, float *x, float *y);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001561
1562void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001563weston_view_from_global(struct weston_view *view,
1564 int32_t x, int32_t y, int32_t *vx, int32_t *vy);
Daniel Stonebd3489b2012-05-08 17:17:53 +01001565void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001566weston_view_from_global_fixed(struct weston_view *view,
1567 wl_fixed_t x, wl_fixed_t y,
1568 wl_fixed_t *vx, wl_fixed_t *vy);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001569
Derek Foremand1be3122014-09-18 16:46:49 -05001570void
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001571weston_view_activate(struct weston_view *view,
1572 struct weston_seat *seat,
1573 uint32_t flags);
1574
1575void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001576notify_modifiers(struct weston_seat *seat, uint32_t serial);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001577
1578void
Giulio Camuffo412e6a52014-07-09 22:12:56 +03001579weston_layer_entry_insert(struct weston_layer_entry *list,
1580 struct weston_layer_entry *entry);
1581void
1582weston_layer_entry_remove(struct weston_layer_entry *entry);
1583void
Quentin Glidic82681572016-12-17 13:40:51 +01001584weston_layer_init(struct weston_layer *layer,
1585 struct weston_compositor *compositor);
1586void
1587weston_layer_set_position(struct weston_layer *layer,
1588 enum weston_layer_position position);
1589void
1590weston_layer_unset_position(struct weston_layer *layer);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001591
1592void
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001593weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
1594
1595void
1596weston_layer_set_mask_infinite(struct weston_layer *layer);
1597
Daniel Stone3b775632018-07-20 08:38:25 +01001598bool
1599weston_layer_mask_is_infinite(struct weston_layer *layer);
1600
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001601/* An invalid flag in presented_flags to catch logic errors. */
Pekka Paalanenb00c79b2016-02-18 16:53:27 +02001602#define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31)
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001603
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001604void
Kristian Høgsberg49952d12012-06-20 00:35:59 -04001605weston_output_schedule_repaint(struct weston_output *output);
1606void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001607weston_compositor_schedule_repaint(struct weston_compositor *compositor);
1608void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001609weston_compositor_damage_all(struct weston_compositor *compositor);
1610void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001611weston_compositor_wake(struct weston_compositor *compositor);
1612void
Ander Conselvan de Oliveira87524b62013-02-21 18:35:22 +02001613weston_compositor_sleep(struct weston_compositor *compositor);
Jason Ekstranda7af7042013-10-12 22:38:11 -05001614struct weston_view *
1615weston_compositor_pick_view(struct weston_compositor *compositor,
1616 wl_fixed_t x, wl_fixed_t y,
1617 wl_fixed_t *sx, wl_fixed_t *sy);
Ander Conselvan de Oliveira30eebc72012-02-15 17:02:57 +02001618
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001619
1620struct weston_binding;
Derek Foreman8ae2db52015-07-15 13:00:36 -05001621typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001622 const struct timespec *time,
1623 uint32_t key,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001624 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001625struct weston_binding *
Daniel Stone325fc2d2012-05-30 16:31:58 +01001626weston_compositor_add_key_binding(struct weston_compositor *compositor,
1627 uint32_t key,
1628 enum weston_keyboard_modifier modifier,
1629 weston_key_binding_handler_t binding,
1630 void *data);
Marius Vlad3ee9d8e2019-07-18 11:01:51 +03001631struct weston_binding *
1632weston_compositor_add_debug_binding(struct weston_compositor *compositor,
1633 uint32_t key,
1634 weston_key_binding_handler_t binding,
1635 void *data);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001636
Derek Foreman8ae2db52015-07-15 13:00:36 -05001637typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
Daniel Stone96d47c02013-11-19 11:37:12 +01001638 enum weston_keyboard_modifier modifier,
1639 void *data);
1640struct weston_binding *
1641weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
1642 enum weston_keyboard_modifier modifier,
1643 weston_modifier_binding_handler_t binding,
1644 void *data);
1645
Derek Foreman8ae2db52015-07-15 13:00:36 -05001646typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001647 const struct timespec *time,
1648 uint32_t button,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001649 void *data);
1650struct weston_binding *
1651weston_compositor_add_button_binding(struct weston_compositor *compositor,
1652 uint32_t button,
1653 enum weston_keyboard_modifier modifier,
1654 weston_button_binding_handler_t binding,
1655 void *data);
1656
Derek Foreman8ae2db52015-07-15 13:00:36 -05001657typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001658 const struct timespec *time,
Neil Robertsa28c6932013-10-03 16:43:04 +01001659 void *data);
1660struct weston_binding *
1661weston_compositor_add_touch_binding(struct weston_compositor *compositor,
1662 enum weston_keyboard_modifier modifier,
1663 weston_touch_binding_handler_t binding,
1664 void *data);
1665
Derek Foreman8ae2db52015-07-15 13:00:36 -05001666typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +02001667 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001668 struct weston_pointer_axis_event *event,
1669 void *data);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001670struct weston_binding *
1671weston_compositor_add_axis_binding(struct weston_compositor *compositor,
1672 uint32_t axis,
1673 enum weston_keyboard_modifier modifier,
1674 weston_axis_binding_handler_t binding,
1675 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001676
1677void
sichemec8c8762019-08-23 11:47:44 +00001678weston_binding_destroy(struct weston_binding *binding);
1679
1680void
Pekka Paalanen2829f7c2015-02-19 17:02:13 +02001681weston_install_debug_key_binding(struct weston_compositor *compositor,
1682 uint32_t mod);
1683
1684void
Giulio Camuffocdb4d292013-11-14 23:42:53 +01001685weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
1686 const struct weston_pointer_grab_interface *interface);
1687
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001688struct weston_surface *
Kristian Høgsberg18c93002012-01-27 11:58:31 -05001689weston_surface_create(struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001690
Jason Ekstranda7af7042013-10-12 22:38:11 -05001691struct weston_view *
1692weston_view_create(struct weston_surface *surface);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001693
1694void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001695weston_view_destroy(struct weston_view *view);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001696
1697void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001698weston_view_set_position(struct weston_view *view,
1699 float x, float y);
1700
1701void
1702weston_view_set_transform_parent(struct weston_view *view,
1703 struct weston_view *parent);
1704
Pekka Paalanen380adf52015-02-16 14:39:11 +02001705void
1706weston_view_set_mask(struct weston_view *view,
1707 int x, int y, int width, int height);
1708
1709void
1710weston_view_set_mask_infinite(struct weston_view *view);
1711
Derek Foreman280e7dd2014-10-03 13:13:42 -05001712bool
Jason Ekstranda7af7042013-10-12 22:38:11 -05001713weston_view_is_mapped(struct weston_view *view);
1714
1715void
1716weston_view_schedule_repaint(struct weston_view *view);
Pekka Paalanen483243f2013-03-08 14:56:50 +02001717
Derek Foreman280e7dd2014-10-03 13:13:42 -05001718bool
Ander Conselvan de Oliveirab8ab14f2012-03-27 17:36:36 +03001719weston_surface_is_mapped(struct weston_surface *surface);
1720
Derek Foremand1be3122014-09-18 16:46:49 -05001721void
Jason Ekstrand5c11a332013-12-04 20:32:03 -06001722weston_surface_set_size(struct weston_surface *surface,
1723 int32_t width, int32_t height);
1724
Pekka Paalanen8fb8d3b2012-02-13 13:03:59 +02001725void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001726weston_surface_damage(struct weston_surface *surface);
1727
1728void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001729weston_view_damage_below(struct weston_view *view);
Kristian Høgsbergd8bf90c2012-02-23 23:03:14 -05001730
1731void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001732weston_view_unmap(struct weston_view *view);
1733
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001734void
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001735weston_surface_unmap(struct weston_surface *surface);
1736
Pekka Paalanen01388e22013-04-25 13:57:44 +03001737struct weston_surface *
1738weston_surface_get_main_surface(struct weston_surface *surface);
1739
Pekka Paalanen50b67472014-10-01 15:02:41 +03001740int
1741weston_surface_set_role(struct weston_surface *surface,
1742 const char *role_name,
1743 struct wl_resource *error_resource,
1744 uint32_t error_code);
Quentin Glidic9c5dd7e2016-08-12 10:41:37 +02001745const char *
1746weston_surface_get_role(struct weston_surface *surface);
Pekka Paalanen50b67472014-10-01 15:02:41 +03001747
Pekka Paalanen8274d902014-08-06 19:36:51 +03001748void
1749weston_surface_set_label_func(struct weston_surface *surface,
1750 int (*desc)(struct weston_surface *,
1751 char *, size_t));
1752
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001753void
1754weston_surface_get_content_size(struct weston_surface *surface,
1755 int *width, int *height);
1756
Quentin Glidic248dd102016-08-12 10:41:34 +02001757struct weston_geometry
1758weston_surface_get_bounding_box(struct weston_surface *surface);
1759
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001760int
1761weston_surface_copy_content(struct weston_surface *surface,
1762 void *target, size_t size,
1763 int src_x, int src_y,
1764 int width, int height);
1765
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001766struct weston_buffer *
1767weston_buffer_from_resource(struct wl_resource *resource);
1768
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001769void
Alexandros Frantzis409b01f2017-11-16 18:21:01 +02001770weston_compositor_get_time(struct timespec *time);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001771
Giulio Camuffo459137b2014-10-11 23:56:24 +03001772void
1773weston_compositor_destroy(struct weston_compositor *ec);
Marius Vlad284d5342019-06-24 12:00:47 +03001774
Giulio Camuffo459137b2014-10-11 23:56:24 +03001775struct weston_compositor *
Marius Vlad880b4852019-04-07 17:07:58 +03001776weston_compositor_create(struct wl_display *display,
Marius Vlad3d7d9782019-04-17 12:35:38 +03001777 struct weston_log_context *log_ctx, void *user_data);
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001778
Pekka Paalanen6ffbba32019-11-06 12:59:32 +02001779bool
1780weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor,
1781 struct wl_listener *listener,
1782 wl_notify_func_t destroy_handler);
1783
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001784enum weston_compositor_backend {
1785 WESTON_BACKEND_DRM,
1786 WESTON_BACKEND_FBDEV,
1787 WESTON_BACKEND_HEADLESS,
1788 WESTON_BACKEND_RDP,
1789 WESTON_BACKEND_WAYLAND,
1790 WESTON_BACKEND_X11,
1791};
1792
Pekka Paalanendd186732016-06-03 14:49:54 +03001793int
1794weston_compositor_load_backend(struct weston_compositor *compositor,
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001795 enum weston_compositor_backend backend,
Pekka Paalanendd186732016-06-03 14:49:54 +03001796 struct weston_backend_config *config_base);
Giulio Camuffo459137b2014-10-11 23:56:24 +03001797void
1798weston_compositor_exit(struct weston_compositor *ec);
1799void *
1800weston_compositor_get_user_data(struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001801void
Frederic Plourdec336f062014-10-29 14:44:33 -04001802weston_compositor_exit_with_code(struct weston_compositor *compositor,
1803 int exit_code);
1804void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001805weston_output_update_zoom(struct weston_output *output);
Scott Moreauccbf29d2012-02-22 14:21:41 -07001806void
Derek Foreman22276a52015-07-23 14:55:15 -05001807weston_output_activate_zoom(struct weston_output *output,
1808 struct weston_seat *seat);
Giulio Camuffo412b0242013-11-14 23:42:51 +01001809void
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +02001810weston_output_add_destroy_listener(struct weston_output *output,
1811 struct wl_listener *listener);
1812struct wl_listener *
1813weston_output_get_destroy_listener(struct weston_output *output,
1814 wl_notify_func_t notify);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001815int
Giulio Camuffo0358af42016-06-02 21:48:08 +03001816weston_compositor_set_xkb_rule_names(struct weston_compositor *ec,
1817 struct xkb_rule_names *names);
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001818
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001819/* String literal of spaces, the same width as the timestamp. */
1820#define STAMP_SPACE " "
1821
Marius Vlad35ff4a82019-06-28 14:08:24 +03001822/**
1823 * \ingroup wlog
1824 */
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001825typedef int (*log_func_t)(const char *fmt, va_list ap);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001826void
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001827weston_log_set_handler(log_func_t log, log_func_t cont);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001828int
Pekka Paalanend525b562012-08-06 14:57:04 +03001829weston_log(const char *fmt, ...)
1830 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001831int
Pekka Paalanend525b562012-08-06 14:57:04 +03001832weston_log_continue(const char *fmt, ...)
1833 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001834
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001835enum weston_screenshooter_outcome {
1836 WESTON_SCREENSHOOTER_SUCCESS,
1837 WESTON_SCREENSHOOTER_NO_MEMORY,
1838 WESTON_SCREENSHOOTER_BAD_BUFFER
1839};
1840
1841typedef void (*weston_screenshooter_done_func_t)(void *data,
1842 enum weston_screenshooter_outcome outcome);
1843int
1844weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
1845 weston_screenshooter_done_func_t done, void *data);
Giulio Camuffo26f62d42016-06-02 21:48:09 +03001846struct weston_recorder *
1847weston_recorder_start(struct weston_output *output, const char *filename);
1848void
1849weston_recorder_stop(struct weston_recorder *recorder);
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001850
Jason Ekstranda7af7042013-10-12 22:38:11 -05001851struct weston_view_animation;
1852typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001853
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001854void
1855weston_view_animation_destroy(struct weston_view_animation *animation);
1856
Jason Ekstranda7af7042013-10-12 22:38:11 -05001857struct weston_view_animation *
1858weston_zoom_run(struct weston_view *view, float start, float stop,
1859 weston_view_animation_done_func_t done, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001860
Jason Ekstranda7af7042013-10-12 22:38:11 -05001861struct weston_view_animation *
1862weston_fade_run(struct weston_view *view,
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001863 float start, float end, float k,
Jason Ekstranda7af7042013-10-12 22:38:11 -05001864 weston_view_animation_done_func_t done, void *data);
Daniel Stonea67e6b92013-11-19 11:37:13 +01001865
1866struct weston_view_animation *
1867weston_move_scale_run(struct weston_view *view, int dx, int dy,
Quentin Glidic24d306c2016-08-10 15:53:33 +02001868 float start, float end, bool reverse,
Daniel Stonea67e6b92013-11-19 11:37:13 +01001869 weston_view_animation_done_func_t done, void *data);
1870
Quentin Glidic24d306c2016-08-10 15:53:33 +02001871struct weston_view_animation *
1872weston_move_run(struct weston_view *view, int dx, int dy,
1873 float start, float end, bool reverse,
1874 weston_view_animation_done_func_t done, void *data);
1875
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001876void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001877weston_fade_update(struct weston_view_animation *fade, float target);
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001878
Jason Ekstranda7af7042013-10-12 22:38:11 -05001879struct weston_view_animation *
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001880weston_stable_fade_run(struct weston_view *front_view, float start,
1881 struct weston_view *back_view, float end,
1882 weston_view_animation_done_func_t done, void *data);
1883
1884struct weston_view_animation *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001885weston_slide_run(struct weston_view *view, float start, float stop,
1886 weston_view_animation_done_func_t done, void *data);
Juan Zhaoe10d2792012-04-25 19:09:52 +08001887
Alex Wu8811bf92012-02-28 18:07:54 +08001888void
1889weston_surface_set_color(struct weston_surface *surface,
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001890 float red, float green, float blue, float alpha);
Alex Wu8811bf92012-02-28 18:07:54 +08001891
1892void
1893weston_surface_destroy(struct weston_surface *surface);
1894
Alex Wu2dda6042012-04-17 17:20:47 +08001895int
Derek Foreman6ae7bc92014-11-04 10:47:33 -06001896weston_output_mode_switch_to_temporary(struct weston_output *output,
1897 struct weston_mode *mode,
1898 int32_t scale);
1899int
1900weston_output_mode_switch_to_native(struct weston_output *output);
Alex Wu2dda6042012-04-17 17:20:47 +08001901
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001902int
Quentin Glidic23e1d6f2016-12-02 14:08:44 +01001903weston_backend_init(struct weston_compositor *c,
1904 struct weston_backend_config *config_base);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001905int
Quentin Glidic3d7ca3b2016-12-02 14:20:35 +01001906weston_module_init(struct weston_compositor *compositor);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001907
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +03001908void *
1909weston_load_module(const char *name, const char *entrypoint);
1910
Daniel Stonee03c1112016-11-24 20:45:45 +00001911size_t
1912weston_module_path_from_env(const char *name, char *path, size_t path_len);
1913
Derek Foreman64a3df02014-10-23 12:24:18 -05001914int
1915weston_parse_transform(const char *transform, uint32_t *out);
1916
1917const char *
1918weston_transform_to_string(uint32_t output_transform);
1919
Derek Foreman1281a362015-07-31 16:55:32 -05001920struct weston_keyboard *
1921weston_seat_get_keyboard(struct weston_seat *seat);
1922
1923struct weston_pointer *
1924weston_seat_get_pointer(struct weston_seat *seat);
1925
1926struct weston_touch *
1927weston_seat_get_touch(struct weston_seat *seat);
1928
Bryce Harrington24f917e2016-06-29 19:04:07 -07001929void
1930weston_seat_set_keyboard_focus(struct weston_seat *seat,
1931 struct weston_surface *surface);
1932
Derek Foremanf8f7fd62017-06-28 11:41:43 -05001933void
1934weston_keyboard_send_keymap(struct weston_keyboard *kbd,
1935 struct wl_resource *resource);
1936
Giulio Camuffo9c764df2016-06-29 11:54:27 +02001937int
1938weston_compositor_load_xwayland(struct weston_compositor *compositor);
1939
Pekka Paalanen7fe858b2017-08-14 15:45:14 +03001940bool
1941weston_head_is_connected(struct weston_head *head);
1942
Pekka Paalanen8e552fd2018-02-15 15:18:20 +02001943bool
1944weston_head_is_enabled(struct weston_head *head);
1945
Pekka Paalanene19970f2017-08-28 14:11:02 +03001946bool
1947weston_head_is_device_changed(struct weston_head *head);
1948
Philipp Zabelc18ffd32018-08-30 17:38:03 +02001949bool
1950weston_head_is_non_desktop(struct weston_head *head);
1951
Pekka Paalanene19970f2017-08-28 14:11:02 +03001952void
1953weston_head_reset_device_changed(struct weston_head *head);
1954
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03001955const char *
1956weston_head_get_name(struct weston_head *head);
1957
1958struct weston_output *
1959weston_head_get_output(struct weston_head *head);
1960
Lucas Stacha69cb712019-11-25 23:29:31 +00001961uint32_t
1962weston_head_get_transform(struct weston_head *head);
1963
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03001964void
1965weston_head_detach(struct weston_head *head);
1966
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +03001967void
1968weston_head_add_destroy_listener(struct weston_head *head,
1969 struct wl_listener *listener);
1970
1971struct wl_listener *
1972weston_head_get_destroy_listener(struct weston_head *head,
1973 wl_notify_func_t notify);
1974
Ankit Nautiyal4f64ff82019-04-03 18:44:35 +05301975void
1976weston_head_set_content_protection_status(struct weston_head *head,
1977 enum weston_hdcp_protection status);
1978
Pekka Paalanen1adcbac2017-08-14 16:05:35 +03001979struct weston_head *
1980weston_compositor_iterate_heads(struct weston_compositor *compositor,
1981 struct weston_head *iter);
1982
Pekka Paalanen01f60212017-03-24 15:39:24 +02001983void
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03001984weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor,
1985 struct wl_listener *listener);
1986
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03001987struct weston_output *
Pekka Paalanen1ae9d082017-11-02 14:11:53 +02001988weston_compositor_find_output_by_name(struct weston_compositor *compositor,
1989 const char *name);
1990
1991struct weston_output *
1992weston_compositor_create_output(struct weston_compositor *compositor,
1993 const char *name);
1994
1995struct weston_output *
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03001996weston_compositor_create_output_with_head(struct weston_compositor *compositor,
1997 struct weston_head *head);
1998
1999void
2000weston_output_destroy(struct weston_output *output);
2001
2002int
2003weston_output_attach_head(struct weston_output *output,
2004 struct weston_head *head);
2005
2006struct weston_head *
2007weston_output_iterate_heads(struct weston_output *output,
2008 struct weston_head *iter);
2009
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002010void
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002011weston_output_set_scale(struct weston_output *output,
2012 int32_t scale);
2013
2014void
2015weston_output_set_transform(struct weston_output *output,
2016 uint32_t transform);
2017
2018void
Armin Krezović40087402016-09-30 14:11:12 +02002019weston_output_init(struct weston_output *output,
Pekka Paalanen26ac2e12017-04-03 13:18:13 +03002020 struct weston_compositor *compositor,
2021 const char *name);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002022
sichemb86eb202019-09-13 08:57:31 +00002023void
2024weston_output_move(struct weston_output *output, int x, int y);
2025
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002026int
2027weston_output_enable(struct weston_output *output);
2028
2029void
2030weston_output_disable(struct weston_output *output);
2031
2032void
Pekka Paalanen8a8dcac2017-08-17 17:29:36 +03002033weston_compositor_flush_heads_changed(struct weston_compositor *compositor);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002034
Pekka Paalanen055c1132017-03-27 16:31:25 +03002035struct weston_head *
2036weston_head_from_resource(struct wl_resource *resource);
Pekka Paalanen9ffb2502017-03-27 15:14:32 +03002037
Pekka Paalanencf0a4762017-04-04 16:36:07 +03002038struct weston_head *
2039weston_output_get_first_head(struct weston_output *output);
2040
Ankit Nautiyal2844f8e2019-04-03 10:14:59 +05302041void
2042weston_output_allow_protection(struct weston_output *output,
2043 bool allow_protection);
2044
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05002045int
2046weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor,
2047 weston_touch_calibration_save_func save);
2048
Marius Vlad3d7d9782019-04-17 12:35:38 +03002049struct weston_log_context *
Leandro Ribeiro4f135952020-01-17 11:19:59 -03002050weston_log_ctx_create(void);
Marius Vlad880b4852019-04-07 17:07:58 +03002051
Pekka Paalanena5630ea2017-10-12 13:13:42 +02002052void
Leandro Ribeiro4ec38d12020-01-24 01:12:59 -03002053weston_log_ctx_destroy(struct weston_log_context *log_ctx);
Pekka Paalanena5630ea2017-10-12 13:13:42 +02002054
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05302055int
2056weston_compositor_enable_content_protection(struct weston_compositor *compositor);
2057
Marius Vlad5de92972019-10-15 13:25:41 +03002058void
2059weston_timeline_refresh_subscription_objects(struct weston_compositor *wc,
2060 void *object);
2061
Giulio Camuffo7fe01b12013-03-28 18:02:42 +01002062#ifdef __cplusplus
2063}
2064#endif
2065
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05002066#endif