blob: ff10b3631284d72e6211c837075ca91179365cb0 [file] [log] [blame]
Marius Vlade41c1bf2019-07-16 23:11:25 +03001/*
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
Pekka Paalanene48bfc72019-07-17 00:09:06 +030028/*
29 * This header contains the libweston ABI exported only for internal backends.
30 */
31
Marius Vlade41c1bf2019-07-16 23:11:25 +030032#ifndef LIBWESTON_BACKEND_INTERNAL_H
33#define LIBWESTON_BACKEND_INTERNAL_H
34
Pekka Paalanene48bfc72019-07-17 00:09:06 +030035struct weston_backend {
36 void (*destroy)(struct weston_compositor *compositor);
37
38 /** Begin a repaint sequence
39 *
40 * Provides the backend with explicit markers around repaint
41 * sequences, which may allow the backend to aggregate state
42 * application. This call will be bracketed by the repaint_flush (on
43 * success), or repaint_cancel (when any output in the grouping fails
44 * repaint).
45 *
46 * Returns an opaque pointer, which the backend may use as private
47 * data referring to the repaint cycle.
48 */
49 void * (*repaint_begin)(struct weston_compositor *compositor);
50
51 /** Cancel a repaint sequence
52 *
53 * Cancels a repaint sequence, when an error has occurred during
54 * one output's repaint; see repaint_begin.
55 *
56 * @param repaint_data Data returned by repaint_begin
57 */
58 void (*repaint_cancel)(struct weston_compositor *compositor,
59 void *repaint_data);
60
61 /** Conclude a repaint sequence
62 *
63 * Called on successful completion of a repaint sequence; see
64 * repaint_begin.
65 *
66 * @param repaint_data Data returned by repaint_begin
67 */
68 int (*repaint_flush)(struct weston_compositor *compositor,
69 void *repaint_data);
70
71 /** Allocate a new output
72 *
73 * @param compositor The compositor.
74 * @param name Name for the new output.
75 *
76 * Allocates a new output structure that embeds a weston_output,
77 * initializes it, and returns the pointer to the weston_output
78 * member.
79 *
80 * Must set weston_output members @c destroy, @c enable and @c disable.
81 */
82 struct weston_output *
83 (*create_output)(struct weston_compositor *compositor,
84 const char *name);
85
86 /** Notify of device addition/removal
87 *
88 * @param compositor The compositor.
89 * @param device The device that has changed.
90 * @param added Where it was added (or removed)
91 *
92 * Called when a device has been added/removed from the session.
93 * The backend can decide what to do based on whether it is a
94 * device that it is controlling or not.
95 */
96 void (*device_changed)(struct weston_compositor *compositor,
97 dev_t device, bool added);
Marius Vlad5a701542019-11-16 20:26:52 +020098
99 /** Verifies if the dmabuf can be used directly/scanned-out by the HW.
100 *
101 * @param compositor The compositor.
102 * @param buffer The dmabuf to verify.
103 *
104 * Determines if the buffer can be imported directly by the display
105 * controller/HW. Back-ends can use this to check if the supplied
106 * buffer can be scanned-out, as to void importing it into the GPU.
107 */
108 bool (*can_scanout_dmabuf)(struct weston_compositor *compositor,
109 struct linux_dmabuf_buffer *buffer);
Pekka Paalanene48bfc72019-07-17 00:09:06 +0300110};
111
Marius Vlade41c1bf2019-07-16 23:11:25 +0300112/* weston_head */
113
114void
115weston_head_init(struct weston_head *head, const char *name);
116
117void
118weston_head_release(struct weston_head *head);
119
120void
121weston_head_set_connection_status(struct weston_head *head, bool connected);
122
123void
124weston_head_set_internal(struct weston_head *head);
125
126void
127weston_head_set_monitor_strings(struct weston_head *head,
128 const char *make,
129 const char *model,
130 const char *serialno);
131void
132weston_head_set_non_desktop(struct weston_head *head, bool non_desktop);
133
134void
135weston_head_set_physical_size(struct weston_head *head,
136 int32_t mm_width, int32_t mm_height);
137
138void
139weston_head_set_subpixel(struct weston_head *head,
140 enum wl_output_subpixel sp);
Marius Vlad63ef0782019-07-16 23:34:14 +0300141/* weston_output */
142
143void
144weston_output_init(struct weston_output *output,
145 struct weston_compositor *compositor,
146 const char *name);
147void
148weston_output_damage(struct weston_output *output);
149
150void
Marius Vlad63ef0782019-07-16 23:34:14 +0300151weston_output_release(struct weston_output *output);
152
153void
154weston_output_init_zoom(struct weston_output *output);
155
156void
157weston_output_finish_frame(struct weston_output *output,
158 const struct timespec *stamp,
159 uint32_t presented_flags);
160int
161weston_output_mode_set_native(struct weston_output *output,
162 struct weston_mode *mode,
163 int32_t scale);
164void
165weston_output_transform_coordinate(struct weston_output *output,
166 double device_x, double device_y,
167 double *x, double *y);
168
Marius Vlad5d649b62019-07-16 23:44:21 +0300169/* weston_seat */
170
171void
172notify_axis(struct weston_seat *seat, const struct timespec *time,
173 struct weston_pointer_axis_event *event);
174void
175notify_axis_source(struct weston_seat *seat, uint32_t source);
176
177void
178notify_button(struct weston_seat *seat, const struct timespec *time,
179 int32_t button, enum wl_pointer_button_state state);
180
181void
182notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
183 enum wl_keyboard_key_state state,
184 enum weston_key_state_update update_state);
185void
186notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
187 enum weston_key_state_update update_state);
188void
189notify_keyboard_focus_out(struct weston_seat *seat);
190
191void
192notify_motion(struct weston_seat *seat, const struct timespec *time,
193 struct weston_pointer_motion_event *event);
194void
195notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
196 double x, double y);
197void
198notify_modifiers(struct weston_seat *seat, uint32_t serial);
199
200void
201notify_pointer_frame(struct weston_seat *seat);
202
203void
204notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
205 double x, double y);
206
207/* weston_touch_device */
208
209void
210notify_touch_normalized(struct weston_touch_device *device,
211 const struct timespec *time,
212 int touch_id,
213 double x, double y,
214 const struct weston_point2d_device_normalized *norm,
215 int touch_type);
216
217/** Feed in touch down, motion, and up events, non-calibratable device.
218 *
219 * @sa notify_touch_cal
220 */
221static inline void
222notify_touch(struct weston_touch_device *device, const struct timespec *time,
223 int touch_id, double x, double y, int touch_type)
224{
225 notify_touch_normalized(device, time, touch_id, x, y, NULL, touch_type);
226}
227
228void
229notify_touch_frame(struct weston_touch_device *device);
230
231void
232notify_touch_cancel(struct weston_touch_device *device);
233
234void
235notify_touch_calibrator(struct weston_touch_device *device,
236 const struct timespec *time, int32_t slot,
237 const struct weston_point2d_device_normalized *norm,
238 int touch_type);
239void
240notify_touch_calibrator_cancel(struct weston_touch_device *device);
241void
242notify_touch_calibrator_frame(struct weston_touch_device *device);
Marius Vlade41c1bf2019-07-16 23:11:25 +0300243
244#endif