MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SetRawData

Method SetRawData

Source/Engine/Platform/SDL/SDLPlatform.Linux.cpp:1247–1293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1245}
1246
1247void SDLClipboard::SetRawData(const Span<byte>& data)
1248{
1249 if (CommandLine::Options.Headless.IsTrue())
1250 return;
1251 auto mainWindow = Engine::MainWindow;
1252 if (!mainWindow)
1253 return;
1254
1255 if (X11Impl::xDisplay)
1256 {
1257 X11Impl::ClipboardData.Set(data.Get(), data.Length());
1258 X11Impl::ClipboardText.Clear();
1259 X11Impl::ClipboardFiles.Clear();
1260
1261 X11::Window window = (X11::Window)(mainWindow->GetNativePtr());
1262 X11::XSetSelectionOwner(X11Impl::xDisplay, X11Impl::xAtomClipboard, window, CurrentTime); // CLIPBOARD
1263 //X11::XSetSelectionOwner(xDisplay, xAtomPrimary, window, CurrentTime); // XA_PRIMARY
1264 X11::XFlush(X11Impl::xDisplay);
1265 }
1266 else
1267 {
1268 if (data.Length() == 0)
1269 return;
1270
1271 const char* uriList = "flaxengine/raw";
1272 Array<byte>* buffer = New<Array<byte>>(data.Get(), data.Length());
1273
1274 SDL_SetClipboardData([](void* userdata, const char* mime_type, size_t* size) -> const void*
1275 {
1276 // Clipboard data is requested
1277 Array<byte>* buffer = static_cast<Array<byte>*>(userdata);
1278 if (StringUtils::Compare(mime_type, "flaxengine/raw") == 0)
1279 {
1280 *size = buffer->Count();
1281 return buffer->Get();
1282 }
1283 *size = 0;
1284 return nullptr;
1285 },
1286 [](void* userdata)
1287 {
1288 // Cleanup previous clipboard data
1289 Array<byte>* buffer = static_cast<Array<byte>*>(userdata);
1290 Delete(buffer);
1291 }, buffer, &uriList, 1);
1292 }
1293}
1294
1295void SDLClipboard::SetFiles(const Array<String>& files)
1296{

Callers

nothing calls this directly

Calls 8

DeleteFunction · 0.85
IsTrueMethod · 0.45
SetMethod · 0.45
GetMethod · 0.45
LengthMethod · 0.45
ClearMethod · 0.45
GetNativePtrMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected