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 /*
29 * This header contains the libweston ABI exported only for internal backends.
30 */
31
32 #ifndef LIBWESTON_BACKEND_INTERNAL_H
33 #define LIBWESTON_BACKEND_INTERNAL_H
34
35 struct 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);
98
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);
110 };
111
112 /* weston_head */
113
114 void
115 weston_head_init(struct weston_head *head, const char *name);
116
117 void
118 weston_head_release(struct weston_head *head);
119
120 void
121 weston_head_set_connection_status(struct weston_head *head, bool connected);
122
123 void
124 weston_head_set_internal(struct weston_head *head);
125
126 void
127 weston_head_set_monitor_strings(struct weston_head *head,
128 const char *make,
129 const char *model,
130 const char *serialno);
131 void
132 weston_head_set_non_desktop(struct weston_head *head, bool non_desktop);
133
134 void
135 weston_head_set_physical_size(struct weston_head *head,
136 int32_t mm_width, int32_t mm_height);
137
138 void
139 weston_head_set_subpixel(struct weston_head *head,
140 enum wl_output_subpixel sp);
141
142 void
143 weston_head_set_transform(struct weston_head *head, uint32_t transform);
144
145 /* weston_output */
146
147 void
148 weston_output_init(struct weston_output *output,
149 struct weston_compositor *compositor,
150 const char *name);
151 void
152 weston_output_damage(struct weston_output *output);
153
154 void
155 weston_output_release(struct weston_output *output);
156
157 void
158 weston_output_init_zoom(struct weston_output *output);
159
160 void
161 weston_output_finish_frame(struct weston_output *output,
162 const struct timespec *stamp,
163 uint32_t presented_flags);
164 int
165 weston_output_mode_set_native(struct weston_output *output,
166 struct weston_mode *mode,
167 int32_t scale);
168 void
169 weston_output_transform_coordinate(struct weston_output *output,
170 double device_x, double device_y,
171 double *x, double *y);
172
173 /* weston_seat */
174
175 void
176 notify_axis(struct weston_seat *seat, const struct timespec *time,
177 struct weston_pointer_axis_event *event);
178 void
179 notify_axis_source(struct weston_seat *seat, uint32_t source);
180
181 void
182 notify_button(struct weston_seat *seat, const struct timespec *time,
183 int32_t button, enum wl_pointer_button_state state);
184
185 void
186 notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
187 enum wl_keyboard_key_state state,
188 enum weston_key_state_update update_state);
189 void
190 notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
191 enum weston_key_state_update update_state);
192 void
193 notify_keyboard_focus_out(struct weston_seat *seat);
194
195 void
196 notify_motion(struct weston_seat *seat, const struct timespec *time,
197 struct weston_pointer_motion_event *event);
198 void
199 notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
200 double x, double y);
201 void
202 notify_modifiers(struct weston_seat *seat, uint32_t serial);
203
204 void
205 notify_pointer_frame(struct weston_seat *seat);
206
207 void
208 notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
209 double x, double y);
210
211 /* weston_touch_device */
212
213 void
214 notify_touch_normalized(struct weston_touch_device *device,
215 const struct timespec *time,
216 int touch_id,
217 double x, double y,
218 const struct weston_point2d_device_normalized *norm,
219 int touch_type);
220
221 /** Feed in touch down, motion, and up events, non-calibratable device.
222 *
223 * @sa notify_touch_cal
224 */
225 static inline void
notify_touch(struct weston_touch_device * device,const struct timespec * time,int touch_id,double x,double y,int touch_type)226 notify_touch(struct weston_touch_device *device, const struct timespec *time,
227 int touch_id, double x, double y, int touch_type)
228 {
229 notify_touch_normalized(device, time, touch_id, x, y, NULL, touch_type);
230 }
231
232 void
233 notify_touch_frame(struct weston_touch_device *device);
234
235 void
236 notify_touch_cancel(struct weston_touch_device *device);
237
238 void
239 notify_touch_calibrator(struct weston_touch_device *device,
240 const struct timespec *time, int32_t slot,
241 const struct weston_point2d_device_normalized *norm,
242 int touch_type);
243 void
244 notify_touch_calibrator_cancel(struct weston_touch_device *device);
245 void
246 notify_touch_calibrator_frame(struct weston_touch_device *device);
247
248 #endif
249