| 1293 | } |
| 1294 | |
| 1295 | void SDLClipboard::SetFiles(const Array<String>& files) |
| 1296 | { |
| 1297 | if (CommandLine::Options.Headless.IsTrue()) |
| 1298 | return; |
| 1299 | auto mainWindow = Engine::MainWindow; |
| 1300 | if (!mainWindow) |
| 1301 | return; |
| 1302 | |
| 1303 | if (X11Impl::xDisplay) |
| 1304 | { |
| 1305 | X11Impl::ClipboardFiles.Clear(); |
| 1306 | for (auto file : files) |
| 1307 | X11Impl::ClipboardFiles.Add(StringAnsi(file)); |
| 1308 | X11Impl::ClipboardText.Clear(); |
| 1309 | X11Impl::ClipboardData.Clear(); |
| 1310 | |
| 1311 | X11::Window window = (X11::Window)(mainWindow->GetNativePtr()); |
| 1312 | X11::XSetSelectionOwner(X11Impl::xDisplay, X11Impl::xAtomClipboard, window, CurrentTime); // CLIPBOARD |
| 1313 | //X11::XSetSelectionOwner(xDisplay, xAtomPrimary, window, CurrentTime); // XA_PRIMARY |
| 1314 | X11::XFlush(X11Impl::xDisplay); |
| 1315 | } |
| 1316 | else |
| 1317 | { |
| 1318 | if (files.Count() == 0) |
| 1319 | return; |
| 1320 | |
| 1321 | const char* uriList = "text/uri-list"; |
| 1322 | StringAnsi* buffer = New<StringAnsi>(); |
| 1323 | for (auto file : files) |
| 1324 | { |
| 1325 | buffer->Append("file://"); |
| 1326 | buffer->Append(StringAnsi(file)); |
| 1327 | buffer->Append("\n"); |
| 1328 | } |
| 1329 | |
| 1330 | SDL_SetClipboardData([](void* userdata, const char* mime_type, size_t* size) -> const void* |
| 1331 | { |
| 1332 | // Clipboard data is requested |
| 1333 | StringAnsi* buffer = (StringAnsi*)userdata; |
| 1334 | if (StringUtils::Compare(mime_type, "text/uri-list") == 0) |
| 1335 | { |
| 1336 | *size = buffer->Length(); |
| 1337 | return buffer->Get(); |
| 1338 | } |
| 1339 | *size = 0; |
| 1340 | return nullptr; |
| 1341 | }, |
| 1342 | [](void* userdata) |
| 1343 | { |
| 1344 | // Cleanup previous clipboard data |
| 1345 | StringAnsi* buffer = (StringAnsi*)userdata; |
| 1346 | Delete(buffer); |
| 1347 | }, buffer, &uriList, 1); |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | String SDLClipboard::GetText() |
| 1352 | { |
nothing calls this directly
no test coverage detected