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

Function ClipboardGetData

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

Source from the content-addressed store, hash-verified

469 }
470
471 void ClipboardGetData(Array<byte>& result, X11::Atom source, X11::Atom atom, X11::Window window)
472 {
473 X11::Window selectionOwner = X11::XGetSelectionOwner(xDisplay, source);
474 if (selectionOwner == 0)
475 {
476 // No copy owner
477 return;
478 }
479 if (selectionOwner == window)
480 {
481 // Copy/paste from self
482 result.Set(ClipboardData.Get(), ClipboardData.Count());
483 return;
484 }
485
486 // Send event to get data from the owner
487 int format;
488 unsigned long N, size;
489 byte* data;
490 X11::Atom target;
491 X11::XEvent event;
492 X11::XConvertSelection(xDisplay, xAtomClipboard, atom, xAtomXselData, window, CurrentTime);
493 X11::XSync(xDisplay, 0);
494 if (X11::XCheckTypedEvent(xDisplay, SelectionNotify, &event))
495 {
496 if (event.xselection.selection != xAtomClipboard)
497 return;
498 if (event.xselection.property)
499 {
500 X11::XGetWindowProperty(event.xselection.display, event.xselection.requestor, event.xselection.property, 0L,(~0L), 0, AnyPropertyType, &target, &format, &size, &N, (byte**)&data);
501 if (target == atom)
502 {
503 result.Set(data, size);
504 X11::XFree(data);
505 }
506 X11::XDeleteProperty(event.xselection.display, event.xselection.requestor, event.xselection.property);
507 }
508 }
509 }
510
511 void ClipboardGetFiles(Array<String>& result, X11::Atom source, X11::Atom atom, X11::Window window)
512 {

Callers 1

GetRawDataMethod · 0.85

Calls 3

SetMethod · 0.45
GetMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected