summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-12-27 12:03:39 -0800
committer3gg <3gg@shellblade.net>2025-12-27 12:03:39 -0800
commit5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch)
tree8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h')
-rw-r--r--contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h
new file mode 100644
index 0000000..adca17b
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h
@@ -0,0 +1,162 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 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#define FILE_PORTAL_MIME "application/vnd.portal.filetransfer"
33
34typedef struct
35{
36 char *mime_type;
37 void *data;
38 size_t length;
39 struct wl_list link;
40} SDL_MimeDataList;
41
42typedef struct SDL_WaylandUserdata
43{
44 Uint32 sequence;
45 void *data;
46} SDL_WaylandUserdata;
47
48typedef struct
49{
50 struct wl_data_source *source;
51 void *data_device;
52 SDL_ClipboardDataCallback callback;
53 SDL_WaylandUserdata userdata;
54} SDL_WaylandDataSource;
55
56typedef struct
57{
58 struct zwp_primary_selection_source_v1 *source;
59 void *data_device;
60 void *primary_selection_device;
61 SDL_ClipboardDataCallback callback;
62 SDL_WaylandUserdata userdata;
63} SDL_WaylandPrimarySelectionSource;
64
65typedef struct
66{
67 struct wl_data_offer *offer;
68 struct wl_list mimes;
69 void *data_device;
70} SDL_WaylandDataOffer;
71
72typedef struct
73{
74 struct zwp_primary_selection_offer_v1 *offer;
75 struct wl_list mimes;
76 void *primary_selection_device;
77} SDL_WaylandPrimarySelectionOffer;
78
79typedef struct
80{
81 struct wl_data_device *data_device;
82 SDL_VideoData *video_data;
83
84 // Drag and Drop
85 uint32_t drag_serial;
86 SDL_WaylandDataOffer *drag_offer;
87 SDL_WaylandDataOffer *selection_offer;
88 bool has_mime_file, has_mime_text;
89 SDL_Window *dnd_window;
90
91 // Clipboard and Primary Selection
92 uint32_t selection_serial;
93 SDL_WaylandDataSource *selection_source;
94} SDL_WaylandDataDevice;
95
96typedef struct
97{
98 struct zwp_primary_selection_device_v1 *primary_selection_device;
99 SDL_VideoData *video_data;
100
101 uint32_t selection_serial;
102 SDL_WaylandPrimarySelectionSource *selection_source;
103 SDL_WaylandPrimarySelectionOffer *selection_offer;
104} SDL_WaylandPrimarySelectionDevice;
105
106// Wayland Data Source / Primary Selection Source - (Sending)
107extern SDL_WaylandDataSource *Wayland_data_source_create(SDL_VideoDevice *_this);
108extern SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(SDL_VideoDevice *_this);
109extern ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source,
110 const char *mime_type, int fd);
111extern ssize_t Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source,
112 const char *mime_type, int fd);
113extern void Wayland_data_source_set_callback(SDL_WaylandDataSource *source,
114 SDL_ClipboardDataCallback callback,
115 void *userdata,
116 Uint32 sequence);
117extern void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSource *source,
118 SDL_ClipboardDataCallback callback,
119 void *userdata);
120extern void *Wayland_data_source_get_data(SDL_WaylandDataSource *source,
121 const char *mime_type,
122 size_t *length);
123extern void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source,
124 const char *mime_type,
125 size_t *length);
126extern void Wayland_data_source_destroy(SDL_WaylandDataSource *source);
127extern void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source);
128
129// Wayland Data / Primary Selection Offer - (Receiving)
130extern void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer,
131 const char *mime_type,
132 size_t *length);
133extern void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer,
134 const char *mime_type,
135 size_t *length);
136extern bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer,
137 const char *mime_type);
138extern bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer,
139 const char *mime_type);
140extern bool Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer,
141 const char *mime_type);
142extern bool Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer,
143 const char *mime_type);
144extern void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer);
145extern void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer);
146
147// Clipboard / Primary Selection
148extern bool Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device);
149extern bool Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *device);
150extern bool Wayland_data_device_set_selection(SDL_WaylandDataDevice *device,
151 SDL_WaylandDataSource *source,
152 const char **mime_types,
153 size_t mime_count);
154extern bool Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *device,
155 SDL_WaylandPrimarySelectionSource *source,
156 const char **mime_types,
157 size_t mime_count);
158extern void Wayland_data_device_set_serial(SDL_WaylandDataDevice *device,
159 uint32_t serial);
160extern void Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *device,
161 uint32_t serial);
162#endif // SDL_waylanddatamanager_h_