Remote: paste the phone clipboard, including images, on the desktop
CI / test (push) Failing after 1m2s
CI / test (push) Failing after 1m2s
- Web UI: Ctrl+V, Ctrl+Shift+V, Shift+Insert (Cmd+V on Mac) and a Paste button send the phone clipboard (text or PNG, up to 16 MB) to the desktop over POST /api/clipboard - chandra-remote passes clipboard data to the compositor in a sealed memfd (clipboard-set-fd), replacing the 4 KB hex clipboard-set line - Compositor: new clipboard-status and input-paste commands; text is typed into the launcher, password dialog and shell popups, otherwise the paste chord is sent (Ctrl+Shift+V in terminals) - Paste data is captured when a paste starts, so a clipboard change mid-transfer can't corrupt it - VNC clipboard text limit raised from 4 KB to 1 MB - Upload endpoints are authorized with the same token check as /ws; the no-header cross-site case is refused with 403
This commit is contained in:
1 parent
8a6d19d16f
commit
d2e00b4658
11 files changed
+853
-68
No files matched your search
@@ -364,8 +364,11 @@ pub(all) struct WaylandServer {
|
||||
/// `Some((0, 0))`: its mime types and bytes.
|
||||
mut own_mimes : Array[String]
|
||||
mut own_data : Bytes
|
||||
/// Clipboard pastes of `own_data` still being written: (pipe fd, bytes written, give up at ms).
|
||||
transfers : Array[(Int, Int, UInt64)]
|
||||
/// Counts every time something was put on the clipboard (by a client or the compositor).
|
||||
mut selection_serial : UInt
|
||||
/// Clipboard pastes of `own_data` still being written: (pipe fd, the data as it was when the
|
||||
/// paste began, bytes written, give up at ms).
|
||||
transfers : Array[(Int, Bytes, Int, UInt64)]
|
||||
/// CHANDRA_DEBUG_CONFIGURE=1: log each configure, ack and committed buffer size to stderr.
|
||||
mut debug_configure : Bool
|
||||
/// Drag and drop in progress (dnd.mbt), and a drop its target is still taking.
|
||||
@@ -405,6 +408,7 @@ pub fn WaylandServer::listen(
|
||||
popup_bounds: fn(_) { (-1000000, -1000000, 2000000, 2000000) },
|
||||
own_mimes: [],
|
||||
own_data: Bytes::from_array([]),
|
||||
selection_serial: 0U,
|
||||
transfers: [],
|
||||
debug_configure: @sys.getenv("CHANDRA_DEBUG_CONFIGURE").length() > 0,
|
||||
drag: None,
|
||||
@@ -937,6 +941,7 @@ fn WaylandServer::dispatch_msg(
|
||||
self.selection = None
|
||||
} else {
|
||||
self.selection = Some((c.client_id, src))
|
||||
self.selection_serial = self.selection_serial + 1U
|
||||
}
|
||||
match old {
|
||||
Some((ocid, osid)) =>
|
||||
@@ -976,7 +981,7 @@ fn WaylandServer::dispatch_msg(
|
||||
// The compositor's own clipboard: write it out a piece at a time (pump_transfers),
|
||||
// so a client that is slow to read can't stall the desktop.
|
||||
if self.selection == Some((0U, 0U)) && self.own_mimes.contains(mime) {
|
||||
self.transfers.push((fd, 0, @sys.monotonic_ms() + 10000UL))
|
||||
self.transfers.push((fd, self.own_data, 0, @sys.monotonic_ms() + 10000UL))
|
||||
self.pump_transfers()
|
||||
} else {
|
||||
@sys.close_fd(fd)
|
||||
@@ -2450,6 +2455,7 @@ pub fn WaylandServer::set_own_selection(
|
||||
self.own_mimes = mime_types
|
||||
self.own_data = data
|
||||
self.selection = Some((0U, 0U))
|
||||
self.selection_serial = self.selection_serial + 1U
|
||||
self.notify_selection()
|
||||
}
|
||||
|
||||
@@ -2458,22 +2464,31 @@ pub fn WaylandServer::owns_selection(self : WaylandServer) -> Bool {
|
||||
self.selection == Some((0U, 0U))
|
||||
}
|
||||
|
||||
///| The text the compositor itself has on the clipboard, if that is what is there.
|
||||
pub fn WaylandServer::own_selection_text(self : WaylandServer) -> Bytes? {
|
||||
if self.owns_selection() && self.own_mimes.contains("text/plain;charset=utf-8") {
|
||||
Some(self.own_data)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
///| 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 {
|
||||
if self.transfers.length() == 0 {
|
||||
return
|
||||
}
|
||||
let total = self.own_data.length()
|
||||
let now = @sys.monotonic_ms()
|
||||
let keep : Array[(Int, Int, UInt64)] = []
|
||||
let keep : Array[(Int, Bytes, Int, UInt64)] = []
|
||||
for t in self.transfers {
|
||||
let (fd, sent0, deadline) = t
|
||||
let (fd, data, sent0, deadline) = t
|
||||
let total = data.length()
|
||||
let mut sent = sent0
|
||||
let mut ok = true
|
||||
while sent < total {
|
||||
let len = if total - sent > 65536 { 65536 } else { total - sent }
|
||||
let n = @sys.write_nonblock(fd, self.own_data[sent:sent + len].to_bytes())
|
||||
let n = @sys.write_nonblock(fd, data[sent:sent + len].to_bytes())
|
||||
if n < 0 {
|
||||
ok = false
|
||||
break
|
||||
@@ -2484,7 +2499,7 @@ pub fn WaylandServer::pump_transfers(self : WaylandServer) -> Unit {
|
||||
sent = sent + n
|
||||
}
|
||||
if ok && sent < total && now < deadline {
|
||||
keep.push((fd, sent, deadline))
|
||||
keep.push((fd, data, sent, deadline))
|
||||
} else {
|
||||
@sys.close_fd(fd)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user