Marius Vlad | e41c1bf | 2019-07-16 23:11:25 +0300 | [diff] [blame] | 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 | |
Pekka Paalanen | e48bfc7 | 2019-07-17 00:09:06 +0300 | [diff] [blame] | 28 | /* |
| 29 | * This header contains the libweston ABI exported only for internal backends. |
| 30 | */ |
| 31 | |
Marius Vlad | e41c1bf | 2019-07-16 23:11:25 +0300 | [diff] [blame] | 32 | #ifndef LIBWESTON_BACKEND_INTERNAL_H |
| 33 | #define LIBWESTON_BACKEND_INTERNAL_H |
| 34 | |
Pekka Paalanen | e48bfc7 | 2019-07-17 00:09:06 +0300 | [diff] [blame] | 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); |
Marius Vlad | 5a70154 | 2019-11-16 20:26:52 +0200 | [diff] [blame] | 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); |
Pekka Paalanen | e48bfc7 | 2019-07-17 00:09:06 +0300 | [diff] [blame] | 110 | }; |
| 111 | |
Marius Vlad | e41c1bf | 2019-07-16 23:11:25 +0300 | [diff] [blame] | 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); |
Marius Vlad | 63ef078 | 2019-07-16 23:34:14 +0300 | [diff] [blame] | 141 | /* weston_output */ |
| 142 | |
| 143 | void |
| 144 | weston_output_init(struct weston_output *output, |
| 145 | struct weston_compositor *compositor, |
| 146 | const char *name); |
| 147 | void |
| 148 | weston_output_damage(struct weston_output *output); |
| 149 | |
| 150 | void |
Marius Vlad | 63ef078 | 2019-07-16 23:34:14 +0300 | [diff] [blame] | 151 | weston_output_release(struct weston_output *output); |
| 152 | |
| 153 | void |
| 154 | weston_output_init_zoom(struct weston_output *output); |
| 155 | |
| 156 | void |
| 157 | weston_output_finish_frame(struct weston_output *output, |
| 158 | const struct timespec *stamp, |
| 159 | uint32_t presented_flags); |
| 160 | int |
| 161 | weston_output_mode_set_native(struct weston_output *output, |
| 162 | struct weston_mode *mode, |
| 163 | int32_t scale); |
| 164 | void |
| 165 | weston_output_transform_coordinate(struct weston_output *output, |
| 166 | double device_x, double device_y, |
| 167 | double *x, double *y); |
| 168 | |
Marius Vlad | 5d649b6 | 2019-07-16 23:44:21 +0300 | [diff] [blame] | 169 | /* weston_seat */ |
| 170 | |
| 171 | void |
| 172 | notify_axis(struct weston_seat *seat, const struct timespec *time, |
| 173 | struct weston_pointer_axis_event *event); |
| 174 | void |
| 175 | notify_axis_source(struct weston_seat *seat, uint32_t source); |
| 176 | |
| 177 | void |
| 178 | notify_button(struct weston_seat *seat, const struct timespec *time, |
| 179 | int32_t button, enum wl_pointer_button_state state); |
| 180 | |
| 181 | void |
| 182 | notify_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); |
| 185 | void |
| 186 | notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys, |
| 187 | enum weston_key_state_update update_state); |
| 188 | void |
| 189 | notify_keyboard_focus_out(struct weston_seat *seat); |
| 190 | |
| 191 | void |
| 192 | notify_motion(struct weston_seat *seat, const struct timespec *time, |
| 193 | struct weston_pointer_motion_event *event); |
| 194 | void |
| 195 | notify_motion_absolute(struct weston_seat *seat, const struct timespec *time, |
| 196 | double x, double y); |
| 197 | void |
| 198 | notify_modifiers(struct weston_seat *seat, uint32_t serial); |
| 199 | |
| 200 | void |
| 201 | notify_pointer_frame(struct weston_seat *seat); |
| 202 | |
| 203 | void |
| 204 | notify_pointer_focus(struct weston_seat *seat, struct weston_output *output, |
| 205 | double x, double y); |
| 206 | |
| 207 | /* weston_touch_device */ |
| 208 | |
| 209 | void |
| 210 | notify_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 | */ |
| 221 | static inline void |
| 222 | notify_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 | |
| 228 | void |
| 229 | notify_touch_frame(struct weston_touch_device *device); |
| 230 | |
| 231 | void |
| 232 | notify_touch_cancel(struct weston_touch_device *device); |
| 233 | |
| 234 | void |
| 235 | notify_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); |
| 239 | void |
| 240 | notify_touch_calibrator_cancel(struct weston_touch_device *device); |
| 241 | void |
| 242 | notify_touch_calibrator_frame(struct weston_touch_device *device); |
Marius Vlad | e41c1bf | 2019-07-16 23:11:25 +0300 | [diff] [blame] | 243 | |
| 244 | #endif |