blob: cc597317a282bffbd4fafa972b9fdfdf136ba796 [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
158void
159weston_output_disable_planes_incr(struct weston_output *output);
160
161void
162weston_output_disable_planes_decr(struct weston_output *output);
163
Marius Vlad58cac082019-07-10 16:29:05 +0300164/* weston_plane */
165
166void
167weston_plane_init(struct weston_plane *plane,
168 struct weston_compositor *ec,
169 int32_t x, int32_t y);
170void
171weston_plane_release(struct weston_plane *plane);
Marius Vlad0bf3f5a2019-07-10 17:32:42 +0300172
173/* weston_seat */
174
175struct clipboard *
176clipboard_create(struct weston_seat *seat);
177
178void
179weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
180 const char *seat_name);
181
182void
183weston_seat_repick(struct weston_seat *seat);
184
185void
186weston_seat_release(struct weston_seat *seat);
187
188void
189weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
190
Marius Vladeb34f822021-03-30 23:09:05 +0300191int
Marius Vlad0bf3f5a2019-07-10 17:32:42 +0300192weston_seat_init_pointer(struct weston_seat *seat);
193
194int
195weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
196
Marius Vladeb34f822021-03-30 23:09:05 +0300197int
Marius Vlad0bf3f5a2019-07-10 17:32:42 +0300198weston_seat_init_touch(struct weston_seat *seat);
199
200void
201weston_seat_release_keyboard(struct weston_seat *seat);
202
203void
204weston_seat_release_pointer(struct weston_seat *seat);
205
206void
207weston_seat_release_touch(struct weston_seat *seat);
208
209void
210weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
211
212void
213wl_data_device_set_keyboard_focus(struct weston_seat *seat);
214
Marius Vlad9eb20642019-07-10 18:23:43 +0300215/* weston_pointer */
216
217void
218weston_pointer_clamp(struct weston_pointer *pointer,
219 wl_fixed_t *fx, wl_fixed_t *fy);
220void
221weston_pointer_set_default_grab(struct weston_pointer *pointer,
222 const struct weston_pointer_grab_interface *interface);
223
224void
225weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
226
227/* weston_keyboard */
228bool
229weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
230
231/* weston_touch */
232
233struct weston_touch_device *
234weston_touch_create_touch_device(struct weston_touch *touch,
235 const char *syspath,
236 void *backend_data,
237 const struct weston_touch_device_ops *ops);
238
239void
240weston_touch_device_destroy(struct weston_touch_device *device);
241
242bool
243weston_touch_has_focus_resource(struct weston_touch *touch);
244
245int
246weston_touch_start_drag(struct weston_touch *touch,
247 struct weston_data_source *source,
248 struct weston_surface *icon,
249 struct wl_client *client);
250
251
252/* weston_touch_device */
253
254bool
255weston_touch_device_can_calibrate(struct weston_touch_device *device);
256
Marius Vladf1a65942019-07-10 20:42:45 +0300257/* weston_surface */
258void
259weston_surface_to_buffer_float(struct weston_surface *surface,
260 float x, float y, float *bx, float *by);
261pixman_box32_t
262weston_surface_to_buffer_rect(struct weston_surface *surface,
263 pixman_box32_t rect);
Marius Vladf1a65942019-07-10 20:42:45 +0300264void
265weston_surface_to_buffer_region(struct weston_surface *surface,
266 pixman_region32_t *surface_region,
267 pixman_region32_t *buffer_region);
268void
269weston_surface_schedule_repaint(struct weston_surface *surface);
Marius Vlad4e1d0972019-07-10 20:56:04 +0300270
271/* weston_spring */
272
273void
274weston_spring_init(struct weston_spring *spring,
275 double k, double current, double target);
276int
277weston_spring_done(struct weston_spring *spring);
278
279void
280weston_spring_update(struct weston_spring *spring, const struct timespec *time);
Marius Vlad7e4f58f2019-07-10 21:06:15 +0300281
282/* weston_view */
283
284void
285weston_view_to_global_fixed(struct weston_view *view,
286 wl_fixed_t sx, wl_fixed_t sy,
287 wl_fixed_t *x, wl_fixed_t *y);
288void
289weston_view_from_global_float(struct weston_view *view,
290 float x, float y, float *vx, float *vy);
291bool
292weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region);
293
Marius Vlad5f6bee42019-09-11 16:41:04 +0300294bool
295weston_view_has_valid_buffer(struct weston_view *ev);
296
Marius Vlad47e3d1e2019-09-11 16:53:08 +0300297bool
298weston_view_matches_output_entirely(struct weston_view *ev,
299 struct weston_output *output);
Marius Vlad7e4f58f2019-07-10 21:06:15 +0300300void
301weston_view_move_to_plane(struct weston_view *view,
302 struct weston_plane *plane);
303
Marius Vlad3ff296e2019-07-10 21:27:49 +0300304void
305weston_transformed_coord(int width, int height,
306 enum wl_output_transform transform,
307 int32_t scale,
308 float sx, float sy, float *bx, float *by);
309pixman_box32_t
310weston_transformed_rect(int width, int height,
311 enum wl_output_transform transform,
312 int32_t scale,
313 pixman_box32_t rect);
314void
315weston_transformed_region(int width, int height,
316 enum wl_output_transform transform,
317 int32_t scale,
318 pixman_region32_t *src, pixman_region32_t *dest);
319void
320weston_matrix_transform_region(pixman_region32_t *dest,
321 struct weston_matrix *matrix,
322 pixman_region32_t *src);
323
Marius Vlada9b69b42019-07-10 21:31:20 +0300324/* protected_surface */
325void
326weston_protected_surface_send_event(struct protected_surface *psurface,
327 enum weston_hdcp_protection protection);
328
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300329/* weston_drm_format */
330
331struct weston_drm_format {
332 uint32_t format;
333 struct wl_array modifiers;
334};
335
336struct weston_drm_format_array {
337 struct wl_array arr;
338};
339
340struct weston_drm_format_array *
341weston_drm_format_array_create(void);
342
343void
344weston_drm_format_array_init(struct weston_drm_format_array *formats);
345
346void
347weston_drm_format_array_destroy(struct weston_drm_format_array *formats);
348
349void
350weston_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
367bool
368weston_drm_format_array_equal(const struct weston_drm_format_array *formats_A,
369 const struct weston_drm_format_array *formats_B);
370
371int
372weston_drm_format_array_join(struct weston_drm_format_array *formats_A,
373 const struct weston_drm_format_array *formats_B);
374
Leandro Ribeiroc51d4ad2021-08-30 12:52:26 -0300375int
376weston_drm_format_array_intersect(struct weston_drm_format_array *formats_A,
Leandro Ribeiro78f01922020-12-01 16:39:47 -0300377 const struct weston_drm_format_array *formats_B);
378
379int
380weston_drm_format_array_subtract(struct weston_drm_format_array *formats_A,
381 const struct weston_drm_format_array *formats_B);
382
383int
384weston_drm_format_add_modifier(struct weston_drm_format *format,
385 uint64_t modifier);
386
387bool
388weston_drm_format_has_modifier(const struct weston_drm_format *format,
389 uint64_t modifier);
390
391const uint64_t *
392weston_drm_format_get_modifiers(const struct weston_drm_format *format,
393 unsigned int *count_out);
394
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300395/**
396 * paint node
397 *
398 * A generic data structure unique for surface-view-output combination.
399 */
400struct weston_paint_node {
Pekka Paalanen2fddc532021-04-30 17:41:29 +0300401 /* Immutable members: */
402
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300403 /* struct weston_surface::paint_node_list */
404 struct wl_list surface_link;
405 struct weston_surface *surface;
406
407 /* struct weston_view::paint_node_list */
408 struct wl_list view_link;
409 struct weston_view *view;
410
411 /* struct weston_output::paint_node_list */
412 struct wl_list output_link;
413 struct weston_output *output;
Pekka Paalanen2fddc532021-04-30 17:41:29 +0300414
415 /* Mutable members: */
416
417 /* struct weston_output::paint_node_z_order_list */
418 struct wl_list z_order_link;
Pekka Paalanen90a5ffa2021-02-25 12:03:28 +0200419
420 struct weston_surface_color_transform surf_xform;
421 bool surf_xform_valid;
Pekka Paalanen1a4f87d2021-04-30 14:48:52 +0300422};
423
424struct weston_paint_node *
425weston_view_find_paint_node(struct weston_view *view,
426 struct weston_output *output);
427
Marius Vlad0260fed2019-07-11 14:54:46 +0300428/* others */
429int
430wl_data_device_manager_init(struct wl_display *display);
431
Marius Vlada72e3712019-07-10 13:46:39 +0300432#endif