blob: 47337d8a8bb03a3249f0f671ea35fcb8a39c66ae [file] [log] [blame]
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
Pekka Paalanen925788f2018-04-19 14:20:01 +03003 * Copyright © 2012, 2017, 2018 Collabora, Ltd.
4 * Copyright © 2017, 2018 General Electric Company
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05005 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -07006 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050013 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -070014 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050026 */
27
28#ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
29#define _WAYLAND_SYSTEM_COMPOSITOR_H_
30
Giulio Camuffo7fe01b12013-03-28 18:02:42 +010031#ifdef __cplusplus
32extern "C" {
33#endif
34
Derek Foreman280e7dd2014-10-03 13:13:42 -050035#include <stdbool.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030036#include <stdint.h>
Pekka Paalanenb5eedad2014-09-23 22:08:45 -040037#include <time.h>
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050038#include <pixman.h>
Daniel Stone855028f2012-05-01 20:37:10 +010039#include <xkbcommon/xkbcommon.h>
Kristian Høgsberg3c179332013-08-06 19:27:04 -070040
41#define WL_HIDE_DEPRECATED
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050042#include <wayland-server.h>
43
Kristian Høgsbergaf4f2aa2013-02-15 20:53:20 -050044#include "matrix.h"
45#include "config-parser.h"
Peter Huttererb1bc4a62013-08-08 11:57:04 +100046#include "zalloc.h"
Pekka Paalanenb5026542014-11-12 15:09:24 +020047#include "timeline-object.h"
Pekka Paalanen2eaa11e2012-03-30 15:45:40 +030048
Quentin Glidic248dd102016-08-12 10:41:34 +020049struct weston_geometry {
50 int32_t x, y;
51 int32_t width, height;
52};
53
54struct weston_position {
55 int32_t x, y;
56};
57
58struct weston_size {
59 int32_t width, height;
60};
61
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050062struct weston_transform {
63 struct weston_matrix matrix;
Pekka Paalanenc61eca62012-01-06 14:10:06 +020064 struct wl_list link;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050065};
66
67struct weston_surface;
Jason Ekstrand6bd62942013-06-20 20:38:23 -050068struct weston_buffer;
Tiago Vignattibc052c92012-04-19 16:18:18 +030069struct shell_surface;
Daniel Stone37816df2012-05-16 18:45:18 +010070struct weston_seat;
Scott Moreau062be7e2012-04-20 13:37:33 -060071struct weston_output;
Jan Arne Petersene829adc2012-08-10 16:47:22 +020072struct input_method;
Derek Foremane4d6c832015-08-05 14:48:11 -050073struct weston_pointer;
Pekka Paalanen230f3b12014-09-29 14:18:40 -040074struct linux_dmabuf_buffer;
Giulio Camuffo26f62d42016-06-02 21:48:09 +030075struct weston_recorder;
Jonas Ådahld3414f22016-07-22 17:56:31 +080076struct weston_pointer_constraint;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050077
Daniel Stone496ca172012-05-30 16:31:42 +010078enum weston_keyboard_modifier {
79 MODIFIER_CTRL = (1 << 0),
80 MODIFIER_ALT = (1 << 1),
81 MODIFIER_SUPER = (1 << 2),
Kristian Høgsberg73694c82012-06-28 14:13:10 -040082 MODIFIER_SHIFT = (1 << 3),
Daniel Stone496ca172012-05-30 16:31:42 +010083};
84
Giulio Camuffo6ef444d2014-08-28 19:44:09 +030085enum weston_keyboard_locks {
86 WESTON_NUM_LOCK = (1 << 0),
87 WESTON_CAPS_LOCK = (1 << 1),
88};
89
Daniel Stone8c8164f2012-05-30 16:31:45 +010090enum weston_led {
91 LED_NUM_LOCK = (1 << 0),
92 LED_CAPS_LOCK = (1 << 1),
93 LED_SCROLL_LOCK = (1 << 2),
94};
95
Kristian Høgsberg8334bc12012-01-03 10:29:47 -050096struct weston_mode {
97 uint32_t flags;
98 int32_t width, height;
99 uint32_t refresh;
100 struct wl_list link;
101};
102
Scott Moreaue6603982012-06-11 13:07:51 -0600103struct weston_animation {
104 void (*frame)(struct weston_animation *animation,
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200105 struct weston_output *output,
106 const struct timespec *time);
Scott Moreaue6603982012-06-11 13:07:51 -0600107 int frame_counter;
108 struct wl_list link;
109};
110
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400111enum {
112 WESTON_SPRING_OVERSHOOT,
113 WESTON_SPRING_CLAMP,
114 WESTON_SPRING_BOUNCE
115};
116
Scott Moreaue6603982012-06-11 13:07:51 -0600117struct weston_spring {
118 double k;
119 double friction;
120 double current;
121 double target;
122 double previous;
Kristian Høgsberg091b0962013-06-17 09:23:14 -0400123 double min, max;
Alexandros Frantzis8250a612017-11-16 18:20:52 +0200124 struct timespec timestamp;
Kristian Høgsberg7eec9b32013-06-17 09:15:22 -0400125 uint32_t clip;
Scott Moreaue6603982012-06-11 13:07:51 -0600126};
127
Scott Moreauccbf29d2012-02-22 14:21:41 -0700128struct weston_output_zoom {
Derek Foremana36eb502015-07-23 14:55:12 -0500129 bool active;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700130 float increment;
131 float level;
Scott Moreaue6603982012-06-11 13:07:51 -0600132 float max_level;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700133 float trans_x, trans_y;
Giulio Camuffo6850e7b2015-10-07 20:14:18 +0300134 struct {
135 double x, y;
136 } current;
Derek Foreman22276a52015-07-23 14:55:15 -0500137 struct weston_seat *seat;
Scott Moreaue6603982012-06-11 13:07:51 -0600138 struct weston_animation animation_z;
139 struct weston_spring spring_z;
Giulio Camuffo412b0242013-11-14 23:42:51 +0100140 struct wl_listener motion_listener;
Scott Moreauccbf29d2012-02-22 14:21:41 -0700141};
142
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200143/* bit compatible with drm definitions. */
144enum dpms_enum {
145 WESTON_DPMS_ON,
146 WESTON_DPMS_STANDBY,
147 WESTON_DPMS_SUSPEND,
148 WESTON_DPMS_OFF
149};
150
Pekka Paalanen01f60212017-03-24 15:39:24 +0200151/** Represents a monitor
152 *
153 * This object represents a monitor (hardware backends like DRM) or a window
154 * (windowed nested backends).
155 */
156struct weston_head {
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300157 struct weston_compositor *compositor; /**< owning compositor */
158 struct wl_list compositor_link; /**< in weston_compositor::head_list */
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +0300159 struct wl_signal destroy_signal; /**< destroy callbacks */
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300160
Pekka Paalanen05347622017-03-27 12:24:34 +0300161 struct weston_output *output; /**< the output driving this head */
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300162 struct wl_list output_link; /**< in weston_output::head_list */
Pekka Paalanen05347622017-03-27 12:24:34 +0300163
Pekka Paalanen1b9bf592017-03-27 12:15:38 +0300164 struct wl_list resource_list; /**< wl_output protocol objects */
165 struct wl_global *global; /**< wl_output global */
166
Pekka Paalanen01f60212017-03-24 15:39:24 +0200167 int32_t mm_width; /**< physical image width in mm */
168 int32_t mm_height; /**< physical image height in mm */
169 char *make; /**< monitor manufacturer (PNP ID) */
170 char *model; /**< monitor model */
171 char *serial_number; /**< monitor serial */
172 uint32_t subpixel; /**< enum wl_output_subpixel */
173 bool connection_internal; /**< embedded monitor (e.g. laptop) */
Pekka Paalanene19970f2017-08-28 14:11:02 +0300174 bool device_changed; /**< monitor information has changed */
Pekka Paalanen9b02e472017-08-14 14:43:13 +0300175
176 char *name; /**< head name, e.g. connector name */
Pekka Paalanen7fe858b2017-08-14 15:45:14 +0300177 bool connected; /**< is physically connected */
Pekka Paalanen01f60212017-03-24 15:39:24 +0200178};
179
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500180struct weston_output {
Casey Dahlin58ba1372012-04-19 22:50:08 -0400181 uint32_t id;
Richard Hughesafe690c2013-05-02 10:10:04 +0100182 char *name;
Casey Dahlin58ba1372012-04-19 22:50:08 -0400183
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +0200184 /** Matches the lifetime from the user perspective */
185 struct wl_signal user_destroy_signal;
186
John Kåre Alsaker94659272012-11-13 19:10:18 +0100187 void *renderer_state;
188
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500189 struct wl_list link;
190 struct weston_compositor *compositor;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500191
192 /** From global to output buffer coordinates. */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500193 struct weston_matrix matrix;
Derek Foremanc0023212015-03-24 11:36:13 -0500194 /** From output buffer to global coordinates. */
195 struct weston_matrix inverse_matrix;
Jason Ekstrandfb23df72014-10-16 10:55:21 -0500196
Scott Moreau9d1b1122012-06-08 19:40:53 -0600197 struct wl_list animation_list;
Scott Moreau1bad5db2012-08-18 01:04:05 -0600198 int32_t x, y, width, height;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200199
200 /** Output area in global coordinates, simple rect */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500201 pixman_region32_t region;
Pekka Paalanenefd08c72015-02-23 13:54:49 +0200202
Ander Conselvan de Oliveirab8fcca92012-11-16 17:23:52 +0200203 pixman_region32_t previous_damage;
Daniel Stone09a97e22017-03-01 11:34:06 +0000204
205 /** True if damage has occurred since the last repaint for this output;
206 * if set, a repaint will eventually occur. */
207 bool repaint_needed;
Daniel Stone05df8c12017-03-03 16:59:42 +0000208
209 /** State of the repaint loop */
210 enum {
211 REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */
212 REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */
213 REPAINT_SCHEDULED, /**< repaint is scheduled to occur */
214 REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
215 } repaint_status;
216
Daniel Stone6847b852017-03-01 11:34:08 +0000217 /** If repaint_status is REPAINT_SCHEDULED, contains the time the
218 * next repaint should be run */
219 struct timespec next_repaint;
220
Pekka Paalanendcbcfc72017-10-26 14:33:59 +0300221 /** For cancelling the idle_repaint callback on output destruction. */
222 struct wl_event_source *idle_repaint_source;
223
Scott Moreauccbf29d2012-02-22 14:21:41 -0700224 struct weston_output_zoom zoom;
225 int dirty;
Kristian Høgsberg5fb70bf2012-05-24 12:29:46 -0400226 struct wl_signal frame_signal;
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +0200227 struct wl_signal destroy_signal; /**< sent when disabled */
Zhang, Xiong Yf3012412013-12-13 22:10:53 +0200228 int move_x, move_y;
Alexandros Frantzise6ac2af2017-11-16 18:20:53 +0200229 struct timespec frame_time; /* presentation timestamp */
Pekka Paalanen641307c2014-09-23 22:08:47 -0400230 uint64_t msc; /* media stream counter */
Kristian Høgsberg79af73e2012-08-03 15:45:23 -0400231 int disable_planes;
Ander Conselvan de Oliveirae1e23522013-12-13 22:10:55 +0200232 int destroying;
Pekka Paalanen133e4392014-09-23 22:08:46 -0400233 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500234
Kristian Høgsberg05890dc2012-08-10 10:09:20 -0400235 uint32_t transform;
Hardening57388e42013-09-18 23:56:36 +0200236 int32_t native_scale;
Hardeningff39efa2013-09-18 23:56:35 +0200237 int32_t current_scale;
Hardening57388e42013-09-18 23:56:36 +0200238 int32_t original_scale;
Alexander Larsson4ea95522013-05-22 14:41:37 +0200239
Hardening57388e42013-09-18 23:56:36 +0200240 struct weston_mode *native_mode;
Hardeningff39efa2013-09-18 23:56:35 +0200241 struct weston_mode *current_mode;
242 struct weston_mode *original_mode;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500243 struct wl_list mode_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500244
Pekka Paalanen7cdbabe2017-03-28 16:27:25 +0300245 struct wl_list head_list; /**< List of driven weston_heads */
Pekka Paalanen01f60212017-03-24 15:39:24 +0200246
Jonas Ådahle5a12252013-04-05 23:07:11 +0200247 void (*start_repaint_loop)(struct weston_output *output);
David Herrmann1edf44c2013-10-22 17:11:26 +0200248 int (*repaint)(struct weston_output *output,
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000249 pixman_region32_t *damage,
250 void *repaint_data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500251 void (*destroy)(struct weston_output *output);
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000252 void (*assign_planes)(struct weston_output *output, void *repaint_data);
Alex Wu2dda6042012-04-17 17:20:47 +0800253 int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200254
Tiago Vignatti5ab91ad2012-03-12 19:40:09 -0300255 /* backlight values are on 0-255 range, where higher is brighter */
Kristian Høgsberg7c609122013-05-23 20:30:26 -0400256 int32_t backlight_current;
Tiago Vignatti8e53c7f2012-02-29 19:53:50 +0200257 void (*set_backlight)(struct weston_output *output, uint32_t value);
258 void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
Richard Hughese7299962013-05-01 21:52:12 +0100259
260 uint16_t gamma_size;
261 void (*set_gamma)(struct weston_output *output,
262 uint16_t size,
263 uint16_t *r,
264 uint16_t *g,
265 uint16_t *b);
Pekka Paalanenb5026542014-11-12 15:09:24 +0200266
267 struct weston_timeline_object timeline;
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200268
Pekka Paalanen7f340ff2017-03-30 14:56:22 +0300269 bool enabled; /**< is in the output_list, not pending list */
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200270 int scale;
271
272 int (*enable)(struct weston_output *output);
273 int (*disable)(struct weston_output *output);
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300274
275 /** Attach a head in the backend
276 *
277 * @param output The output to attach to.
278 * @param head The head to attach.
279 * @return 0 on success, -1 on failure.
280 *
281 * Do anything necessary to account for a new head being attached to
282 * the output, and check any conditions possible. On failure, both
283 * the head and the output must be left as before the call.
284 *
285 * Libweston core will add the head to the head_list after a successful
286 * call.
287 */
288 int (*attach_head)(struct weston_output *output,
289 struct weston_head *head);
290
291 /** Detach a head in the backend
292 *
293 * @param output The output to detach from.
294 * @param head The head to detach.
295 *
296 * Do any clean-up necessary to detach this head from the output.
297 * The head has already been removed from the output's head_list.
298 */
299 void (*detach_head)(struct weston_output *output,
300 struct weston_head *head);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500301};
302
Jonas Ådahld2510102014-10-05 21:39:14 +0200303enum weston_pointer_motion_mask {
304 WESTON_POINTER_MOTION_ABS = 1 << 0,
305 WESTON_POINTER_MOTION_REL = 1 << 1,
Jonas Ådahl3845b322014-10-21 23:51:29 +0200306 WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2,
Jonas Ådahld2510102014-10-05 21:39:14 +0200307};
308
309struct weston_pointer_motion_event {
310 uint32_t mask;
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200311 struct timespec time;
Jonas Ådahld2510102014-10-05 21:39:14 +0200312 double x;
313 double y;
314 double dx;
315 double dy;
Jonas Ådahl3845b322014-10-21 23:51:29 +0200316 double dx_unaccel;
317 double dy_unaccel;
Jonas Ådahld2510102014-10-05 21:39:14 +0200318};
319
Peter Hutterer89b6a492016-01-18 15:58:17 +1000320struct weston_pointer_axis_event {
321 uint32_t axis;
Giulio Camuffo90a6fc62016-03-22 17:44:54 +0200322 double value;
Peter Hutterer87743e92016-01-18 16:38:22 +1000323 bool has_discrete;
324 int32_t discrete;
Peter Hutterer89b6a492016-01-18 15:58:17 +1000325};
326
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400327struct weston_pointer_grab;
328struct weston_pointer_grab_interface {
Kristian Høgsberg6848c252013-05-08 22:02:59 -0400329 void (*focus)(struct weston_pointer_grab *grab);
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200330 void (*motion)(struct weston_pointer_grab *grab,
331 const struct timespec *time,
Jonas Ådahld2510102014-10-05 21:39:14 +0200332 struct weston_pointer_motion_event *event);
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400333 void (*button)(struct weston_pointer_grab *grab,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200334 const struct timespec *time,
335 uint32_t button, uint32_t state);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200336 void (*axis)(struct weston_pointer_grab *grab,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200337 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000338 struct weston_pointer_axis_event *event);
Peter Hutterer87743e92016-01-18 16:38:22 +1000339 void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
340 void (*frame)(struct weston_pointer_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200341 void (*cancel)(struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400342};
343
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400344struct weston_pointer_grab {
345 const struct weston_pointer_grab_interface *interface;
346 struct weston_pointer *pointer;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400347};
348
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400349struct weston_keyboard_grab;
350struct weston_keyboard_grab_interface {
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200351 void (*key)(struct weston_keyboard_grab *grab,
352 const struct timespec *time, uint32_t key, uint32_t state);
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400353 void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400354 uint32_t mods_depressed, uint32_t mods_latched,
355 uint32_t mods_locked, uint32_t group);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200356 void (*cancel)(struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400357};
358
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400359struct weston_keyboard_grab {
360 const struct weston_keyboard_grab_interface *interface;
361 struct weston_keyboard *keyboard;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400362};
363
Kristian Høgsberge329f362013-05-06 22:19:57 -0400364struct weston_touch_grab;
365struct weston_touch_grab_interface {
366 void (*down)(struct weston_touch_grab *grab,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200367 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400368 int touch_id,
369 wl_fixed_t sx,
370 wl_fixed_t sy);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400371 void (*up)(struct weston_touch_grab *grab,
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200372 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400373 int touch_id);
Kristian Høgsberge329f362013-05-06 22:19:57 -0400374 void (*motion)(struct weston_touch_grab *grab,
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200375 const struct timespec *time,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400376 int touch_id,
377 wl_fixed_t sx,
378 wl_fixed_t sy);
Jonas Ådahl1679f232014-04-12 09:39:51 +0200379 void (*frame)(struct weston_touch_grab *grab);
Jonas Ådahl1ea343e2013-10-25 23:18:05 +0200380 void (*cancel)(struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400381};
382
Kristian Høgsberge329f362013-05-06 22:19:57 -0400383struct weston_touch_grab {
384 const struct weston_touch_grab_interface *interface;
385 struct weston_touch *touch;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400386};
387
Kristian Høgsberg5e76a492013-07-25 16:09:37 -0700388struct weston_data_offer {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500389 struct wl_resource *resource;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700390 struct weston_data_source *source;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400391 struct wl_listener source_destroy_listener;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100392 uint32_t dnd_actions;
393 enum wl_data_device_manager_dnd_action preferred_dnd_action;
394 bool in_ask;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400395};
396
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700397struct weston_data_source {
Jason Ekstrand8a4a9eb2013-06-14 10:07:55 -0500398 struct wl_resource *resource;
399 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400400 struct wl_array mime_types;
Carlos Garnacho78d4bf92016-01-15 21:14:23 +0100401 struct weston_data_offer *offer;
402 struct weston_seat *seat;
403 bool accepted;
Carlos Garnacho9c931792016-01-18 23:52:12 +0100404 bool actions_set;
405 uint32_t dnd_actions;
406 enum wl_data_device_manager_dnd_action current_dnd_action;
Carlos Garnachob2889882016-01-15 21:14:26 +0100407 enum wl_data_device_manager_dnd_action compositor_action;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400408
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700409 void (*accept)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400410 uint32_t serial, const char *mime_type);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700411 void (*send)(struct weston_data_source *source,
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400412 const char *mime_type, int32_t fd);
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700413 void (*cancel)(struct weston_data_source *source);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400414};
415
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800416struct weston_pointer_client {
417 struct wl_list link;
418 struct wl_client *client;
419 struct wl_list pointer_resources;
Jonas Ådahl30d61d82014-10-22 21:21:17 +0200420 struct wl_list relative_pointer_resources;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800421};
422
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400423struct weston_pointer {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400424 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400425
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800426 struct wl_list pointer_clients;
427
Jason Ekstranda7af7042013-10-12 22:38:11 -0500428 struct weston_view *focus;
Jonas Ådahl2cbf2932015-07-22 12:05:38 +0800429 struct weston_pointer_client *focus_client;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400430 uint32_t focus_serial;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100431 struct wl_listener focus_view_listener;
432 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400433 struct wl_signal focus_signal;
Giulio Camuffo6fcb3782013-11-14 23:42:50 +0100434 struct wl_signal motion_signal;
Jonas Ådahl3eb4ddd2016-07-22 17:52:58 +0800435 struct wl_signal destroy_signal;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400436
Jason Ekstranda7af7042013-10-12 22:38:11 -0500437 struct weston_view *sprite;
Kristian Høgsberg195b8692013-05-08 15:02:05 -0400438 struct wl_listener sprite_destroy_listener;
439 int32_t hotspot_x, hotspot_y;
440
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400441 struct weston_pointer_grab *grab;
442 struct weston_pointer_grab default_grab;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400443 wl_fixed_t grab_x, grab_y;
444 uint32_t grab_button;
445 uint32_t grab_serial;
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200446 struct timespec grab_time;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400447
448 wl_fixed_t x, y;
Kristian Høgsbergdb1fccb2014-02-05 17:14:42 -0800449 wl_fixed_t sx, sy;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400450 uint32_t button_count;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +0200451
452 struct wl_listener output_destroy_listener;
Alexandros Frantzisdb907b72018-02-20 14:06:26 +0200453
454 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400455};
456
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400457
Kristian Høgsberge329f362013-05-06 22:19:57 -0400458struct weston_touch {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400459 struct weston_seat *seat;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400460
461 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100462 struct wl_list focus_resource_list;
Jason Ekstranda7af7042013-10-12 22:38:11 -0500463 struct weston_view *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100464 struct wl_listener focus_view_listener;
465 struct wl_listener focus_resource_listener;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400466 uint32_t focus_serial;
467 struct wl_signal focus_signal;
468
Jonas Ådahl9484b692013-12-02 22:05:03 +0100469 uint32_t num_tp;
470
Kristian Høgsberge329f362013-05-06 22:19:57 -0400471 struct weston_touch_grab *grab;
472 struct weston_touch_grab default_grab;
Neil Roberts306fe082013-10-03 16:43:06 +0100473 int grab_touch_id;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400474 wl_fixed_t grab_x, grab_y;
475 uint32_t grab_serial;
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200476 struct timespec grab_time;
Alexandros Frantzisd7157842018-02-20 14:07:03 +0200477
478 struct wl_list timestamps_list;
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400479};
480
Jonas Ådahld2510102014-10-05 21:39:14 +0200481void
482weston_pointer_motion_to_abs(struct weston_pointer *pointer,
483 struct weston_pointer_motion_event *event,
484 wl_fixed_t *x, wl_fixed_t *y);
485
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400486void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +0200487weston_pointer_send_motion(struct weston_pointer *pointer,
488 const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200489 struct weston_pointer_motion_event *event);
490bool
491weston_pointer_has_focus_resource(struct weston_pointer *pointer);
492void
493weston_pointer_send_button(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200494 const struct timespec *time,
495 uint32_t button, uint32_t state_w);
Quentin Glidiccde13452016-08-12 10:41:32 +0200496void
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200497weston_pointer_send_axis(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +0200498 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +1000499 struct weston_pointer_axis_event *event);
Jonas Ådahl0336ca02014-10-04 16:28:29 +0200500void
Peter Hutterer87743e92016-01-18 16:38:22 +1000501weston_pointer_send_axis_source(struct weston_pointer *pointer,
502 uint32_t source);
503void
504weston_pointer_send_frame(struct weston_pointer *pointer);
505
506void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400507weston_pointer_set_focus(struct weston_pointer *pointer,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500508 struct weston_view *view,
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400509 wl_fixed_t sx, wl_fixed_t sy);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400510void
Derek Foremanf9318d12015-05-11 15:40:11 -0500511weston_pointer_clear_focus(struct weston_pointer *pointer);
512void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400513weston_pointer_start_grab(struct weston_pointer *pointer,
514 struct weston_pointer_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400515void
Kristian Høgsberg02bbabb2013-05-06 22:15:05 -0400516weston_pointer_end_grab(struct weston_pointer *pointer);
Rob Bradford806d8c02013-06-25 18:56:41 +0100517void
518weston_pointer_clamp(struct weston_pointer *pointer,
519 wl_fixed_t *fx, wl_fixed_t *fy);
Giulio Camuffo1959ab82013-11-14 23:42:52 +0100520void
521weston_pointer_move(struct weston_pointer *pointer,
Jonas Ådahld2510102014-10-05 21:39:14 +0200522 struct weston_pointer_motion_event *event);
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100523void
524weston_pointer_set_default_grab(struct weston_pointer *pointer,
525 const struct weston_pointer_grab_interface *interface);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400526
Jonas Ådahld3414f22016-07-22 17:56:31 +0800527void
528weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
529
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400530void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400531weston_keyboard_set_focus(struct weston_keyboard *keyboard,
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400532 struct weston_surface *surface);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400533void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400534weston_keyboard_start_grab(struct weston_keyboard *device,
535 struct weston_keyboard_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400536void
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400537weston_keyboard_end_grab(struct weston_keyboard *keyboard);
Giulio Camuffo6ef444d2014-08-28 19:44:09 +0300538int
539/*
540 * 'mask' and 'value' should be a bitwise mask of one or more
541 * valued of the weston_keyboard_locks enum.
542 */
543weston_keyboard_set_locks(struct weston_keyboard *keyboard,
544 uint32_t mask, uint32_t value);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400545
Quentin Glidiccde13452016-08-12 10:41:32 +0200546bool
547weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
548void
549weston_keyboard_send_key(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200550 const struct timespec *time, uint32_t key,
Quentin Glidiccde13452016-08-12 10:41:32 +0200551 enum wl_keyboard_key_state state);
552void
553weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
554 uint32_t serial, uint32_t mods_depressed,
555 uint32_t mods_latched,
556 uint32_t mods_locked, uint32_t group);
557
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400558void
Derek Foreman4c93c082015-04-30 16:45:41 -0500559weston_touch_set_focus(struct weston_touch *touch,
Jason Ekstranda7af7042013-10-12 22:38:11 -0500560 struct weston_view *view);
Michael Fua2bb7912013-07-23 15:51:06 +0800561void
Louis-Francis Ratté-Boulianne8549e162017-11-28 20:42:47 -0500562weston_touch_start_grab(struct weston_touch *touch,
Kristian Høgsberge329f362013-05-06 22:19:57 -0400563 struct weston_touch_grab *grab);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400564void
Kristian Høgsberge329f362013-05-06 22:19:57 -0400565weston_touch_end_grab(struct weston_touch *touch);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400566
Quentin Glidiccde13452016-08-12 10:41:32 +0200567bool
568weston_touch_has_focus_resource(struct weston_touch *touch);
569void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200570weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
Quentin Glidiccde13452016-08-12 10:41:32 +0200571 int touch_id, wl_fixed_t x, wl_fixed_t y);
572void
Alexandros Frantzis27a51b82017-11-16 18:20:59 +0200573weston_touch_send_up(struct weston_touch *touch, const struct timespec *time,
574 int touch_id);
Quentin Glidiccde13452016-08-12 10:41:32 +0200575void
Alexandros Frantzis7d2abcf2017-11-16 18:21:00 +0200576weston_touch_send_motion(struct weston_touch *touch,
577 const struct timespec *time, int touch_id,
578 wl_fixed_t x, wl_fixed_t y);
Quentin Glidiccde13452016-08-12 10:41:32 +0200579void
580weston_touch_send_frame(struct weston_touch *touch);
581
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400582void
Kristian Høgsberge3148752013-05-06 23:19:49 -0400583wl_data_device_set_keyboard_focus(struct weston_seat *seat);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400584
585int
586wl_data_device_manager_init(struct wl_display *display);
587
588
589void
Kristian Høgsberge3148752013-05-06 23:19:49 -0400590weston_seat_set_selection(struct weston_seat *seat,
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700591 struct weston_data_source *source, uint32_t serial);
Giulio Camuffodddf9e62015-05-01 12:59:35 +0300592void
593weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
594
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700595int
Xiong Zhangfd51e7b2013-11-25 18:42:49 +0800596weston_pointer_start_drag(struct weston_pointer *pointer,
Kristian Høgsberg85de9c22013-09-04 20:44:26 -0700597 struct weston_data_source *source,
598 struct weston_surface *icon,
599 struct wl_client *client);
Xiong Zhangfd51e7b2013-11-25 18:42:49 +0800600int
601weston_touch_start_drag(struct weston_touch *touch,
602 struct weston_data_source *source,
603 struct weston_surface *icon,
604 struct wl_client *client);
Kristian Høgsberg2158a882013-04-18 15:07:39 -0400605
Daniel Stoned65b9092012-05-30 16:32:05 +0100606struct weston_xkb_info {
607 struct xkb_keymap *keymap;
Daniel Stoneb7452fe2012-06-01 12:14:06 +0100608 int keymap_fd;
609 size_t keymap_size;
610 char *keymap_area;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +0000611 int32_t ref_count;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100612 xkb_mod_index_t shift_mod;
613 xkb_mod_index_t caps_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100614 xkb_mod_index_t ctrl_mod;
615 xkb_mod_index_t alt_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100616 xkb_mod_index_t mod2_mod;
617 xkb_mod_index_t mod3_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100618 xkb_mod_index_t super_mod;
Daniel Stoneabb9dcd2012-06-22 13:21:33 +0100619 xkb_mod_index_t mod5_mod;
Daniel Stoned65b9092012-05-30 16:32:05 +0100620 xkb_led_index_t num_led;
621 xkb_led_index_t caps_led;
622 xkb_led_index_t scroll_led;
623};
624
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100625struct weston_keyboard {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400626 struct weston_seat *seat;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100627
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400628 struct wl_list resource_list;
Neil Roberts96d790e2013-09-19 17:32:00 +0100629 struct wl_list focus_resource_list;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400630 struct weston_surface *focus;
Giulio Camuffo576fe2a2013-11-20 18:00:24 +0100631 struct wl_listener focus_resource_listener;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400632 uint32_t focus_serial;
633 struct wl_signal focus_signal;
634
635 struct weston_keyboard_grab *grab;
636 struct weston_keyboard_grab default_grab;
637 uint32_t grab_key;
638 uint32_t grab_serial;
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200639 struct timespec grab_time;
Kristian Høgsberg29139d42013-04-18 15:25:39 -0400640
641 struct wl_array keys;
642
643 struct {
644 uint32_t mods_depressed;
645 uint32_t mods_latched;
646 uint32_t mods_locked;
647 uint32_t group;
648 } modifiers;
649
650 struct weston_keyboard_grab input_method_grab;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100651 struct wl_resource *input_method_resource;
Jonas Ådahl7395ea02013-12-03 09:14:26 +0100652
653 struct weston_xkb_info *xkb_info;
654 struct {
655 struct xkb_state *state;
656 enum weston_led leds;
657 } xkb_state;
658 struct xkb_keymap *pending_keymap;
Alexandros Frantzis2b442482018-02-20 14:05:50 +0200659
660 struct wl_list timestamps_list;
Jan Arne Petersena75a7892013-01-16 21:26:50 +0100661};
662
Daniel Stone37816df2012-05-16 18:45:18 +0100663struct weston_seat {
Kristian Høgsberge3148752013-05-06 23:19:49 -0400664 struct wl_list base_resource_list;
665
Kristian Høgsbergaaadc772013-07-08 16:20:31 -0400666 struct wl_global *global;
Derek Foreman1281a362015-07-31 16:55:32 -0500667 struct weston_pointer *pointer_state;
668 struct weston_keyboard *keyboard_state;
669 struct weston_touch *touch_state;
Jonas Ådahld6e1c342013-10-17 23:04:05 +0200670 int pointer_device_count;
671 int keyboard_device_count;
672 int touch_device_count;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400673
Rob Bradford66bd9f52013-06-25 18:56:42 +0100674 struct weston_output *output; /* constraint */
675
Giulio Camuffo5085a752013-03-25 21:42:45 +0100676 struct wl_signal destroy_signal;
Jason Ekstranda4ab5422014-04-02 19:53:45 -0500677 struct wl_signal updated_caps_signal;
Daniel Stone74419a22012-05-30 16:32:02 +0100678
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500679 struct weston_compositor *compositor;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500680 struct wl_list link;
Daniel Stone496ca172012-05-30 16:31:42 +0100681 enum weston_keyboard_modifier modifier_state;
Kristian Høgsbergfe7aa902013-05-08 09:54:37 -0400682 struct weston_surface *saved_kbd_focus;
Ander Conselvan de Oliveira71b1d0c2012-03-16 17:25:11 +0200683 struct wl_listener saved_kbd_focus_listener;
Kristian Høgsberg054c50a2013-05-08 15:27:47 -0400684 struct wl_list drag_resource_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500685
Kristian Høgsberge3148752013-05-06 23:19:49 -0400686 uint32_t selection_serial;
Kristian Høgsberg7ff3bdb2013-07-25 15:52:14 -0700687 struct weston_data_source *selection_data_source;
Kristian Høgsberge3148752013-05-06 23:19:49 -0400688 struct wl_listener selection_data_source_listener;
689 struct wl_signal selection_signal;
690
Daniel Stone8c8164f2012-05-30 16:31:45 +0100691 void (*led_update)(struct weston_seat *ws, enum weston_led leds);
692
Jan Arne Petersene829adc2012-08-10 16:47:22 +0200693 struct input_method *input_method;
Rob Bradford9af5f9e2013-05-31 18:09:50 +0100694 char *seat_name;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500695};
696
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500697enum {
Bryce Harringtonc2be8572015-12-11 13:11:37 -0800698 WESTON_COMPOSITOR_ACTIVE, /* normal rendering and events */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500699 WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */
Philipp Brüschweiler57edf7f2013-03-29 13:01:56 +0100700 WESTON_COMPOSITOR_OFFSCREEN, /* no rendering, no frame events */
Bryce Harrington873a3f82016-08-30 12:05:01 -0700701 WESTON_COMPOSITOR_SLEEPING /* same as offscreen, but also set dpms
702 * to off */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500703};
704
Giulio Camuffo412e6a52014-07-09 22:12:56 +0300705struct weston_layer_entry {
706 struct wl_list link;
707 struct weston_layer *layer;
708};
709
Quentin Glidic82681572016-12-17 13:40:51 +0100710/**
711 * Higher value means higher in the stack.
712 *
713 * These values are based on well-known concepts in a classic desktop
714 * environment. Third-party modules based on libweston are encouraged to use
715 * them to integrate better with other projects.
716 *
717 * A fully integrated environment can use any value, based on these or not,
718 * at their discretion.
719 */
720enum weston_layer_position {
721 /*
722 * Special value to make the layer invisible and still rendered.
723 * This is used by compositors wanting e.g. minimized surfaces to still
724 * receive frame callbacks.
725 */
726 WESTON_LAYER_POSITION_HIDDEN = 0x00000000,
727
728 /*
729 * There should always be a background layer with a surface covering
730 * the visible area.
731 *
732 * If the compositor handles the background itself, it should use
733 * BACKGROUND.
734 *
735 * If the compositor supports runtime-loadable modules to set the
736 * background, it should put a solid color surface at (BACKGROUND - 1)
737 * and modules must use BACKGROUND.
738 */
739 WESTON_LAYER_POSITION_BACKGROUND = 0x00000002,
740
741 /* For "desktop widgets" and applications like conky. */
742 WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000,
743
744 /* For regular applications, only one layer should have this value
745 * to ensure proper stacking control. */
746 WESTON_LAYER_POSITION_NORMAL = 0x50000000,
747
748 /* For desktop UI, like panels. */
749 WESTON_LAYER_POSITION_UI = 0x80000000,
750
751 /* For fullscreen applications that should cover UI. */
752 WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000,
753
754 /* For special UI like on-screen keyboard that fullscreen applications
755 * will need. */
756 WESTON_LAYER_POSITION_TOP_UI = 0xe0000000,
757
758 /* For the lock surface. */
759 WESTON_LAYER_POSITION_LOCK = 0xffff0000,
760
761 /* Values reserved for libweston internal usage */
762 WESTON_LAYER_POSITION_CURSOR = 0xfffffffe,
763 WESTON_LAYER_POSITION_FADE = 0xffffffff,
764};
765
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500766struct weston_layer {
Quentin Glidic82681572016-12-17 13:40:51 +0100767 struct weston_compositor *compositor;
768 struct wl_list link; /* weston_compositor::layer_list */
769 enum weston_layer_position position;
Giulio Camuffo95ec0f92014-07-09 22:12:57 +0300770 pixman_box32_t mask;
Quentin Glidic82681572016-12-17 13:40:51 +0100771 struct weston_layer_entry view_list;
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500772};
773
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400774struct weston_plane {
Xiong Zhang97116532013-10-23 13:58:31 +0800775 struct weston_compositor *compositor;
Pekka Paalanen502f5e02015-02-23 14:08:25 +0200776 pixman_region32_t damage; /**< in global coords */
Ander Conselvan de Oliveirae1bd5a02013-03-05 17:30:29 +0200777 pixman_region32_t clip;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400778 int32_t x, y;
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +0200779 struct wl_list link;
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400780};
781
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400782struct weston_renderer {
John Kåre Alsakera95b2d62012-11-13 19:10:21 +0100783 int (*read_pixels)(struct weston_output *output,
784 pixman_format_code_t format, void *pixels,
785 uint32_t x, uint32_t y,
786 uint32_t width, uint32_t height);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400787 void (*repaint_output)(struct weston_output *output,
788 pixman_region32_t *output_damage);
789 void (*flush_damage)(struct weston_surface *surface);
Jason Ekstrand6bd62942013-06-20 20:38:23 -0500790 void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
John Kåre Alsaker878f4492012-11-13 19:10:23 +0100791 void (*surface_set_color)(struct weston_surface *surface,
792 float red, float green,
793 float blue, float alpha);
Vasily Khoruzhick52cfd612013-01-08 19:09:01 +0300794 void (*destroy)(struct weston_compositor *ec);
Pekka Paalanenc647ed72015-02-09 13:16:57 +0200795
796
797 /** See weston_surface_get_content_size() */
798 void (*surface_get_content_size)(struct weston_surface *surface,
799 int *width, int *height);
800
801 /** See weston_surface_copy_content() */
802 int (*surface_copy_content)(struct weston_surface *surface,
803 void *target, size_t size,
804 int src_x, int src_y,
805 int width, int height);
Pekka Paalanen230f3b12014-09-29 14:18:40 -0400806
807 /** See weston_compositor_import_dmabuf() */
808 bool (*import_dmabuf)(struct weston_compositor *ec,
809 struct linux_dmabuf_buffer *buffer);
Varad Gautam0775cd12016-11-23 14:03:20 +0530810
Emil Velikovfbf165f2017-12-05 14:26:16 +0000811 /** On error sets num_formats to zero */
812 void (*query_dmabuf_formats)(struct weston_compositor *ec,
Varad Gautam0775cd12016-11-23 14:03:20 +0530813 int **formats, int *num_formats);
814
Emil Velikovfbf165f2017-12-05 14:26:16 +0000815 /** On error sets num_modifiers to zero */
816 void (*query_dmabuf_modifiers)(struct weston_compositor *ec,
Varad Gautam0775cd12016-11-23 14:03:20 +0530817 int format, uint64_t **modifiers,
818 int *num_modifiers);
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400819};
820
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300821enum weston_capability {
822 /* backend/renderer supports arbitrary rotation */
823 WESTON_CAP_ROTATION_ANY = 0x0001,
Pekka Paalanen4fc5dd02013-05-22 18:03:05 +0300824
825 /* screencaptures need to be y-flipped */
826 WESTON_CAP_CAPTURE_YFLIP = 0x0002,
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500827
Bryce Harringtona86c3ee2015-03-18 18:42:00 -0700828 /* backend/renderer has a separate cursor plane */
Jason Ekstrand9fc71512014-04-02 19:53:46 -0500829 WESTON_CAP_CURSOR_PLANE = 0x0004,
830
831 /* backend supports setting arbitrary resolutions */
832 WESTON_CAP_ARBITRARY_MODES = 0x0008,
Pekka Paalanen380adf52015-02-16 14:39:11 +0200833
834 /* renderer supports weston_view_set_mask() clipping */
835 WESTON_CAP_VIEW_CLIP_MASK = 0x0010,
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300836};
837
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300838/* Configuration struct for a backend.
839 *
840 * This struct carries the configuration for a backend, and it's
841 * passed to the backend's init entry point. The backend will
842 * likely want to subclass this in order to handle backend specific
843 * data.
Bryce Harrington20b66c32016-04-15 20:28:29 -0700844 *
845 * NOTE: Alternate designs were proposed (Feb 2016) for using opaque
846 * structures[1] and for section+key/value getter/setters[2]. The rationale
847 * for selecting the transparent structure design is based on several
848 * assumptions[3] which may require re-evaluating the design choice if they
849 * fail to hold.
850 *
851 * 1: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html
852 * 2: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html
853 * 3: https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300854 */
855struct weston_backend_config {
Bryce Harrington20b66c32016-04-15 20:28:29 -0700856 /** Major version for the backend-specific config struct
857 *
858 * This version must match exactly what the backend expects, otherwise
859 * the struct is incompatible.
860 */
861 uint32_t struct_version;
862
863 /** Minor version of the backend-specific config struct
864 *
865 * This must be set to sizeof(struct backend-specific config).
866 * If the value here is smaller than what the backend expects, the
867 * extra config members will assume their default values.
868 *
869 * A value greater than what the backend expects is incompatible.
870 */
871 size_t struct_size;
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300872};
873
Giulio Camuffo954f1832014-10-11 18:27:30 +0300874struct weston_backend {
Giulio Camuffoe3c0d8a2015-10-17 19:24:13 +0300875 void (*destroy)(struct weston_compositor *compositor);
Daniel Stoneb1f166d2017-03-01 11:34:10 +0000876
877 /** Begin a repaint sequence
878 *
879 * Provides the backend with explicit markers around repaint
880 * sequences, which may allow the backend to aggregate state
881 * application. This call will be bracketed by the repaint_flush (on
882 * success), or repaint_cancel (when any output in the grouping fails
883 * repaint).
884 *
885 * Returns an opaque pointer, which the backend may use as private
886 * data referring to the repaint cycle.
887 */
888 void * (*repaint_begin)(struct weston_compositor *compositor);
889
890 /** Cancel a repaint sequence
891 *
892 * Cancels a repaint sequence, when an error has occurred during
893 * one output's repaint; see repaint_begin.
894 *
895 * @param repaint_data Data returned by repaint_begin
896 */
897 void (*repaint_cancel)(struct weston_compositor *compositor,
898 void *repaint_data);
899
900 /** Conclude a repaint sequence
901 *
902 * Called on successful completion of a repaint sequence; see
903 * repaint_begin.
904 *
905 * @param repaint_data Data returned by repaint_begin
906 */
907 void (*repaint_flush)(struct weston_compositor *compositor,
908 void *repaint_data);
Pekka Paalanen992a8cb2017-08-16 10:39:17 +0300909
910 /** Allocate a new output
911 *
912 * @param compositor The compositor.
913 * @param name Name for the new output.
914 *
915 * Allocates a new output structure that embeds a weston_output,
916 * initializes it, and returns the pointer to the weston_output
917 * member.
918 *
919 * Must set weston_output members @c destroy, @c enable and @c disable.
920 */
921 struct weston_output *
922 (*create_output)(struct weston_compositor *compositor,
923 const char *name);
Giulio Camuffo954f1832014-10-11 18:27:30 +0300924};
925
Quentin Glidic955cec02016-08-12 10:41:35 +0200926struct weston_desktop_xwayland;
927struct weston_desktop_xwayland_interface;
928
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500929struct weston_compositor {
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -0400930 struct wl_signal destroy_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500931
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500932 struct wl_display *wl_display;
Quentin Glidic955cec02016-08-12 10:41:35 +0200933 struct weston_desktop_xwayland *xwayland;
934 const struct weston_desktop_xwayland_interface *xwayland_interface;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500935
Tiago Vignattifb2adba2013-06-12 15:43:21 -0300936 /* surface signals */
Kristian Høgsbergf03a04a2014-04-06 22:04:50 -0700937 struct wl_signal create_surface_signal;
Kristian Høgsberg02e79dc2012-04-12 09:55:26 -0400938 struct wl_signal activate_signal;
Tiago Vignattifb2adba2013-06-12 15:43:21 -0300939 struct wl_signal transform_signal;
940
Tiago Vignatti1d01b012012-09-27 17:48:36 +0300941 struct wl_signal kill_signal;
Ander Conselvan de Oliveiraa4575632013-02-21 18:35:23 +0200942 struct wl_signal idle_signal;
943 struct wl_signal wake_signal;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500944
Jan Arne Petersen42feced2012-06-21 21:52:17 +0200945 struct wl_signal show_input_panel_signal;
946 struct wl_signal hide_input_panel_signal;
Jan Arne Petersen14da96b2013-04-18 16:47:28 +0200947 struct wl_signal update_input_panel_signal;
Jan Arne Petersen42feced2012-06-21 21:52:17 +0200948
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +0100949 struct wl_signal seat_created_signal;
Richard Hughes59d5da72013-05-01 21:52:11 +0100950 struct wl_signal output_created_signal;
Ander Conselvan de Oliveiraf84327a2014-01-29 18:47:51 +0200951 struct wl_signal output_destroyed_signal;
Ander Conselvan de Oliveiraa8a9baf2014-01-29 18:47:52 +0200952 struct wl_signal output_moved_signal;
David Fort0de859e2016-05-27 23:22:57 +0200953 struct wl_signal output_resized_signal; /* callback argument: resized output */
Jan Arne Petersen674fd1d2012-11-18 19:06:42 +0100954
Pekka Paalanen8dc6db82018-03-20 13:29:40 +0200955 /* Signal for output changes triggered by configuration from frontend
956 * or head state changes from backend.
957 */
958 struct wl_signal output_heads_changed_signal; /* arg: weston_output */
959
Kristian Høgsberg61741a22013-09-17 16:02:57 -0700960 struct wl_signal session_signal;
961 int session_active;
962
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -0500963 struct weston_layer fade_layer;
964 struct weston_layer cursor_layer;
965
Armin Krezovića01ab6d2016-09-30 14:11:02 +0200966 struct wl_list pending_output_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500967 struct wl_list output_list;
Pekka Paalanen1adcbac2017-08-14 16:05:35 +0300968 struct wl_list head_list; /* struct weston_head::compositor_link */
Daniel Stone37816df2012-05-16 18:45:18 +0100969 struct wl_list seat_list;
Quentin Glidic82681572016-12-17 13:40:51 +0100970 struct wl_list layer_list; /* struct weston_layer::link */
Pekka Paalanen20c7e552016-03-30 14:08:24 +0300971 struct wl_list view_list; /* struct weston_view::link */
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +0200972 struct wl_list plane_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +0100973 struct wl_list key_binding_list;
Daniel Stone96d47c02013-11-19 11:37:12 +0100974 struct wl_list modifier_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +0100975 struct wl_list button_binding_list;
Neil Robertsa28c6932013-10-03 16:43:04 +0100976 struct wl_list touch_binding_list;
Daniel Stone325fc2d2012-05-30 16:31:58 +0100977 struct wl_list axis_binding_list;
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +0200978 struct wl_list debug_binding_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500979
980 uint32_t state;
981 struct wl_event_source *idle_source;
982 uint32_t idle_inhibit;
Philipp Brüschweiler4b409c32013-03-10 14:37:04 +0100983 int idle_time; /* timeout, s */
Daniel Stone6847b852017-03-01 11:34:08 +0000984 struct wl_event_source *repaint_timer;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500985
Giulio Camuffocdb4d292013-11-14 23:42:53 +0100986 const struct weston_pointer_grab_interface *default_pointer_grab;
987
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500988 /* Repaint state. */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -0400989 struct weston_plane primary_plane;
Pekka Paalanen7bb65102013-05-22 18:03:04 +0300990 uint32_t capabilities; /* combination of enum weston_capability */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -0500991
Kristian Høgsbergfa1be022012-09-05 22:49:55 -0400992 struct weston_renderer *renderer;
993
John Kåre Alsakerf9e710b2012-11-13 19:10:22 +0100994 pixman_format_code_t read_format;
Pekka Paalanen52bfbaa2012-04-11 16:19:37 +0300995
Giulio Camuffo954f1832014-10-11 18:27:30 +0300996 struct weston_backend *backend;
Kristian Høgsberg3466bc82012-01-03 11:29:15 -0500997
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700998 struct weston_launcher *launcher;
Casey Dahlin58ba1372012-04-19 22:50:08 -0400999
Pekka Paalanen827b5d22016-06-29 11:54:26 +02001000 struct wl_list plugin_api_list; /* struct weston_plugin_api::link */
1001
Casey Dahlin58ba1372012-04-19 22:50:08 -04001002 uint32_t output_id_pool;
Daniel Stone855028f2012-05-01 20:37:10 +01001003
Daniel Stonee379da92012-05-30 16:32:04 +01001004 struct xkb_rule_names xkb_names;
1005 struct xkb_context *xkb_context;
Andrew Wedgbury9a6f02a2013-09-05 13:31:40 +00001006 struct weston_xkb_info *xkb_info;
Matt Roper01a92732013-06-24 16:52:44 +01001007
Jonny Lamb66a41a02014-08-12 14:58:25 +02001008 int32_t kb_repeat_rate;
1009 int32_t kb_repeat_delay;
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001010
Bob Ham91880f12016-01-12 10:21:47 +00001011 bool vt_switching;
1012
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001013 clockid_t presentation_clock;
Pekka Paalanen0513a952014-05-21 16:17:27 +03001014 int32_t repaint_msec;
Frederic Plourdec336f062014-10-29 14:44:33 -04001015
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001016 unsigned int activate_serial;
1017
Jonas Ådahld3414f22016-07-22 17:56:31 +08001018 struct wl_global *pointer_constraints;
1019
Frederic Plourdec336f062014-10-29 14:44:33 -04001020 int exit_code;
Giulio Camuffo459137b2014-10-11 23:56:24 +03001021
1022 void *user_data;
1023 void (*exit)(struct weston_compositor *c);
Daniel Díaz75b71972016-10-21 14:03:13 -05001024
1025 /* Whether to let the compositor run without any input device. */
1026 bool require_input;
1027
Pekka Paalanen8dc6db82018-03-20 13:29:40 +02001028 /* Signal for a backend to inform a frontend about possible changes
1029 * in head status.
1030 */
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03001031 struct wl_signal heads_changed_signal;
1032 struct wl_event_source *heads_changed_source;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001033};
1034
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001035struct weston_buffer {
1036 struct wl_resource *resource;
1037 struct wl_signal destroy_signal;
1038 struct wl_listener destroy_listener;
1039
1040 union {
1041 struct wl_shm_buffer *shm_buffer;
Jason Ekstranda85118c2013-06-27 20:17:02 -05001042 void *legacy_buffer;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001043 };
1044 int32_t width, height;
1045 uint32_t busy_count;
Stanislav Vorobiovbfbb8e52013-08-29 11:36:44 +04001046 int y_inverted;
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001047};
1048
Pekka Paalanende685b82012-12-04 15:58:12 +02001049struct weston_buffer_reference {
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001050 struct weston_buffer *buffer;
Pekka Paalanende685b82012-12-04 15:58:12 +02001051 struct wl_listener destroy_listener;
1052};
1053
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001054struct weston_buffer_viewport {
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001055 struct {
1056 /* wl_surface.set_buffer_transform */
1057 uint32_t transform;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001058
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001059 /* wl_surface.set_scaling_factor */
1060 int32_t scale;
Jonny Lamb74130762013-11-26 18:19:46 +01001061
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001062 /*
1063 * If src_width != wl_fixed_from_int(-1),
1064 * then and only then src_* are used.
1065 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001066 wl_fixed_t src_x, src_y;
1067 wl_fixed_t src_width, src_height;
1068 } buffer;
1069
1070 struct {
Pekka Paalanenf0cad482014-03-14 14:38:16 +02001071 /*
1072 * If width == -1, the size is inferred from the buffer.
1073 */
Pekka Paalanen952b6c82014-03-14 14:38:15 +02001074 int32_t width, height;
1075 } surface;
George Kiagiadakis8f9e87f2014-06-13 18:14:20 +02001076
1077 int changed;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001078};
1079
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001080struct weston_region {
Jason Ekstrand8895efc2013-06-14 10:07:56 -05001081 struct wl_resource *resource;
Kristian Høgsberg5e7e6f22012-02-23 16:11:59 -05001082 pixman_region32_t region;
1083};
1084
Jason Ekstranda7af7042013-10-12 22:38:11 -05001085/* Using weston_view transformations
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001086 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001087 * To add a transformation to a view, create a struct weston_transform, and
1088 * add it to the list view->geometry.transformation_list. Whenever you
1089 * change the list, anything under view->geometry, or anything in the
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001090 * weston_transforms linked into the list, you must call
Jason Ekstranda7af7042013-10-12 22:38:11 -05001091 * weston_view_geometry_dirty().
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001092 *
1093 * The order in the list defines the order of transformations. Let the list
1094 * contain the transformation matrices M1, ..., Mn as head to tail. The
Jason Ekstranda7af7042013-10-12 22:38:11 -05001095 * transformation is applied to view-local coordinate vector p as
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001096 * P = Mn * ... * M2 * M1 * p
1097 * to produce the global coordinate vector P. The total transform
1098 * Mn * ... * M2 * M1
Jason Ekstranda7af7042013-10-12 22:38:11 -05001099 * is cached in view->transform.matrix, and the inverse of it in
1100 * view->transform.inverse.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001101 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001102 * The list always contains view->transform.position transformation, which
1103 * is the translation by view->geometry.x and y.
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001104 *
1105 * If you want to apply a transformation in local coordinates, add your
1106 * weston_transform to the head of the list. If you want to apply a
1107 * transformation in global coordinates, add it to the tail of the list.
Pekka Paalanen483243f2013-03-08 14:56:50 +02001108 *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001109 * If view->geometry.parent is set, the total transformation of this
1110 * view will be the parent's total transformation and this transformation
Pekka Paalanen483243f2013-03-08 14:56:50 +02001111 * combined:
1112 * Mparent * Mn * ... * M2 * M1
Pekka Paalanen44ab69c2012-02-07 13:18:00 +02001113 */
1114
Jason Ekstranda7af7042013-10-12 22:38:11 -05001115struct weston_view {
1116 struct weston_surface *surface;
1117 struct wl_list surface_link;
Jason Ekstrand26ed73c2013-06-06 22:34:41 -05001118 struct wl_signal destroy_signal;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001119
Pekka Paalanen20c7e552016-03-30 14:08:24 +03001120 struct wl_list link; /* weston_compositor::view_list */
Pekka Paalanen8844bf22015-02-18 16:30:47 +02001121 struct weston_layer_entry layer_link; /* part of geometry */
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001122 struct weston_plane *plane;
Pekka Paalanen2d6e5512015-02-18 16:06:46 +02001123
1124 /* For weston_layer inheritance from another view */
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001125 struct weston_view *parent_view;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001126
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001127 unsigned int click_to_activate_serial;
1128
Pekka Paalanen51723d52015-02-17 13:10:01 +02001129 pixman_region32_t clip; /* See weston_view_damage_below() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001130 float alpha; /* part of geometry, see below */
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001131
John Kåre Alsaker878f4492012-11-13 19:10:23 +01001132 void *renderer_state;
1133
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001134 /* Surface geometry state, mutable.
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001135 * If you change anything, call weston_surface_geometry_dirty().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001136 * That includes the transformations referenced from the list.
1137 */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001138 struct {
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001139 float x, y; /* surface translation on display */
Pekka Paalanenba3cf952012-01-25 16:22:05 +02001140
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001141 /* struct weston_transform */
1142 struct wl_list transformation_list;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001143
1144 /* managed by weston_surface_set_transform_parent() */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001145 struct weston_view *parent;
Pekka Paalanen483243f2013-03-08 14:56:50 +02001146 struct wl_listener parent_destroy_listener;
1147 struct wl_list child_list; /* geometry.parent_link */
1148 struct wl_list parent_link;
Pekka Paalanen380adf52015-02-16 14:39:11 +02001149
1150 /* managed by weston_view_set_mask() */
1151 bool scissor_enabled;
1152 pixman_region32_t scissor; /* always a simple rect */
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001153 } geometry;
1154
1155 /* State derived from geometry state, read-only.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001156 * This is updated by weston_view_update_transform().
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001157 */
1158 struct {
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001159 int dirty;
1160
Pekka Paalanenfbd00f12015-02-19 11:49:18 +02001161 /* Approximations in global coordinates:
1162 * - boundingbox is guaranteed to include the whole view in
1163 * the smallest possible single rectangle.
1164 * - opaque is guaranteed to be fully opaque, though not
1165 * necessarily include all opaque areas.
1166 */
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001167 pixman_region32_t boundingbox;
Pekka Paalanen730d87e2012-02-09 16:39:38 +02001168 pixman_region32_t opaque;
Pekka Paalanen6720d8f2012-01-25 15:17:40 +02001169
Pekka Paalanenbc0b7e72012-01-24 09:53:37 +02001170 /* matrix and inverse are used only if enabled = 1.
1171 * If enabled = 0, use x, y, width, height directly.
1172 */
1173 int enabled;
Pekka Paalanen061b7472012-01-12 15:00:57 +02001174 struct weston_matrix matrix;
Pekka Paalanend1f0ab62012-01-20 10:47:57 +02001175 struct weston_matrix inverse;
Pekka Paalanencd403622012-01-25 13:37:39 +02001176
1177 struct weston_transform position; /* matrix from x, y */
Pekka Paalanenc61eca62012-01-06 14:10:06 +02001178 } transform;
1179
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001180 /*
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001181 * The primary output for this view.
1182 * Used for picking the output for driving internal animations on the
1183 * view, inheriting the primary output for related views in shells, etc.
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001184 */
1185 struct weston_output *output;
Semi Malinene7a52fb2018-04-26 11:08:10 +02001186 struct wl_listener output_destroy_listener;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001187
Casey Dahlin9074db52012-04-19 22:50:09 -04001188 /*
1189 * A more complete representation of all outputs this surface is
1190 * displayed on.
1191 */
1192 uint32_t output_mask;
Pekka Paalanenbf0e0312014-12-17 16:20:41 +02001193
1194 /* Per-surface Presentation feedback flags, controlled by backend. */
1195 uint32_t psf_flags;
Armin Krezovićf8486c32016-06-30 06:04:28 +02001196
1197 bool is_mapped;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001198};
1199
Jason Ekstrand7b982072014-05-20 14:33:03 -05001200struct weston_surface_state {
1201 /* wl_surface.attach */
1202 int newly_attached;
1203 struct weston_buffer *buffer;
1204 struct wl_listener buffer_destroy_listener;
1205 int32_t sx;
1206 int32_t sy;
1207
1208 /* wl_surface.damage */
Derek Foreman152254b2015-11-26 14:17:48 -06001209 pixman_region32_t damage_surface;
1210 /* wl_surface.damage_buffer */
1211 pixman_region32_t damage_buffer;
Jason Ekstrand7b982072014-05-20 14:33:03 -05001212
1213 /* wl_surface.set_opaque_region */
1214 pixman_region32_t opaque;
1215
1216 /* wl_surface.set_input_region */
1217 pixman_region32_t input;
1218
1219 /* wl_surface.frame */
1220 struct wl_list frame_callback_list;
1221
Pekka Paalanen133e4392014-09-23 22:08:46 -04001222 /* presentation.feedback */
1223 struct wl_list feedback_list;
1224
Jason Ekstrand7b982072014-05-20 14:33:03 -05001225 /* wl_surface.set_buffer_transform */
1226 /* wl_surface.set_scaling_factor */
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001227 /* wp_viewport.set_source */
1228 /* wp_viewport.set_destination */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001229 struct weston_buffer_viewport buffer_viewport;
1230};
1231
Jonas Ådahlf7deb6a2016-07-22 17:50:26 +08001232struct weston_surface_activation_data {
1233 struct weston_surface *surface;
1234 struct weston_seat *seat;
1235};
1236
Jonas Ådahld3414f22016-07-22 17:56:31 +08001237struct weston_pointer_constraint {
1238 struct wl_list link;
1239
1240 struct weston_surface *surface;
1241 struct weston_view *view;
1242 struct wl_resource *resource;
1243 struct weston_pointer_grab grab;
1244 struct weston_pointer *pointer;
1245 uint32_t lifetime;
1246
1247 pixman_region32_t region;
1248 pixman_region32_t region_pending;
1249 bool region_is_pending;
1250
1251 wl_fixed_t hint_x;
1252 wl_fixed_t hint_y;
1253 wl_fixed_t hint_x_pending;
1254 wl_fixed_t hint_y_pending;
1255 bool hint_is_pending;
1256
1257 struct wl_listener pointer_destroy_listener;
1258 struct wl_listener surface_destroy_listener;
1259 struct wl_listener surface_commit_listener;
1260 struct wl_listener surface_activate_listener;
1261};
1262
Jason Ekstranda7af7042013-10-12 22:38:11 -05001263struct weston_surface {
1264 struct wl_resource *resource;
Pekka Paalanenca790762015-04-17 14:23:38 +03001265 struct wl_signal destroy_signal; /* callback argument: this surface */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001266 struct weston_compositor *compositor;
Jonas Ådahl5d9ca272016-07-22 17:48:03 +08001267 struct wl_signal commit_signal;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001268
1269 /** Damage in local coordinates from the client, for tex upload. */
Jason Ekstranda7af7042013-10-12 22:38:11 -05001270 pixman_region32_t damage;
Pekka Paalanene508ce62015-02-19 13:59:55 +02001271
Jason Ekstranda7af7042013-10-12 22:38:11 -05001272 pixman_region32_t opaque; /* part of geometry, see below */
1273 pixman_region32_t input;
1274 int32_t width, height;
1275 int32_t ref_count;
1276
1277 /* Not for long-term storage. This exists for book-keeping while
1278 * iterating over surfaces and views
1279 */
Derek Foreman060cf112015-11-18 16:32:26 -06001280 bool touched;
Jason Ekstranda7af7042013-10-12 22:38:11 -05001281
1282 void *renderer_state;
1283
1284 struct wl_list views;
1285
1286 /*
1287 * Which output to vsync this surface to.
Pekka Paalanen130ae6e2016-03-30 14:33:33 +03001288 * Used to determine whether to send or queue frame events, and for
1289 * other client-visible syncing/throttling tied to the output
1290 * repaint cycle.
Jason Ekstranda7af7042013-10-12 22:38:11 -05001291 */
1292 struct weston_output *output;
1293
1294 /*
1295 * A more complete representation of all outputs this surface is
1296 * displayed on.
1297 */
1298 uint32_t output_mask;
Casey Dahlin9074db52012-04-19 22:50:09 -04001299
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001300 struct wl_list frame_callback_list;
Pekka Paalanen133e4392014-09-23 22:08:46 -04001301 struct wl_list feedback_list;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001302
Pekka Paalanende685b82012-12-04 15:58:12 +02001303 struct weston_buffer_reference buffer_ref;
Pekka Paalanen1fd9c0f2013-11-26 18:19:41 +01001304 struct weston_buffer_viewport buffer_viewport;
Pekka Paalanen0b4c5352014-03-14 14:38:17 +02001305 int32_t width_from_buffer; /* before applying viewport */
1306 int32_t height_from_buffer;
Derek Foreman0fd6d4e2014-10-10 09:36:45 -05001307 bool keep_buffer; /* for backends to prevent early release */
Alex Wu8811bf92012-02-28 18:07:54 +08001308
Pekka Paalanene95ad5c2016-04-15 14:47:08 +03001309 /* wp_viewport resource for this surface */
Pekka Paalanenb0420ae2014-01-08 15:39:17 +02001310 struct wl_resource *viewport_resource;
Jonny Lamb74130762013-11-26 18:19:46 +01001311
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001312 /* All the pending state, that wl_surface.commit will apply. */
Jason Ekstrand7b982072014-05-20 14:33:03 -05001313 struct weston_surface_state pending;
Pekka Paalanen5df44de2012-10-10 12:49:23 +03001314
Jason Ekstrand1e059042014-10-16 10:55:19 -05001315 /* Matrices representating of the full transformation between
1316 * buffer and surface coordinates. These matrices are updated
1317 * using the weston_surface_build_buffer_matrix function. */
1318 struct weston_matrix buffer_to_surface_matrix;
1319 struct weston_matrix surface_to_buffer_matrix;
1320
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001321 /*
Jasper St. Pierred67b52a2014-04-28 11:19:27 -04001322 * If non-NULL, this function will be called on
1323 * wl_surface::commit after a new buffer has been set up for
1324 * this surface. The integer params are the sx and sy
1325 * parameters supplied to wl_surface::attach.
Ander Conselvan de Oliveira093bfa32012-03-27 17:36:41 +03001326 */
Quentin Glidic2edc3d52016-08-12 10:41:33 +02001327 void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
1328 void *committed_private;
Pekka Paalanen8274d902014-08-06 19:36:51 +03001329 int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
Pekka Paalanene67858b2013-04-25 13:57:42 +03001330
1331 /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
1332 * Contains also the parent itself as a dummy weston_subsurface,
1333 * if the list is not empty.
1334 */
1335 struct wl_list subsurface_list; /* weston_subsurface::parent_link */
1336 struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
Pekka Paalanen50b67472014-10-01 15:02:41 +03001337
1338 /*
1339 * For tracking protocol role assignments. Different roles may
1340 * have the same configure hook, e.g. in shell.c. Configure hook
1341 * may get reset, this will not.
1342 * XXX: map configure functions 1:1 to roles, and never reset it,
1343 * and replace role_name with configure.
1344 */
1345 const char *role_name;
Pekka Paalanenb5026542014-11-12 15:09:24 +02001346
1347 struct weston_timeline_object timeline;
Armin Krezovićf8486c32016-06-30 06:04:28 +02001348
1349 bool is_mapped;
Jonas Ådahld3414f22016-07-22 17:56:31 +08001350
1351 /* An list of per seat pointer constraints. */
1352 struct wl_list pointer_constraints;
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001353};
1354
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001355struct weston_subsurface {
1356 struct wl_resource *resource;
1357
1358 /* guaranteed to be valid and non-NULL */
1359 struct weston_surface *surface;
1360 struct wl_listener surface_destroy_listener;
1361
1362 /* can be NULL */
1363 struct weston_surface *parent;
1364 struct wl_listener parent_destroy_listener;
1365 struct wl_list parent_link;
1366 struct wl_list parent_link_pending;
1367
1368 struct {
1369 int32_t x;
1370 int32_t y;
1371 int set;
1372 } position;
1373
Jason Ekstrand7b982072014-05-20 14:33:03 -05001374 int has_cached_data;
1375 struct weston_surface_state cached;
1376 struct weston_buffer_reference cached_buffer_ref;
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001377
Emilio Pozuelo Monfort4f3cad72017-01-27 17:30:29 +01001378 /* Sub-surface has been reordered; need to apply damage. */
1379 bool reordered;
1380
Jason Ekstrande9d40e32014-05-20 11:23:53 -05001381 int synchronized;
1382
1383 /* Used for constructing the view tree */
1384 struct wl_list unused_views;
1385};
1386
Daniel Stoned6da09e2012-06-22 13:21:29 +01001387enum weston_key_state_update {
1388 STATE_UPDATE_AUTOMATIC,
1389 STATE_UPDATE_NONE,
1390};
1391
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001392enum weston_activate_flag {
1393 WESTON_ACTIVATE_FLAG_NONE = 0,
1394 WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001395 WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
Jonas Ådahl4361b4e2014-10-18 18:20:16 +02001396};
1397
Kristian Høgsberg9ddb8262012-01-04 21:30:29 -05001398void
Kristian Høgsbergaf4f2aa2013-02-15 20:53:20 -05001399weston_version(int *major, int *minor, int *micro);
1400
1401void
Semi Malinene7a52fb2018-04-26 11:08:10 +02001402weston_view_set_output(struct weston_view *view, struct weston_output *output);
1403
1404void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001405weston_view_update_transform(struct weston_view *view);
Pekka Paalanen460099f2012-01-20 16:48:25 +02001406
1407void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001408weston_view_geometry_dirty(struct weston_view *view);
Pekka Paalanenc3ce7382013-03-08 14:56:49 +02001409
1410void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001411weston_view_to_global_fixed(struct weston_view *view,
1412 wl_fixed_t sx, wl_fixed_t sy,
1413 wl_fixed_t *x, wl_fixed_t *y);
Daniel Stonebd3489b2012-05-08 17:17:53 +01001414void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001415weston_view_to_global_float(struct weston_view *view,
1416 float sx, float sy, float *x, float *y);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001417
1418void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001419weston_view_from_global_float(struct weston_view *view,
1420 float x, float y, float *vx, float *vy);
Kristian Høgsbergecf6ede2012-09-05 21:59:35 -04001421void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001422weston_view_from_global(struct weston_view *view,
1423 int32_t x, int32_t y, int32_t *vx, int32_t *vy);
Daniel Stonebd3489b2012-05-08 17:17:53 +01001424void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001425weston_view_from_global_fixed(struct weston_view *view,
1426 wl_fixed_t x, wl_fixed_t y,
1427 wl_fixed_t *vx, wl_fixed_t *vy);
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001428
Derek Foremand1be3122014-09-18 16:46:49 -05001429void
Ander Conselvan de Oliveira0396ba22012-11-28 17:10:26 +02001430weston_surface_to_buffer_float(struct weston_surface *surface,
1431 float x, float y, float *bx, float *by);
1432pixman_box32_t
1433weston_surface_to_buffer_rect(struct weston_surface *surface,
1434 pixman_box32_t rect);
1435
Pekka Paalanene0f3cb22012-01-24 09:59:29 +02001436void
Pekka Paalanene54e31c2015-03-04 14:23:28 +02001437weston_surface_to_buffer_region(struct weston_surface *surface,
1438 pixman_region32_t *surface_region,
1439 pixman_region32_t *buffer_region);
1440
1441void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001442weston_spring_init(struct weston_spring *spring,
1443 double k, double current, double target);
1444void
Alexandros Frantzis8250a612017-11-16 18:20:52 +02001445weston_spring_update(struct weston_spring *spring, const struct timespec *time);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001446int
1447weston_spring_done(struct weston_spring *spring);
1448
1449void
Jonas Ådahl94e2e2d2014-10-18 18:42:19 +02001450weston_view_activate(struct weston_view *view,
1451 struct weston_seat *seat,
1452 uint32_t flags);
1453
1454void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +02001455notify_motion(struct weston_seat *seat, const struct timespec *time,
Jonas Ådahld2510102014-10-05 21:39:14 +02001456 struct weston_pointer_motion_event *event);
Rob Bradfordc088e2c2013-03-27 15:59:43 +00001457void
Alexandros Frantzis84b31f82017-11-24 18:01:46 +02001458notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
Giulio Camuffo90a6fc62016-03-22 17:44:54 +02001459 double x, double y);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001460void
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001461notify_button(struct weston_seat *seat, const struct timespec *time,
1462 int32_t button, enum wl_pointer_button_state state);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001463void
Alexandros Frantzis80321942017-11-16 18:20:56 +02001464notify_axis(struct weston_seat *seat, const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001465 struct weston_pointer_axis_event *event);
Scott Moreau210d0792012-03-22 10:47:01 -06001466void
Peter Hutterer87743e92016-01-18 16:38:22 +10001467notify_axis_source(struct weston_seat *seat, uint32_t source);
1468
1469void
1470notify_pointer_frame(struct weston_seat *seat);
1471
1472void
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001473notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
Daniel Stone1b4e11f2012-06-22 13:21:37 +01001474 enum wl_keyboard_key_state state,
1475 enum weston_key_state_update update_state);
Daniel Stone05d58682012-06-22 13:21:38 +01001476void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001477notify_modifiers(struct weston_seat *seat, uint32_t serial);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001478
1479void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001480notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
Giulio Camuffo90a6fc62016-03-22 17:44:54 +02001481 double x, double y);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001482
1483void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001484notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
Daniel Stoned6da09e2012-06-22 13:21:29 +01001485 enum weston_key_state_update update_state);
1486void
Kristian Høgsbergcb3eaae2012-08-10 09:50:11 -04001487notify_keyboard_focus_out(struct weston_seat *seat);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001488
1489void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001490notify_touch(struct weston_seat *seat, const struct timespec *time,
1491 int touch_id, double x, double y, int touch_type);
Jonas Ådahl1679f232014-04-12 09:39:51 +02001492void
1493notify_touch_frame(struct weston_seat *seat);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001494
1495void
Derek Foreman3cc004a2015-11-06 15:56:09 -06001496notify_touch_cancel(struct weston_seat *seat);
1497
1498void
Giulio Camuffo412e6a52014-07-09 22:12:56 +03001499weston_layer_entry_insert(struct weston_layer_entry *list,
1500 struct weston_layer_entry *entry);
1501void
1502weston_layer_entry_remove(struct weston_layer_entry *entry);
1503void
Quentin Glidic82681572016-12-17 13:40:51 +01001504weston_layer_init(struct weston_layer *layer,
1505 struct weston_compositor *compositor);
1506void
1507weston_layer_set_position(struct weston_layer *layer,
1508 enum weston_layer_position position);
1509void
1510weston_layer_unset_position(struct weston_layer *layer);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001511
1512void
Giulio Camuffo95ec0f92014-07-09 22:12:57 +03001513weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
1514
1515void
1516weston_layer_set_mask_infinite(struct weston_layer *layer);
1517
1518void
Xiong Zhang97116532013-10-23 13:58:31 +08001519weston_plane_init(struct weston_plane *plane,
1520 struct weston_compositor *ec,
1521 int32_t x, int32_t y);
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001522void
1523weston_plane_release(struct weston_plane *plane);
1524
1525void
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001526weston_compositor_stack_plane(struct weston_compositor *ec,
1527 struct weston_plane *plane,
1528 struct weston_plane *above);
1529
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001530/* An invalid flag in presented_flags to catch logic errors. */
Pekka Paalanenb00c79b2016-02-18 16:53:27 +02001531#define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31)
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001532
Ander Conselvan de Oliveira8ad19822013-03-05 17:30:27 +02001533void
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001534weston_output_finish_frame(struct weston_output *output,
Pekka Paalanen363aa7b2014-12-17 16:20:40 +02001535 const struct timespec *stamp,
1536 uint32_t presented_flags);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001537void
Kristian Høgsberg49952d12012-06-20 00:35:59 -04001538weston_output_schedule_repaint(struct weston_output *output);
1539void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001540weston_output_damage(struct weston_output *output);
1541void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001542weston_compositor_schedule_repaint(struct weston_compositor *compositor);
1543void
1544weston_compositor_fade(struct weston_compositor *compositor, float tint);
1545void
1546weston_compositor_damage_all(struct weston_compositor *compositor);
1547void
1548weston_compositor_unlock(struct weston_compositor *compositor);
1549void
1550weston_compositor_wake(struct weston_compositor *compositor);
1551void
Philipp Brüschweiler57edf7f2013-03-29 13:01:56 +01001552weston_compositor_offscreen(struct weston_compositor *compositor);
1553void
Ander Conselvan de Oliveira87524b62013-02-21 18:35:22 +02001554weston_compositor_sleep(struct weston_compositor *compositor);
Jason Ekstranda7af7042013-10-12 22:38:11 -05001555struct weston_view *
1556weston_compositor_pick_view(struct weston_compositor *compositor,
1557 wl_fixed_t x, wl_fixed_t y,
1558 wl_fixed_t *sx, wl_fixed_t *sy);
Ander Conselvan de Oliveira30eebc72012-02-15 17:02:57 +02001559
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001560
1561struct weston_binding;
Derek Foreman8ae2db52015-07-15 13:00:36 -05001562typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001563 const struct timespec *time,
1564 uint32_t key,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001565 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001566struct weston_binding *
Daniel Stone325fc2d2012-05-30 16:31:58 +01001567weston_compositor_add_key_binding(struct weston_compositor *compositor,
1568 uint32_t key,
1569 enum weston_keyboard_modifier modifier,
1570 weston_key_binding_handler_t binding,
1571 void *data);
1572
Derek Foreman8ae2db52015-07-15 13:00:36 -05001573typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
Daniel Stone96d47c02013-11-19 11:37:12 +01001574 enum weston_keyboard_modifier modifier,
1575 void *data);
1576struct weston_binding *
1577weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
1578 enum weston_keyboard_modifier modifier,
1579 weston_modifier_binding_handler_t binding,
1580 void *data);
1581
Derek Foreman8ae2db52015-07-15 13:00:36 -05001582typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001583 const struct timespec *time,
1584 uint32_t button,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001585 void *data);
1586struct weston_binding *
1587weston_compositor_add_button_binding(struct weston_compositor *compositor,
1588 uint32_t button,
1589 enum weston_keyboard_modifier modifier,
1590 weston_button_binding_handler_t binding,
1591 void *data);
1592
Derek Foreman8ae2db52015-07-15 13:00:36 -05001593typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001594 const struct timespec *time,
Neil Robertsa28c6932013-10-03 16:43:04 +01001595 void *data);
1596struct weston_binding *
1597weston_compositor_add_touch_binding(struct weston_compositor *compositor,
1598 enum weston_keyboard_modifier modifier,
1599 weston_touch_binding_handler_t binding,
1600 void *data);
1601
Derek Foreman8ae2db52015-07-15 13:00:36 -05001602typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
Alexandros Frantzis80321942017-11-16 18:20:56 +02001603 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001604 struct weston_pointer_axis_event *event,
1605 void *data);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001606struct weston_binding *
1607weston_compositor_add_axis_binding(struct weston_compositor *compositor,
1608 uint32_t axis,
1609 enum weston_keyboard_modifier modifier,
1610 weston_axis_binding_handler_t binding,
1611 void *data);
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001612struct weston_binding *
1613weston_compositor_add_debug_binding(struct weston_compositor *compositor,
1614 uint32_t key,
1615 weston_key_binding_handler_t binding,
1616 void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001617void
1618weston_binding_destroy(struct weston_binding *binding);
1619
1620void
Pekka Paalanen2829f7c2015-02-19 17:02:13 +02001621weston_install_debug_key_binding(struct weston_compositor *compositor,
1622 uint32_t mod);
1623
1624void
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001625weston_binding_list_destroy_all(struct wl_list *list);
1626
Pekka Paalanen86b53962014-11-19 13:43:32 +02001627void
Daniel Stone325fc2d2012-05-30 16:31:58 +01001628weston_compositor_run_key_binding(struct weston_compositor *compositor,
Derek Foreman99a6a2d2015-07-15 13:00:43 -05001629 struct weston_keyboard *keyboard,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001630 const struct timespec *time,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001631 uint32_t key,
1632 enum wl_keyboard_key_state state);
Daniel Stone96d47c02013-11-19 11:37:12 +01001633
1634void
1635weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
Derek Foreman99a6a2d2015-07-15 13:00:43 -05001636 struct weston_keyboard *keyboard,
Daniel Stone96d47c02013-11-19 11:37:12 +01001637 enum weston_keyboard_modifier modifier,
1638 enum wl_keyboard_key_state state);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001639void
1640weston_compositor_run_button_binding(struct weston_compositor *compositor,
Alexandros Frantzis215bedc2017-11-16 18:20:55 +02001641 struct weston_pointer *pointer,
1642 const struct timespec *time,
Daniel Stone325fc2d2012-05-30 16:31:58 +01001643 uint32_t button,
1644 enum wl_pointer_button_state value);
Neil Robertsa28c6932013-10-03 16:43:04 +01001645void
1646weston_compositor_run_touch_binding(struct weston_compositor *compositor,
Alexandros Frantzis9448deb2017-11-16 18:20:58 +02001647 struct weston_touch *touch,
1648 const struct timespec *time,
Neil Robertsa28c6932013-10-03 16:43:04 +01001649 int touch_type);
Rune K. Svendsen14b2fe72013-03-07 21:50:00 +01001650int
Daniel Stone325fc2d2012-05-30 16:31:58 +01001651weston_compositor_run_axis_binding(struct weston_compositor *compositor,
Alexandros Frantzis80321942017-11-16 18:20:56 +02001652 struct weston_pointer *pointer,
1653 const struct timespec *time,
Peter Hutterer89b6a492016-01-18 15:58:17 +10001654 struct weston_pointer_axis_event *event);
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001655int
1656weston_compositor_run_debug_binding(struct weston_compositor *compositor,
Alexandros Frantzis47e79c82017-11-16 18:20:57 +02001657 struct weston_keyboard *keyboard,
1658 const struct timespec *time,
Ander Conselvan de Oliveirac509d2b2012-11-08 17:20:45 +02001659 uint32_t key,
1660 enum wl_keyboard_key_state state);
Daniel Stone325fc2d2012-05-30 16:31:58 +01001661
Giulio Camuffocdb4d292013-11-14 23:42:53 +01001662void
1663weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
1664 const struct weston_pointer_grab_interface *interface);
1665
Benjamin Franzkebfeda132012-01-30 14:04:04 +01001666int
1667weston_environment_get_fd(const char *env);
1668
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001669struct weston_surface *
Kristian Høgsberg18c93002012-01-27 11:58:31 -05001670weston_surface_create(struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001671
Jason Ekstranda7af7042013-10-12 22:38:11 -05001672struct weston_view *
1673weston_view_create(struct weston_surface *surface);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001674
1675void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001676weston_view_destroy(struct weston_view *view);
Kristian Høgsberg3be2ce92012-02-29 12:42:35 -05001677
1678void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001679weston_view_set_position(struct weston_view *view,
1680 float x, float y);
1681
1682void
1683weston_view_set_transform_parent(struct weston_view *view,
1684 struct weston_view *parent);
1685
Pekka Paalanen380adf52015-02-16 14:39:11 +02001686void
1687weston_view_set_mask(struct weston_view *view,
1688 int x, int y, int width, int height);
1689
1690void
1691weston_view_set_mask_infinite(struct weston_view *view);
1692
Derek Foreman280e7dd2014-10-03 13:13:42 -05001693bool
Jason Ekstranda7af7042013-10-12 22:38:11 -05001694weston_view_is_mapped(struct weston_view *view);
1695
1696void
1697weston_view_schedule_repaint(struct weston_view *view);
Pekka Paalanen483243f2013-03-08 14:56:50 +02001698
Derek Foreman280e7dd2014-10-03 13:13:42 -05001699bool
Ander Conselvan de Oliveirab8ab14f2012-03-27 17:36:36 +03001700weston_surface_is_mapped(struct weston_surface *surface);
1701
Derek Foremand1be3122014-09-18 16:46:49 -05001702void
Jason Ekstrand5c11a332013-12-04 20:32:03 -06001703weston_surface_set_size(struct weston_surface *surface,
1704 int32_t width, int32_t height);
1705
Pekka Paalanen8fb8d3b2012-02-13 13:03:59 +02001706void
Kristian Høgsberg98238702012-08-03 16:29:12 -04001707weston_surface_schedule_repaint(struct weston_surface *surface);
1708
1709void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001710weston_surface_damage(struct weston_surface *surface);
1711
1712void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001713weston_view_damage_below(struct weston_view *view);
Kristian Høgsbergd8bf90c2012-02-23 23:03:14 -05001714
1715void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001716weston_view_move_to_plane(struct weston_view *view,
1717 struct weston_plane *plane);
1718void
1719weston_view_unmap(struct weston_view *view);
1720
Kristian Høgsberg65a11e12012-08-03 11:30:18 -04001721void
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001722weston_surface_unmap(struct weston_surface *surface);
1723
Pekka Paalanen01388e22013-04-25 13:57:44 +03001724struct weston_surface *
1725weston_surface_get_main_surface(struct weston_surface *surface);
1726
Pekka Paalanen50b67472014-10-01 15:02:41 +03001727int
1728weston_surface_set_role(struct weston_surface *surface,
1729 const char *role_name,
1730 struct wl_resource *error_resource,
1731 uint32_t error_code);
Quentin Glidic9c5dd7e2016-08-12 10:41:37 +02001732const char *
1733weston_surface_get_role(struct weston_surface *surface);
Pekka Paalanen50b67472014-10-01 15:02:41 +03001734
Pekka Paalanen8274d902014-08-06 19:36:51 +03001735void
1736weston_surface_set_label_func(struct weston_surface *surface,
1737 int (*desc)(struct weston_surface *,
1738 char *, size_t));
1739
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001740void
1741weston_surface_get_content_size(struct weston_surface *surface,
1742 int *width, int *height);
1743
Quentin Glidic248dd102016-08-12 10:41:34 +02001744struct weston_geometry
1745weston_surface_get_bounding_box(struct weston_surface *surface);
1746
Pekka Paalanenc647ed72015-02-09 13:16:57 +02001747int
1748weston_surface_copy_content(struct weston_surface *surface,
1749 void *target, size_t size,
1750 int src_x, int src_y,
1751 int width, int height);
1752
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001753struct weston_buffer *
1754weston_buffer_from_resource(struct wl_resource *resource);
1755
Kristian Høgsbergaf7b1ff2012-06-26 21:19:23 -04001756void
Pekka Paalanende685b82012-12-04 15:58:12 +02001757weston_buffer_reference(struct weston_buffer_reference *ref,
Jason Ekstrand6bd62942013-06-20 20:38:23 -05001758 struct weston_buffer *buffer);
Pekka Paalanende685b82012-12-04 15:58:12 +02001759
Alexandros Frantzis409b01f2017-11-16 18:21:01 +02001760void
1761weston_compositor_get_time(struct timespec *time);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001762
Giulio Camuffo459137b2014-10-11 23:56:24 +03001763void
1764weston_compositor_destroy(struct weston_compositor *ec);
1765struct weston_compositor *
1766weston_compositor_create(struct wl_display *display, void *user_data);
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001767
1768enum weston_compositor_backend {
1769 WESTON_BACKEND_DRM,
1770 WESTON_BACKEND_FBDEV,
1771 WESTON_BACKEND_HEADLESS,
1772 WESTON_BACKEND_RDP,
1773 WESTON_BACKEND_WAYLAND,
1774 WESTON_BACKEND_X11,
1775};
1776
Pekka Paalanendd186732016-06-03 14:49:54 +03001777int
1778weston_compositor_load_backend(struct weston_compositor *compositor,
Pekka Paalanen50dbf382016-06-03 15:23:46 +03001779 enum weston_compositor_backend backend,
Pekka Paalanendd186732016-06-03 14:49:54 +03001780 struct weston_backend_config *config_base);
Giulio Camuffo459137b2014-10-11 23:56:24 +03001781void
1782weston_compositor_exit(struct weston_compositor *ec);
1783void *
1784weston_compositor_get_user_data(struct weston_compositor *compositor);
Pekka Paalanenb5eedad2014-09-23 22:08:45 -04001785int
1786weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
1787 clockid_t clk_id);
1788int
1789weston_compositor_set_presentation_clock_software(
1790 struct weston_compositor *compositor);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001791void
Pekka Paalanen662f3842015-03-18 12:17:26 +02001792weston_compositor_read_presentation_clock(
1793 const struct weston_compositor *compositor,
1794 struct timespec *ts);
1795
Pekka Paalanen230f3b12014-09-29 14:18:40 -04001796bool
1797weston_compositor_import_dmabuf(struct weston_compositor *compositor,
1798 struct linux_dmabuf_buffer *buffer);
1799
Pekka Paalanen662f3842015-03-18 12:17:26 +02001800void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001801weston_compositor_shutdown(struct weston_compositor *ec);
1802void
Frederic Plourdec336f062014-10-29 14:44:33 -04001803weston_compositor_exit_with_code(struct weston_compositor *compositor,
1804 int exit_code);
1805void
Scott Moreau429490d2012-06-17 18:10:59 -06001806weston_output_init_zoom(struct weston_output *output);
1807void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001808weston_output_update_zoom(struct weston_output *output);
Scott Moreauccbf29d2012-02-22 14:21:41 -07001809void
Derek Foreman22276a52015-07-23 14:55:15 -05001810weston_output_activate_zoom(struct weston_output *output,
1811 struct weston_seat *seat);
Giulio Camuffo412b0242013-11-14 23:42:51 +01001812void
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001813weston_output_move(struct weston_output *output, int x, int y);
Armin Krezović40087402016-09-30 14:11:12 +02001814
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001815void
Pekka Paalanen37b7c6e2017-11-07 10:15:01 +02001816weston_output_add_destroy_listener(struct weston_output *output,
1817 struct wl_listener *listener);
1818struct wl_listener *
1819weston_output_get_destroy_listener(struct weston_output *output,
1820 wl_notify_func_t notify);
1821void
Pekka Paalanenae6d35d2017-08-16 12:07:14 +03001822weston_output_release(struct weston_output *output);
Kristian Høgsberg98c774f2013-07-22 14:33:42 -07001823void
Jason Ekstrandb6a3cc72013-10-27 22:25:00 -05001824weston_output_transform_coordinate(struct weston_output *output,
Giulio Camuffo90a6fc62016-03-22 17:44:54 +02001825 double device_x, double device_y,
1826 double *x, double *y);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001827
1828void
Rob Bradford9af5f9e2013-05-31 18:09:50 +01001829weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
1830 const char *seat_name);
Daniel Stone74419a22012-05-30 16:32:02 +01001831void
1832weston_seat_init_pointer(struct weston_seat *seat);
Jonas Ådahld6e1c342013-10-17 23:04:05 +02001833void
1834weston_seat_release_pointer(struct weston_seat *seat);
Kristian Høgsberg2f07ef62013-02-16 14:29:24 -05001835int
Daniel Stonebb1df6a2012-05-30 16:32:06 +01001836weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
Daniel Stone74419a22012-05-30 16:32:02 +01001837void
Jonas Ådahld6e1c342013-10-17 23:04:05 +02001838weston_seat_release_keyboard(struct weston_seat *seat);
1839void
Daniel Stone74419a22012-05-30 16:32:02 +01001840weston_seat_init_touch(struct weston_seat *seat);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001841void
Jonas Ådahld6e1c342013-10-17 23:04:05 +02001842weston_seat_release_touch(struct weston_seat *seat);
1843void
Kristian Høgsberga71e8b22013-05-06 21:51:21 -04001844weston_seat_repick(struct weston_seat *seat);
Rui Matos65196bc2013-10-10 19:44:19 +02001845void
1846weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001847
1848void
Daniel Stone37816df2012-05-16 18:45:18 +01001849weston_seat_release(struct weston_seat *seat);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001850int
Giulio Camuffo0358af42016-06-02 21:48:08 +03001851weston_compositor_set_xkb_rule_names(struct weston_compositor *ec,
1852 struct xkb_rule_names *names);
Kristian Høgsbergb5e26102013-04-18 15:40:10 -04001853void
1854weston_compositor_xkb_destroy(struct weston_compositor *ec);
Kristian Høgsberg3466bc82012-01-03 11:29:15 -05001855
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001856/* String literal of spaces, the same width as the timestamp. */
1857#define STAMP_SPACE " "
1858
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001859typedef int (*log_func_t)(const char *fmt, va_list ap);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001860void
Giulio Camuffobe2b11a2016-06-02 21:48:13 +03001861weston_log_set_handler(log_func_t log, log_func_t cont);
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001862int
Kristian Høgsberg082d58c2013-06-18 01:00:27 -04001863weston_vlog(const char *fmt, va_list ap);
1864int
1865weston_vlog_continue(const char *fmt, va_list ap);
1866int
Pekka Paalanend525b562012-08-06 14:57:04 +03001867weston_log(const char *fmt, ...)
1868 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001869int
Pekka Paalanend525b562012-08-06 14:57:04 +03001870weston_log_continue(const char *fmt, ...)
1871 __attribute__ ((format (printf, 1, 2)));
Kristian Høgsberg64eca892012-08-01 00:00:57 -04001872
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001873enum {
1874 TTY_ENTER_VT,
1875 TTY_LEAVE_VT
1876};
1877
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001878struct tty *
Kristian Høgsberg61741a22013-09-17 16:02:57 -07001879tty_create(struct weston_compositor *compositor, int tty_nr);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001880
1881void
1882tty_destroy(struct tty *tty);
1883
Kristian Høgsberg7b884bc2012-07-31 14:32:01 -04001884void
1885tty_reset(struct tty *tty);
1886
Kristian Høgsberg5d1c0c52012-04-10 00:11:50 -04001887int
1888tty_activate_vt(struct tty *tty, int vt);
1889
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001890enum weston_screenshooter_outcome {
1891 WESTON_SCREENSHOOTER_SUCCESS,
1892 WESTON_SCREENSHOOTER_NO_MEMORY,
1893 WESTON_SCREENSHOOTER_BAD_BUFFER
1894};
1895
1896typedef void (*weston_screenshooter_done_func_t)(void *data,
1897 enum weston_screenshooter_outcome outcome);
1898int
1899weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
1900 weston_screenshooter_done_func_t done, void *data);
Giulio Camuffo26f62d42016-06-02 21:48:09 +03001901struct weston_recorder *
1902weston_recorder_start(struct weston_output *output, const char *filename);
1903void
1904weston_recorder_stop(struct weston_recorder *recorder);
Giulio Camuffoe9022e72013-12-11 23:45:11 +01001905
Kristian Høgsberga7ceaff2012-06-03 10:20:13 -04001906struct clipboard *
1907clipboard_create(struct weston_seat *seat);
1908
Jason Ekstranda7af7042013-10-12 22:38:11 -05001909struct weston_view_animation;
1910typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001911
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001912void
1913weston_view_animation_destroy(struct weston_view_animation *animation);
1914
Jason Ekstranda7af7042013-10-12 22:38:11 -05001915struct weston_view_animation *
1916weston_zoom_run(struct weston_view *view, float start, float stop,
1917 weston_view_animation_done_func_t done, void *data);
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05001918
Jason Ekstranda7af7042013-10-12 22:38:11 -05001919struct weston_view_animation *
1920weston_fade_run(struct weston_view *view,
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001921 float start, float end, float k,
Jason Ekstranda7af7042013-10-12 22:38:11 -05001922 weston_view_animation_done_func_t done, void *data);
Daniel Stonea67e6b92013-11-19 11:37:13 +01001923
1924struct weston_view_animation *
1925weston_move_scale_run(struct weston_view *view, int dx, int dy,
Quentin Glidic24d306c2016-08-10 15:53:33 +02001926 float start, float end, bool reverse,
Daniel Stonea67e6b92013-11-19 11:37:13 +01001927 weston_view_animation_done_func_t done, void *data);
1928
Quentin Glidic24d306c2016-08-10 15:53:33 +02001929struct weston_view_animation *
1930weston_move_run(struct weston_view *view, int dx, int dy,
1931 float start, float end, bool reverse,
1932 weston_view_animation_done_func_t done, void *data);
1933
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001934void
Jason Ekstranda7af7042013-10-12 22:38:11 -05001935weston_fade_update(struct weston_view_animation *fade, float target);
Ander Conselvan de Oliveiraee416052013-02-21 18:35:17 +02001936
Jason Ekstranda7af7042013-10-12 22:38:11 -05001937struct weston_view_animation *
Louis-Francis Ratté-Boulianneb482dbd2013-11-19 11:37:11 +01001938weston_stable_fade_run(struct weston_view *front_view, float start,
1939 struct weston_view *back_view, float end,
1940 weston_view_animation_done_func_t done, void *data);
1941
1942struct weston_view_animation *
Jason Ekstranda7af7042013-10-12 22:38:11 -05001943weston_slide_run(struct weston_view *view, float start, float stop,
1944 weston_view_animation_done_func_t done, void *data);
Juan Zhaoe10d2792012-04-25 19:09:52 +08001945
Alex Wu8811bf92012-02-28 18:07:54 +08001946void
1947weston_surface_set_color(struct weston_surface *surface,
John Kåre Alsaker490d02a2012-09-30 02:57:21 +02001948 float red, float green, float blue, float alpha);
Alex Wu8811bf92012-02-28 18:07:54 +08001949
1950void
1951weston_surface_destroy(struct weston_surface *surface);
1952
Alex Wu2dda6042012-04-17 17:20:47 +08001953int
Derek Foreman6ae7bc92014-11-04 10:47:33 -06001954weston_output_mode_set_native(struct weston_output *output,
1955 struct weston_mode *mode,
1956 int32_t scale);
1957int
1958weston_output_mode_switch_to_temporary(struct weston_output *output,
1959 struct weston_mode *mode,
1960 int32_t scale);
1961int
1962weston_output_mode_switch_to_native(struct weston_output *output);
Alex Wu2dda6042012-04-17 17:20:47 +08001963
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001964int
1965noop_renderer_init(struct weston_compositor *ec);
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001966
Giulio Camuffo954f1832014-10-11 18:27:30 +03001967int
Jonas Ådahl30d61d82014-10-22 21:21:17 +02001968weston_input_init(struct weston_compositor *compositor);
1969
1970int
Quentin Glidic23e1d6f2016-12-02 14:08:44 +01001971weston_backend_init(struct weston_compositor *c,
1972 struct weston_backend_config *config_base);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001973int
Quentin Glidic3d7ca3b2016-12-02 14:20:35 +01001974weston_module_init(struct weston_compositor *compositor);
Kristian Høgsbergb00a9d32012-09-11 14:06:27 -04001975
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001976void
1977weston_transformed_coord(int width, int height,
1978 enum wl_output_transform transform,
Alexander Larssonedddbd12013-05-24 13:09:43 +02001979 int32_t scale,
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001980 float sx, float sy, float *bx, float *by);
1981pixman_box32_t
1982weston_transformed_rect(int width, int height,
1983 enum wl_output_transform transform,
Alexander Larssonedddbd12013-05-24 13:09:43 +02001984 int32_t scale,
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001985 pixman_box32_t rect);
Jason Ekstrand33ff6362013-10-27 22:25:01 -05001986void
Derek Foremanbc9a61c2015-11-18 16:32:30 -06001987weston_matrix_transform_region(pixman_region32_t *dest,
1988 struct weston_matrix *matrix,
1989 pixman_region32_t *src);
1990void
Jason Ekstrand33ff6362013-10-27 22:25:01 -05001991weston_transformed_region(int width, int height,
1992 enum wl_output_transform transform,
1993 int32_t scale,
1994 pixman_region32_t *src, pixman_region32_t *dest);
Ander Conselvan de Oliveira409eebf2012-12-05 15:14:04 +02001995
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +03001996void *
1997weston_load_module(const char *name, const char *entrypoint);
1998
Derek Foreman64a3df02014-10-23 12:24:18 -05001999int
2000weston_parse_transform(const char *transform, uint32_t *out);
2001
2002const char *
2003weston_transform_to_string(uint32_t output_transform);
2004
Derek Foreman1281a362015-07-31 16:55:32 -05002005struct weston_keyboard *
2006weston_seat_get_keyboard(struct weston_seat *seat);
2007
2008struct weston_pointer *
2009weston_seat_get_pointer(struct weston_seat *seat);
2010
2011struct weston_touch *
2012weston_seat_get_touch(struct weston_seat *seat);
2013
Bryce Harrington24f917e2016-06-29 19:04:07 -07002014void
2015weston_seat_set_keyboard_focus(struct weston_seat *seat,
2016 struct weston_surface *surface);
2017
Giulio Camuffo9c764df2016-06-29 11:54:27 +02002018int
2019weston_compositor_load_xwayland(struct weston_compositor *compositor);
2020
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002021void
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002022weston_head_init(struct weston_head *head, const char *name);
2023
2024void
2025weston_head_release(struct weston_head *head);
2026
2027void
2028weston_compositor_add_head(struct weston_compositor *compositor,
2029 struct weston_head *head);
2030
2031void
Pekka Paalanen01f60212017-03-24 15:39:24 +02002032weston_head_set_monitor_strings(struct weston_head *head,
2033 const char *make,
2034 const char *model,
2035 const char *serialno);
2036
2037void
2038weston_head_set_physical_size(struct weston_head *head,
2039 int32_t mm_width, int32_t mm_height);
2040
2041void
2042weston_head_set_subpixel(struct weston_head *head,
2043 enum wl_output_subpixel sp);
2044
2045void
Pekka Paalanen7fe858b2017-08-14 15:45:14 +03002046weston_head_set_connection_status(struct weston_head *head, bool connected);
2047
2048void
Pekka Paalanen01f60212017-03-24 15:39:24 +02002049weston_head_set_internal(struct weston_head *head);
2050
Pekka Paalanen7fe858b2017-08-14 15:45:14 +03002051bool
2052weston_head_is_connected(struct weston_head *head);
2053
Pekka Paalanen8e552fd2018-02-15 15:18:20 +02002054bool
2055weston_head_is_enabled(struct weston_head *head);
2056
Pekka Paalanene19970f2017-08-28 14:11:02 +03002057bool
2058weston_head_is_device_changed(struct weston_head *head);
2059
2060void
2061weston_head_reset_device_changed(struct weston_head *head);
2062
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002063const char *
2064weston_head_get_name(struct weston_head *head);
2065
2066struct weston_output *
2067weston_head_get_output(struct weston_head *head);
2068
2069void
2070weston_head_detach(struct weston_head *head);
2071
Pekka Paalanen2e1bedb2017-10-10 11:21:58 +03002072void
2073weston_head_add_destroy_listener(struct weston_head *head,
2074 struct wl_listener *listener);
2075
2076struct wl_listener *
2077weston_head_get_destroy_listener(struct weston_head *head,
2078 wl_notify_func_t notify);
2079
Pekka Paalanen1adcbac2017-08-14 16:05:35 +03002080struct weston_head *
2081weston_compositor_iterate_heads(struct weston_compositor *compositor,
2082 struct weston_head *iter);
2083
Pekka Paalanen01f60212017-03-24 15:39:24 +02002084void
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002085weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor,
2086 struct wl_listener *listener);
2087
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002088struct weston_output *
Pekka Paalanen1ae9d082017-11-02 14:11:53 +02002089weston_compositor_find_output_by_name(struct weston_compositor *compositor,
2090 const char *name);
2091
2092struct weston_output *
2093weston_compositor_create_output(struct weston_compositor *compositor,
2094 const char *name);
2095
2096struct weston_output *
Pekka Paalanen992a8cb2017-08-16 10:39:17 +03002097weston_compositor_create_output_with_head(struct weston_compositor *compositor,
2098 struct weston_head *head);
2099
2100void
2101weston_output_destroy(struct weston_output *output);
2102
2103int
2104weston_output_attach_head(struct weston_output *output,
2105 struct weston_head *head);
2106
2107struct weston_head *
2108weston_output_iterate_heads(struct weston_output *output,
2109 struct weston_head *iter);
2110
Pekka Paalanen37e6c9e2017-08-15 13:00:02 +03002111void
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002112weston_output_set_scale(struct weston_output *output,
2113 int32_t scale);
2114
2115void
2116weston_output_set_transform(struct weston_output *output,
2117 uint32_t transform);
2118
2119void
Armin Krezović40087402016-09-30 14:11:12 +02002120weston_output_init(struct weston_output *output,
Pekka Paalanen26ac2e12017-04-03 13:18:13 +03002121 struct weston_compositor *compositor,
2122 const char *name);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002123
2124void
2125weston_compositor_add_pending_output(struct weston_output *output,
2126 struct weston_compositor *compositor);
2127
2128int
2129weston_output_enable(struct weston_output *output);
2130
2131void
2132weston_output_disable(struct weston_output *output);
2133
2134void
Pekka Paalanen8a8dcac2017-08-17 17:29:36 +03002135weston_compositor_flush_heads_changed(struct weston_compositor *compositor);
Armin Krezovića01ab6d2016-09-30 14:11:02 +02002136
Pekka Paalanen055c1132017-03-27 16:31:25 +03002137struct weston_head *
2138weston_head_from_resource(struct wl_resource *resource);
Pekka Paalanen9ffb2502017-03-27 15:14:32 +03002139
Pekka Paalanencf0a4762017-04-04 16:36:07 +03002140struct weston_head *
2141weston_output_get_first_head(struct weston_output *output);
2142
Giulio Camuffo7fe01b12013-03-28 18:02:42 +01002143#ifdef __cplusplus
2144}
2145#endif
2146
Kristian Høgsberg8334bc12012-01-03 10:29:47 -05002147#endif