feat: support middle-click paste in text fields (#60)

Selecting an nsec in another Linux application and middle-clicking Coop's identity import field currently does nothing. The shared input widget handles left and right clicks but never reads the primary selection for a middle click.

Add middle-click paste from PRIMARY on Linux and FreeBSD, inserting at the nearest visible caret to the click. Read the selection before changing focus, preserve disabled/read-only inputs, strip line breaks in single-line fields, and use the input state's atomic insertion path so Undo removes the paste. Also register Shift+Insert for standard clipboard paste on non-macOS platforms. The existing right-click editing menu and Ctrl+V/Cmd+V remain available.

Document the gestures in the README. Enable GPUI test support for the UI crate; the lockfile additions are its test dependencies.

Validation:

- `cargo check -p ui --locked`
- `cargo test -p ui --lib --locked` — all five tests pass, including empty-field paste, Unicode caret placement, primary/clipboard separation, Undo, and disabled/read-only protection
- `git -c core.whitespace=cr-at-eol diff --check` (preserves the existing CRLF Cargo manifest)

Validated with GPUI's simulated input and clipboard platform; no live X11/Wayland compositor test was performed.

Release Notes:

- Fixed middle-click paste in Linux text fields, including identity import, and added Shift+Insert clipboard paste.

Reviewed-on: #60
Co-authored-by: Vincent Bernardoff <vb@luminar.eu.org>
This commit was merged in pull request #60.
This commit is contained in:
2026-10-10 00:28:07 +00:00
committed by reya
parent 193df36dae
commit 4ef764984b
5 changed files with 357 additions and 9 deletions
Generated
+108 -9
View File
@@ -674,15 +674,30 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "bit-set"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
dependencies = [
"bit-vec 0.8.0",
]
[[package]]
name = "bit-set"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ddef2995421ab6a5c779542c81ee77c115206f4ad9d5a8e05f4ff49716a3dd"
dependencies = [
"bit-vec",
"bit-vec 0.9.1",
]
[[package]]
name = "bit-vec"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
[[package]]
name = "bit-vec"
version = "0.9.1"
@@ -1362,6 +1377,15 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "convert_case"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cookie"
version = "0.18.2"
@@ -1798,7 +1822,7 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"
dependencies = [
"convert_case",
"convert_case 0.10.0",
"proc-macro2",
"quote",
"rustc_version",
@@ -2758,6 +2782,7 @@ dependencies = [
"pollster 0.4.0",
"postage",
"profiling",
"proptest",
"rand 0.9.5",
"raw-window-handle",
"regex",
@@ -3775,7 +3800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3"
dependencies = [
"byteorder-lite",
"quick-error",
"quick-error 2.0.1",
]
[[package]]
@@ -4463,7 +4488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2bf919621e7975acb27d881bae2fb993e0d45c8e0446e85e6272971e00dc8df"
dependencies = [
"arrayvec",
"bit-set",
"bit-set 0.9.1",
"bitflags 2.13.2",
"cfg-if",
"cfg_aliases",
@@ -5814,6 +5839,38 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "proptest"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744"
dependencies = [
"bit-set 0.8.0",
"bit-vec 0.8.0",
"bitflags 2.13.2",
"num-traits",
"proptest-macro",
"rand 0.9.5",
"rand_chacha 0.9.0",
"rand_xorshift",
"regex-syntax",
"rusty-fork",
"tempfile",
"unarray",
]
[[package]]
name = "proptest-macro"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaa288b896cb2b345da7b7f2110ab19e51565b83495b56fcec98a62f8b1f33e"
dependencies = [
"convert_case 0.11.0",
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "pulp"
version = "0.22.3"
@@ -5852,6 +5909,12 @@ dependencies = [
"bytemuck",
]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]]
name = "quick-error"
version = "2.0.1"
@@ -6029,6 +6092,15 @@ dependencies = [
"rand_core 0.10.1",
]
[[package]]
name = "rand_xorshift"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a"
dependencies = [
"rand_core 0.9.5",
]
[[package]]
name = "range-alloc"
version = "0.1.5"
@@ -6085,7 +6157,7 @@ dependencies = [
"avif-serialize",
"imgref",
"loop9",
"quick-error",
"quick-error 2.0.1",
"rav1e",
"rayon",
"rgb",
@@ -6512,6 +6584,18 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
[[package]]
name = "rusty-fork"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2"
dependencies = [
"fnv",
"quick-error 1.2.3",
"tempfile",
"wait-timeout",
]
[[package]]
name = "rustybuzz"
version = "0.20.1"
@@ -7503,7 +7587,7 @@ dependencies = [
"fax",
"flate2",
"half",
"quick-error",
"quick-error 2.0.1",
"weezl",
"zune-jpeg",
]
@@ -7964,6 +8048,12 @@ dependencies = [
"uuid",
]
[[package]]
name = "unarray"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"
[[package]]
name = "unicase"
version = "2.10.0"
@@ -8260,6 +8350,15 @@ dependencies = [
"libc",
]
[[package]]
name = "wait-timeout"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11"
dependencies = [
"libc",
]
[[package]]
name = "waker-fn"
version = "1.2.0"
@@ -8586,8 +8685,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f519832254e56965a9940c4af57dcb75f702b6f6fa4a0b172f685395843a4d7"
dependencies = [
"arrayvec",
"bit-set",
"bit-vec",
"bit-set 0.9.1",
"bit-vec 0.9.1",
"bitflags 2.13.2",
"bytemuck",
"cfg_aliases",
@@ -8658,7 +8757,7 @@ dependencies = [
"android_system_properties",
"arrayvec",
"ash",
"bit-set",
"bit-set 0.9.1",
"bitflags 2.13.2",
"block2 0.6.2",
"bytemuck",