blob: 07df628540e912876d2be703393dbbe736c8bd4a [file] [log] [blame]
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +03003 * Copyright © 2012, 2017, 2018, 2021 Collabora, Ltd.
Pekka Paalanen925788f2018-04-19 14:20:01 +03004 * 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;
Pekka Paalanen1d2eee22021-02-25 12:03:28 +020082struct weston_color_transform;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050083
Daniel Stone496ca172012-05-30 16:31:42 +010084enum weston_keyboard_modifier {
85 MODIFIER_CTRL = (1 << 0),
86 MODIFIER_ALT = (1 << 1),
87 MODIFIER_SUPER = (1 << 2),
Kristian Høgsberg73694c82012-06-28 14:13:10 -040088 MODIFIER_SHIFT = (1 << 3),
Daniel Stone496ca172012-05-30 16:31:42 +010089};
90
Giulio Camuffo6ef444d2014-08-28 19:44:09 +030091enum weston_keyboard_locks {
92 WESTON_NUM_LOCK = (1 << 0),
93 WESTON_CAPS_LOCK = (1 << 1),
94};
95
Daniel Stone8c8164f2012-05-30 16:31:45 +010096enum weston_led {
97 LED_NUM_LOCK = (1 << 0),
98 LED_CAPS_LOCK = (1 << 1),
99 LED_SCROLL_LOCK = (1 << 2),
100};
101
Ankit Nautiyala21c3932097-03-19 00:24:57 +0530102enum weston_mode_aspect_ratio {
103 /** The picture aspect ratio values, for the aspect_ratio field of
104 * weston_mode. The values here, are taken from
105 * DRM_MODE_PICTURE_ASPECT_* from drm_mode.h.
106 */
107 WESTON_MODE_PIC_AR_NONE = 0, /* DRM_MODE_PICTURE_ASPECT_NONE */
108 WESTON_MODE_PIC_AR_4_3 = 1, /* DRM_MODE_PICTURE_ASPECT_4_3 */
109 WESTON_MODE_PIC_AR_16_9 = 2, /* DRM_MODE_PICTURE_ASPECT_16_9 */
110 WESTON_MODE_PIC_AR_64_27 = 3, /* DRM_MODE_PICTURE_ASPECT_64_27 */
111 WESTON_MODE_PIC_AR_256_135 = 4, /* DRM_MODE_PICTURE_ASPECT_256_135*/
112};
113
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +0530114enum weston_surface_protection_mode {
115 WESTON_SURFACE_PROTECTION_MODE_RELAXED,
116 WESTON_SURFACE_PROTECTION_MODE_ENFORCED
117};
Ankit Nautiyala21c3932097-03-19 00:24:57 +0530118
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500119struct weston_mode {
120 uint32_t flags;
Ankit Nautiyala21c3932097-03-19 00:24:57 +0530121 enum weston_mode_aspect_ratio aspect_ratio;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500122 int32_t width, height;
123 uint32_t refresh;
124 struct wl_list link;
125};
126
Scott Moreaue6603982012-06-11 13:07:51 -0600127struct weston_animation {
128 void (*frame)(struct weston_animation *animation,
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200129 struct weston_output *output,
130 const struct timespec *time);
Scott Moreaue6603982012-06-11 13:07:51 -0600131 int frame_counter;
132 struct wl_list link;
133};
134
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400135enum {
136 WESTON_SPRING_OVERSHOOT,
137 WESTON_SPRING_CLAMP,
138 WESTON_SPRING_BOUNCE
139};
140
Scott Moreaue6603982012-06-11 13:07:51 -0600141struct weston_spring {
142 double k;
143 double friction;
144 double current;
145 double target;
146 double previous;
Kristian Høgsberg091b0962013-06-17 09:23:14 -0400147 double min, max;
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200148 struct timespec timestamp;
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400149 uint32_t clip;
Scott Moreaue6603982012-06-11 13:07:51 -0600150};
151
Scott Moreauccbf29d2012-02-22 14:21:41 -0700152struct weston_output_zoom {
Derek Foremana36eb502015-07-23 14:55:12 -0500153 bool active;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700154 float increment;
155 float level;
Scott Moreaue6603982012-06-11 13:07:51 -0600156 float max_level;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700157 float trans_x, trans_y;
Giulio Camuffo6850e7b2015-10-07 20:14:18 +0300158 struct {
159 double x, y;
160 } current;
Derek Foreman22276a52015-07-23 14:55:15 -0500161 struct weston_seat *seat;
Scott Moreaue6603982012-06-11 13:07:51 -0600162 struct weston_animation animation_z;
163 struct weston_spring spring_z;
Giulio Camuffo412b0242013-11-14 23:42:51 +0100164 struct wl_listener motion_listener;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700165};
166
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200167/* bit compatible with drm definitions. */
168enum dpms_enum {
169 WESTON_DPMS_ON,
170 WESTON_DPMS_STANDBY,
171 WESTON_DPMS_SUSPEND,
172 WESTON_DPMS_OFF
173};
174
Ankit Nautiyal2690a772019-03-25 17:57:59 +0530175/* enum for content protection requests/status
176 *
177 * This enum represents the content protection requests and statuses in
178 * libweston and its enum values correspond to those of 'type' enum defined in
179 * weston-content-protection protocol. The values should exactly match to the
180 * values of the 'type' enum of the protocol.
181 */
182
183enum weston_hdcp_protection {
184 WESTON_HDCP_DISABLE = 0,
185 WESTON_HDCP_ENABLE_TYPE_0,
186 WESTON_HDCP_ENABLE_TYPE_1
187};
188
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -0300189/** Weston test suite quirks
190 *
191 * There are some things that need a specific behavior when we run Weston in the
192 * test suite. Tests can use this struct to select for certain behaviors.
193 *
194 * \sa compositor_setup
195 * \ingroup testharness
196 */
197struct weston_testsuite_quirks {
Pekka Paalanenfbd41602020-12-04 15:20:11 +0200198 /** Force GL-renderer to do a full upload of wl_shm buffers. */
199 bool gl_force_full_upload;
Pekka Paalanenb1e56142020-12-08 14:13:56 +0200200 /** Ensure GL shadow fb is used, and always repaint it fully. */
201 bool gl_force_full_redraw_of_shadow_fb;
Pekka Paalanen19d31dd2021-03-01 11:24:59 +0200202 /** Required enum weston_capability bit mask, otherwise skip run. */
203 uint32_t required_capabilities;
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -0300204};
205
206/** Weston test suite data that is given to compositor
207 *
Leandro Ribeirocdb72182020-11-06 11:24:22 -0300208 * It contains two members:
209 *
210 * 1. The struct weston_testsuite_quirks, which can be used by the tests to
211 * change certain behavior of Weston when running these tests.
212 * 2. The void *test_private_data member which can be used by the testsuite of
213 * projects that uses libweston in order to give arbitrary test data to the
214 * compositor. Its type should be defined by the testsuite of the project.
215 *
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -0300216 * \sa compositor_setup
217 * \ingroup testharness
218 */
219struct weston_testsuite_data {
220 struct weston_testsuite_quirks test_quirks;
Leandro Ribeiro2d4dd702020-10-19 16:24:44 -0300221 void *test_private_data;
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -0300222};
223
Pekka Paalanen9dccfd12020-01-16 17:44:51 +0200224/** Represents a head, usually a display connector
Pekka Paalanen01f60212017-03-24 15:39:24 +0200225 *
Pekka Paalanen9dccfd12020-01-16 17:44:51 +0200226 * \rst
227 See :ref:`libweston-head`. \endrst
Marius Vlad78984ee2019-06-11 00:05:08 +0300228 *
229 * \ingroup head
Pekka Paalanen01f60212017-03-24 15:39:24 +0200230 */
231struct weston_head {
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300232 struct weston_compositor *compositor; /**< owning compositor */
233 struct wl_list compositor_link; /**< in weston_compositor::head_list */
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +0300234 struct wl_signal destroy_signal; /**< destroy callbacks */
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300235
Pekka Paalanen05347622017-03-27 12:24:34 +0300236 struct weston_output *output; /**< the output driving this head */
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300237 struct wl_list output_link; /**< in weston_output::head_list */
Pekka Paalanen05347622017-03-27 12:24:34 +0300238
Pekka Paalanen1b9bf592017-03-27 12:15:38 +0300239 struct wl_list resource_list; /**< wl_output protocol objects */
240 struct wl_global *global; /**< wl_output global */
241
Roman Gilge97391c2019-03-29 13:01:06 +0100242 struct wl_list xdg_output_resource_list; /**< xdg_output protocol objects */
243
Pekka Paalanen01f60212017-03-24 15:39:24 +0200244 int32_t mm_width; /**< physical image width in mm */
245 int32_t mm_height; /**< physical image height in mm */
Lucas Stacha69cb712019-11-25 23:29:31 +0000246
247 /** WL_OUTPUT_TRANSFORM enum to apply to match native orientation */
248 uint32_t transform;
249
Pekka Paalanen01f60212017-03-24 15:39:24 +0200250 char *make; /**< monitor manufacturer (PNP ID) */
251 char *model; /**< monitor model */
252 char *serial_number; /**< monitor serial */
253 uint32_t subpixel; /**< enum wl_output_subpixel */
254 bool connection_internal; /**< embedded monitor (e.g. laptop) */
Pekka Paalanene19970f2017-08-28 14:11:02 +0300255 bool device_changed; /**< monitor information has changed */
Pekka Paalanen9b02e472017-08-14 14:43:13 +0300256
257 char *name; /**< head name, e.g. connector name */
Pekka Paalanen7fe858b2017-08-14 15:45:14 +0300258 bool connected; /**< is physically connected */
Philipp Zabelc18ffd32018-08-30 17:38:03 +0200259 bool non_desktop; /**< non-desktop display, e.g. HMD */
Ankit Nautiyal4f64ff82019-04-03 18:44:35 +0530260
261 /** Current content protection status */
262 enum weston_hdcp_protection current_protection;
Pekka Paalanen01f60212017-03-24 15:39:24 +0200263};
264
Pekka Paalanen9dccfd12020-01-16 17:44:51 +0200265/** Content producer for heads
266 *
267 * \rst
268 See :ref:`libweston-output`. \endrst
Marius Vlad55d87362019-06-11 01:15:35 +0300269 *
270 * \ingroup output
271 */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500272struct weston_output {
Casey Dahlin58ba1372012-04-19 22:50:08 -0400273 uint32_t id;
Richard Hughesafe690c2013-05-02 10:10:04 +0100274 char *name;
Casey Dahlin58ba1372012-04-19 22:50:08 -0400275
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +0200276 /** Matches the lifetime from the user perspective */
277 struct wl_signal user_destroy_signal;
278
John Kåre Alsaker94659272012-11-13 19:10:18 +0100279 void *renderer_state;
280
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500281 struct wl_list link;
282 struct weston_compositor *compositor;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500283
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300284 /* struct weston_paint_node::output_link */
285 struct wl_list paint_node_list;
286
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500287 /** From global to output buffer coordinates. */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500288 struct weston_matrix matrix;
Derek Foremanc0023212015-03-24 11:36:13 -0500289 /** From output buffer to global coordinates. */
290 struct weston_matrix inverse_matrix;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500291
Scott Moreau9d1b1122012-06-08 19:40:53 -0600292 struct wl_list animation_list;
Scott Moreau1bad5db2012-08-18 01:04:05 -0600293 int32_t x, y, width, height;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200294
Pekka Paalanen2fddc532021-04-30 17:41:29 +0300295 /** List of paint nodes in z-order, from top to bottom, maybe pruned
296 *
297 * struct weston_paint_node::z_order_link
298 */
299 struct wl_list paint_node_z_order_list;
300
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200301 /** Output area in global coordinates, simple rect */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500302 pixman_region32_t region;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200303
Daniel Stone09a97e22017-03-01 11:34:06 +0000304 /** True if damage has occurred since the last repaint for this output;
305 * if set, a repaint will eventually occur. */
306 bool repaint_needed;
Daniel Stone05df8c12017-03-03 16:59:42 +0000307
Tomohito Esaki7f4d9ff2018-06-05 10:37:06 +0900308 /** Used only between repaint_begin and repaint_cancel. */
309 bool repainted;
310
Daniel Stone05df8c12017-03-03 16:59:42 +0000311 /** State of the repaint loop */
312 enum {
313 REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */
314 REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */
315 REPAINT_SCHEDULED, /**< repaint is scheduled to occur */
316 REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
317 } repaint_status;
318
Daniel Stone6847b852017-03-01 11:34:08 +0000319 /** If repaint_status is REPAINT_SCHEDULED, contains the time the
320 * next repaint should be run */
321 struct timespec next_repaint;
322
Pekka Paalanendcbcfc72017-10-26 14:33:59 +0300323 /** For cancelling the idle_repaint callback on output destruction. */
324 struct wl_event_source *idle_repaint_source;
325
Scott Moreauccbf29d2012-02-22 14:21:41 -0700326 struct weston_output_zoom zoom;
327 int dirty;
Kristian Høgsberg5fb70bf2012-05-24 12:29:46 -0400328 struct wl_signal frame_signal;
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +0200329 struct wl_signal destroy_signal; /**< sent when disabled */
Zhang, Xiong Yf3012412013-12-13 22:10:53 +0200330 int move_x, move_y;
Alexandros Frantzise6ac2af2017-11-16 18:20:53 +0200331 struct timespec frame_time; /* presentation timestamp */
Pekka Paalanen641307c2014-09-23 22:08:47 -0400332 uint64_t msc; /* media stream counter */
Kristian Høgsberg79af73e2012-08-03 15:45:23 -0400333 int disable_planes;
Ander Conselvan de Oliveirae1e23522013-12-13 22:10:55 +0200334 int destroying;
Pekka Paalanen133e4392014-09-23 22:08:46 -0400335 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500336
Kristian Høgsberg05890dc2012-08-10 10:09:20 -0400337 uint32_t transform;
Hardening57388e42013-09-18 23:56:36 +0200338 int32_t native_scale;
Hardeningff39efa2013-09-18 23:56:35 +0200339 int32_t current_scale;
Hardening57388e42013-09-18 23:56:36 +0200340 int32_t original_scale;
Alexander Larsson4ea95522013-05-22 14:41:37 +0200341
Hardening57388e42013-09-18 23:56:36 +0200342 struct weston_mode *native_mode;
Hardeningff39efa2013-09-18 23:56:35 +0200343 struct weston_mode *current_mode;
344 struct weston_mode *original_mode;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500345 struct wl_list mode_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500346
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300347 struct wl_list head_list; /**< List of driven weston_heads */
Pekka Paalanen01f60212017-03-24 15:39:24 +0200348
Ankit Nautiyal2690a772019-03-25 17:57:59 +0530349 enum weston_hdcp_protection desired_protection;
Ankit Nautiyal4f64ff82019-04-03 18:44:35 +0530350 enum weston_hdcp_protection current_protection;
Ankit Nautiyal2844f8e2019-04-03 10:14:59 +0530351 bool allow_protection;
Ankit Nautiyal2690a772019-03-25 17:57:59 +0530352
Antonio Borneoc90fccc2019-06-30 15:51:10 +0200353 int (*start_repaint_loop)(struct weston_output *output);
David Herrmann1edf44c2013-10-22 17:11:26 +0200354 int (*repaint)(struct weston_output *output,
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000355 pixman_region32_t *damage,
356 void *repaint_data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500357 void (*destroy)(struct weston_output *output);
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000358 void (*assign_planes)(struct weston_output *output, void *repaint_data);
Alex Wu2dda6042012-04-17 17:20:47 +0800359 int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200360
Tiago Vignatti5ab91ad2012-03-12 19:40:09 -0300361 /* backlight values are on 0-255 range, where higher is brighter */
Kristian Høgsberg7c609122013-05-23 20:30:26 -0400362 int32_t backlight_current;
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200363 void (*set_backlight)(struct weston_output *output, uint32_t value);
364 void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
Richard Hughese7299962013-05-01 21:52:12 +0100365
366 uint16_t gamma_size;
367 void (*set_gamma)(struct weston_output *output,
368 uint16_t size,
369 uint16_t *r,
370 uint16_t *g,
371 uint16_t *b);
Pekka Paalanenb5026542014-11-12 15:09:24 +0200372
Pekka Paalanen7f340ff2017-03-30 14:56:22 +0300373 bool enabled; /**< is in the output_list, not pending list */
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200374 int scale;
375
Pekka Paalanencda39512021-03-22 17:32:07 +0200376 struct weston_color_transform *from_sRGB_to_output;
Pekka Paalanen8fb23ed2021-03-23 13:40:43 +0200377 struct weston_color_transform *from_sRGB_to_blend;
Pekka Paalanen1d2eee22021-02-25 12:03:28 +0200378 struct weston_color_transform *from_blend_to_output;
379 bool from_blend_to_output_by_backend;
Pekka Paalanenb5265af2020-12-02 11:57:58 +0200380
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200381 int (*enable)(struct weston_output *output);
382 int (*disable)(struct weston_output *output);
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300383
384 /** Attach a head in the backend
385 *
386 * @param output The output to attach to.
387 * @param head The head to attach.
388 * @return 0 on success, -1 on failure.
389 *
390 * Do anything necessary to account for a new head being attached to
391 * the output, and check any conditions possible. On failure, both
392 * the head and the output must be left as before the call.
393 *
394 * Libweston core will add the head to the head_list after a successful
395 * call.
396 */
397 int (*attach_head)(struct weston_output *output,
398 struct weston_head *head);
399
400 /** Detach a head in the backend
401 *
402 * @param output The output to detach from.
403 * @param head The head to detach.
404 *
405 * Do any clean-up necessary to detach this head from the output.
406 * The head has already been removed from the output's head_list.
407 */
408 void (*detach_head)(struct weston_output *output,
409 struct weston_head *head);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500410};
411
Jonas Ådahld2510102014-10-05 21:39:14 +0200412enum weston_pointer_motion_mask {
413 WESTON_POINTER_MOTION_ABS = 1 << 0,
414 WESTON_POINTER_MOTION_REL = 1 << 1,
Jonas Ådahl3845b322014-10-21 23:51:29 +0200415 WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2,
Jonas Ådahld2510102014-10-05 21:39:14 +0200416};
417
418struct weston_pointer_motion_event {
419 uint32_t mask;
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200420 struct timespec time;
Jonas Ådahld2510102014-10-05 21:39:14 +0200421 double x;
422 double y;
423 double dx;
424 double dy;
Jonas Ådahl3845b322014-10-21 23:51:29 +0200425 double dx_unaccel;
426 double dy_unaccel;
Jonas Ådahld2510102014-10-05 21:39:14 +0200427};
428
Peter Hutterer89b6a492016-01-18 15:58:17 +1000429struct weston_pointer_axis_event {
430 uint32_t axis;
Giulio Camuffo90a6fc62016-03-22 17:44:54 +0200431 double value;
Peter Hutterer87743e92016-01-18 16:38:22 +1000432 bool has_discrete;
433 int32_t discrete;
Peter Hutterer89b6a492016-01-18 15:58:17 +1000434};
435
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400436struct weston_pointer_grab;
437struct weston_pointer_grab_interface {
Kristian Høgsberg6848c252013-05-08 22:02:59 -0400438 void (*focus)(struct weston_pointer_grab *grab);
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200439 void (*motion)(struct weston_pointer_grab *grab,
440 const struct timespec *time,
Jonas Ådahld2510102014-10-05 21:39:14 +0200441 struct weston_pointer_motion_event *event);
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400442 void (*button)(struct weston_pointer_grab *grab,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200443 const struct timespec *time,
444 uint32_t button, uint32_t state);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200445 void (*axis)(struct weston_pointer_grab *grab,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200446 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000447 struct weston_pointer_axis_event *event);
Peter Hutterer87743e92016-01-18 16:38:22 +1000448 void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
449 void (*frame)(struct weston_pointer_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200450 void (*cancel)(struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400451};
452
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400453struct weston_pointer_grab {
454 const struct weston_pointer_grab_interface *interface;
455 struct weston_pointer *pointer;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400456};
457
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400458struct weston_keyboard_grab;
459struct weston_keyboard_grab_interface {
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200460 void (*key)(struct weston_keyboard_grab *grab,
461 const struct timespec *time, uint32_t key, uint32_t state);
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400462 void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400463 uint32_t mods_depressed, uint32_t mods_latched,
464 uint32_t mods_locked, uint32_t group);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200465 void (*cancel)(struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400466};
467
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400468struct weston_keyboard_grab {
469 const struct weston_keyboard_grab_interface *interface;
470 struct weston_keyboard *keyboard;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400471};
472
Kristian Høgsberge329f362013-05-06 22:19:57 -0400473struct weston_touch_grab;
474struct weston_touch_grab_interface {
475 void (*down)(struct weston_touch_grab *grab,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200476 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400477 int touch_id,
478 wl_fixed_t sx,
479 wl_fixed_t sy);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400480 void (*up)(struct weston_touch_grab *grab,
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200481 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400482 int touch_id);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400483 void (*motion)(struct weston_touch_grab *grab,
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200484 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400485 int touch_id,
486 wl_fixed_t sx,
487 wl_fixed_t sy);
Jonas Ådahl1679f232014-04-12 09:39:51 +0200488 void (*frame)(struct weston_touch_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200489 void (*cancel)(struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400490};
491
Kristian Høgsberge329f362013-05-06 22:19:57 -0400492struct weston_touch_grab {
493 const struct weston_touch_grab_interface *interface;
494 struct weston_touch *touch;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400495};
496
Kristian Høgsberg5e76a492013-07-25 16:09:37 -0700497struct weston_data_offer {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500498 struct wl_resource *resource;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700499 struct weston_data_source *source;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400500 struct wl_listener source_destroy_listener;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100501 uint32_t dnd_actions;
502 enum wl_data_device_manager_dnd_action preferred_dnd_action;
503 bool in_ask;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400504};
505
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700506struct weston_data_source {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500507 struct wl_resource *resource;
508 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400509 struct wl_array mime_types;
Carlos Garnacho78d4bf92016-01-15 21:14:23 +0100510 struct weston_data_offer *offer;
511 struct weston_seat *seat;
512 bool accepted;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100513 bool actions_set;
Harish Krupo737ac0d2019-04-19 22:06:37 +0530514 bool set_selection;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100515 uint32_t dnd_actions;
516 enum wl_data_device_manager_dnd_action current_dnd_action;
Carlos Garnachob2889882016-01-15 21:14:26 +0100517 enum wl_data_device_manager_dnd_action compositor_action;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400518
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700519 void (*accept)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400520 uint32_t serial, const char *mime_type);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700521 void (*send)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400522 const char *mime_type, int32_t fd);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700523 void (*cancel)(struct weston_data_source *source);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400524};
525
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800526struct weston_pointer_client {
527 struct wl_list link;
528 struct wl_client *client;
529 struct wl_list pointer_resources;
Jonas Ådahl30d61d82014-10-22 21:21:17 +0200530 struct wl_list relative_pointer_resources;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800531};
532
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400533struct weston_pointer {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400534 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400535
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800536 struct wl_list pointer_clients;
537
Jason Ekstranda7af7042013-10-12 22:38:11 -0500538 struct weston_view *focus;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800539 struct weston_pointer_client *focus_client;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400540 uint32_t focus_serial;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100541 struct wl_listener focus_view_listener;
542 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400543 struct wl_signal focus_signal;
Giulio Camuffo6fcb3782013-11-14 23:42:50 +0100544 struct wl_signal motion_signal;
Jonas Ådahl3eb4ddd2016-07-22 17:52:58 +0800545 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400546
Jason Ekstranda7af7042013-10-12 22:38:11 -0500547 struct weston_view *sprite;
Kristian Høgsberg195b8692013-05-08 15:02:05 -0400548 struct wl_listener sprite_destroy_listener;
549 int32_t hotspot_x, hotspot_y;
550
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400551 struct weston_pointer_grab *grab;
552 struct weston_pointer_grab default_grab;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400553 wl_fixed_t grab_x, grab_y;
554 uint32_t grab_button;
555 uint32_t grab_serial;
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200556 struct timespec grab_time;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400557
558 wl_fixed_t x, y;
Kristian Høgsbergdb1fccb2014-02-05 17:14:42 -0800559 wl_fixed_t sx, sy;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400560 uint32_t button_count;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +0200561
562 struct wl_listener output_destroy_listener;
Alexandros Frantzisdb907b72018-02-20 14:06:26 +0200563
564 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400565};
566
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500567/** libinput style calibration matrix
568 *
569 * See https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html
570 * and libinput_device_config_calibration_set_matrix().
571 */
572struct weston_touch_device_matrix {
573 float m[6];
574};
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400575
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500576struct weston_touch_device;
577
578/** Operations for a calibratable touchscreen */
579struct weston_touch_device_ops {
580 /** Get the associated output if existing. */
581 struct weston_output *(*get_output)(struct weston_touch_device *device);
582
583 /** Get the name of the associated head if existing. */
584 const char *
585 (*get_calibration_head_name)(struct weston_touch_device *device);
586
587 /** Retrieve the current calibration matrix. */
588 void (*get_calibration)(struct weston_touch_device *device,
589 struct weston_touch_device_matrix *cal);
590
591 /** Set a new calibration matrix. */
592 void (*set_calibration)(struct weston_touch_device *device,
593 const struct weston_touch_device_matrix *cal);
594};
595
Louis-Francis Ratté-Bouliannec4689ff2017-11-28 20:42:47 -0500596enum weston_touch_mode {
597 /** Normal touch event handling */
598 WESTON_TOUCH_MODE_NORMAL,
599
600 /** Prepare moving to WESTON_TOUCH_MODE_CALIB.
601 *
602 * Move to WESTON_TOUCH_MODE_CALIB as soon as no touches are down on
603 * any seat. Until then, all touch events are routed normally.
604 */
605 WESTON_TOUCH_MODE_PREP_CALIB,
606
607 /** Calibration mode
608 *
609 * Only a single weston_touch_device forwards events to the calibrator
610 * all other touch device cause a calibrator "wrong device" event to
611 * be sent.
612 */
613 WESTON_TOUCH_MODE_CALIB,
614
615 /** Prepare moving to WESTON_TOUCH_MODE_NORMAL.
616 *
617 * Move to WESTON_TOUCH_MODE_NORMAL as soon as no touches are down on
618 * any seat. Until then, touch events are routed as in
619 * WESTON_TOUCH_MODE_CALIB except "wrong device" events are not sent.
620 */
621 WESTON_TOUCH_MODE_PREP_NORMAL
622};
623
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500624/** Represents a physical touchscreen input device */
625struct weston_touch_device {
626 char *syspath; /**< unique name */
627
628 struct weston_touch *aggregate; /**< weston_touch this is part of */
629 struct wl_list link; /**< in weston_touch::device_list */
630 struct wl_signal destroy_signal; /**< destroy notifier */
631
632 void *backend_data; /**< backend-specific private */
633
634 const struct weston_touch_device_ops *ops;
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -0500635 struct weston_touch_device_matrix saved_calibration;
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500636};
637
638/** Represents a set of touchscreen devices aggregated under a seat */
Kristian Høgsberge329f362013-05-06 22:19:57 -0400639struct weston_touch {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400640 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400641
Louis-Francis Ratté-Boulianne6ef59c92017-11-28 20:42:47 -0500642 struct wl_list device_list; /* struct weston_touch_device::link */
643
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400644 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100645 struct wl_list focus_resource_list;
Jason Ekstranda7af7042013-10-12 22:38:11 -0500646 struct weston_view *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100647 struct wl_listener focus_view_listener;
648 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400649 uint32_t focus_serial;
650 struct wl_signal focus_signal;
651
Jonas Ådahl9484b692013-12-02 22:05:03 +0100652 uint32_t num_tp;
653
Kristian Høgsberge329f362013-05-06 22:19:57 -0400654 struct weston_touch_grab *grab;
655 struct weston_touch_grab default_grab;
Neil Roberts306fe082013-10-03 16:43:06 +0100656 int grab_touch_id;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400657 wl_fixed_t grab_x, grab_y;
658 uint32_t grab_serial;
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200659 struct timespec grab_time;
Alexandros Frantzisd7157842018-02-20 14:07:03 +0200660
661 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400662};
663
Jonas Ådahld2510102014-10-05 21:39:14 +0200664void
665weston_pointer_motion_to_abs(struct weston_pointer *pointer,
666 struct weston_pointer_motion_event *event,
667 wl_fixed_t *x, wl_fixed_t *y);
668
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400669void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200670weston_pointer_send_motion(struct weston_pointer *pointer,
671 const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200672 struct weston_pointer_motion_event *event);
673bool
674weston_pointer_has_focus_resource(struct weston_pointer *pointer);
675void
676weston_pointer_send_button(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200677 const struct timespec *time,
678 uint32_t button, uint32_t state_w);
Quentin Glidiccde13452016-08-12 10:41:32 +0200679void
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200680weston_pointer_send_axis(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200681 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000682 struct weston_pointer_axis_event *event);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200683void
Peter Hutterer87743e92016-01-18 16:38:22 +1000684weston_pointer_send_axis_source(struct weston_pointer *pointer,
685 uint32_t source);
686void
687weston_pointer_send_frame(struct weston_pointer *pointer);
688
689void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400690weston_pointer_set_focus(struct weston_pointer *pointer,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500691 struct weston_view *view,
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400692 wl_fixed_t sx, wl_fixed_t sy);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400693void
Derek Foremanf9318d12015-05-11 15:40:11 -0500694weston_pointer_clear_focus(struct weston_pointer *pointer);
695void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400696weston_pointer_start_grab(struct weston_pointer *pointer,
697 struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400698void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400699weston_pointer_end_grab(struct weston_pointer *pointer);
Rob Bradford806d8c02013-06-25 18:56:41 +0100700void
Giulio Camuffo1959ab82013-11-14 23:42:52 +0100701weston_pointer_move(struct weston_pointer *pointer,
Jonas Ådahld2510102014-10-05 21:39:14 +0200702 struct weston_pointer_motion_event *event);
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100703void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400704weston_keyboard_set_focus(struct weston_keyboard *keyboard,
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400705 struct weston_surface *surface);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400706void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400707weston_keyboard_start_grab(struct weston_keyboard *device,
708 struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400709void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400710weston_keyboard_end_grab(struct weston_keyboard *keyboard);
Giulio Camuffo6ef444d2014-08-28 19:44:09 +0300711int
712/*
713 * 'mask' and 'value' should be a bitwise mask of one or more
714 * valued of the weston_keyboard_locks enum.
715 */
716weston_keyboard_set_locks(struct weston_keyboard *keyboard,
717 uint32_t mask, uint32_t value);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400718
Quentin Glidiccde13452016-08-12 10:41:32 +0200719void
720weston_keyboard_send_key(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200721 const struct timespec *time, uint32_t key,
Quentin Glidiccde13452016-08-12 10:41:32 +0200722 enum wl_keyboard_key_state state);
723void
724weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
725 uint32_t serial, uint32_t mods_depressed,
726 uint32_t mods_latched,
727 uint32_t mods_locked, uint32_t group);
728
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400729void
Derek Foreman4c93c082015-04-30 16:45:41 -0500730weston_touch_set_focus(struct weston_touch *touch,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500731 struct weston_view *view);
Michael Fua2bb7912013-07-23 15:51:06 +0800732void
Louis-Francis Ratté-Boulianne8549e162017-11-28 20:42:47 -0500733weston_touch_start_grab(struct weston_touch *touch,
Kristian Høgsberge329f362013-05-06 22:19:57 -0400734 struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400735void
Kristian Høgsberge329f362013-05-06 22:19:57 -0400736weston_touch_end_grab(struct weston_touch *touch);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400737
Quentin Glidiccde13452016-08-12 10:41:32 +0200738void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200739weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200740 int touch_id, wl_fixed_t x, wl_fixed_t y);
741void
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200742weston_touch_send_up(struct weston_touch *touch, const struct timespec *time,
743 int touch_id);
Quentin Glidiccde13452016-08-12 10:41:32 +0200744void
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200745weston_touch_send_motion(struct weston_touch *touch,
746 const struct timespec *time, int touch_id,
747 wl_fixed_t x, wl_fixed_t y);
Quentin Glidiccde13452016-08-12 10:41:32 +0200748void
749weston_touch_send_frame(struct weston_touch *touch);
750
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400751
752void
Kristian Høgsberge3148752013-05-06 23:19:49 -0400753weston_seat_set_selection(struct weston_seat *seat,
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700754 struct weston_data_source *source, uint32_t serial);
Giulio Camuffodddf9e62015-05-01 12:59:35 +0300755
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700756int
Xiong Zhangfd51e7b2013-11-25 18:42:49 +0800757weston_pointer_start_drag(struct weston_pointer *pointer,
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700758 struct weston_data_source *source,
759 struct weston_surface *icon,
760 struct wl_client *client);
Daniel Stoned65b9092012-05-30 16:32:05 +0100761struct weston_xkb_info {
762 struct xkb_keymap *keymap;
Sebastian Wickabec5122019-11-01 02:38:45 +0100763 struct ro_anonymous_file *keymap_rofile;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +0000764 int32_t ref_count;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100765 xkb_mod_index_t shift_mod;
766 xkb_mod_index_t caps_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100767 xkb_mod_index_t ctrl_mod;
768 xkb_mod_index_t alt_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100769 xkb_mod_index_t mod2_mod;
770 xkb_mod_index_t mod3_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100771 xkb_mod_index_t super_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100772 xkb_mod_index_t mod5_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100773 xkb_led_index_t num_led;
774 xkb_led_index_t caps_led;
775 xkb_led_index_t scroll_led;
776};
777
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100778struct weston_keyboard {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400779 struct weston_seat *seat;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100780
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400781 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100782 struct wl_list focus_resource_list;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400783 struct weston_surface *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100784 struct wl_listener focus_resource_listener;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400785 uint32_t focus_serial;
786 struct wl_signal focus_signal;
787
788 struct weston_keyboard_grab *grab;
789 struct weston_keyboard_grab default_grab;
790 uint32_t grab_key;
791 uint32_t grab_serial;
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200792 struct timespec grab_time;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400793
794 struct wl_array keys;
795
796 struct {
797 uint32_t mods_depressed;
798 uint32_t mods_latched;
799 uint32_t mods_locked;
800 uint32_t group;
801 } modifiers;
802
803 struct weston_keyboard_grab input_method_grab;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100804 struct wl_resource *input_method_resource;
Jonas Ådahl7395ea02013-12-03 09:14:26 +0100805
806 struct weston_xkb_info *xkb_info;
807 struct {
808 struct xkb_state *state;
809 enum weston_led leds;
810 } xkb_state;
811 struct xkb_keymap *pending_keymap;
Alexandros Frantzis2b442482018-02-20 14:05:50 +0200812
813 struct wl_list timestamps_list;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100814};
815
Daniel Stone37816df2012-05-16 18:45:18 +0100816struct weston_seat {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400817 struct wl_list base_resource_list;
818
Kristian Høgsbergaaadc772013-07-08 16:20:31 -0400819 struct wl_global *global;
Derek Foreman1281a362015-07-31 16:55:32 -0500820 struct weston_pointer *pointer_state;
821 struct weston_keyboard *keyboard_state;
822 struct weston_touch *touch_state;
Jonas Ådahld6e1c342013-10-17 23:04:05 +0200823 int pointer_device_count;
824 int keyboard_device_count;
825 int touch_device_count;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400826
Rob Bradford66bd9f52013-06-25 18:56:42 +0100827 struct weston_output *output; /* constraint */
828
Giulio Camuffo5085a752013-03-25 21:42:45 +0100829 struct wl_signal destroy_signal;
Jason Ekstranda4ab5422014-04-02 19:53:45 -0500830 struct wl_signal updated_caps_signal;
Daniel Stone74419a22012-05-30 16:32:02 +0100831
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500832 struct weston_compositor *compositor;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500833 struct wl_list link;
Daniel Stone496ca172012-05-30 16:31:42 +0100834 enum weston_keyboard_modifier modifier_state;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400835 struct weston_surface *saved_kbd_focus;
Ander Conselvan de Oliveira71b1d0c2012-03-16 17:25:11 +0200836 struct wl_listener saved_kbd_focus_listener;
Kristian Høgsberg054c50a2013-05-08 15:27:47 -0400837 struct wl_list drag_resource_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500838
Kristian Høgsberge3148752013-05-06 23:19:49 -0400839 uint32_t selection_serial;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700840 struct weston_data_source *selection_data_source;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400841 struct wl_listener selection_data_source_listener;
842 struct wl_signal selection_signal;
843
Daniel Stone8c8164f2012-05-30 16:31:45 +0100844 void (*led_update)(struct weston_seat *ws, enum weston_led leds);
845
Jan Arne Petersene829adc2012-08-10 16:47:22 +0200846 struct input_method *input_method;
Rob Bradford9af5f9e2013-05-31 18:09:50 +0100847 char *seat_name;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500848};
849
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500850enum {
Emmanuel Gil Peyroteff793a2021-07-31 17:25:41 +0200851 WESTON_COMPOSITOR_ACTIVE, /* normal rendering and events */
852 WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */
853 WESTON_COMPOSITOR_OFFSCREEN, /* no rendering, no frame events */
854 WESTON_COMPOSITOR_SLEEPING /* same as offscreen, but also set dpms
855 * to off */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500856};
857
Giulio Camuffo412e6a52014-07-09 22:12:56 +0300858struct weston_layer_entry {
859 struct wl_list link;
860 struct weston_layer *layer;
861};
862
Quentin Glidic82681572016-12-17 13:40:51 +0100863/**
864 * Higher value means higher in the stack.
865 *
866 * These values are based on well-known concepts in a classic desktop
867 * environment. Third-party modules based on libweston are encouraged to use
868 * them to integrate better with other projects.
869 *
870 * A fully integrated environment can use any value, based on these or not,
871 * at their discretion.
872 */
873enum weston_layer_position {
874 /*
875 * Special value to make the layer invisible and still rendered.
876 * This is used by compositors wanting e.g. minimized surfaces to still
877 * receive frame callbacks.
878 */
879 WESTON_LAYER_POSITION_HIDDEN = 0x00000000,
880
881 /*
882 * There should always be a background layer with a surface covering
883 * the visible area.
884 *
885 * If the compositor handles the background itself, it should use
886 * BACKGROUND.
887 *
888 * If the compositor supports runtime-loadable modules to set the
889 * background, it should put a solid color surface at (BACKGROUND - 1)
890 * and modules must use BACKGROUND.
891 */
892 WESTON_LAYER_POSITION_BACKGROUND = 0x00000002,
893
894 /* For "desktop widgets" and applications like conky. */
895 WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000,
896
897 /* For regular applications, only one layer should have this value
898 * to ensure proper stacking control. */
899 WESTON_LAYER_POSITION_NORMAL = 0x50000000,
900
901 /* For desktop UI, like panels. */
902 WESTON_LAYER_POSITION_UI = 0x80000000,
903
904 /* For fullscreen applications that should cover UI. */
905 WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000,
906
907 /* For special UI like on-screen keyboard that fullscreen applications
908 * will need. */
909 WESTON_LAYER_POSITION_TOP_UI = 0xe0000000,
910
911 /* For the lock surface. */
912 WESTON_LAYER_POSITION_LOCK = 0xffff0000,
913
914 /* Values reserved for libweston internal usage */
915 WESTON_LAYER_POSITION_CURSOR = 0xfffffffe,
916 WESTON_LAYER_POSITION_FADE = 0xffffffff,
917};
918
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500919struct weston_layer {
Quentin Glidic82681572016-12-17 13:40:51 +0100920 struct weston_compositor *compositor;
921 struct wl_list link; /* weston_compositor::layer_list */
922 enum weston_layer_position position;
Giulio Camuffo95ec0f92014-07-09 22:12:57 +0300923 pixman_box32_t mask;
Quentin Glidic82681572016-12-17 13:40:51 +0100924 struct weston_layer_entry view_list;
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500925};
926
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400927struct weston_plane {
Xiong Zhang97116532013-10-23 13:58:31 +0800928 struct weston_compositor *compositor;
Pekka Paalanen502f5e02015-02-23 14:08:25 +0200929 pixman_region32_t damage; /**< in global coords */
Ander Conselvan de Oliveirae1bd5a02013-03-05 17:30:29 +0200930 pixman_region32_t clip;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400931 int32_t x, y;
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +0200932 struct wl_list link;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400933};
934
Leandro Ribeiro1b403262021-03-04 17:47:13 -0300935struct weston_drm_format_array;
936
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400937struct weston_renderer {
John Kåre Alsakera95b2d62012-11-13 19:10:21 +0100938 int (*read_pixels)(struct weston_output *output,
939 pixman_format_code_t format, void *pixels,
940 uint32_t x, uint32_t y,
941 uint32_t width, uint32_t height);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400942 void (*repaint_output)(struct weston_output *output,
943 pixman_region32_t *output_damage);
944 void (*flush_damage)(struct weston_surface *surface);
Jason Ekstrand6bd62942013-06-20 20:38:23 -0500945 void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
John Kåre Alsaker878f4492012-11-13 19:10:23 +0100946 void (*surface_set_color)(struct weston_surface *surface,
947 float red, float green,
948 float blue, float alpha);
Vasily Khoruzhick52cfd612013-01-08 19:09:01 +0300949 void (*destroy)(struct weston_compositor *ec);
Pekka Paalanenc647ed72015-02-09 13:16:57 +0200950
951
952 /** See weston_surface_get_content_size() */
953 void (*surface_get_content_size)(struct weston_surface *surface,
954 int *width, int *height);
955
956 /** See weston_surface_copy_content() */
957 int (*surface_copy_content)(struct weston_surface *surface,
958 void *target, size_t size,
959 int src_x, int src_y,
960 int width, int height);
Pekka Paalanen230f3b12014-09-29 14:18:40 -0400961
962 /** See weston_compositor_import_dmabuf() */
963 bool (*import_dmabuf)(struct weston_compositor *ec,
964 struct linux_dmabuf_buffer *buffer);
Varad Gautam0775cd12016-11-23 14:03:20 +0530965
Leandro Ribeiro1b403262021-03-04 17:47:13 -0300966 const struct weston_drm_format_array *
967 (*get_supported_formats)(struct weston_compositor *ec);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400968};
969
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300970enum weston_capability {
971 /* backend/renderer supports arbitrary rotation */
972 WESTON_CAP_ROTATION_ANY = 0x0001,
Pekka Paalanen4fc5dd02013-05-22 18:03:05 +0300973
974 /* screencaptures need to be y-flipped */
975 WESTON_CAP_CAPTURE_YFLIP = 0x0002,
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500976
Bryce Harringtona86c3ee2015-03-18 18:42:00 -0700977 /* backend/renderer has a separate cursor plane */
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500978 WESTON_CAP_CURSOR_PLANE = 0x0004,
979
980 /* backend supports setting arbitrary resolutions */
981 WESTON_CAP_ARBITRARY_MODES = 0x0008,
Pekka Paalanen380adf52015-02-16 14:39:11 +0200982
983 /* renderer supports weston_view_set_mask() clipping */
984 WESTON_CAP_VIEW_CLIP_MASK = 0x0010,
Alexandros Frantzisacff29b2018-10-19 12:14:11 +0300985
986 /* renderer supports explicit synchronization */
987 WESTON_CAP_EXPLICIT_SYNC = 0x0020,
Pekka Paalanenb5265af2020-12-02 11:57:58 +0200988
989 /* renderer supports color management operations */
990 WESTON_CAP_COLOR_OPS = 0x0040,
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300991};
992
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300993/* Configuration struct for a backend.
994 *
995 * This struct carries the configuration for a backend, and it's
996 * passed to the backend's init entry point. The backend will
997 * likely want to subclass this in order to handle backend specific
998 * data.
Bryce Harrington20b66c32016-04-15 20:28:29 -0700999 *
Marius Vladae263412019-06-06 23:10:49 +03001000 * \rststar
1001 * .. note:
Bryce Harrington20b66c32016-04-15 20:28:29 -07001002 *
Marius Vladae263412019-06-06 23:10:49 +03001003 * Alternate designs were proposed (Feb 2016) for using opaque structures[1]
1004 * and for section+key/value getter/setters[2]. The rationale for selecting
1005 * the transparent structure design is based on several assumptions[3] which
1006 * may require re-evaluating the design choice if they fail to hold.
1007 *
1008 * 1. https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html
1009 * 2. https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html
1010 * 3. https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html
1011 *
1012 * \endrststar
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +03001013 */
1014struct weston_backend_config {
Emmanuel Gil Peyroteff793a2021-07-31 17:25:41 +02001015 /** Major version for the backend-specific config struct
1016 *
1017 * This version must match exactly what the backend expects, otherwise
1018 * the struct is incompatible.
1019 */
1020 uint32_t struct_version;
Bryce Harrington20b66c32016-04-15 20:28:29 -07001021
Emmanuel Gil Peyroteff793a2021-07-31 17:25:41 +02001022 /** Minor version of the backend-specific config struct
1023 *
1024 * This must be set to sizeof(struct backend-specific config).
1025 * If the value here is smaller than what the backend expects, the
1026 * extra config members will assume their default values.
1027 *
1028 * A value greater than what the backend expects is incompatible.
1029 */
1030 size_t struct_size;
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +03001031};
1032
Pekka Paalanene48bfc72019-07-17 00:09:06 +03001033struct weston_backend;
Giulio Camuffo954f1832014-10-11 18:27:30 +03001034
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05001035/** Callback for saving calibration
1036 *
1037 * \param compositor The compositor.
1038 * \param device The physical touch device to save for.
1039 * \param calibration The new calibration from a client.
1040 * \return -1 on failure, 0 on success.
1041 *
1042 * Failure will prevent taking the new calibration into use.
1043 */
1044typedef int (*weston_touch_calibration_save_func)(
1045 struct weston_compositor *compositor,
1046 struct weston_touch_device *device,
1047 const struct weston_touch_device_matrix *calibration);
1048struct weston_touch_calibrator;
1049
Quentin Glidic955cec02016-08-12 10:41:35 +02001050struct weston_desktop_xwayland;
1051struct weston_desktop_xwayland_interface;
Pekka Paalanena5630ea2017-10-12 13:13:42 +02001052struct weston_debug_compositor;
Pekka Paalanen90a5ffa2021-02-25 12:03:28 +02001053struct weston_color_manager;
Quentin Glidic955cec02016-08-12 10:41:35 +02001054
Marius Vlad9fdda7f2019-06-11 16:08:55 +03001055/** Main object, container-like structure which aggregates all other objects.
1056 *
1057 * \ingroup compositor
1058 */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001059struct weston_compositor {
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -04001060 struct wl_signal destroy_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001061
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001062 struct wl_display *wl_display;
Quentin Glidic955cec02016-08-12 10:41:35 +02001063 struct weston_desktop_xwayland *xwayland;
1064 const struct weston_desktop_xwayland_interface *xwayland_interface;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001065
Tiago Vignattifb2adba2013-06-12 15:43:21 -03001066 /* surface signals */
Kristian Høgsbergf03a04a2014-04-06 22:04:50 -07001067 struct wl_signal create_surface_signal;
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -04001068 struct wl_signal activate_signal;
Tiago Vignattifb2adba2013-06-12 15:43:21 -03001069 struct wl_signal transform_signal;
1070
Tiago Vignatti1d01b012012-09-27 17:48:36 +03001071 struct wl_signal kill_signal;
Ander Conselvan de Oliveiraa4575632013-02-21 18:35:23 +02001072 struct wl_signal idle_signal;
1073 struct wl_signal wake_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001074
Jan Arne Petersen42feced2012-06-21 21:52:17 +02001075 struct wl_signal show_input_panel_signal;
1076 struct wl_signal hide_input_panel_signal;
Jan Arne Petersen14da96b2013-04-18 16:47:28 +02001077 struct wl_signal update_input_panel_signal;
Jan Arne Petersen42feced2012-06-21 21:52:17 +02001078
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +01001079 struct wl_signal seat_created_signal;
Richard Hughes59d5da72013-05-01 21:52:11 +01001080 struct wl_signal output_created_signal;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +02001081 struct wl_signal output_destroyed_signal;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +02001082 struct wl_signal output_moved_signal;
David Fort0de859e2016-05-27 23:22:57 +02001083 struct wl_signal output_resized_signal; /* callback argument: resized output */
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +01001084
Pekka Paalanen8dc6db82018-03-20 13:29:40 +02001085 /* Signal for output changes triggered by configuration from frontend
1086 * or head state changes from backend.
1087 */
1088 struct wl_signal output_heads_changed_signal; /* arg: weston_output */
1089
Kristian Høgsberg61741a22013-09-17 16:02:57 -07001090 struct wl_signal session_signal;
Robert Beckettc569bdc2019-07-10 16:40:12 +01001091 bool session_active;
Kristian Høgsberg61741a22013-09-17 16:02:57 -07001092
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001093 struct weston_layer fade_layer;
1094 struct weston_layer cursor_layer;
1095
Armin Krezovića01ab6d2016-09-30 14:11:02 +02001096 struct wl_list pending_output_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001097 struct wl_list output_list;
Pekka Paalanen1adcbac2017-08-14 16:05:35 +03001098 struct wl_list head_list; /* struct weston_head::compositor_link */
Daniel Stone37816df2012-05-16 18:45:18 +01001099 struct wl_list seat_list;
Quentin Glidic82681572016-12-17 13:40:51 +01001100 struct wl_list layer_list; /* struct weston_layer::link */
Pekka Paalanen20c7e552016-03-30 14:08:24 +03001101 struct wl_list view_list; /* struct weston_view::link */
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001102 struct wl_list plane_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +01001103 struct wl_list key_binding_list;
Daniel Stone96d47c02013-11-19 11:37:12 +01001104 struct wl_list modifier_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +01001105 struct wl_list button_binding_list;
Neil Robertsa28c6932013-10-03 16:43:04 +01001106 struct wl_list touch_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +01001107 struct wl_list axis_binding_list;
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001108 struct wl_list debug_binding_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001109
1110 uint32_t state;
1111 struct wl_event_source *idle_source;
1112 uint32_t idle_inhibit;
Philipp Brüschweiler4b409c32013-03-10 14:37:04 +01001113 int idle_time; /* timeout, s */
Daniel Stone6847b852017-03-01 11:34:08 +00001114 struct wl_event_source *repaint_timer;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001115
Giulio Camuffocdb4d292013-11-14 23:42:53 +01001116 const struct weston_pointer_grab_interface *default_pointer_grab;
1117
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001118 /* Repaint state. */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001119 struct weston_plane primary_plane;
Pekka Paalanen7bb65102013-05-22 18:03:04 +03001120 uint32_t capabilities; /* combination of enum weston_capability */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001121
Pekka Paalanen90a5ffa2021-02-25 12:03:28 +02001122 struct weston_color_manager *color_manager;
Kristian Høgsbergfa1be022012-09-05 22:49:55 -04001123 struct weston_renderer *renderer;
John Kåre Alsakerf9e710b2012-11-13 19:10:22 +01001124 pixman_format_code_t read_format;
Pekka Paalanen52bfbaa2012-04-11 16:19:37 +03001125
Giulio Camuffo954f1832014-10-11 18:27:30 +03001126 struct weston_backend *backend;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -07001127 struct weston_launcher *launcher;
Casey Dahlin58ba1372012-04-19 22:50:08 -04001128
Pekka Paalanen827b5d22016-06-29 11:54:26 +02001129 struct wl_list plugin_api_list; /* struct weston_plugin_api::link */
1130
Casey Dahlin58ba1372012-04-19 22:50:08 -04001131 uint32_t output_id_pool;
Daniel Stone855028f2012-05-01 20:37:10 +01001132
Daniel Stonee379da92012-05-30 16:32:04 +01001133 struct xkb_rule_names xkb_names;
1134 struct xkb_context *xkb_context;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +00001135 struct weston_xkb_info *xkb_info;
Matt Roper01a92732013-06-24 16:52:44 +01001136
Jonny Lamb66a41a02014-08-12 14:58:25 +02001137 int32_t kb_repeat_rate;
1138 int32_t kb_repeat_delay;
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001139
Bob Ham91880f12016-01-12 10:21:47 +00001140 bool vt_switching;
1141
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001142 clockid_t presentation_clock;
Pekka Paalanen0513a952014-05-21 16:17:27 +03001143 int32_t repaint_msec;
Pekka Paalanen1ed2cad2021-02-10 12:33:03 +02001144 struct timespec last_repaint_start;
Frederic Plourdec336f062014-10-29 14:44:33 -04001145
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001146 unsigned int activate_serial;
1147
Jonas Ådahld3414f22016-07-22 17:56:31 +08001148 struct wl_global *pointer_constraints;
1149
Frederic Plourdec336f062014-10-29 14:44:33 -04001150 int exit_code;
Giulio Camuffo459137b2014-10-11 23:56:24 +03001151
1152 void *user_data;
1153 void (*exit)(struct weston_compositor *c);
Daniel Díaz75b71972016-10-21 14:03:13 -05001154
1155 /* Whether to let the compositor run without any input device. */
1156 bool require_input;
1157
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -03001158 /* Test suite data */
1159 struct weston_testsuite_data test_data;
1160
Pekka Paalanen8dc6db82018-03-20 13:29:40 +02001161 /* Signal for a backend to inform a frontend about possible changes
1162 * in head status.
1163 */
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03001164 struct wl_signal heads_changed_signal;
1165 struct wl_event_source *heads_changed_source;
Louis-Francis Ratté-Bouliannec4689ff2017-11-28 20:42:47 -05001166
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05001167 /* Touchscreen calibrator support: */
Louis-Francis Ratté-Bouliannec4689ff2017-11-28 20:42:47 -05001168 enum weston_touch_mode touch_mode;
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05001169 struct wl_global *touch_calibration;
1170 weston_touch_calibration_save_func touch_calibration_save;
1171 struct weston_layer calibrator_layer;
1172 struct weston_touch_calibrator *touch_calibrator;
Pekka Paalanena5630ea2017-10-12 13:13:42 +02001173
Marius Vlad3d7d9782019-04-17 12:35:38 +03001174 struct weston_log_context *weston_log_ctx;
Marius Vlad5d5e3352019-04-17 13:05:38 +03001175 struct weston_log_scope *debug_scene;
Marius Vladda104eb2019-09-05 14:31:01 +03001176 struct weston_log_scope *timeline;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301177
1178 struct content_protection *content_protection;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001179};
1180
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001181struct weston_buffer {
1182 struct wl_resource *resource;
1183 struct wl_signal destroy_signal;
1184 struct wl_listener destroy_listener;
1185
1186 union {
1187 struct wl_shm_buffer *shm_buffer;
Jason Ekstranda85118c2013-06-27 20:17:02 -05001188 void *legacy_buffer;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001189 };
1190 int32_t width, height;
1191 uint32_t busy_count;
Stanislav Vorobiovbfbb8e52013-08-29 11:36:44 +04001192 int y_inverted;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001193};
1194
Pekka Paalanende685b82012-12-04 15:58:12 +02001195struct weston_buffer_reference {
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001196 struct weston_buffer *buffer;
Pekka Paalanende685b82012-12-04 15:58:12 +02001197 struct wl_listener destroy_listener;
1198};
1199
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001200struct weston_buffer_viewport {
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001201 struct {
1202 /* wl_surface.set_buffer_transform */
1203 uint32_t transform;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001204
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001205 /* wl_surface.set_scaling_factor */
1206 int32_t scale;
Jonny Lamb74130762013-11-26 18:19:46 +01001207
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001208 /*
1209 * If src_width != wl_fixed_from_int(-1),
1210 * then and only then src_* are used.
1211 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001212 wl_fixed_t src_x, src_y;
1213 wl_fixed_t src_width, src_height;
1214 } buffer;
1215
1216 struct {
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001217 /*
1218 * If width == -1, the size is inferred from the buffer.
1219 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001220 int32_t width, height;
1221 } surface;
George Kiagiadakis8f9e87f2014-06-13 18:14:20 +02001222
1223 int changed;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001224};
1225
Alexandros Frantzis67629672018-10-19 12:14:11 +03001226struct weston_buffer_release {
1227 /* The associated zwp_linux_buffer_release_v1 resource. */
1228 struct wl_resource *resource;
1229 /* How many weston_buffer_release_reference objects point to this
1230 * object. */
1231 uint32_t ref_count;
1232 /* The fence fd, if any, associated with this release. If the fence fd
1233 * is -1 then this is considered an immediate release. */
1234 int fence_fd;
1235};
1236
1237struct weston_buffer_release_reference {
1238 struct weston_buffer_release *buffer_release;
1239 /* Listener for the destruction of the wl_resource associated with the
1240 * referenced buffer_release object. */
1241 struct wl_listener destroy_listener;
1242};
1243
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001244struct weston_region {
Jason Ekstrand8895efc2013-06-14 10:07:56 -05001245 struct wl_resource *resource;
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001246 pixman_region32_t region;
1247};
1248
Jason Ekstranda7af7042013-10-12 22:38:11 -05001249/* Using weston_view transformations
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001250 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001251 * To add a transformation to a view, create a struct weston_transform, and
1252 * add it to the list view->geometry.transformation_list. Whenever you
1253 * change the list, anything under view->geometry, or anything in the
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001254 * weston_transforms linked into the list, you must call
Jason Ekstranda7af7042013-10-12 22:38:11 -05001255 * weston_view_geometry_dirty().
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001256 *
1257 * The order in the list defines the order of transformations. Let the list
1258 * contain the transformation matrices M1, ..., Mn as head to tail. The
Jason Ekstranda7af7042013-10-12 22:38:11 -05001259 * transformation is applied to view-local coordinate vector p as
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001260 * P = Mn * ... * M2 * M1 * p
1261 * to produce the global coordinate vector P. The total transform
1262 * Mn * ... * M2 * M1
Jason Ekstranda7af7042013-10-12 22:38:11 -05001263 * is cached in view->transform.matrix, and the inverse of it in
1264 * view->transform.inverse.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001265 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001266 * The list always contains view->transform.position transformation, which
1267 * is the translation by view->geometry.x and y.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001268 *
1269 * If you want to apply a transformation in local coordinates, add your
1270 * weston_transform to the head of the list. If you want to apply a
1271 * transformation in global coordinates, add it to the tail of the list.
Pekka Paalanen483243f2013-03-08 14:56:50 +02001272 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001273 * If view->geometry.parent is set, the total transformation of this
1274 * view will be the parent's total transformation and this transformation
Pekka Paalanen483243f2013-03-08 14:56:50 +02001275 * combined:
1276 * Mparent * Mn * ... * M2 * M1
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001277 */
1278
Jason Ekstranda7af7042013-10-12 22:38:11 -05001279struct weston_view {
1280 struct weston_surface *surface;
1281 struct wl_list surface_link;
Jason Ekstrand26ed73c2013-06-06 22:34:41 -05001282 struct wl_signal destroy_signal;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001283
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +03001284 /* struct weston_paint_node::view_link */
1285 struct wl_list paint_node_list;
1286
Pekka Paalanen20c7e552016-03-30 14:08:24 +03001287 struct wl_list link; /* weston_compositor::view_list */
Pekka Paalanen8844bf22015-02-18 16:30:47 +02001288 struct weston_layer_entry layer_link; /* part of geometry */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001289 struct weston_plane *plane;
Pekka Paalanen2d6e5512015-02-18 16:06:46 +02001290
1291 /* For weston_layer inheritance from another view */
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001292 struct weston_view *parent_view;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001293
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001294 unsigned int click_to_activate_serial;
1295
Pekka Paalanen51723d52015-02-17 13:10:01 +02001296 pixman_region32_t clip; /* See weston_view_damage_below() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001297 float alpha; /* part of geometry, see below */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001298
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001299 /* Surface geometry state, mutable.
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001300 * If you change anything, call weston_surface_geometry_dirty().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001301 * That includes the transformations referenced from the list.
1302 */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001303 struct {
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001304 float x, y; /* surface translation on display */
Pekka Paalanenba3cf952012-01-25 16:22:05 +02001305
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001306 /* struct weston_transform */
1307 struct wl_list transformation_list;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001308
1309 /* managed by weston_surface_set_transform_parent() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001310 struct weston_view *parent;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001311 struct wl_listener parent_destroy_listener;
1312 struct wl_list child_list; /* geometry.parent_link */
1313 struct wl_list parent_link;
Pekka Paalanen380adf52015-02-16 14:39:11 +02001314
1315 /* managed by weston_view_set_mask() */
1316 bool scissor_enabled;
1317 pixman_region32_t scissor; /* always a simple rect */
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001318 } geometry;
1319
1320 /* State derived from geometry state, read-only.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001321 * This is updated by weston_view_update_transform().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001322 */
1323 struct {
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001324 int dirty;
1325
Pekka Paalanenfbd00f12015-02-19 11:49:18 +02001326 /* Approximations in global coordinates:
1327 * - boundingbox is guaranteed to include the whole view in
1328 * the smallest possible single rectangle.
1329 * - opaque is guaranteed to be fully opaque, though not
1330 * necessarily include all opaque areas.
1331 */
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001332 pixman_region32_t boundingbox;
Pekka Paalanen730d87e2012-02-09 16:39:38 +02001333 pixman_region32_t opaque;
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001334
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001335 /* matrix and inverse are used only if enabled = 1.
1336 * If enabled = 0, use x, y, width, height directly.
1337 */
1338 int enabled;
Pekka Paalanen061b7472012-01-12 15:00:57 +02001339 struct weston_matrix matrix;
Pekka Paalanend1f0ab62012-01-20 10:47:57 +02001340 struct weston_matrix inverse;
Pekka Paalanencd403622012-01-25 13:37:39 +02001341
1342 struct weston_transform position; /* matrix from x, y */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001343 } transform;
1344
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001345 /*
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001346 * The primary output for this view.
1347 * Used for picking the output for driving internal animations on the
1348 * view, inheriting the primary output for related views in shells, etc.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001349 */
1350 struct weston_output *output;
Semi Malinene7a52fb2018-04-26 11:08:10 +02001351 struct wl_listener output_destroy_listener;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001352
Casey Dahlin9074db52012-04-19 22:50:09 -04001353 /*
1354 * A more complete representation of all outputs this surface is
1355 * displayed on.
1356 */
1357 uint32_t output_mask;
Pekka Paalanenbf0e0312014-12-17 16:20:41 +02001358
1359 /* Per-surface Presentation feedback flags, controlled by backend. */
1360 uint32_t psf_flags;
Armin Krezovićf8486c32016-06-30 06:04:28 +02001361
1362 bool is_mapped;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001363};
1364
Jason Ekstrand7b982072014-05-20 14:33:03 -05001365struct weston_surface_state {
1366 /* wl_surface.attach */
1367 int newly_attached;
1368 struct weston_buffer *buffer;
1369 struct wl_listener buffer_destroy_listener;
1370 int32_t sx;
1371 int32_t sy;
1372
1373 /* wl_surface.damage */
Derek Foreman152254b2015-11-26 14:17:48 -06001374 pixman_region32_t damage_surface;
1375 /* wl_surface.damage_buffer */
1376 pixman_region32_t damage_buffer;
Jason Ekstrand7b982072014-05-20 14:33:03 -05001377
1378 /* wl_surface.set_opaque_region */
1379 pixman_region32_t opaque;
1380
1381 /* wl_surface.set_input_region */
1382 pixman_region32_t input;
1383
1384 /* wl_surface.frame */
1385 struct wl_list frame_callback_list;
1386
Pekka Paalanen133e4392014-09-23 22:08:46 -04001387 /* presentation.feedback */
1388 struct wl_list feedback_list;
1389
Jason Ekstrand7b982072014-05-20 14:33:03 -05001390 /* wl_surface.set_buffer_transform */
1391 /* wl_surface.set_scaling_factor */
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001392 /* wp_viewport.set_source */
1393 /* wp_viewport.set_destination */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001394 struct weston_buffer_viewport buffer_viewport;
Alexandros Frantzisacff29b2018-10-19 12:14:11 +03001395
1396 /* zwp_surface_synchronization_v1.set_acquire_fence */
1397 int acquire_fence_fd;
Alexandros Frantzis67629672018-10-19 12:14:11 +03001398
1399 /* zwp_surface_synchronization_v1.get_release */
1400 struct weston_buffer_release_reference buffer_release_ref;
Ankit Nautiyal4b6e73d2019-03-26 13:37:12 +05301401
1402 /* weston_protected_surface.set_type */
1403 enum weston_hdcp_protection desired_protection;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301404
1405 /* weston_protected_surface.enforced/relaxed */
1406 enum weston_surface_protection_mode protection_mode;
Jason Ekstrand7b982072014-05-20 14:33:03 -05001407};
1408
Jonas Ådahlf7deb6a2016-07-22 17:50:26 +08001409struct weston_surface_activation_data {
1410 struct weston_surface *surface;
1411 struct weston_seat *seat;
1412};
1413
Jonas Ådahld3414f22016-07-22 17:56:31 +08001414struct weston_pointer_constraint {
1415 struct wl_list link;
1416
1417 struct weston_surface *surface;
1418 struct weston_view *view;
1419 struct wl_resource *resource;
1420 struct weston_pointer_grab grab;
1421 struct weston_pointer *pointer;
1422 uint32_t lifetime;
1423
1424 pixman_region32_t region;
1425 pixman_region32_t region_pending;
1426 bool region_is_pending;
1427
1428 wl_fixed_t hint_x;
1429 wl_fixed_t hint_y;
1430 wl_fixed_t hint_x_pending;
1431 wl_fixed_t hint_y_pending;
1432 bool hint_is_pending;
1433
1434 struct wl_listener pointer_destroy_listener;
1435 struct wl_listener surface_destroy_listener;
1436 struct wl_listener surface_commit_listener;
1437 struct wl_listener surface_activate_listener;
1438};
1439
Jason Ekstranda7af7042013-10-12 22:38:11 -05001440struct weston_surface {
1441 struct wl_resource *resource;
Pekka Paalanenca790762015-04-17 14:23:38 +03001442 struct wl_signal destroy_signal; /* callback argument: this surface */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001443 struct weston_compositor *compositor;
Jonas Ådahl5d9ca272016-07-22 17:48:03 +08001444 struct wl_signal commit_signal;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001445
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +03001446 /* struct weston_paint_node::surface_link */
1447 struct wl_list paint_node_list;
1448
Pekka Paalanene508ce62015-02-19 13:59:55 +02001449 /** Damage in local coordinates from the client, for tex upload. */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001450 pixman_region32_t damage;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001451
Jason Ekstranda7af7042013-10-12 22:38:11 -05001452 pixman_region32_t opaque; /* part of geometry, see below */
1453 pixman_region32_t input;
1454 int32_t width, height;
1455 int32_t ref_count;
1456
1457 /* Not for long-term storage. This exists for book-keeping while
1458 * iterating over surfaces and views
1459 */
Derek Foreman060cf112015-11-18 16:32:26 -06001460 bool touched;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001461
1462 void *renderer_state;
1463
1464 struct wl_list views;
1465
1466 /*
1467 * Which output to vsync this surface to.
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001468 * Used to determine whether to send or queue frame events, and for
1469 * other client-visible syncing/throttling tied to the output
1470 * repaint cycle.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001471 */
1472 struct weston_output *output;
1473
1474 /*
1475 * A more complete representation of all outputs this surface is
1476 * displayed on.
1477 */
1478 uint32_t output_mask;
Casey Dahlin9074db52012-04-19 22:50:09 -04001479
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001480 struct wl_list frame_callback_list;
Pekka Paalanen133e4392014-09-23 22:08:46 -04001481 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001482
Pekka Paalanende685b82012-12-04 15:58:12 +02001483 struct weston_buffer_reference buffer_ref;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001484 struct weston_buffer_viewport buffer_viewport;
Pekka Paalanen0b4c5352014-03-14 14:38:17 +02001485 int32_t width_from_buffer; /* before applying viewport */
1486 int32_t height_from_buffer;
Derek Foreman0fd6d4e2014-10-10 09:36:45 -05001487 bool keep_buffer; /* for backends to prevent early release */
Alex Wu8811bf92012-02-28 18:07:54 +08001488
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001489 /* wp_viewport resource for this surface */
Pekka Paalanenb0420ae2014-01-08 15:39:17 +02001490 struct wl_resource *viewport_resource;
Jonny Lamb74130762013-11-26 18:19:46 +01001491
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001492 /* All the pending state, that wl_surface.commit will apply. */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001493 struct weston_surface_state pending;
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001494
Maxime Roussin-Bélanger1d009c22020-12-17 17:10:13 -05001495 /* Matrices representing of the full transformation between
Jason Ekstrand1e059042014-10-16 10:55:19 -05001496 * buffer and surface coordinates. These matrices are updated
1497 * using the weston_surface_build_buffer_matrix function. */
1498 struct weston_matrix buffer_to_surface_matrix;
1499 struct weston_matrix surface_to_buffer_matrix;
1500
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001501 /*
Jasper St. Pierred67b52a2014-04-28 11:19:27 -04001502 * If non-NULL, this function will be called on
1503 * wl_surface::commit after a new buffer has been set up for
1504 * this surface. The integer params are the sx and sy
1505 * parameters supplied to wl_surface::attach.
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001506 */
Quentin Glidic2edc3d52016-08-12 10:41:33 +02001507 void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
1508 void *committed_private;
Pekka Paalanen8274d902014-08-06 19:36:51 +03001509 int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
Pekka Paalanene67858b2013-04-25 13:57:42 +03001510
1511 /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
1512 * Contains also the parent itself as a dummy weston_subsurface,
1513 * if the list is not empty.
1514 */
1515 struct wl_list subsurface_list; /* weston_subsurface::parent_link */
1516 struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
Pekka Paalanen50b67472014-10-01 15:02:41 +03001517
1518 /*
1519 * For tracking protocol role assignments. Different roles may
1520 * have the same configure hook, e.g. in shell.c. Configure hook
1521 * may get reset, this will not.
1522 * XXX: map configure functions 1:1 to roles, and never reset it,
1523 * and replace role_name with configure.
1524 */
1525 const char *role_name;
Pekka Paalanenb5026542014-11-12 15:09:24 +02001526
Armin Krezovićf8486c32016-06-30 06:04:28 +02001527 bool is_mapped;
Philipp Zabel195dade2018-09-03 19:44:59 +02001528 bool is_opaque;
Jonas Ådahld3414f22016-07-22 17:56:31 +08001529
1530 /* An list of per seat pointer constraints. */
1531 struct wl_list pointer_constraints;
Alexandros Frantzis27d7c392018-10-19 12:14:11 +03001532
1533 /* zwp_surface_synchronization_v1 resource for this surface */
1534 struct wl_resource *synchronization_resource;
Alexandros Frantzisacff29b2018-10-19 12:14:11 +03001535 int acquire_fence_fd;
Alexandros Frantzis67629672018-10-19 12:14:11 +03001536 struct weston_buffer_release_reference buffer_release_ref;
Ankit Nautiyal4b6e73d2019-03-26 13:37:12 +05301537
1538 enum weston_hdcp_protection desired_protection;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301539 enum weston_hdcp_protection current_protection;
1540 enum weston_surface_protection_mode protection_mode;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001541};
1542
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001543struct weston_subsurface {
1544 struct wl_resource *resource;
1545
1546 /* guaranteed to be valid and non-NULL */
1547 struct weston_surface *surface;
1548 struct wl_listener surface_destroy_listener;
1549
1550 /* can be NULL */
1551 struct weston_surface *parent;
1552 struct wl_listener parent_destroy_listener;
1553 struct wl_list parent_link;
1554 struct wl_list parent_link_pending;
1555
1556 struct {
1557 int32_t x;
1558 int32_t y;
1559 int set;
1560 } position;
1561
Jason Ekstrand7b982072014-05-20 14:33:03 -05001562 int has_cached_data;
1563 struct weston_surface_state cached;
1564 struct weston_buffer_reference cached_buffer_ref;
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001565
Emilio Pozuelo Monfort4f3cad72017-01-27 17:30:29 +01001566 /* Sub-surface has been reordered; need to apply damage. */
1567 bool reordered;
1568
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001569 int synchronized;
1570
1571 /* Used for constructing the view tree */
1572 struct wl_list unused_views;
1573};
1574
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301575struct protected_surface {
1576 struct weston_surface *surface;
1577 struct wl_listener surface_destroy_listener;
1578 struct wl_list link;
1579 struct wl_resource *protection_resource;
1580 struct content_protection *cp_backptr;
1581};
1582
1583struct content_protection {
1584 struct weston_compositor *compositor;
1585 struct wl_listener destroy_listener;
1586 struct weston_log_scope *debug;
1587 struct wl_list protected_list;
Ankit Nautiyalf74c35b2019-04-03 19:21:58 +05301588 struct wl_event_source *surface_protection_update;
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05301589};
1590
1591
Daniel Stoned6da09e2012-06-22 13:21:29 +01001592enum weston_key_state_update {
1593 STATE_UPDATE_AUTOMATIC,
1594 STATE_UPDATE_NONE,
1595};
1596
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001597enum weston_activate_flag {
1598 WESTON_ACTIVATE_FLAG_NONE = 0,
1599 WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001600 WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001601};
1602
Kristian Høgsberg9ddb8262012-01-04 21:30:29 -05001603void
Kristian Høgsbergaf4f2aa2013-02-15 20:53:20 -05001604weston_version(int *major, int *minor, int *micro);
1605
1606void
Semi Malinene7a52fb2018-04-26 11:08:10 +02001607weston_view_set_output(struct weston_view *view, struct weston_output *output);
1608
1609void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001610weston_view_update_transform(struct weston_view *view);
Pekka Paalanen460099f2012-01-20 16:48:25 +02001611
1612void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001613weston_view_geometry_dirty(struct weston_view *view);
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001614
1615void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001616weston_view_to_global_float(struct weston_view *view,
1617 float sx, float sy, float *x, float *y);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001618
1619void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001620weston_view_from_global(struct weston_view *view,
1621 int32_t x, int32_t y, int32_t *vx, int32_t *vy);
Daniel Stonebd3489b2012-05-08 17:17:53 +01001622void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001623weston_view_from_global_fixed(struct weston_view *view,
1624 wl_fixed_t x, wl_fixed_t y,
1625 wl_fixed_t *vx, wl_fixed_t *vy);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001626
Derek Foremand1be3122014-09-18 16:46:49 -05001627void
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001628weston_view_activate(struct weston_view *view,
1629 struct weston_seat *seat,
1630 uint32_t flags);
1631
1632void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001633notify_modifiers(struct weston_seat *seat, uint32_t serial);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001634
1635void
Giulio Camuffo412e6a52014-07-09 22:12:56 +03001636weston_layer_entry_insert(struct weston_layer_entry *list,
1637 struct weston_layer_entry *entry);
1638void
1639weston_layer_entry_remove(struct weston_layer_entry *entry);
1640void
Quentin Glidic82681572016-12-17 13:40:51 +01001641weston_layer_init(struct weston_layer *layer,
1642 struct weston_compositor *compositor);
1643void
Pekka Paalanen87400372021-05-14 14:29:40 +03001644weston_layer_fini(struct weston_layer *layer);
1645void
Quentin Glidic82681572016-12-17 13:40:51 +01001646weston_layer_set_position(struct weston_layer *layer,
1647 enum weston_layer_position position);
1648void
1649weston_layer_unset_position(struct weston_layer *layer);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001650
1651void
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001652weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
1653
1654void
1655weston_layer_set_mask_infinite(struct weston_layer *layer);
1656
Daniel Stone3b775632018-07-20 08:38:25 +01001657bool
1658weston_layer_mask_is_infinite(struct weston_layer *layer);
1659
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001660/* An invalid flag in presented_flags to catch logic errors. */
Pekka Paalanenb00c79b2016-02-18 16:53:27 +02001661#define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31)
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001662
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001663void
Kristian Høgsberg49952d12012-06-20 00:35:59 -04001664weston_output_schedule_repaint(struct weston_output *output);
1665void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001666weston_compositor_schedule_repaint(struct weston_compositor *compositor);
1667void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001668weston_compositor_damage_all(struct weston_compositor *compositor);
1669void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001670weston_compositor_wake(struct weston_compositor *compositor);
1671void
Ander Conselvan de Oliveira87524b62013-02-21 18:35:22 +02001672weston_compositor_sleep(struct weston_compositor *compositor);
Jason Ekstranda7af7042013-10-12 22:38:11 -05001673struct weston_view *
1674weston_compositor_pick_view(struct weston_compositor *compositor,
1675 wl_fixed_t x, wl_fixed_t y,
1676 wl_fixed_t *sx, wl_fixed_t *sy);
Ander Conselvan de Oliveira30eebc72012-02-15 17:02:57 +02001677
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001678
1679struct weston_binding;
Derek Foreman8ae2db52015-07-15 13:00:36 -05001680typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001681 const struct timespec *time,
1682 uint32_t key,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001683 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001684struct weston_binding *
Daniel Stone325fc2d2012-05-30 16:31:58 +01001685weston_compositor_add_key_binding(struct weston_compositor *compositor,
1686 uint32_t key,
1687 enum weston_keyboard_modifier modifier,
1688 weston_key_binding_handler_t binding,
1689 void *data);
Marius Vlad3ee9d8e2019-07-18 11:01:51 +03001690struct weston_binding *
1691weston_compositor_add_debug_binding(struct weston_compositor *compositor,
1692 uint32_t key,
1693 weston_key_binding_handler_t binding,
1694 void *data);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001695
Derek Foreman8ae2db52015-07-15 13:00:36 -05001696typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
Daniel Stone96d47c02013-11-19 11:37:12 +01001697 enum weston_keyboard_modifier modifier,
1698 void *data);
1699struct weston_binding *
1700weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
1701 enum weston_keyboard_modifier modifier,
1702 weston_modifier_binding_handler_t binding,
1703 void *data);
1704
Derek Foreman8ae2db52015-07-15 13:00:36 -05001705typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001706 const struct timespec *time,
1707 uint32_t button,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001708 void *data);
1709struct weston_binding *
1710weston_compositor_add_button_binding(struct weston_compositor *compositor,
1711 uint32_t button,
1712 enum weston_keyboard_modifier modifier,
1713 weston_button_binding_handler_t binding,
1714 void *data);
1715
Derek Foreman8ae2db52015-07-15 13:00:36 -05001716typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001717 const struct timespec *time,
Neil Robertsa28c6932013-10-03 16:43:04 +01001718 void *data);
1719struct weston_binding *
1720weston_compositor_add_touch_binding(struct weston_compositor *compositor,
1721 enum weston_keyboard_modifier modifier,
1722 weston_touch_binding_handler_t binding,
1723 void *data);
1724
Derek Foreman8ae2db52015-07-15 13:00:36 -05001725typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +02001726 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001727 struct weston_pointer_axis_event *event,
1728 void *data);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001729struct weston_binding *
1730weston_compositor_add_axis_binding(struct weston_compositor *compositor,
1731 uint32_t axis,
1732 enum weston_keyboard_modifier modifier,
1733 weston_axis_binding_handler_t binding,
1734 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001735
1736void
sichemec8c8762019-08-23 11:47:44 +00001737weston_binding_destroy(struct weston_binding *binding);
1738
1739void
Pekka Paalanen2829f7c2015-02-19 17:02:13 +02001740weston_install_debug_key_binding(struct weston_compositor *compositor,
1741 uint32_t mod);
1742
1743void
Giulio Camuffocdb4d292013-11-14 23:42:53 +01001744weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
1745 const struct weston_pointer_grab_interface *interface);
1746
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001747struct weston_surface *
Kristian Høgsberg18c93002012-01-27 11:58:31 -05001748weston_surface_create(struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001749
Jason Ekstranda7af7042013-10-12 22:38:11 -05001750struct weston_view *
1751weston_view_create(struct weston_surface *surface);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001752
1753void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001754weston_view_destroy(struct weston_view *view);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001755
1756void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001757weston_view_set_position(struct weston_view *view,
1758 float x, float y);
1759
1760void
1761weston_view_set_transform_parent(struct weston_view *view,
1762 struct weston_view *parent);
1763
Pekka Paalanen380adf52015-02-16 14:39:11 +02001764void
1765weston_view_set_mask(struct weston_view *view,
1766 int x, int y, int width, int height);
1767
1768void
1769weston_view_set_mask_infinite(struct weston_view *view);
1770
Derek Foreman280e7dd2014-10-03 13:13:42 -05001771bool
Jason Ekstranda7af7042013-10-12 22:38:11 -05001772weston_view_is_mapped(struct weston_view *view);
1773
1774void
1775weston_view_schedule_repaint(struct weston_view *view);
Pekka Paalanen483243f2013-03-08 14:56:50 +02001776
Derek Foreman280e7dd2014-10-03 13:13:42 -05001777bool
Ander Conselvan de Oliveirab8ab14f2012-03-27 17:36:36 +03001778weston_surface_is_mapped(struct weston_surface *surface);
1779
Derek Foremand1be3122014-09-18 16:46:49 -05001780void
Jason Ekstrand5c11a332013-12-04 20:32:03 -06001781weston_surface_set_size(struct weston_surface *surface,
1782 int32_t width, int32_t height);
1783
Pekka Paalanen8fb8d3b2012-02-13 13:03:59 +02001784void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001785weston_surface_damage(struct weston_surface *surface);
1786
1787void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001788weston_view_damage_below(struct weston_view *view);
Kristian Høgsbergd8bf90c2012-02-23 23:03:14 -05001789
1790void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001791weston_view_unmap(struct weston_view *view);
1792
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001793void
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001794weston_surface_unmap(struct weston_surface *surface);
1795
Pekka Paalanen01388e22013-04-25 13:57:44 +03001796struct weston_surface *
1797weston_surface_get_main_surface(struct weston_surface *surface);
1798
Pekka Paalanen50b67472014-10-01 15:02:41 +03001799int
1800weston_surface_set_role(struct weston_surface *surface,
1801 const char *role_name,
1802 struct wl_resource *error_resource,
1803 uint32_t error_code);
Quentin Glidic9c5dd7e2016-08-12 10:41:37 +02001804const char *
1805weston_surface_get_role(struct weston_surface *surface);
Pekka Paalanen50b67472014-10-01 15:02:41 +03001806
Pekka Paalanen8274d902014-08-06 19:36:51 +03001807void
1808weston_surface_set_label_func(struct weston_surface *surface,
1809 int (*desc)(struct weston_surface *,
1810 char *, size_t));
1811
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001812void
1813weston_surface_get_content_size(struct weston_surface *surface,
1814 int *width, int *height);
1815
Quentin Glidic248dd102016-08-12 10:41:34 +02001816struct weston_geometry
1817weston_surface_get_bounding_box(struct weston_surface *surface);
1818
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001819int
1820weston_surface_copy_content(struct weston_surface *surface,
1821 void *target, size_t size,
1822 int src_x, int src_y,
1823 int width, int height);
1824
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001825struct weston_buffer *
1826weston_buffer_from_resource(struct wl_resource *resource);
1827
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001828void
Alexandros Frantzis409b01f2017-11-16 18:21:01 +02001829weston_compositor_get_time(struct timespec *time);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001830
Giulio Camuffo459137b2014-10-11 23:56:24 +03001831void
1832weston_compositor_destroy(struct weston_compositor *ec);
Marius Vlad284d5342019-06-24 12:00:47 +03001833
Giulio Camuffo459137b2014-10-11 23:56:24 +03001834struct weston_compositor *
Marius Vlad880b4852019-04-07 17:07:58 +03001835weston_compositor_create(struct wl_display *display,
Leandro Ribeirocdb72182020-11-06 11:24:22 -03001836 struct weston_log_context *log_ctx, void *user_data,
1837 const struct weston_testsuite_data *test_data);
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001838
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -03001839void *
1840weston_compositor_get_test_data(struct weston_compositor *ec);
1841
Pekka Paalanen6ffbba32019-11-06 12:59:32 +02001842bool
1843weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor,
1844 struct wl_listener *listener,
1845 wl_notify_func_t destroy_handler);
1846
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001847enum weston_compositor_backend {
1848 WESTON_BACKEND_DRM,
1849 WESTON_BACKEND_FBDEV,
1850 WESTON_BACKEND_HEADLESS,
1851 WESTON_BACKEND_RDP,
1852 WESTON_BACKEND_WAYLAND,
1853 WESTON_BACKEND_X11,
1854};
1855
Pekka Paalanendd186732016-06-03 14:49:54 +03001856int
1857weston_compositor_load_backend(struct weston_compositor *compositor,
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001858 enum weston_compositor_backend backend,
Pekka Paalanendd186732016-06-03 14:49:54 +03001859 struct weston_backend_config *config_base);
Giulio Camuffo459137b2014-10-11 23:56:24 +03001860void
1861weston_compositor_exit(struct weston_compositor *ec);
1862void *
1863weston_compositor_get_user_data(struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001864void
Frederic Plourdec336f062014-10-29 14:44:33 -04001865weston_compositor_exit_with_code(struct weston_compositor *compositor,
1866 int exit_code);
1867void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001868weston_output_update_zoom(struct weston_output *output);
Scott Moreauccbf29d2012-02-22 14:21:41 -07001869void
Derek Foreman22276a52015-07-23 14:55:15 -05001870weston_output_activate_zoom(struct weston_output *output,
1871 struct weston_seat *seat);
Giulio Camuffo412b0242013-11-14 23:42:51 +01001872void
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +02001873weston_output_add_destroy_listener(struct weston_output *output,
1874 struct wl_listener *listener);
1875struct wl_listener *
1876weston_output_get_destroy_listener(struct weston_output *output,
1877 wl_notify_func_t notify);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001878int
Giulio Camuffo0358af42016-06-02 21:48:08 +03001879weston_compositor_set_xkb_rule_names(struct weston_compositor *ec,
1880 struct xkb_rule_names *names);
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001881
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001882/* String literal of spaces, the same width as the timestamp. */
1883#define STAMP_SPACE " "
1884
Marius Vlad35ff4a82019-06-28 14:08:24 +03001885/**
1886 * \ingroup wlog
1887 */
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001888typedef int (*log_func_t)(const char *fmt, va_list ap);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001889void
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001890weston_log_set_handler(log_func_t log, log_func_t cont);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001891int
Pekka Paalanend525b562012-08-06 14:57:04 +03001892weston_log(const char *fmt, ...)
1893 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001894int
Pekka Paalanend525b562012-08-06 14:57:04 +03001895weston_log_continue(const char *fmt, ...)
1896 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001897
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001898enum weston_screenshooter_outcome {
1899 WESTON_SCREENSHOOTER_SUCCESS,
1900 WESTON_SCREENSHOOTER_NO_MEMORY,
1901 WESTON_SCREENSHOOTER_BAD_BUFFER
1902};
1903
1904typedef void (*weston_screenshooter_done_func_t)(void *data,
1905 enum weston_screenshooter_outcome outcome);
1906int
1907weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
1908 weston_screenshooter_done_func_t done, void *data);
Giulio Camuffo26f62d42016-06-02 21:48:09 +03001909struct weston_recorder *
1910weston_recorder_start(struct weston_output *output, const char *filename);
1911void
1912weston_recorder_stop(struct weston_recorder *recorder);
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001913
Jason Ekstranda7af7042013-10-12 22:38:11 -05001914struct weston_view_animation;
1915typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001916
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001917void
1918weston_view_animation_destroy(struct weston_view_animation *animation);
1919
Jason Ekstranda7af7042013-10-12 22:38:11 -05001920struct weston_view_animation *
1921weston_zoom_run(struct weston_view *view, float start, float stop,
1922 weston_view_animation_done_func_t done, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001923
Jason Ekstranda7af7042013-10-12 22:38:11 -05001924struct weston_view_animation *
1925weston_fade_run(struct weston_view *view,
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001926 float start, float end, float k,
Jason Ekstranda7af7042013-10-12 22:38:11 -05001927 weston_view_animation_done_func_t done, void *data);
Daniel Stonea67e6b92013-11-19 11:37:13 +01001928
1929struct weston_view_animation *
1930weston_move_scale_run(struct weston_view *view, int dx, int dy,
Quentin Glidic24d306c2016-08-10 15:53:33 +02001931 float start, float end, bool reverse,
Daniel Stonea67e6b92013-11-19 11:37:13 +01001932 weston_view_animation_done_func_t done, void *data);
1933
Quentin Glidic24d306c2016-08-10 15:53:33 +02001934struct weston_view_animation *
1935weston_move_run(struct weston_view *view, int dx, int dy,
1936 float start, float end, bool reverse,
1937 weston_view_animation_done_func_t done, void *data);
1938
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001939void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001940weston_fade_update(struct weston_view_animation *fade, float target);
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001941
Jason Ekstranda7af7042013-10-12 22:38:11 -05001942struct weston_view_animation *
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001943weston_stable_fade_run(struct weston_view *front_view, float start,
1944 struct weston_view *back_view, float end,
1945 weston_view_animation_done_func_t done, void *data);
1946
1947struct weston_view_animation *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001948weston_slide_run(struct weston_view *view, float start, float stop,
1949 weston_view_animation_done_func_t done, void *data);
Juan Zhaoe10d2792012-04-25 19:09:52 +08001950
Alex Wu8811bf92012-02-28 18:07:54 +08001951void
1952weston_surface_set_color(struct weston_surface *surface,
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001953 float red, float green, float blue, float alpha);
Alex Wu8811bf92012-02-28 18:07:54 +08001954
1955void
1956weston_surface_destroy(struct weston_surface *surface);
1957
Alex Wu2dda6042012-04-17 17:20:47 +08001958int
Derek Foreman6ae7bc92014-11-04 10:47:33 -06001959weston_output_mode_switch_to_temporary(struct weston_output *output,
1960 struct weston_mode *mode,
1961 int32_t scale);
1962int
1963weston_output_mode_switch_to_native(struct weston_output *output);
Alex Wu2dda6042012-04-17 17:20:47 +08001964
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001965int
Quentin Glidic23e1d6f2016-12-02 14:08:44 +01001966weston_backend_init(struct weston_compositor *c,
1967 struct weston_backend_config *config_base);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001968int
Quentin Glidic3d7ca3b2016-12-02 14:20:35 +01001969weston_module_init(struct weston_compositor *compositor);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001970
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +03001971void *
1972weston_load_module(const char *name, const char *entrypoint);
1973
Daniel Stonee03c1112016-11-24 20:45:45 +00001974size_t
1975weston_module_path_from_env(const char *name, char *path, size_t path_len);
1976
Derek Foreman64a3df02014-10-23 12:24:18 -05001977int
1978weston_parse_transform(const char *transform, uint32_t *out);
1979
1980const char *
1981weston_transform_to_string(uint32_t output_transform);
1982
Derek Foreman1281a362015-07-31 16:55:32 -05001983struct weston_keyboard *
1984weston_seat_get_keyboard(struct weston_seat *seat);
1985
1986struct weston_pointer *
1987weston_seat_get_pointer(struct weston_seat *seat);
1988
1989struct weston_touch *
1990weston_seat_get_touch(struct weston_seat *seat);
1991
Bryce Harrington24f917e2016-06-29 19:04:07 -07001992void
1993weston_seat_set_keyboard_focus(struct weston_seat *seat,
1994 struct weston_surface *surface);
1995
Derek Foremanf8f7fd62017-06-28 11:41:43 -05001996void
1997weston_keyboard_send_keymap(struct weston_keyboard *kbd,
1998 struct wl_resource *resource);
1999
Giulio Camuffo9c764df2016-06-29 11:54:27 +02002000int
2001weston_compositor_load_xwayland(struct weston_compositor *compositor);
2002
Pekka Paalanen5e79dd42021-03-29 14:11:49 +03002003int
2004weston_compositor_load_color_manager(struct weston_compositor *compositor);
2005
Pekka Paalanen7fe858b2017-08-14 15:45:14 +03002006bool
2007weston_head_is_connected(struct weston_head *head);
2008
Pekka Paalanen8e552fd2018-02-15 15:18:20 +02002009bool
2010weston_head_is_enabled(struct weston_head *head);
2011
Pekka Paalanene19970f2017-08-28 14:11:02 +03002012bool
2013weston_head_is_device_changed(struct weston_head *head);
2014
Philipp Zabelc18ffd32018-08-30 17:38:03 +02002015bool
2016weston_head_is_non_desktop(struct weston_head *head);
2017
Pekka Paalanene19970f2017-08-28 14:11:02 +03002018void
2019weston_head_reset_device_changed(struct weston_head *head);
2020
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002021const char *
2022weston_head_get_name(struct weston_head *head);
2023
2024struct weston_output *
2025weston_head_get_output(struct weston_head *head);
2026
Lucas Stacha69cb712019-11-25 23:29:31 +00002027uint32_t
2028weston_head_get_transform(struct weston_head *head);
2029
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002030void
2031weston_head_detach(struct weston_head *head);
2032
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +03002033void
2034weston_head_add_destroy_listener(struct weston_head *head,
2035 struct wl_listener *listener);
2036
2037struct wl_listener *
2038weston_head_get_destroy_listener(struct weston_head *head,
2039 wl_notify_func_t notify);
2040
Ankit Nautiyal4f64ff82019-04-03 18:44:35 +05302041void
2042weston_head_set_content_protection_status(struct weston_head *head,
2043 enum weston_hdcp_protection status);
2044
Pekka Paalanen1adcbac2017-08-14 16:05:35 +03002045struct weston_head *
2046weston_compositor_iterate_heads(struct weston_compositor *compositor,
2047 struct weston_head *iter);
2048
Pekka Paalanen01f60212017-03-24 15:39:24 +02002049void
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002050weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor,
2051 struct wl_listener *listener);
2052
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002053struct weston_output *
Pekka Paalanen1ae9d082017-11-02 14:11:53 +02002054weston_compositor_find_output_by_name(struct weston_compositor *compositor,
2055 const char *name);
2056
2057struct weston_output *
2058weston_compositor_create_output(struct weston_compositor *compositor,
2059 const char *name);
2060
2061struct weston_output *
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002062weston_compositor_create_output_with_head(struct weston_compositor *compositor,
2063 struct weston_head *head);
2064
2065void
2066weston_output_destroy(struct weston_output *output);
2067
2068int
2069weston_output_attach_head(struct weston_output *output,
2070 struct weston_head *head);
2071
2072struct weston_head *
2073weston_output_iterate_heads(struct weston_output *output,
2074 struct weston_head *iter);
2075
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002076void
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002077weston_output_set_scale(struct weston_output *output,
2078 int32_t scale);
2079
2080void
2081weston_output_set_transform(struct weston_output *output,
2082 uint32_t transform);
2083
2084void
Armin Krezović40087402016-09-30 14:11:12 +02002085weston_output_init(struct weston_output *output,
Pekka Paalanen26ac2e12017-04-03 13:18:13 +03002086 struct weston_compositor *compositor,
2087 const char *name);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002088
sichemb86eb202019-09-13 08:57:31 +00002089void
2090weston_output_move(struct weston_output *output, int x, int y);
2091
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002092int
2093weston_output_enable(struct weston_output *output);
2094
2095void
2096weston_output_disable(struct weston_output *output);
2097
2098void
Pekka Paalanen8a8dcac2017-08-17 17:29:36 +03002099weston_compositor_flush_heads_changed(struct weston_compositor *compositor);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002100
Pekka Paalanen055c1132017-03-27 16:31:25 +03002101struct weston_head *
2102weston_head_from_resource(struct wl_resource *resource);
Pekka Paalanen9ffb2502017-03-27 15:14:32 +03002103
Pekka Paalanencf0a4762017-04-04 16:36:07 +03002104struct weston_head *
2105weston_output_get_first_head(struct weston_output *output);
2106
Ankit Nautiyal2844f8e2019-04-03 10:14:59 +05302107void
2108weston_output_allow_protection(struct weston_output *output,
2109 bool allow_protection);
2110
Louis-Francis Ratté-Boulianne83630982017-11-28 20:42:47 -05002111int
2112weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor,
2113 weston_touch_calibration_save_func save);
2114
Marius Vlad3d7d9782019-04-17 12:35:38 +03002115struct weston_log_context *
Leandro Ribeiro4f135952020-01-17 11:19:59 -03002116weston_log_ctx_create(void);
Marius Vlad880b4852019-04-07 17:07:58 +03002117
Pekka Paalanena5630ea2017-10-12 13:13:42 +02002118void
Leandro Ribeiro4ec38d12020-01-24 01:12:59 -03002119weston_log_ctx_destroy(struct weston_log_context *log_ctx);
Pekka Paalanena5630ea2017-10-12 13:13:42 +02002120
Ankit Nautiyal5cfe03c2019-03-28 15:05:42 +05302121int
2122weston_compositor_enable_content_protection(struct weston_compositor *compositor);
2123
Marius Vlad5de92972019-10-15 13:25:41 +03002124void
2125weston_timeline_refresh_subscription_objects(struct weston_compositor *wc,
2126 void *object);
2127
Giulio Camuffo7fe01b12013-03-28 18:02:42 +01002128#ifdef __cplusplus
2129}
2130#endif
2131
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05002132#endif