Atlas - SDL_waylanddatamanager.h
Home / ext / SDL / src / video / wayland Lines: 1 | Size: 7726 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 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#include "SDL_waylandevents_c.h" 24 25#ifndef SDL_waylanddatamanager_h_ 26#define SDL_waylanddatamanager_h_ 27 28#include "SDL_waylandvideo.h" 29#include "SDL_waylandwindow.h" 30 31#define TEXT_MIME "text/plain;charset=utf-8" 32#define FILE_MIME "text/uri-list" 33#define FILE_PORTAL_MIME "application/vnd.portal.filetransfer" 34#define SDL_DATA_ORIGIN_MIME "application/x-sdl3-source-id" 35 36typedef struct SDL_WaylandDataDevice SDL_WaylandDataDevice; 37typedef struct SDL_WaylandPrimarySelectionDevice SDL_WaylandPrimarySelectionDevice; 38 39typedef struct 40{ 41 char *mime_type; 42 void *data; 43 size_t length; 44 struct wl_list link; 45} SDL_MimeDataList; 46 47typedef struct SDL_WaylandUserdata 48{ 49 Uint32 sequence; 50 void *data; 51} SDL_WaylandUserdata; 52 53typedef struct 54{ 55 struct wl_data_source *source; 56 SDL_WaylandDataDevice *data_device; 57 SDL_ClipboardDataCallback callback; 58 SDL_WaylandUserdata userdata; 59} SDL_WaylandDataSource; 60 61typedef struct 62{ 63 struct zwp_primary_selection_source_v1 *source; 64 SDL_WaylandDataDevice *data_device; 65 SDL_WaylandPrimarySelectionDevice *primary_selection_device; 66 SDL_ClipboardDataCallback callback; 67 SDL_WaylandUserdata userdata; 68} SDL_WaylandPrimarySelectionSource; 69 70typedef struct 71{ 72 struct wl_data_offer *offer; 73 struct wl_list mimes; 74 SDL_WaylandDataDevice *data_device; 75 76 // Callback data for queued receive. 77 struct wl_callback *callback; 78 int read_fd; 79} SDL_WaylandDataOffer; 80 81typedef struct 82{ 83 struct zwp_primary_selection_offer_v1 *offer; 84 struct wl_list mimes; 85 SDL_WaylandPrimarySelectionDevice *primary_selection_device; 86} SDL_WaylandPrimarySelectionOffer; 87 88struct SDL_WaylandDataDevice 89{ 90 struct wl_data_device *data_device; 91 struct SDL_WaylandSeat *seat; 92 char *id_str; 93 94 // Drag and Drop 95 uint32_t drag_serial; 96 SDL_WaylandDataOffer *drag_offer; 97 SDL_WaylandDataOffer *selection_offer; 98 const char *mime_type; 99 bool has_mime_file, has_mime_text; 100 SDL_Window *dnd_window; 101 102 // Clipboard and Primary Selection 103 uint32_t selection_serial; 104 SDL_WaylandDataSource *selection_source; 105}; 106 107struct SDL_WaylandPrimarySelectionDevice 108{ 109 struct zwp_primary_selection_device_v1 *primary_selection_device; 110 struct SDL_WaylandSeat *seat; 111 112 uint32_t selection_serial; 113 SDL_WaylandPrimarySelectionSource *selection_source; 114 SDL_WaylandPrimarySelectionOffer *selection_offer; 115}; 116 117// Wayland Data Source / Primary Selection Source - (Sending) 118extern SDL_WaylandDataSource *Wayland_data_source_create(SDL_VideoDevice *_this); 119extern SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(SDL_VideoDevice *_this); 120extern ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, 121 const char *mime_type, int fd); 122extern ssize_t Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source, 123 const char *mime_type, int fd); 124extern void Wayland_data_source_set_callback(SDL_WaylandDataSource *source, 125 SDL_ClipboardDataCallback callback, 126 void *userdata, 127 Uint32 sequence); 128extern void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSource *source, 129 SDL_ClipboardDataCallback callback, 130 void *userdata); 131extern void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, 132 const char *mime_type, 133 size_t *length); 134extern void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source, 135 const char *mime_type, 136 size_t *length); 137extern void Wayland_data_source_destroy(SDL_WaylandDataSource *source); 138extern void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source); 139 140// Wayland Data / Primary Selection Offer - (Receiving) 141extern void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, 142 const char *mime_type, 143 size_t *length); 144extern void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, 145 const char *mime_type, 146 size_t *length); 147extern bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, 148 const char *mime_type); 149extern void Wayland_data_offer_notify_from_mimes(SDL_WaylandDataOffer *offer, 150 bool check_origin); 151extern bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, 152 const char *mime_type); 153extern bool Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, 154 const char *mime_type); 155extern bool Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer, 156 const char *mime_type); 157extern void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer); 158extern void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer); 159 160// Clipboard / Primary Selection 161extern bool Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device); 162extern bool Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *device); 163extern bool Wayland_data_device_set_selection(SDL_WaylandDataDevice *device, 164 SDL_WaylandDataSource *source, 165 const char **mime_types, 166 size_t mime_count); 167extern bool Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *device, 168 SDL_WaylandPrimarySelectionSource *source, 169 const char **mime_types, 170 size_t mime_count); 171extern void Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, 172 uint32_t serial); 173extern void Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *device, 174 uint32_t serial); 175#endif // SDL_waylanddatamanager_h_ 176[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.