Package limn.backend.lwjgl.transfer
Interface NativeClipboard
- All Known Implementing Classes:
MacClipboard,WaylandClipboard,WindowsClipboard,X11Clipboard
public interface NativeClipboard
One windowing system's clipboard, in the terms every one of them shares: a list of type names
and the bytes behind each. The names are the canonical ones of
ClipboardTypes for the
four standard formats, whatever the system calls them, and an application's own format under
its own name.
Every method may be called from the UI thread; what an implementation does on threads of its own is its business, and the two callbacks it is handed say which thread they tolerate.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Lets go of the system's resources.booleanisOwner()The types worth making ahead of anybody asking, because this system asks on the UI thread and waits there: the picture's, where making it is slow.voidMakes this process the clipboard's owner.CompletableFuture<byte[]> Asks for the bytes of one type.voidsetChangeListener(Runnable listener) types()The types on the clipboard as the system last reported them, without asking it again.
-
Method Details
-
isOwner
boolean isOwner()- Returns:
- whether what the clipboard holds was put there by the last
offer(java.util.List<java.lang.String>, java.util.function.Function<java.lang.String, byte[]>)of this process and has not been replaced since
-
types
The types on the clipboard as the system last reported them, without asking it again.- Returns:
- canonical type names, best first; empty when the clipboard is empty or unknown
-
read
Asks for the bytes of one type.- Parameters:
type- one oftypes()- Returns:
- the bytes, completed on whatever thread the implementation reads on; completed exceptionally when the type is not, or no longer, there
-
offer
Makes this process the clipboard's owner.- Parameters:
types- what is offered, best first; empty empties the clipboardbytes- the bytes of one of those types, asked for when a program wants them; it may be called on any thread and may block, and answers null for what it cannot make
-
madeAhead
The types worth making ahead of anybody asking, because this system asks on the UI thread and waits there: the picture's, where making it is slow.- Parameters:
offered- the types about to be offered- Returns:
- those of
offered, and of the private types this clipboard asks for itself, that should be made in the background as soon as they are offered
-
setChangeListener
- Parameters:
listener- called, on any thread, after the clipboard's types or its owner change, anoffer(java.util.List<java.lang.String>, java.util.function.Function<java.lang.String, byte[]>)of this process included; replaces the one before
-
close
void close()Lets go of the system's resources. The clipboard is not used afterwards.
-