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

Function ClipboardGetText

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

Source from the content-addressed store, hash-verified

429 Array<StringAnsi> ClipboardFiles;
430
431 void ClipboardGetText(String& result, X11::Atom source, X11::Atom atom, X11::Window window)
432 {
433 X11::Window selectionOwner = X11::XGetSelectionOwner(xDisplay, source);
434 if (selectionOwner == 0)
435 {
436 // No copy owner
437 return;
438 }
439 if (selectionOwner == window)
440 {
441 // Copy/paste from self
442 result.Set(ClipboardText.Get(), ClipboardText.Length());
443 return;
444 }
445
446 // Send event to get data from the owner
447 int format;
448 unsigned long N, size;
449 char* data;
450 X11::Atom target;
451 X11::XEvent event;
452 X11::XConvertSelection(xDisplay, xAtomClipboard, atom, xAtomXselData, window, CurrentTime);
453 X11::XSync(xDisplay, 0);
454 if (X11::XCheckTypedEvent(xDisplay, SelectionNotify, &event))
455 {
456 if (event.xselection.selection != xAtomClipboard)
457 return;
458 if (event.xselection.property)
459 {
460 X11::XGetWindowProperty(event.xselection.display, event.xselection.requestor, event.xselection.property, 0L, (~0L), 0, AnyPropertyType, &target, &format, &size, &N, (unsigned char**)&data);
461 if (target == xAtomUTF8String || target == xAtomString)
462 {
463 result.Set(data, size);
464 X11::XFree(data);
465 }
466 X11::XDeleteProperty(event.xselection.display, event.xselection.requestor, event.xselection.property);
467 }
468 }
469 }
470
471 void ClipboardGetData(Array<byte>& result, X11::Atom source, X11::Atom atom, X11::Window window)
472 {

Callers 1

GetTextMethod · 0.70

Calls 3

SetMethod · 0.45
GetMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected