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
@@ -2172,10 +2172,69 @@ pub fn ChandraCompositor::remote_set_clipboard(
|
||||
self : ChandraCompositor,
|
||||
text : String,
|
||||
) -> Unit {
|
||||
self.server.set_own_selection(
|
||||
["text/plain;charset=utf-8", "text/plain", "UTF8_STRING"],
|
||||
@utf8.encode(text),
|
||||
)
|
||||
self.remote_set_clipboard_data("text/plain", @utf8.encode(text))
|
||||
}
|
||||
|
||||
///| Put `data` on the compositor's own Wayland clipboard as `mime`: UTF-8 text, or an image.
|
||||
fn ChandraCompositor::remote_set_clipboard_data(
|
||||
self : ChandraCompositor,
|
||||
mime : String,
|
||||
data : Bytes,
|
||||
) -> Unit {
|
||||
let mimes = if mime == "text/plain" {
|
||||
["text/plain;charset=utf-8", "text/plain", "UTF8_STRING"]
|
||||
} else {
|
||||
[mime]
|
||||
}
|
||||
self.server.set_own_selection(mimes, data)
|
||||
}
|
||||
|
||||
///| Paste the clipboard. The password dialog and the shell's popups have no paste key of their
|
||||
/// own, so clipboard text is typed into them as one line. Anything else gets the paste chord:
|
||||
/// `chord` as (evdev code, modifiers), or the focused app's usual one. True when typed.
|
||||
pub fn ChandraCompositor::remote_paste(
|
||||
self : ChandraCompositor,
|
||||
chord : (UInt, UInt)?,
|
||||
) -> Bool {
|
||||
let text = self.server.own_selection_text()
|
||||
match text {
|
||||
Some(t) =>
|
||||
if self.auth is Some(_) || self.shell.popup_open() {
|
||||
let line = StringBuilder::new()
|
||||
for ch in @utf8.decode_lossy(t).trim() {
|
||||
line.write_char(if ch.to_int() < 0x20 { ' ' } else { ch })
|
||||
}
|
||||
return self.remote_commit_text(line.to_string())
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
let (code, mods) = match chord {
|
||||
Some(c) => c
|
||||
// Ctrl+V; terminals keep that for themselves and paste text with Ctrl+Shift+V.
|
||||
None => (47U, if text is Some(_) && self.terminal_focused() { 5U } else { 4U })
|
||||
}
|
||||
self.remote_key_tap(code, mods, @sys.monotonic_ms().to_uint())
|
||||
false
|
||||
}
|
||||
|
||||
///| Whether the window with keyboard focus looks like a terminal, by its app id.
|
||||
fn ChandraCompositor::terminal_focused(self : ChandraCompositor) -> Bool {
|
||||
match self.kbd_win {
|
||||
Some(wid) =>
|
||||
match self.windows.get(wid) {
|
||||
Some(w) => {
|
||||
let id = w.app_id.to_lower()
|
||||
for s in ["term", "konsole", "console", "foot", "kitty", "alacritty", "ghostty", "ptyxis", "org.kde.kwi"] {
|
||||
if id.contains(s) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
None => false
|
||||
}
|
||||
None => false
|
||||
}
|
||||
}
|
||||
|
||||
///| Commit UTF-8 text directly to the active popup, Wayland text-input-v3 surface, or desktop;
|
||||
|
||||
Reference in new issue
Block a user