- Web UI: Ctrl+C, Ctrl+X, Ctrl+Shift+C (Cmd+C on Mac) also put what they copied, text or PNG, on this device's clipboard; Copy, Copy Selection and Copy Clipboard buttons - chandra-remote: GET /api/clipboard/data, with the same authorization as the upload - Compositor: clipboard-get-fd has the clipboard's owner write into a pipe, refused while locked; input-copy presses Ctrl+Shift+C in terminals, Ctrl+C elsewhere - Pending clipboard transfers keep the main loop awake Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5dbe028e6
commit
589d167f79
11 files changed
+552
-19
No files matched your search
@@ -2638,6 +2638,59 @@ pub fn WaylandServer::own_selection_text(self : WaylandServer) -> Bytes? {
|
||||
}
|
||||
}
|
||||
|
||||
///| Have the clipboard written into `fd` (a pipe), as text when it has any, else as a PNG image.
|
||||
/// What it is: "text/plain" or "image/png", or None when it holds neither. The compositor's own
|
||||
/// data is written by `pump_transfers`, which then owns `fd` (see `is_transfer`); a client's is
|
||||
/// written by that client, and `fd` stays the caller's.
|
||||
pub fn WaylandServer::send_clipboard_to(self : WaylandServer, fd : Int) -> String? {
|
||||
let mimes : Array[String] = match self.selection {
|
||||
Some((0U, 0U)) => self.own_mimes
|
||||
Some((ocid, osid)) =>
|
||||
match self.find_client(ocid) {
|
||||
Some(oc) if oc.alive => oc.data_sources.get(osid).unwrap_or([])
|
||||
_ => []
|
||||
}
|
||||
None => []
|
||||
}
|
||||
let (mime, kind) = match
|
||||
clipboard_text_mimes.iter().find_first(m => mimes.contains(m)) {
|
||||
Some(m) => (m, "text/plain")
|
||||
None =>
|
||||
if mimes.contains("image/png") {
|
||||
("image/png", "image/png")
|
||||
} else {
|
||||
return None
|
||||
}
|
||||
}
|
||||
match self.selection {
|
||||
Some((0U, 0U)) =>
|
||||
self.transfers.push((fd, self.own_data, 0, @sys.monotonic_ms() + 10000UL))
|
||||
Some((ocid, osid)) =>
|
||||
match self.find_client(ocid) {
|
||||
Some(oc) => {
|
||||
let w = WireWriter::new()
|
||||
w.str(mime)
|
||||
if @sys.sendmsg_fd(oc.fd, w.finish_msg(osid, 1U), fd) < 0 {
|
||||
return None
|
||||
}
|
||||
}
|
||||
None => return None
|
||||
}
|
||||
None => return None
|
||||
}
|
||||
Some(kind)
|
||||
}
|
||||
|
||||
///| The types UTF-8 text goes by on the clipboard, best first.
|
||||
let clipboard_text_mimes : Array[String] = [
|
||||
"text/plain;charset=utf-8", "text/plain;charset=UTF-8", "UTF8_STRING", "text/plain",
|
||||
]
|
||||
|
||||
///| Whether `fd` is a paste of the compositor's clipboard still being written (and closed) here.
|
||||
pub fn WaylandServer::is_transfer(self : WaylandServer, fd : Int) -> Bool {
|
||||
self.transfers.iter().any(t => t.0 == fd)
|
||||
}
|
||||
|
||||
///| Write what the pipes of pending pastes can take without blocking; close the finished ones
|
||||
/// and any a reader stopped taking for ten seconds.
|
||||
pub fn WaylandServer::pump_transfers(self : WaylandServer) -> Unit {
|
||||
|
||||
Reference in new issue
Block a user