Vixen
02b45cc4
csharp
public sealed class LinuxClipboard

The Linux clipboard, for everything that is not text.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

There is no clipboard on Linux. There is a protocol by which one client offers a list of MIME types and another asks for one of them, and the offering client — which has to still be running — produces the bytes on demand. That is why an image survives closing the application it was copied from on Windows and macOS and does not here unless something is holding it, and why the tools this drives keep running after they exit (see ExternalTool).

Wayland and X11 need different programs, and the session says which. WAYLAND_DISPLAY is set by a Wayland session and is what SDL itself keys on. A Wayland session running XWayland has both, and wl-copy is the right one there — its selection is visible to XWayland clients and the reverse is not reliably true.

Text stays with the portable implementation. SDL handles it on both display servers, in-process, without a helper program, and it is the one format that always works. What is added here is the two that never did.

Fields and properties (3)

  • public bool HasText

    Whether the clipboard currently holds text.

  • public bool HasImage

    Whether the clipboard currently holds an image.

  • public static bool IsAvailable

    Whether either helper program is installed.

Methods (8)

  • public LinuxClipboard(IClipboard fallback)

    The Linux clipboard, for everything that is not text.

  • public bool TryGetText(out string? text)

    Reads the clipboard's text.

  • public bool SetText(string text)

    Puts text on the clipboard.

  • public bool TryGetImage(out ClipboardImage image)

    Reads the clipboard's image.

  • public bool SetImage(in ClipboardImage image)

    Puts an image on the clipboard.

  • public bool TryGetData(string format, out ReadOnlyMemory<byte> data)

    Reads a format's bytes.

  • public bool SetData(string format, ReadOnlySpan<byte> data)

    Puts a custom format's bytes on the clipboard.

  • public void Clear()

    Empties the clipboard, if the platform allows it.

Used by (1)

  • LinuxPlatformSupplementVixen.Platform.Linux