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#define UWAC_API __attribute__((visibility("default")))
31#else
32#define UWAC_API
33#endif
34
35typedef struct uwac_position UwacPosition;
36typedef struct uwac_size UwacSize;
37typedef struct uwac_display UwacDisplay;
38typedef struct uwac_output UwacOutput;
39typedef struct uwac_window UwacWindow;
40typedef struct uwac_seat UwacSeat;
41typedef uint32_t UwacSeatId;
42
44typedef enum
45{
46 UWAC_SUCCESS = 0,
47 UWAC_ERROR_NOMEMORY,
48 UWAC_ERROR_UNABLE_TO_CONNECT,
49 UWAC_ERROR_INVALID_DISPLAY,
50 UWAC_NOT_ENOUGH_RESOURCES,
51 UWAC_TIMEDOUT,
52 UWAC_NOT_FOUND,
53 UWAC_ERROR_CLOSED,
54 UWAC_ERROR_INTERNAL,
55
56 UWAC_ERROR_LAST,
57} UwacReturnCode;
58
60enum
61{
62 UWAC_MOD_SHIFT_MASK = 0x01,
63 UWAC_MOD_ALT_MASK = 0x02,
64 UWAC_MOD_CONTROL_MASK = 0x04,
65 UWAC_MOD_CAPS_MASK = 0x08,
66 UWAC_MOD_NUM_MASK = 0x10,
67};
68
71{
72 int x;
73 int y;
74};
75
78{
79 int width;
80 int height;
81};
82
84enum
85{
86 UWAC_EVENT_NEW_SEAT = 0,
87 UWAC_EVENT_REMOVED_SEAT,
88 UWAC_EVENT_NEW_OUTPUT,
89 UWAC_EVENT_CONFIGURE,
90 UWAC_EVENT_POINTER_ENTER,
91 UWAC_EVENT_POINTER_LEAVE,
92 UWAC_EVENT_POINTER_MOTION,
93 UWAC_EVENT_POINTER_BUTTONS,
94 UWAC_EVENT_POINTER_AXIS,
95 UWAC_EVENT_KEYBOARD_ENTER,
96 UWAC_EVENT_KEYBOARD_MODIFIERS,
97 UWAC_EVENT_KEY,
98 UWAC_EVENT_TOUCH_FRAME_BEGIN,
99 UWAC_EVENT_TOUCH_UP,
100 UWAC_EVENT_TOUCH_DOWN,
101 UWAC_EVENT_TOUCH_MOTION,
102 UWAC_EVENT_TOUCH_CANCEL,
103 UWAC_EVENT_TOUCH_FRAME_END,
104 UWAC_EVENT_FRAME_DONE,
105 UWAC_EVENT_CLOSE,
106 UWAC_EVENT_CLIPBOARD_AVAILABLE,
107 UWAC_EVENT_CLIPBOARD_SELECT,
108 UWAC_EVENT_CLIPBOARD_OFFER,
109 UWAC_EVENT_OUTPUT_GEOMETRY,
110 UWAC_EVENT_POINTER_AXIS_DISCRETE,
111 UWAC_EVENT_POINTER_FRAME,
112 UWAC_EVENT_POINTER_SOURCE
113};
114
116enum
117{
118 UWAC_WINDOW_MAXIMIZED = 0x1,
119 UWAC_WINDOW_RESIZING = 0x2,
120 UWAC_WINDOW_FULLSCREEN = 0x4,
121 UWAC_WINDOW_ACTIVATED = 0x8,
122};
123
125{
126 int type;
127 UwacOutput* output;
128};
129typedef struct uwac_new_output_event UwacOutputNewEvent;
130
132{
133 int type;
134 UwacSeat* seat;
135};
136typedef struct uwac_new_seat_event UwacSeatNewEvent;
137
139{
140 int type;
141 UwacSeatId id;
142};
143typedef struct uwac_removed_seat_event UwacSeatRemovedEvent;
144
146{
147 int type;
148 UwacWindow* window;
149 UwacSeat* seat;
150};
151typedef struct uwac_keyboard_enter_event UwacKeyboardEnterLeaveEvent;
152
154{
155 int type;
156 uint32_t modifiers;
157};
158typedef struct uwac_keyboard_modifiers_event UwacKeyboardModifiersEvent;
159
161{
162 int type;
163 UwacWindow* window;
164 UwacSeat* seat;
165 uint32_t x, y;
166};
167typedef struct uwac_pointer_enter_event UwacPointerEnterLeaveEvent;
168
170{
171 int type;
172 UwacWindow* window;
173 UwacSeat* seat;
174 uint32_t x, y;
175};
176typedef struct uwac_pointer_motion_event UwacPointerMotionEvent;
177
179{
180 int type;
181 UwacWindow* window;
182 UwacSeat* seat;
183 uint32_t x, y;
184 uint32_t button;
185 enum wl_pointer_button_state state;
186};
187typedef struct uwac_pointer_button_event UwacPointerButtonEvent;
188
190{
191 int type;
192 UwacWindow* window;
193 UwacSeat* seat;
194 uint32_t x, y;
195 uint32_t axis;
196 wl_fixed_t value;
197};
198typedef struct uwac_pointer_axis_event UwacPointerAxisEvent;
199
201{
202 int type;
203 UwacWindow* window;
204 UwacSeat* seat;
205};
206typedef struct uwac_pointer_frame_event UwacPointerFrameEvent;
207
209{
210 int type;
211 UwacWindow* window;
212 UwacSeat* seat;
213 enum wl_pointer_axis_source axis_source;
214};
215typedef struct uwac_pointer_source_event UwacPointerSourceEvent;
216
218{
219 int type;
220 UwacWindow* window;
221 UwacSeat* seat;
222};
223typedef struct uwac_touch_frame_event UwacTouchFrameBegin;
224typedef struct uwac_touch_frame_event UwacTouchFrameEnd;
225typedef struct uwac_touch_frame_event UwacTouchCancel;
226
228{
229 int type;
230 UwacWindow* window;
231 UwacSeat* seat;
232 int32_t id;
233 wl_fixed_t x;
234 wl_fixed_t y;
235};
236typedef struct uwac_touch_data UwacTouchUp;
237typedef struct uwac_touch_data UwacTouchDown;
238typedef struct uwac_touch_data UwacTouchMotion;
239
241{
242 int type;
243 UwacWindow* window;
244};
245typedef struct uwac_frame_done_event UwacFrameDoneEvent;
246
248{
249 int type;
250 UwacWindow* window;
251 int32_t width;
252 int32_t height;
253 int states;
254};
255typedef struct uwac_configure_event UwacConfigureEvent;
256
258{
259 int type;
260 UwacWindow* window;
261 uint32_t raw_key;
262 uint32_t sym;
263 bool pressed;
264 bool repeated;
265};
266typedef struct uwac_key_event UwacKeyEvent;
267
269{
270 int type;
271 UwacWindow* window;
272};
273typedef struct uwac_close_event UwacCloseEvent;
274
276{
277 int type;
278 UwacSeat* seat;
279 char mime[64];
280};
281typedef struct uwac_clipboard_event UwacClipboardEvent;
282
284{
285 int type;
286 UwacOutput* output;
287 int x;
288 int y;
289 int physical_width;
290 int physical_height;
291 int subpixel;
292 const char* make;
293 const char* model;
294 int transform;
295};
296typedef struct uwac_output_geometry_event UwacOutputGeometryEvent;
297
299{
300 int type;
301 UwacOutputNewEvent output_new;
302 UwacOutputGeometryEvent output_geometry;
303 UwacSeatNewEvent seat_new;
304 UwacSeatRemovedEvent seat_removed;
305 UwacPointerEnterLeaveEvent mouse_enter_leave;
306 UwacPointerMotionEvent mouse_motion;
307 UwacPointerButtonEvent mouse_button;
308 UwacPointerAxisEvent mouse_axis;
309 UwacPointerFrameEvent mouse_frame;
310 UwacPointerSourceEvent mouse_source;
311 UwacKeyboardEnterLeaveEvent keyboard_enter_leave;
312 UwacKeyboardModifiersEvent keyboard_modifiers;
313 UwacClipboardEvent clipboard;
314 UwacKeyEvent key;
315 UwacTouchFrameBegin touchFrameBegin;
316 UwacTouchUp touchUp;
317 UwacTouchDown touchDown;
318 UwacTouchMotion touchMotion;
319 UwacTouchFrameEnd touchFrameEnd;
320 UwacTouchCancel touchCancel;
321 UwacFrameDoneEvent frame_done;
322 UwacConfigureEvent configure;
323 UwacCloseEvent close;
324};
325typedef union uwac_event UwacEvent;
326
327typedef bool (*UwacErrorHandler)(UwacDisplay* d, UwacReturnCode code, const char* msg, ...);
328typedef void (*UwacDataTransferHandler)(UwacSeat* seat, void* context, const char* mime, int fd);
329typedef void (*UwacCancelDataTransferHandler)(UwacSeat* seat, void* context);
330
331#ifdef __cplusplus
332extern "C"
333{
334#endif
335
343 UWAC_API void UwacInstallErrorHandler(UwacErrorHandler handler);
344
352 UWAC_API UwacDisplay* UwacOpenDisplay(const char* name, UwacReturnCode* err);
353
360 UWAC_API UwacReturnCode UwacCloseDisplay(UwacDisplay** pdisplay);
361
369 UWAC_API int UwacDisplayGetFd(UwacDisplay* display);
370
377 UWAC_API const char* UwacErrorString(UwacReturnCode error);
378
385 UWAC_API UwacReturnCode UwacDisplayGetLastError(const UwacDisplay* display);
386
395 UWAC_API UwacReturnCode UwacDisplayQueryInterfaceVersion(const UwacDisplay* display,
396 const char* name, uint32_t* version);
397
404 UWAC_API uint32_t UwacDisplayQueryGetNbShmFormats(UwacDisplay* display);
405
416 UWAC_API UwacReturnCode UwacDisplayQueryShmFormats(const UwacDisplay* display,
417 enum wl_shm_format* formats,
418 int formats_size, int* filled);
419
426 UWAC_API uint32_t UwacDisplayGetNbOutputs(const UwacDisplay* display);
427
436 UWAC_API const UwacOutput* UwacDisplayGetOutput(UwacDisplay* display, int index);
437
445 UWAC_API UwacReturnCode UwacOutputGetResolution(const UwacOutput* output, UwacSize* resolution);
446
454 UWAC_API UwacReturnCode UwacOutputGetPosition(const UwacOutput* output, UwacPosition* pos);
455
466 UWAC_API UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t height,
467 enum wl_shm_format format);
468
475 UWAC_API UwacReturnCode UwacDestroyWindow(UwacWindow** window);
476
487 UWAC_API UwacReturnCode UwacWindowSetOpaqueRegion(UwacWindow* window, uint32_t x, uint32_t y,
488 uint32_t width, uint32_t height);
489
500 UWAC_API UwacReturnCode UwacWindowSetInputRegion(UwacWindow* window, uint32_t x, uint32_t y,
501 uint32_t width, uint32_t height);
502
508 UWAC_API void* UwacWindowGetDrawingBuffer(UwacWindow* window);
509
520 UWAC_API UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y,
521 uint32_t width, uint32_t height);
522
531 UWAC_API UwacReturnCode UwacWindowGetDrawingBufferGeometry(UwacWindow* window,
532 UwacSize* geometry, size_t* stride);
533
542 UWAC_API UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window,
543 bool copyContentForNextFrame);
544
552 UWAC_API UwacReturnCode UwacWindowGetGeometry(UwacWindow* window, UwacSize* geometry);
553
564 UWAC_API UwacReturnCode UwacWindowSetFullscreenState(UwacWindow* window, UwacOutput* output,
565 bool isFullscreen);
566
573 UWAC_API void UwacWindowSetTitle(UwacWindow* window, const char* name);
574
581 UWAC_API void UwacWindowSetAppId(UwacWindow* window, const char* app_id);
582
589 UWAC_API int UwacDisplayDispatch(UwacDisplay* display, int timeout);
590
597 UWAC_API bool UwacHasEvent(UwacDisplay* display);
598
606 UWAC_API UwacReturnCode UwacNextEvent(UwacDisplay* display, UwacEvent* event);
607
614 UWAC_API const char* UwacSeatGetName(const UwacSeat* seat);
615
622 UWAC_API UwacSeatId UwacSeatGetId(const UwacSeat* seat);
623
627 UWAC_API UwacReturnCode UwacClipboardOfferDestroy(UwacSeat* seat);
628 UWAC_API UwacReturnCode UwacClipboardOfferCreate(UwacSeat* seat, const char* mime);
629 UWAC_API UwacReturnCode UwacClipboardOfferAnnounce(UwacSeat* seat, void* context,
630 UwacDataTransferHandler transfer,
631 UwacCancelDataTransferHandler cancel);
632 UWAC_API void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size);
633
642 UWAC_API UwacReturnCode UwacSeatInhibitShortcuts(UwacSeat* seat, bool inhibit);
643
660 UWAC_API UwacReturnCode UwacSeatSetMouseCursor(UwacSeat* seat, const void* data, size_t length,
661 size_t width, size_t height, size_t hot_x,
662 size_t hot_y);
663
664#ifdef __cplusplus
665}
666#endif
667
668#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:71
a seat attached to a wayland display
Definition uwac-priv.h:164
a rectangle size measure
Definition uwac.h:78
a window
Definition uwac-priv.h:239