Skip to content

Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.

Windows: Win+V pastes into the phone's windows

Beedbb8df1fa923
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fcb4006..6f7dcef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -89,6 +89,9 @@ change things that need a step from you, and its notes say so.
- Windows: the emoji panel (**Win+.**) and input methods for Chinese and
other languages type into the phone's screen and app windows while you
control them. Only plain key presses got through before.
+- Windows: **Win+V** pastes into the phone's screen and app windows. Windows
+ marks an item picked from clipboard history as one for clipboard watchers
+ to skip, and NectarLink skipped it even when you asked to paste it.
- Pausing a transfer on the receiving device just as its last bytes
arrived left the sending device waiting, showing it as still sending. Both
now show it paused.
diff --git a/desktop/app/src/bridge/mirror.rs b/desktop/app/src/bridge/mirror.rs
index 59bd973..d3d20fa 100644
--- a/desktop/app/src/bridge/mirror.rs
+++ b/desktop/app/src/bridge/mirror.rs
@@ -384,7 +384,7 @@ impl qobject::Mirror {
}
pub fn paste(&self, key: &QString) {
- if let crate::win::clipboard::Clip::Text { text, .. } = crate::win::clipboard::read() {
+ if let crate::win::clipboard::Clip::Text { text, .. } = crate::win::clipboard::read_for_paste() {
// Long text goes in pieces, each a whole number of characters.
let mut piece = String::new();
for c in text.chars() {
diff --git a/desktop/app/src/mirror.rs b/desktop/app/src/mirror.rs
index 5dc8cbe..bc9d5d2 100644
--- a/desktop/app/src/mirror.rs
+++ b/desktop/app/src/mirror.rs
@@ -828,7 +828,7 @@ pub fn keyboard_paste(device: DeviceId) {
if keyboard_device() != Some(device) {
return;
}
- if let crate::win::clipboard::Clip::Text { text, .. } = crate::win::clipboard::read() {
+ if let crate::win::clipboard::Clip::Text { text, .. } = crate::win::clipboard::read_for_paste() {
keyboard_text(device, text);
}
}
diff --git a/desktop/app/src/win/clipboard.rs b/desktop/app/src/win/clipboard.rs
index f209337..1daa751 100644
--- a/desktop/app/src/win/clipboard.rs
+++ b/desktop/app/src/win/clipboard.rs
@@ -198,7 +198,7 @@ fn on_clipboard_changed(hwnd: HWND) {
if unsafe { GetClipboardOwner() }.is_ok_and(|owner| owner == hwnd) {
return;
}
- let clip = read_with(Some(hwnd));
+ let clip = read_with(Some(hwnd), true);
if let Clip::Text { ref text, html: None, rtf: None } = clip {
let restore = LAST_WRITTEN_RICH
.lock()
@@ -231,9 +231,18 @@ fn window() -> Option<HWND> {
(raw != 0).then_some(HWND(raw as *mut _))
}
-/// What's on the clipboard now.
+/// What's on the clipboard now, for watching it: content marked private
+/// (password managers, or kept out of clipboard history) reads as
+/// [`Clip::Private`].
pub fn read() -> Clip {
- read_with(window())
+ read_with(window(), true)
+}
+
+/// What's on the clipboard now, for a paste the user asked for (Ctrl+V,
+/// or an item picked in clipboard history, which Windows marks to keep
+/// monitors away). Pasting it is what any app does; only watchers skip it.
+pub fn read_for_paste() -> Clip {
+ read_with(window(), false)
}
/// Reads an image from the clipboard as PNG bytes, if an image (`PNG`,
@@ -420,7 +429,7 @@ fn format(name: &str) -> u32 {
unsafe { RegisterClipboardFormatW(&HSTRING::from(name)) }
}
-fn read_with(owner: Option<HWND>) -> Clip {
+fn read_with(owner: Option<HWND>, skip_private: bool) -> Clip {
// SAFETY: format availability checks need no open clipboard.
let has = |format: u32| format != 0 && unsafe { IsClipboardFormatAvailable(format) }.is_ok();
let png = format("PNG");
@@ -429,11 +438,14 @@ fn read_with(owner: Option<HWND>) -> Clip {
return Clip::Empty;
}
// Password managers and other apps mark private content this way.
- if has(format("ExcludeClipboardContentFromMonitorProcessing")) || has(format("Clipboard Viewer Ignore")) {
+ if skip_private
+ && (has(format("ExcludeClipboardContentFromMonitorProcessing"))
+ || has(format("Clipboard Viewer Ignore")))
+ {
return Clip::Private;
}
let Some(_open) = Opened::open(owner) else { return Clip::Empty };
- if let Some(0) = read_dword(format("CanIncludeInClipboardHistory")) {
+ if skip_private && let Some(0) = read_dword(format("CanIncludeInClipboardHistory")) {
return Clip::Private;
}
// Apps that copy both (a table from a spreadsheet) mean the text.