Class WaylandClipboard
- All Implemented Interfaces:
NativeClipboard
wl_data_device of our own on the display GLFW opened.
GLFW has one too and keeps it; a client may have several, and each is told of the selection.
Ours needs three things GLFW does not give away. A wl_seat bound again from a registry
of ours, since GLFW's proxy is private. The serial of the last key or button, which
set_selection must quote and GLFW does not expose: a wl_keyboard and a
wl_pointer of ours hear the same input for that number alone. And an event queue of
our own, dispatched by a thread of ours: GLFW reads what another client offers with a
blocking read() on the UI thread, so when this process is the one offering, the request
to send can only be served from another thread. On the default queue that is a deadlock,
measured on KWin on 2026-10-08, and with the queue it is not.
Bytes cross through pipes, read and written on short-lived threads so that neither the UI
thread nor the dispatch thread ever waits on another program. A file descriptor is opened as a
stream through /proc/self/fd, which is what spares this class a binding of
read and write.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAsks the compositor to bring a surface in front, with a token that says the user asked.booleanvoidclose()Lets go of the system's resources.voidfilesOfADrop(List<Path> files) The files the window library read of a drop on one of this program's windows.booleanisOwner()voidMakes this process the clipboard's owner.CompletableFuture<byte[]> Asks for the bytes of one type.register(long surface, Supplier<WindowInput> input, DoubleUnaryOperator toLogical, UiRuntime ui) Makes a window a source and a destination of the system's drags.requestToken(long surface) Asks the compositor for a token that says the user is acting in a surface of ours now: the last key or button it was given, and the surface.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
-
WaylandClipboard
public WaylandClipboard(long display) - Parameters:
display- GLFW'swl_display- Throws:
RuntimeException- when the library is absent or the compositor has no seat or no data device manager; the caller then keeps GLFW's text clipboard
-
-
Method Details
-
canActivate
public boolean canActivate()- Returns:
- whether this compositor can be shown a token
-
activate
Asks the compositor to bring a surface in front, with a token that says the user asked. Any thread.- Parameters:
token- the token, from a panel or fromrequestToken(long)surface- the window'swl_surface- Returns:
- whether the request was sent; what the compositor does with it is its own
-
requestToken
Asks the compositor for a token that says the user is acting in a surface of ours now: the last key or button it was given, and the surface. A program handed the token may come in front of that surface. Any thread.- Parameters:
surface- thewl_surfacethe user is acting in- Returns:
- the token, or an empty string where the compositor gives none; completed on the thread that hears the compositor, or at once
-
filesOfADrop
The files the window library read of a drop on one of this program's windows. It keeps a data device of its own and takes a drop of files itself, after which the source gives the offer made to this one nothing: these are then what a read of that drop's files answers.- Parameters:
files- the files it read
-
register
public WindowDrag register(long surface, Supplier<WindowInput> input, DoubleUnaryOperator toLogical, UiRuntime ui) Makes a window a source and a destination of the system's drags. UI thread.- Parameters:
surface- the window'swl_surfaceinput- the window's input, as it is at the time of each call; may answer nulltoLogical- from the surface's coordinates to the window's logical pointsui- the UI runtime- Returns:
- the window's drag
-
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
-
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
-