1 /*
2  * Copyright © 2008-2011 Kristian Høgsberg
3  * Copyright © 2017, 2018 General Electric Company
4  * Copyright © 2012, 2017-2019 Collabora, Ltd.
5  *
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 
43 
44 /* weston_buffer */
45 
46 void
47 weston_buffer_send_server_error(struct weston_buffer *buffer,
48 				const char *msg);
49 void
50 weston_buffer_reference(struct weston_buffer_reference *ref,
51 			struct weston_buffer *buffer);
52 
53 void
54 weston_buffer_release_move(struct weston_buffer_release_reference *dest,
55 			   struct weston_buffer_release_reference *src);
56 
57 void
58 weston_buffer_release_reference(struct weston_buffer_release_reference *ref,
59 				struct weston_buffer_release *buf_release);
60 
61 /* weston_bindings */
62 void
63 weston_binding_destroy(struct weston_binding *binding);
64 
65 void
66 weston_binding_list_destroy_all(struct wl_list *list);
67 
68 /* weston_compositor */
69 
70 void
71 touch_calibrator_mode_changed(struct weston_compositor *compositor);
72 
73 int
74 noop_renderer_init(struct weston_compositor *ec);
75 
76 void
77 weston_compositor_add_head(struct weston_compositor *compositor,
78 			   struct weston_head *head);
79 void
80 weston_compositor_add_pending_output(struct weston_output *output,
81 				     struct weston_compositor *compositor);
82 bool
83 weston_compositor_import_dmabuf(struct weston_compositor *compositor,
84 				struct linux_dmabuf_buffer *buffer);
85 void
86 weston_compositor_offscreen(struct weston_compositor *compositor);
87 
88 char *
89 weston_compositor_print_scene_graph(struct weston_compositor *ec);
90 
91 void
92 weston_compositor_read_presentation_clock(
93 			const struct weston_compositor *compositor,
94 			struct timespec *ts);
95 
96 int
97 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
98 				   struct weston_pointer *pointer,
99 				   const struct timespec *time,
100 				   struct weston_pointer_axis_event *event);
101 void
102 weston_compositor_run_button_binding(struct weston_compositor *compositor,
103 				     struct weston_pointer *pointer,
104 				     const struct timespec *time,
105 				     uint32_t button,
106 				     enum wl_pointer_button_state value);
107 int
108 weston_compositor_run_debug_binding(struct weston_compositor *compositor,
109 				    struct weston_keyboard *keyboard,
110 				    const struct timespec *time,
111 				    uint32_t key,
112 				    enum wl_keyboard_key_state state);
113 void
114 weston_compositor_run_key_binding(struct weston_compositor *compositor,
115 				  struct weston_keyboard *keyboard,
116 				  const struct timespec *time,
117 				  uint32_t key,
118 				  enum wl_keyboard_key_state state);
119 void
120 weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
121 				       struct weston_keyboard *keyboard,
122 				       enum weston_keyboard_modifier modifier,
123 				       enum wl_keyboard_key_state state);
124 void
125 weston_compositor_run_touch_binding(struct weston_compositor *compositor,
126 				    struct weston_touch *touch,
127 				    const struct timespec *time,
128 				    int touch_type);
129 void
130 weston_compositor_stack_plane(struct weston_compositor *ec,
131 			      struct weston_plane *plane,
132 			      struct weston_plane *above);
133 void
134 weston_compositor_set_touch_mode_normal(struct weston_compositor *compositor);
135 
136 void
137 weston_compositor_set_touch_mode_calib(struct weston_compositor *compositor);
138 
139 int
140 weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
141 					 clockid_t clk_id);
142 int
143 weston_compositor_set_presentation_clock_software(
144 					struct weston_compositor *compositor);
145 void
146 weston_compositor_shutdown(struct weston_compositor *ec);
147 
148 void
149 weston_compositor_xkb_destroy(struct weston_compositor *ec);
150 
151 int
152 weston_input_init(struct weston_compositor *compositor);
153 
154 /* weston_plane */
155 
156 void
157 weston_plane_init(struct weston_plane *plane,
158 			struct weston_compositor *ec,
159 			int32_t x, int32_t y);
160 void
161 weston_plane_release(struct weston_plane *plane);
162 
163 /* weston_seat */
164 
165 struct clipboard *
166 clipboard_create(struct weston_seat *seat);
167 
168 void
169 weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
170 		 const char *seat_name);
171 
172 void
173 weston_seat_repick(struct weston_seat *seat);
174 
175 void
176 weston_seat_release(struct weston_seat *seat);
177 
178 void
179 weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
180 
181 void
182 weston_seat_init_pointer(struct weston_seat *seat);
183 
184 int
185 weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
186 
187 void
188 weston_seat_init_touch(struct weston_seat *seat);
189 
190 void
191 weston_seat_release_keyboard(struct weston_seat *seat);
192 
193 void
194 weston_seat_release_pointer(struct weston_seat *seat);
195 
196 void
197 weston_seat_release_touch(struct weston_seat *seat);
198 
199 void
200 weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
201 
202 void
203 wl_data_device_set_keyboard_focus(struct weston_seat *seat);
204 
205 /* weston_pointer */
206 
207 void
208 weston_pointer_clamp(struct weston_pointer *pointer,
209 		     wl_fixed_t *fx, wl_fixed_t *fy);
210 void
211 weston_pointer_set_default_grab(struct weston_pointer *pointer,
212 			        const struct weston_pointer_grab_interface *interface);
213 
214 void
215 weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
216 
217 /* weston_keyboard */
218 bool
219 weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
220 
221 /* weston_touch */
222 
223 struct weston_touch_device *
224 weston_touch_create_touch_device(struct weston_touch *touch,
225 				 const char *syspath,
226 				 void *backend_data,
227 				 const struct weston_touch_device_ops *ops);
228 
229 void
230 weston_touch_device_destroy(struct weston_touch_device *device);
231 
232 bool
233 weston_touch_has_focus_resource(struct weston_touch *touch);
234 
235 int
236 weston_touch_start_drag(struct weston_touch *touch,
237 			struct weston_data_source *source,
238 			struct weston_surface *icon,
239 			struct wl_client *client);
240 
241 
242 /* weston_touch_device */
243 
244 bool
245 weston_touch_device_can_calibrate(struct weston_touch_device *device);
246 
247 /* weston_surface */
248 void
249 weston_surface_to_buffer_float(struct weston_surface *surface,
250 			       float x, float y, float *bx, float *by);
251 pixman_box32_t
252 weston_surface_to_buffer_rect(struct weston_surface *surface,
253 			      pixman_box32_t rect);
254 
255 void
256 weston_surface_to_buffer_region(struct weston_surface *surface,
257 				pixman_region32_t *surface_region,
258 				pixman_region32_t *buffer_region);
259 void
260 weston_surface_schedule_repaint(struct weston_surface *surface);
261 
262 /* weston_spring */
263 
264 void
265 weston_spring_init(struct weston_spring *spring,
266 		   double k, double current, double target);
267 int
268 weston_spring_done(struct weston_spring *spring);
269 
270 void
271 weston_spring_update(struct weston_spring *spring, const struct timespec *time);
272 
273 /* weston_view */
274 
275 void
276 weston_view_to_global_fixed(struct weston_view *view,
277 			    wl_fixed_t sx, wl_fixed_t sy,
278 			    wl_fixed_t *x, wl_fixed_t *y);
279 void
280 weston_view_from_global_float(struct weston_view *view,
281 			      float x, float y, float *vx, float *vy);
282 bool
283 weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region);
284 
285 void
286 weston_view_move_to_plane(struct weston_view *view,
287 			  struct weston_plane *plane);
288 
289 void
290 weston_transformed_coord(int width, int height,
291 			 enum wl_output_transform transform,
292 			 int32_t scale,
293 			 float sx, float sy, float *bx, float *by);
294 pixman_box32_t
295 weston_transformed_rect(int width, int height,
296 			enum wl_output_transform transform,
297 			int32_t scale,
298 			pixman_box32_t rect);
299 void
300 weston_transformed_region(int width, int height,
301 			  enum wl_output_transform transform,
302 			  int32_t scale,
303 			  pixman_region32_t *src, pixman_region32_t *dest);
304 void
305 weston_matrix_transform_region(pixman_region32_t *dest,
306 			       struct weston_matrix *matrix,
307 			       pixman_region32_t *src);
308 
309 /* protected_surface */
310 void
311 weston_protected_surface_send_event(struct protected_surface *psurface,
312 				    enum weston_hdcp_protection protection);
313 
314 /* others */
315 int
316 wl_data_device_manager_init(struct wl_display *display);
317 
318 #endif
319