| 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 | { |