Class X11Clipboard
- All Implemented Interfaces:
NativeClipboard
CLIPBOARD selection, owned and converted by a hidden window on a
connection of our own.
A second connection, and one thread that makes every call on it. GLFW's connection is
GLFW's: its event loop reads every event on it, the selection events included, and hands none
on. Ours has a thread that waits on the connection and on a pipe that wakes it; the UI thread
only queues work and writes a byte. No two threads ever touch one display, so nothing here
depends on XInitThreads having been the first Xlib call of the process, which it was
not.
What does not fit one request crosses by INCR, both ways. XFixes tells of a new
owner, which is when the types are asked for again, so types() never has to ask.
An X error on our display (a requestor that closed mid-transfer) is ignored; one on any other display goes to the handler that was there, as before.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Lets go of the system's resources.The drags of this connection, made the first time a window asks.booleanisOwner()voidMakes this process the clipboard's owner.pinches(long xwindow, Supplier<WindowInput> input, DoubleUnaryOperator toLogical, UiRuntime ui) Sends the pinches over one of this program's windows to its input, read on this connection.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface limn.backend.lwjgl.transfer.NativeClipboard
madeAhead
-
Constructor Details
-
X11Clipboard
public X11Clipboard()- Throws:
RuntimeException- when Xlib or XFixes is absent, or no display opens; the caller then keeps GLFW's text clipboard
-
-
Method Details
-
isOwner
public boolean isOwner()- Specified by:
isOwnerin interfaceNativeClipboard- Returns:
- whether what the clipboard holds was put there by the last
NativeClipboard.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
Description copied from interface:NativeClipboardThe types on the clipboard as the system last reported them, without asking it again.- Specified by:
typesin interfaceNativeClipboard- Returns:
- canonical type names, best first; empty when the clipboard is empty or unknown
-
read
Description copied from interface:NativeClipboardAsks for the bytes of one type.- Specified by:
readin interfaceNativeClipboard- Parameters:
type- one ofNativeClipboard.types()- Returns:
- the bytes, completed on whatever thread the implementation reads on; completed exceptionally when the type is not, or no longer, there
-
drags
The drags of this connection, made the first time a window asks. Any thread.- Parameters:
ui- the UI runtime- Returns:
- what speaks XDND for this program's windows
-
pinches
public Runnable pinches(long xwindow, Supplier<WindowInput> input, DoubleUnaryOperator toLogical, UiRuntime ui) Sends the pinches over one of this program's windows to its input, read on this connection. Any thread.- Returns:
- what forgets the window
-
offer
Description copied from interface:NativeClipboardMakes this process the clipboard's owner.- Specified by:
offerin interfaceNativeClipboard- 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
-
setChangeListener
- Specified by:
setChangeListenerin interfaceNativeClipboard- Parameters:
listener- called, on any thread, after the clipboard's types or its owner change, anNativeClipboard.offer(java.util.List<java.lang.String>, java.util.function.Function<java.lang.String, byte[]>)of this process included; replaces the one before
-
close
public void close()Description copied from interface:NativeClipboardLets go of the system's resources. The clipboard is not used afterwards.- Specified by:
closein interfaceNativeClipboard
-