FreeRDP
Loading...
Searching...
No Matches
uwac.h
1/*
2 * Copyright © 2014-2015 David FORT <contact@hardening-consulting.com>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef UWAC_H_
24#define UWAC_H_
25
26#include <wayland-client.h>
27#include <stdbool.h>
28
29#if defined(__GNUC__) && (__GNUC__ >= 4)
30#if defined(__cplusplus) && (__cplusplus >= 201703L)
31#define UWAC_API [[gnu::visibility("default")]]
32#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
33#define UWAC_API [[gnu::visibility("default")]]
34#else
35#define UWAC_API __attribute__((visibility("default")))
36#endif
37#else
38#define UWAC_API
39#endif
40
41typedef struct uwac_position UwacPosition;
42typedef struct uwac_size UwacSize;
43typedef struct uwac_display UwacDisplay;
44typedef struct uwac_output UwacOutput;
45typedef struct uwac_window UwacWindow;
46typedef struct uwac_seat UwacSeat;
47typedef uint32_t UwacSeatId;
48
50typedef enum
51{
52 UWAC_SUCCESS = 0,
53 UWAC_ERROR_NOMEMORY,
54 UWAC_ERROR_UNABLE_TO_CONNECT,
55 UWAC_ERROR_INVALID_DISPLAY,
56 UWAC_NOT_ENOUGH_RESOURCES,
57 UWAC_TIMEDOUT,
58 UWAC_NOT_FOUND,
59 UWAC_ERROR_CLOSED,
60 UWAC_ERROR_INTERNAL,
61
62 UWAC_ERROR_LAST,
63} UwacReturnCode;
64
66enum
67{
68 UWAC_MOD_SHIFT_MASK = 0x01,
69 UWAC_MOD_ALT_MASK = 0x02,
70 UWAC_MOD_CONTROL_MASK = 0x04,
71 UWAC_MOD_CAPS_MASK = 0x08,
72 UWAC_MOD_NUM_MASK = 0x10,
73};
74
77{
78 int x;
79 int y;
80};
81
84{
85 int width;
86 int height;
87};
88
90enum
91{
92 UWAC_EVENT_NEW_SEAT = 0,
93 UWAC_EVENT_REMOVED_SEAT,
94 UWAC_EVENT_NEW_OUTPUT,
95 UWAC_EVENT_CONFIGURE,
96 UWAC_EVENT_POINTER_ENTER,
97 UWAC_EVENT_POINTER_LEAVE,
98 UWAC_EVENT_POINTER_MOTION,
99 UWAC_EVENT_POINTER_BUTTONS,
100 UWAC_EVENT_POINTER_AXIS,
101 UWAC_EVENT_KEYBOARD_ENTER,
102 UWAC_EVENT_KEYBOARD_MODIFIERS,
103 UWAC_EVENT_KEY,
104 UWAC_EVENT_TOUCH_FRAME_BEGIN,
105 UWAC_EVENT_TOUCH_UP,
106 UWAC_EVENT_TOUCH_DOWN,
107 UWAC_EVENT_TOUCH_MOTION,
108 UWAC_EVENT_TOUCH_CANCEL,
109 UWAC_EVENT_TOUCH_FRAME_END,
110 UWAC_EVENT_FRAME_DONE,
111 UWAC_EVENT_CLOSE,
112 UWAC_EVENT_CLIPBOARD_AVAILABLE,
113 UWAC_EVENT_CLIPBOARD_SELECT,
114 UWAC_EVENT_CLIPBOARD_OFFER,
115 UWAC_EVENT_OUTPUT_GEOMETRY,
116 UWAC_EVENT_POINTER_AXIS_DISCRETE,
117 UWAC_EVENT_POINTER_FRAME,
118 UWAC_EVENT_POINTER_SOURCE
119};
120
122enum
123{
124 UWAC_WINDOW_MAXIMIZED = 0x1,
125 UWAC_WINDOW_RESIZING = 0x2,
126 UWAC_WINDOW_FULLSCREEN = 0x4,
127 UWAC_WINDOW_ACTIVATED = 0x8,
128};
129
131{
132 int type;
133 UwacOutput* output;
134};
135typedef struct uwac_new_output_event UwacOutputNewEvent;
136
138{
139 int type;
140 UwacSeat* seat;
141};
142typedef struct uwac_new_seat_event UwacSeatNewEvent;
143
145{
146 int type;
147 UwacSeatId id;
148};
149typedef struct uwac_removed_seat_event UwacSeatRemovedEvent;
150
152{
153 int type;
154 UwacWindow* window;
155 UwacSeat* seat;
156};
157typedef struct uwac_keyboard_enter_event UwacKeyboardEnterLeaveEvent;
158
160{
161 int type;
162 uint32_t modifiers;
163};
164typedef struct uwac_keyboard_modifiers_event UwacKeyboardModifiersEvent;
165
167{
168 int type;
169 UwacWindow* window;
170 UwacSeat* seat;
171 uint32_t x, y;
172};
173typedef struct uwac_pointer_enter_event UwacPointerEnterLeaveEvent;
174
176{
177 int type;
178 UwacWindow* window;
179 UwacSeat* seat;
180 uint32_t x, y;
181};
182typedef struct uwac_pointer_motion_event UwacPointerMotionEvent;
183
185{
186 int type;
187 UwacWindow* window;
188 UwacSeat* seat;
189 uint32_t x, y;
190 uint32_t button;
191 enum wl_pointer_button_state state;
192};
193typedef struct uwac_pointer_button_event UwacPointerButtonEvent;
194
196{
197 int type;
198 UwacWindow* window;
199 UwacSeat* seat;
200 uint32_t x, y;
201 uint32_t axis;
202 wl_fixed_t value;
203};
204typedef struct uwac_pointer_axis_event UwacPointerAxisEvent;
205
207{
208 int type;
209 UwacWindow* window;
210 UwacSeat* seat;
211};
212typedef struct uwac_pointer_frame_event UwacPointerFrameEvent;
213
215{
216 int type;
217 UwacWindow* window;
218 UwacSeat* seat;
219 enum wl_pointer_axis_source axis_source;
220};
221typedef struct uwac_pointer_source_event UwacPointerSourceEvent;
222
224{
225 int type;
226 UwacWindow* window;
227 UwacSeat* seat;
228};
229typedef struct uwac_touch_frame_event UwacTouchFrameBegin;
230typedef struct uwac_touch_frame_event UwacTouchFrameEnd;
231typedef struct uwac_touch_frame_event UwacTouchCancel;
232
234{
235 int type;
236 UwacWindow* window;
237 UwacSeat* seat;
238 int32_t id;
239 wl_fixed_t x;
240 wl_fixed_t y;
241};
242typedef struct uwac_touch_data UwacTouchUp;
243typedef struct uwac_touch_data UwacTouchDown;
244typedef struct uwac_touch_data UwacTouchMotion;
245
247{
248 int type;
249 UwacWindow* window;
250};
251typedef struct uwac_frame_done_event UwacFrameDoneEvent;
252
254{
255 int type;
256 UwacWindow* window;
257 int32_t width;
258 int32_t height;
259 int states;
260};
261typedef struct uwac_configure_event UwacConfigureEvent;
262
264{
265 int type;
266 UwacWindow* window;
267 uint32_t raw_key;
268 uint32_t sym;
269 bool pressed;
270 bool repeated;
271};
272typedef struct uwac_key_event UwacKeyEvent;
273
275{
276 int type;
277 UwacWindow* window;
278};
279typedef struct uwac_close_event UwacCloseEvent;
280
282{
283 int type;
284 UwacSeat* seat;
285 char mime[64];
286};
287typedef struct uwac_clipboard_event UwacClipboardEvent;
288
290{
291 int type;
292 UwacOutput* output;
293 int x;
294 int y;
295 int physical_width;
296 int physical_height;
297 int subpixel;
298 const char* make;
299 const char* model;
300 int transform;
301};
302typedef struct uwac_output_geometry_event UwacOutputGeometryEvent;
303
305{
306 int type;
307 UwacOutputNewEvent output_new;
308 UwacOutputGeometryEvent output_geometry;
309 UwacSeatNewEvent seat_new;
310 UwacSeatRemovedEvent seat_removed;
311 UwacPointerEnterLeaveEvent mouse_enter_leave;
312 UwacPointerMotionEvent mouse_motion;
313 UwacPointerButtonEvent mouse_button;
314 UwacPointerAxisEvent mouse_axis;
315 UwacPointerFrameEvent mouse_frame;
316 UwacPointerSourceEvent mouse_source;
317 UwacKeyboardEnterLeaveEvent keyboard_enter_leave;
318 UwacKeyboardModifiersEvent keyboard_modifiers;
319 UwacClipboardEvent clipboard;
320 UwacKeyEvent key;
321 UwacTouchFrameBegin touchFrameBegin;
322 UwacTouchUp touchUp;
323 UwacTouchDown touchDown;
324 UwacTouchMotion touchMotion;
325 UwacTouchFrameEnd touchFrameEnd;
326 UwacTouchCancel touchCancel;
327 UwacFrameDoneEvent frame_done;
328 UwacConfigureEvent configure;
329 UwacCloseEvent close;
330};
331typedef union uwac_event UwacEvent;
332
333typedef bool (*UwacErrorHandler)(UwacDisplay* d, UwacReturnCode code, const char* msg, ...);
334typedef void (*UwacDataTransferHandler)(UwacSeat* seat, void* context, const char* mime, int fd);
335typedef void (*UwacCancelDataTransferHandler)(UwacSeat* seat, void* context);
336
337#ifdef __cplusplus
338extern "C"
339{
340#endif
341
349 UWAC_API void UwacInstallErrorHandler(UwacErrorHandler handler);
350
358 UWAC_API UwacDisplay* UwacOpenDisplay(const char* name, UwacReturnCode* err);
359
366 UWAC_API UwacReturnCode UwacCloseDisplay(UwacDisplay** pdisplay);
367
375 UWAC_API int UwacDisplayGetFd(UwacDisplay* display);
376
383 UWAC_API const char* UwacErrorString(UwacReturnCode error);
384
391 UWAC_API UwacReturnCode UwacDisplayGetLastError(const UwacDisplay* display);
392
401 UWAC_API UwacReturnCode UwacDisplayQueryInterfaceVersion(const UwacDisplay* display,
402 const char* name, uint32_t* version);
403
410 UWAC_API uint32_t UwacDisplayQueryGetNbShmFormats(UwacDisplay* display);
411
422 UWAC_API UwacReturnCode UwacDisplayQueryShmFormats(const UwacDisplay* display,
423 enum wl_shm_format* formats,
424 int formats_size, int* filled);
425
432 UWAC_API uint32_t UwacDisplayGetNbOutputs(const UwacDisplay* display);
433
442 UWAC_API const UwacOutput* UwacDisplayGetOutput(UwacDisplay* display, int index);
443
451 UWAC_API UwacReturnCode UwacOutputGetResolution(const UwacOutput* output, UwacSize* resolution);
452
460 UWAC_API UwacReturnCode UwacOutputGetPosition(const UwacOutput* output, UwacPosition* pos);
461
472 UWAC_API UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t height,
473 enum wl_shm_format format);
474
481 UWAC_API UwacReturnCode UwacDestroyWindow(UwacWindow** window);
482
493 UWAC_API UwacReturnCode UwacWindowSetOpaqueRegion(UwacWindow* window, uint32_t x, uint32_t y,
494 uint32_t width, uint32_t height);
495
506 UWAC_API UwacReturnCode UwacWindowSetInputRegion(UwacWindow* window, uint32_t x, uint32_t y,
507 uint32_t width, uint32_t height);
508
514 UWAC_API void* UwacWindowGetDrawingBuffer(UwacWindow* window);
515
526 UWAC_API UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y,
527 uint32_t width, uint32_t height);
528
537 UWAC_API UwacReturnCode UwacWindowGetDrawingBufferGeometry(UwacWindow* window,
538 UwacSize* geometry, size_t* stride);
539
548 UWAC_API UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window,
549 bool copyContentForNextFrame);
550
558 UWAC_API UwacReturnCode UwacWindowGetGeometry(UwacWindow* window, UwacSize* geometry);
559
570 UWAC_API UwacReturnCode UwacWindowSetFullscreenState(UwacWindow* window, UwacOutput* output,
571 bool isFullscreen);
572
579 UWAC_API void UwacWindowSetTitle(UwacWindow* window, const char* name);
580
587 UWAC_API void UwacWindowSetAppId(UwacWindow* window, const char* app_id);
588
595 UWAC_API int UwacDisplayDispatch(UwacDisplay* display, int timeout);
596
603 UWAC_API bool UwacHasEvent(UwacDisplay* display);
604
612 UWAC_API UwacReturnCode UwacNextEvent(UwacDisplay* display, UwacEvent* event);
613
620 UWAC_API const char* UwacSeatGetName(const UwacSeat* seat);
621
628 UWAC_API UwacSeatId UwacSeatGetId(const UwacSeat* seat);
629
633 UWAC_API UwacReturnCode UwacClipboardOfferDestroy(UwacSeat* seat);
634 UWAC_API UwacReturnCode UwacClipboardOfferCreate(UwacSeat* seat, const char* mime);
635 UWAC_API UwacReturnCode UwacClipboardOfferAnnounce(UwacSeat* seat, void* context,
636 UwacDataTransferHandler transfer,
637 UwacCancelDataTransferHandler cancel);
638 UWAC_API void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size);
639
648 UWAC_API UwacReturnCode UwacSeatInhibitShortcuts(UwacSeat* seat, bool inhibit);
649
666 UWAC_API UwacReturnCode UwacSeatSetMouseCursor(UwacSeat* seat, const void* data, size_t length,
667 size_t width, size_t height, size_t hot_x,
668 size_t hot_y);
669
670#ifdef __cplusplus
671}
672#endif
673
674#endif /* UWAC_H_ */
main connection object to a wayland display
Definition uwac-priv.h:90
an output on a wayland display
Definition uwac-priv.h:142
a position
Definition uwac.h:77
a seat attached to a wayland display
Definition uwac-priv.h:164
a rectangle size measure
Definition uwac.h:84
a window
Definition uwac-priv.h:239