blob: e775548bf671f832eb5e1e7ad11b164558948b6c [file] [log] [blame]
Marius Vlada72e3712019-07-10 13:46:39 +03001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
3 * Copyright © 2017, 2018 General Electric Company
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +03004 * Copyright © 2012, 2017-2019, 2021 Collabora, Ltd.
Marius Vlada72e3712019-07-10 13:46:39 +03005 *
6 * 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:
13 *
14 * 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.
26 */
27
28#ifndef LIBWESTON_INTERNAL_H
29#define LIBWESTON_INTERNAL_H
30
31/*
32 * This is the internal (private) part of libweston. All symbols found here
33 * are, and should be only (with a few exceptions) used within the internal
34 * parts of libweston. Notable exception(s) include a few files in tests/ that
35 * need access to these functions, screen-share file from compositor/ and those
36 * remoting/. Those will require some further fixing as to avoid including this
37 * private header.
38 *
39 * Eventually, these symbols should reside naturally into their own scope. New
40 * features should either provide their own (internal) header or use this one.
41 */
42
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +030043#include <libweston/libweston.h>
Pekka Paalanen90a5ffa2021-02-25 12:03:28 +020044#include "color.h"
Marius Vlada72e3712019-07-10 13:46:39 +030045
46/* weston_buffer */
47
48void
49weston_buffer_send_server_error(struct weston_buffer *buffer,
50 const char *msg);
51void
52weston_buffer_reference(struct weston_buffer_reference *ref,
53 struct weston_buffer *buffer);
54
55void
56weston_buffer_release_move(struct weston_buffer_release_reference *dest,
57 struct weston_buffer_release_reference *src);
58
59void
60weston_buffer_release_reference(struct weston_buffer_release_reference *ref,
61 struct weston_buffer_release *buf_release);
62
Marius Vlad56f3a682019-07-10 14:48:39 +030063/* weston_bindings */
64void
Marius Vlad56f3a682019-07-10 14:48:39 +030065weston_binding_list_destroy_all(struct wl_list *list);
66
67/* weston_compositor */
68
69void
70touch_calibrator_mode_changed(struct weston_compositor *compositor);
71
72int
73noop_renderer_init(struct weston_compositor *ec);
74
75void
76weston_compositor_add_head(struct weston_compositor *compositor,
77 struct weston_head *head);
78void
79weston_compositor_add_pending_output(struct weston_output *output,
80 struct weston_compositor *compositor);
Marius Vlad56f3a682019-07-10 14:48:39 +030081bool
82weston_compositor_import_dmabuf(struct weston_compositor *compositor,
83 struct linux_dmabuf_buffer *buffer);
Marius Vlad5a701542019-11-16 20:26:52 +020084bool
85weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
86 struct linux_dmabuf_buffer *buffer);
Marius Vlad56f3a682019-07-10 14:48:39 +030087void
88weston_compositor_offscreen(struct weston_compositor *compositor);
89
90char *
91weston_compositor_print_scene_graph(struct weston_compositor *ec);
92
93void
94weston_compositor_read_presentation_clock(
95 const struct weston_compositor *compositor,
96 struct timespec *ts);
97
98int
99weston_compositor_run_axis_binding(struct weston_compositor *compositor,
100 struct weston_pointer *pointer,
101 const struct timespec *time,
102 struct weston_pointer_axis_event *event);
103void
104weston_compositor_run_button_binding(struct weston_compositor *compositor,
105 struct weston_pointer *pointer,
106 const struct timespec *time,
107 uint32_t button,
108 enum wl_pointer_button_state value);
109int
110weston_compositor_run_debug_binding(struct weston_compositor *compositor,
111 struct weston_keyboard *keyboard,
112 const struct timespec *time,
113 uint32_t key,
114 enum wl_keyboard_key_state state);
115void
116weston_compositor_run_key_binding(struct weston_compositor *compositor,
117 struct weston_keyboard *keyboard,
118 const struct timespec *time,
119 uint32_t key,
120 enum wl_keyboard_key_state state);
121void
122weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
123 struct weston_keyboard *keyboard,
124 enum weston_keyboard_modifier modifier,
125 enum wl_keyboard_key_state state);
126void
127weston_compositor_run_touch_binding(struct weston_compositor *compositor,
128 struct weston_touch *touch,
129 const struct timespec *time,
130 int touch_type);
131void
132weston_compositor_stack_plane(struct weston_compositor *ec,
133 struct weston_plane *plane,
134 struct weston_plane *above);
135void
136weston_compositor_set_touch_mode_normal(struct weston_compositor *compositor);
137
138void
139weston_compositor_set_touch_mode_calib(struct weston_compositor *compositor);
140
141int
142weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
143 clockid_t clk_id);
144int
145weston_compositor_set_presentation_clock_software(
146 struct weston_compositor *compositor);
147void
148weston_compositor_shutdown(struct weston_compositor *ec);
149
150void
151weston_compositor_xkb_destroy(struct weston_compositor *ec);
152
153int
154weston_input_init(struct weston_compositor *compositor);
155
Ankit Nautiyal93dde242019-07-08 11:46:42 +0530156/* weston_output */
157
leng.fang32af9fc2024-06-13 11:22:15 +0800158int
159aml_config_setup(struct weston_compositor *ec);
160
limin.tianff789062024-08-14 02:24:40 +0000161int
162aml_drm_config_setup(struct weston_compositor *ec);
163
Ankit Nautiyal93dde242019-07-08 11:46:42 +0530164void
165weston_output_disable_planes_incr(struct weston_output *output);
166
167void
168weston_output_disable_planes_decr(struct weston_output *output);
169
Marius Vlad58cac082019-07-10 16:29:05 +0300170/* weston_plane */
171
172void
173weston_plane_init(struct weston_plane *plane,
174 struct weston_compositor *ec,
175 int32_t x, int32_t y);
176void
177weston_plane_release(struct weston_plane *plane);
Marius Vlad0bf3f5a2019-07-10 17:32:42 +0300178
179/* weston_seat */
180
181struct clipboard *
182clipboard_create(struct weston_seat *seat);
183
184void
185weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
186 const char *seat_name);
187
188void
189weston_seat_repick(struct weston_seat *seat);
190
191void
192weston_seat_release(struct weston_seat *seat);
193
194void
195weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
196
Marius Vladeb34f822021-03-30 23:09:05 +0300197int
Marius Vlad0bf3f5a2019-07-10 17:32:42 +0300198weston_seat_init_pointer(struct weston_seat *seat);
199
200int
201weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
202
Marius Vladeb34f822021-03-30 23:09:05 +0300203int
Marius Vlad0bf3f5a2019-07-10 17:32:42 +0300204weston_seat_init_touch(struct weston_seat *seat);
205
206void
207weston_seat_release_keyboard(struct weston_seat *seat);
208
209void
210weston_seat_release_pointer(struct weston_seat *seat);
211
212void
213weston_seat_release_touch(struct weston_seat *seat);
214
215void
216weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
217
218void
219wl_data_device_set_keyboard_focus(struct weston_seat *seat);
220
Marius Vlad9eb20642019-07-10 18:23:43 +0300221/* weston_pointer */
222
223void
224weston_pointer_clamp(struct weston_pointer *pointer,
225 wl_fixed_t *fx, wl_fixed_t *fy);
226void
227weston_pointer_set_default_grab(struct weston_pointer *pointer,
228 const struct weston_pointer_grab_interface *interface);
229
230void
231weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
232
233/* weston_keyboard */
234bool
235weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
236
237/* weston_touch */
238
239struct weston_touch_device *
240weston_touch_create_touch_device(struct weston_touch *touch,
241 const char *syspath,
242 void *backend_data,
243 const struct weston_touch_device_ops *ops);
244
245void
246weston_touch_device_destroy(struct weston_touch_device *device);
247
248bool
249weston_touch_has_focus_resource(struct weston_touch *touch);
250
251int
252weston_touch_start_drag(struct weston_touch *touch,
253 struct weston_data_source *source,
254 struct weston_surface *icon,
255 struct wl_client *client);
256
257
258/* weston_touch_device */
259
260bool
261weston_touch_device_can_calibrate(struct weston_touch_device *device);
262
Marius Vladf1a65942019-07-10 20:42:45 +0300263/* weston_surface */
264void
265weston_surface_to_buffer_float(struct weston_surface *surface,
266 float x, float y, float *bx, float *by);
267pixman_box32_t
268weston_surface_to_buffer_rect(struct weston_surface *surface,
269 pixman_box32_t rect);
Marius Vladf1a65942019-07-10 20:42:45 +0300270void
271weston_surface_to_buffer_region(struct weston_surface *surface,
272 pixman_region32_t *surface_region,
273 pixman_region32_t *buffer_region);
274void
275weston_surface_schedule_repaint(struct weston_surface *surface);
Marius Vlad4e1d0972019-07-10 20:56:04 +0300276
277/* weston_spring */
278
279void
280weston_spring_init(struct weston_spring *spring,
281 double k, double current, double target);
282int
283weston_spring_done(struct weston_spring *spring);
284
285void
286weston_spring_update(struct weston_spring *spring, const struct timespec *time);
Marius Vlad7e4f58f2019-07-10 21:06:15 +0300287
288/* weston_view */
289
290void
291weston_view_to_global_fixed(struct weston_view *view,
292 wl_fixed_t sx, wl_fixed_t sy,
293 wl_fixed_t *x, wl_fixed_t *y);
294void
295weston_view_from_global_float(struct weston_view *view,
296 float x, float y, float *vx, float *vy);
297bool
298weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region);
299
Marius Vlad5f6bee42019-09-11 16:41:04 +0300300bool
301weston_view_has_valid_buffer(struct weston_view *ev);
302
Marius Vlad47e3d1e2019-09-11 16:53:08 +0300303bool
304weston_view_matches_output_entirely(struct weston_view *ev,
305 struct weston_output *output);
Marius Vlad7e4f58f2019-07-10 21:06:15 +0300306void
307weston_view_move_to_plane(struct weston_view *view,
308 struct weston_plane *plane);
309
Marius Vlad3ff296e2019-07-10 21:27:49 +0300310void
311weston_transformed_coord(int width, int height,
312 enum wl_output_transform transform,
313 int32_t scale,
314 float sx, float sy, float *bx, float *by);
315pixman_box32_t
316weston_transformed_rect(int width, int height,
317 enum wl_output_transform transform,
318 int32_t scale,
319 pixman_box32_t rect);
320void
321weston_transformed_region(int width, int height,
322 enum wl_output_transform transform,
323 int32_t scale,
324 pixman_region32_t *src, pixman_region32_t *dest);
325void
326weston_matrix_transform_region(pixman_region32_t *dest,
327 struct weston_matrix *matrix,
328 pixman_region32_t *src);
329
Marius Vlada9b69b42019-07-10 21:31:20 +0300330/* protected_surface */
331void
332weston_protected_surface_send_event(struct protected_surface *psurface,
333 enum weston_hdcp_protection protection);
334
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300335/* weston_drm_format */
336
337struct weston_drm_format {
338 uint32_t format;
339 struct wl_array modifiers;
340};
341
342struct weston_drm_format_array {
343 struct wl_array arr;
344};
345
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300346void
347weston_drm_format_array_init(struct weston_drm_format_array *formats);
348
349void
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300350weston_drm_format_array_fini(struct weston_drm_format_array *formats);
351
352int
353weston_drm_format_array_replace(struct weston_drm_format_array *formats,
354 const struct weston_drm_format_array *source_formats);
355
356struct weston_drm_format *
357weston_drm_format_array_add_format(struct weston_drm_format_array *formats,
358 uint32_t format);
359
360void
361weston_drm_format_array_remove_latest_format(struct weston_drm_format_array *formats);
362
363struct weston_drm_format *
364weston_drm_format_array_find_format(const struct weston_drm_format_array *formats,
365 uint32_t format);
366
Leandro Ribeiro60c7fee2021-10-06 12:05:40 -0300367unsigned int
368weston_drm_format_array_count_pairs(const struct weston_drm_format_array *formats);
369
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300370bool
371weston_drm_format_array_equal(const struct weston_drm_format_array *formats_A,
372 const struct weston_drm_format_array *formats_B);
373
374int
375weston_drm_format_array_join(struct weston_drm_format_array *formats_A,
376 const struct weston_drm_format_array *formats_B);
377
Leandro Ribeiroc51d4ad2021-08-30 12:52:26 -0300378int
379weston_drm_format_array_intersect(struct weston_drm_format_array *formats_A,
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300380 const struct weston_drm_format_array *formats_B);
381
382int
383weston_drm_format_array_subtract(struct weston_drm_format_array *formats_A,
384 const struct weston_drm_format_array *formats_B);
385
386int
387weston_drm_format_add_modifier(struct weston_drm_format *format,
388 uint64_t modifier);
389
390bool
391weston_drm_format_has_modifier(const struct weston_drm_format *format,
392 uint64_t modifier);
393
394const uint64_t *
395weston_drm_format_get_modifiers(const struct weston_drm_format *format,
396 unsigned int *count_out);
397
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300398/**
399 * paint node
400 *
401 * A generic data structure unique for surface-view-output combination.
402 */
403struct weston_paint_node {
Pekka Paalanen2fddc532021-04-30 17:41:29 +0300404 /* Immutable members: */
405
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300406 /* struct weston_surface::paint_node_list */
407 struct wl_list surface_link;
408 struct weston_surface *surface;
409
410 /* struct weston_view::paint_node_list */
411 struct wl_list view_link;
412 struct weston_view *view;
413
414 /* struct weston_output::paint_node_list */
415 struct wl_list output_link;
416 struct weston_output *output;
Pekka Paalanen2fddc532021-04-30 17:41:29 +0300417
418 /* Mutable members: */
419
420 /* struct weston_output::paint_node_z_order_list */
421 struct wl_list z_order_link;
Pekka Paalanen90a5ffa2021-02-25 12:03:28 +0200422
423 struct weston_surface_color_transform surf_xform;
424 bool surf_xform_valid;
Leandro Ribeiro0a7034c2021-09-13 14:52:53 -0300425
426 uint32_t try_view_on_plane_failure_reasons;
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300427};
428
429struct weston_paint_node *
430weston_view_find_paint_node(struct weston_view *view,
431 struct weston_output *output);
432
Marius Vlad0260fed2019-07-11 14:54:46 +0300433/* others */
434int
435wl_data_device_manager_init(struct wl_display *display);
436
Marius Vlada72e3712019-07-10 13:46:39 +0300437#endif