1 | /* |
2 | Simple DirectMedia Layer |
3 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> |
4 | |
5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. |
8 | |
9 | Permission is granted to anyone to use this software for any purpose, |
10 | including commercial applications, and to alter it and redistribute it |
11 | freely, subject to the following restrictions: |
12 | |
13 | 1. The origin of this software must not be misrepresented; you must not |
14 | claim that you wrote the original software. If you use this software |
15 | in a product, an acknowledgment in the product documentation would be |
16 | appreciated but is not required. |
17 | 2. Altered source versions must be plainly marked as such, and must not be |
18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. |
20 | */ |
21 | |
22 | #include "../../SDL_internal.h" |
23 | |
24 | #ifndef SDL_waylanddatamanager_h_ |
25 | #define SDL_waylanddatamanager_h_ |
26 | |
27 | #include "SDL_waylandvideo.h" |
28 | #include "SDL_waylandwindow.h" |
29 | |
30 | #define TEXT_MIME "text/plain;charset=utf-8" |
31 | #define FILE_MIME "text/uri-list" |
32 | |
33 | typedef struct { |
34 | char *mime_type; |
35 | void *data; |
36 | size_t length; |
37 | struct wl_list link; |
38 | } SDL_MimeDataList; |
39 | |
40 | typedef struct { |
41 | struct wl_data_source *source; |
42 | struct wl_list mimes; |
43 | } SDL_WaylandDataSource; |
44 | |
45 | typedef struct { |
46 | struct wl_data_offer *offer; |
47 | struct wl_list mimes; |
48 | void *data_device; |
49 | } SDL_WaylandDataOffer; |
50 | |
51 | typedef struct { |
52 | struct wl_data_device *data_device; |
53 | SDL_VideoData *video_data; |
54 | |
55 | /* Drag and Drop */ |
56 | uint32_t drag_serial; |
57 | SDL_WaylandDataOffer *drag_offer; |
58 | SDL_WaylandDataOffer *selection_offer; |
59 | |
60 | /* Clipboard */ |
61 | uint32_t selection_serial; |
62 | SDL_WaylandDataSource *selection_source; |
63 | } SDL_WaylandDataDevice; |
64 | |
65 | extern const char* Wayland_convert_mime_type(const char *mime_type); |
66 | |
67 | /* Wayland Data Source - (Sending) */ |
68 | extern SDL_WaylandDataSource* Wayland_data_source_create(_THIS); |
69 | extern ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, |
70 | const char *mime_type, int fd); |
71 | extern int Wayland_data_source_add_data(SDL_WaylandDataSource *source, |
72 | const char *mime_type, |
73 | const void *buffer, |
74 | size_t length); |
75 | extern SDL_bool Wayland_data_source_has_mime(SDL_WaylandDataSource *source, |
76 | const char *mime_type); |
77 | extern void* Wayland_data_source_get_data(SDL_WaylandDataSource *source, |
78 | size_t *length, |
79 | const char *mime_type, |
80 | SDL_bool null_terminate); |
81 | extern void Wayland_data_source_destroy(SDL_WaylandDataSource *source); |
82 | |
83 | /* Wayland Data Offer - (Receiving) */ |
84 | extern void* Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, |
85 | size_t *length, |
86 | const char *mime_type, |
87 | SDL_bool null_terminate); |
88 | extern SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, |
89 | const char *mime_type); |
90 | extern int Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, |
91 | const char *mime_type); |
92 | extern void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer); |
93 | |
94 | /* Clipboard */ |
95 | extern int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device); |
96 | extern int Wayland_data_device_set_selection(SDL_WaylandDataDevice *device, |
97 | SDL_WaylandDataSource *source); |
98 | extern int Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, |
99 | uint32_t serial); |
100 | #endif /* SDL_waylanddatamanager_h_ */ |
101 | |
102 | /* vi: set ts=4 sw=4 expandtab: */ |
103 | |
104 | |