Compare commits
31 Commits
config-wat
...
windows-ms
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c01c6b3454 | ||
|
|
3e7b04c184 | ||
|
|
f252567ef9 | ||
|
|
53c668b355 | ||
|
|
e5862e10e3 | ||
|
|
e863cdb801 | ||
|
|
bb1cc805c1 | ||
|
|
3b4b3a51aa | ||
|
|
373e382152 | ||
|
|
10fd728804 | ||
|
|
99344a3104 | ||
|
|
94e9301e9c | ||
|
|
07cc40f6ba | ||
|
|
5d7d14fbf7 | ||
|
|
2dc9ebb6cd | ||
|
|
8a444f98dd | ||
|
|
b3cade9bac | ||
|
|
cbdb86ce05 | ||
|
|
5e79743bd0 | ||
|
|
903b0504e0 | ||
|
|
c40e10505b | ||
|
|
f858a7de00 | ||
|
|
e6cd1630b2 | ||
|
|
a878c985f0 | ||
|
|
ac96faabec | ||
|
|
64d5058544 | ||
|
|
61259445c0 | ||
|
|
b9a4497fa4 | ||
|
|
2f824d8bd3 | ||
|
|
4397ce9f1c | ||
|
|
acb067bfde |
202
Cargo.lock
generated
@@ -920,6 +920,15 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fsevent-sys"
|
||||||
|
version = "4.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures"
|
name = "futures"
|
||||||
version = "0.3.32"
|
version = "0.3.32"
|
||||||
@@ -1606,6 +1615,26 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inotify"
|
||||||
|
version = "0.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd5b3eaf1a28b758ac0faa5a4254e8ab2705605496f1b1f3fbbc3988ad73d199"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.11.0",
|
||||||
|
"inotify-sys",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inotify-sys"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inout"
|
name = "inout"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@@ -1653,6 +1682,8 @@ dependencies = [
|
|||||||
"ashpd",
|
"ashpd",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bitflags 2.11.0",
|
"bitflags 2.11.0",
|
||||||
|
"core-foundation",
|
||||||
|
"core-foundation-sys",
|
||||||
"core-graphics",
|
"core-graphics",
|
||||||
"futures",
|
"futures",
|
||||||
"input-event",
|
"input-event",
|
||||||
@@ -1787,6 +1818,26 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kqueue"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a"
|
||||||
|
dependencies = [
|
||||||
|
"kqueue-sys",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kqueue-sys"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lan-mouse"
|
name = "lan-mouse"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
@@ -1805,6 +1856,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"local-channel",
|
"local-channel",
|
||||||
"log",
|
"log",
|
||||||
|
"notify",
|
||||||
"rcgen",
|
"rcgen",
|
||||||
"rustls",
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2039,6 +2091,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1"
|
checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
|
"log",
|
||||||
"wasi",
|
"wasi",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
@@ -2083,6 +2136,33 @@ dependencies = [
|
|||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "notify"
|
||||||
|
version = "8.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.11.0",
|
||||||
|
"fsevent-sys",
|
||||||
|
"inotify",
|
||||||
|
"kqueue",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"mio",
|
||||||
|
"notify-types",
|
||||||
|
"walkdir",
|
||||||
|
"windows-sys 0.60.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "notify-types"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.11.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-bigint"
|
name = "num-bigint"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
@@ -2678,6 +2758,15 @@ version = "1.0.22"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "same-file"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@@ -3352,6 +3441,16 @@ version = "0.9.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "walkdir"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||||
|
dependencies = [
|
||||||
|
"same-file",
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.1+wasi-snapshot-preview1"
|
version = "0.11.1+wasi-snapshot-preview1"
|
||||||
@@ -3619,6 +3718,15 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@@ -3781,7 +3889,7 @@ version = "0.52.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3790,7 +3898,16 @@ version = "0.59.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.60.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.53.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3808,14 +3925,31 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.52.6",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.52.6",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.52.6",
|
||||||
"windows_i686_gnullvm",
|
"windows_i686_gnullvm 0.52.6",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.52.6",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.52.6",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.52.6",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.53.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.2.1",
|
||||||
|
"windows_aarch64_gnullvm 0.53.1",
|
||||||
|
"windows_aarch64_msvc 0.53.1",
|
||||||
|
"windows_i686_gnu 0.53.1",
|
||||||
|
"windows_i686_gnullvm 0.53.1",
|
||||||
|
"windows_i686_msvc 0.53.1",
|
||||||
|
"windows_x86_64_gnu 0.53.1",
|
||||||
|
"windows_x86_64_gnullvm 0.53.1",
|
||||||
|
"windows_x86_64_msvc 0.53.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3833,48 +3967,96 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnullvm"
|
name = "windows_i686_gnullvm"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.7.15"
|
version = "0.7.15"
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ rustls = { version = "0.23.12", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
rcgen = "0.13.1"
|
rcgen = "0.13.1"
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
|
notify = "8.2.0"
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
libc = "0.2.148"
|
libc = "0.2.148"
|
||||||
@@ -95,3 +96,5 @@ rdp_emulation = ["input-emulation/remote_desktop_portal"]
|
|||||||
name = "Lan Mouse"
|
name = "Lan Mouse"
|
||||||
icon = ["target/icon.icns"]
|
icon = ["target/icon.icns"]
|
||||||
identifier = "de.feschber.LanMouse"
|
identifier = "de.feschber.LanMouse"
|
||||||
|
osx_info_plist_exts = ["build-aux/macos-lsui-element.plist"]
|
||||||
|
resources = ["target/menubar-template.png"]
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ dnf install lan-mouse
|
|||||||
- Unzip it
|
- Unzip it
|
||||||
- Remove the quarantine with `xattr -rd com.apple.quarantine "Lan Mouse.app"`
|
- Remove the quarantine with `xattr -rd com.apple.quarantine "Lan Mouse.app"`
|
||||||
- Launch the app
|
- Launch the app
|
||||||
|
- Use the menu bar item to open the settings window or quit Lan Mouse. Bundled macOS builds run as a menu bar app and do not keep a Dock icon visible.
|
||||||
- Grant accessibility permissions in System Preferences
|
- Grant accessibility permissions in System Preferences
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
8
build-aux/macos-lsui-element.plist
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<key>LSUIElement</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSAppSleepDisabled</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSInputMonitoringUsageDescription</key>
|
||||||
|
<string>Lan Mouse needs Input Monitoring access to capture keyboard and mouse input and forward it to remote machines on your network.</string>
|
||||||
|
<key>NSAppleEventsUsageDescription</key>
|
||||||
|
<string>Lan Mouse uses Apple Events to deliver synthesized keyboard and mouse events to the system.</string>
|
||||||
@@ -149,6 +149,10 @@ pub enum MacosCaptureCreationError {
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
#[error("event tap creation failed")]
|
#[error("event tap creation failed")]
|
||||||
EventTapCreation,
|
EventTapCreation,
|
||||||
|
#[error("accessibility permission is required")]
|
||||||
|
AccessibilityPermission,
|
||||||
|
#[error("input monitoring permission is required")]
|
||||||
|
InputMonitoringPermission,
|
||||||
#[error("failed to set CG Cursor property")]
|
#[error("failed to set CG Cursor property")]
|
||||||
CGCursorProperty,
|
CGCursorProperty,
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -171,6 +171,19 @@ impl InputCapture {
|
|||||||
self.capture.release().await
|
self.capture.release().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Drain and return every key the capture has forwarded as
|
||||||
|
/// down-but-not-up. The caller is expected to synthesize key-up
|
||||||
|
/// events to the remote peer for each — otherwise the peer
|
||||||
|
/// retains phantom-held keys after capture is released. The
|
||||||
|
/// canonical case is the release-bind chord
|
||||||
|
/// (Ctrl+Shift+Alt+Meta): the down events were sent while
|
||||||
|
/// capture was active, but the matching up events arrive after
|
||||||
|
/// the local tap has flipped to passthrough and never reach
|
||||||
|
/// the peer.
|
||||||
|
pub fn take_pressed_keys(&mut self) -> HashSet<scancode::Linux> {
|
||||||
|
std::mem::take(&mut self.pressed_keys)
|
||||||
|
}
|
||||||
|
|
||||||
/// destroy the input capture
|
/// destroy the input capture
|
||||||
pub async fn terminate(&mut self) -> Result<(), CaptureError> {
|
pub async fn terminate(&mut self) -> Result<(), CaptureError> {
|
||||||
self.capture.terminate().await
|
self.capture.terminate().await
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use super::{Capture, CaptureError, CaptureEvent, Position, error::MacosCaptureCr
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use core_foundation::{
|
use core_foundation::{
|
||||||
base::{CFRelease, kCFAllocatorDefault},
|
base::{CFRelease, TCFType, kCFAllocatorDefault},
|
||||||
date::CFTimeInterval,
|
date::CFTimeInterval,
|
||||||
number::{CFBooleanRef, kCFBooleanTrue},
|
number::{CFBooleanRef, kCFBooleanTrue},
|
||||||
runloop::{CFRunLoop, CFRunLoopSource, kCFRunLoopCommonModes},
|
runloop::{CFRunLoop, CFRunLoopSource, kCFRunLoopCommonModes},
|
||||||
@@ -28,7 +28,7 @@ use std::{
|
|||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
ffi::{CString, c_char},
|
ffi::{CString, c_char},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::Arc,
|
sync::{Arc, OnceLock},
|
||||||
task::{Context, Poll, ready},
|
task::{Context, Poll, ready},
|
||||||
thread::{self},
|
thread::{self},
|
||||||
};
|
};
|
||||||
@@ -67,6 +67,7 @@ enum ProducerEvent {
|
|||||||
Destroy(Position),
|
Destroy(Position),
|
||||||
Grab(Position),
|
Grab(Position),
|
||||||
EventTapDisabled,
|
EventTapDisabled,
|
||||||
|
DisplayReconfigured,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputCaptureState {
|
impl InputCaptureState {
|
||||||
@@ -176,7 +177,31 @@ impl InputCaptureState {
|
|||||||
}
|
}
|
||||||
self.active_clients.remove(&p);
|
self.active_clients.remove(&p);
|
||||||
}
|
}
|
||||||
ProducerEvent::EventTapDisabled => return Err(CaptureError::EventTapDisabled),
|
ProducerEvent::EventTapDisabled => {
|
||||||
|
// Tap death can happen mid-capture (TCC Accessibility
|
||||||
|
// revoked, tap-timeout, etc). Release state so we
|
||||||
|
// don't leave the cursor hidden even if the outer
|
||||||
|
// task only logs this error rather than propagating.
|
||||||
|
if self.current_pos.is_some() {
|
||||||
|
self.show_cursor()?;
|
||||||
|
self.current_pos = None;
|
||||||
|
}
|
||||||
|
return Err(CaptureError::EventTapDisabled);
|
||||||
|
}
|
||||||
|
ProducerEvent::DisplayReconfigured => {
|
||||||
|
// The macOS display configuration changed — a monitor
|
||||||
|
// was plugged in/out, the resolution changed, the
|
||||||
|
// arrangement was rearranged, etc. Re-fetch the
|
||||||
|
// active-display bounds so barrier crossings and the
|
||||||
|
// cursor-warp on capture-start use the current
|
||||||
|
// geometry instead of whatever was true at process
|
||||||
|
// start.
|
||||||
|
if let Err(e) = self.update_bounds() {
|
||||||
|
log::warn!("failed to refresh display bounds: {e}");
|
||||||
|
} else {
|
||||||
|
log::info!("display reconfigured: {:?}", self.bounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -385,6 +410,14 @@ fn create_event_tap<'a>(
|
|||||||
notify_tx: Sender<ProducerEvent>,
|
notify_tx: Sender<ProducerEvent>,
|
||||||
event_tx: Sender<(Position, CaptureEvent)>,
|
event_tx: Sender<(Position, CaptureEvent)>,
|
||||||
) -> Result<CGEventTap<'a>, MacosCaptureCreationError> {
|
) -> Result<CGEventTap<'a>, MacosCaptureCreationError> {
|
||||||
|
// Shared slot for the tap's mach port pointer. Stored as `usize`
|
||||||
|
// because raw pointers aren't `Send`, but the integer
|
||||||
|
// representation is — and CGEventTapEnable is documented as
|
||||||
|
// thread-safe. Set immediately after CGEventTap::new returns;
|
||||||
|
// read by the callback to recover from a TapDisabledByTimeout.
|
||||||
|
let tap_mach_port: Arc<OnceLock<usize>> = Arc::new(OnceLock::new());
|
||||||
|
let tap_mach_port_cb = Arc::clone(&tap_mach_port);
|
||||||
|
|
||||||
let cg_events_of_interest: Vec<CGEventType> = vec![
|
let cg_events_of_interest: Vec<CGEventType> = vec![
|
||||||
CGEventType::LeftMouseDown,
|
CGEventType::LeftMouseDown,
|
||||||
CGEventType::LeftMouseUp,
|
CGEventType::LeftMouseUp,
|
||||||
@@ -402,76 +435,114 @@ fn create_event_tap<'a>(
|
|||||||
CGEventType::FlagsChanged,
|
CGEventType::FlagsChanged,
|
||||||
];
|
];
|
||||||
|
|
||||||
let event_tap_callback =
|
let event_tap_callback = move |_proxy: CGEventTapProxy,
|
||||||
move |_proxy: CGEventTapProxy, event_type: CGEventType, cg_ev: &CGEvent| {
|
event_type: CGEventType,
|
||||||
log::trace!("Got event from tap: {event_type:?}");
|
cg_ev: &CGEvent| {
|
||||||
let mut state = client_state.blocking_lock();
|
log::trace!("Got event from tap: {event_type:?}");
|
||||||
let mut capture_position = None;
|
let mut state = client_state.blocking_lock();
|
||||||
let mut res_events = vec![];
|
let mut capture_position = None;
|
||||||
|
let mut res_events = vec![];
|
||||||
|
|
||||||
|
if matches!(event_type, CGEventType::TapDisabledByTimeout) {
|
||||||
|
// The kernel disables the tap when our callback runs
|
||||||
|
// longer than ~1s on a single event — typical causes
|
||||||
|
// are heavy load, scheduler contention, or this
|
||||||
|
// process being briefly suspended (e.g. App Nap on a
|
||||||
|
// long idle). It is NOT a fatal condition: Apple's
|
||||||
|
// documented recovery is to call CGEventTapEnable
|
||||||
|
// and resume processing. Re-enable in place and KEEP
|
||||||
|
// existing capture state so the user doesn't see the
|
||||||
|
// cursor pop back to the local screen mid-session.
|
||||||
|
if let Some(&port) = tap_mach_port_cb.get() {
|
||||||
|
log::warn!("CGEventTap disabled by timeout — re-enabling");
|
||||||
|
unsafe {
|
||||||
|
CGEventTapEnable(port as *mut c_void, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::error!(
|
||||||
|
"CGEventTap disabled by timeout, but mach port not yet stored — cannot re-enable"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return CallbackResult::Keep;
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches!(event_type, CGEventType::TapDisabledByUserInput) {
|
||||||
|
// Deliberate kill — secure-input mode (e.g. password
|
||||||
|
// field), TCC Accessibility revoked mid-session, or
|
||||||
|
// the user disabling event-monitoring. We can't
|
||||||
|
// recover from this; drop captured state synchronously
|
||||||
|
// and return Keep on this event. Otherwise the
|
||||||
|
// `current_pos.is_some()` branch below would drop this
|
||||||
|
// event (and any racing callback still in flight) back
|
||||||
|
// into `CallbackResult::Drop`, silently eating the
|
||||||
|
// user's clicks and keypresses while the tap winds
|
||||||
|
// down. Clear state + show the cursor here, then
|
||||||
|
// notify the producer loop so the service can tear
|
||||||
|
// down cleanly.
|
||||||
|
log::error!("CGEventTap disabled by user input, releasing capture state");
|
||||||
|
if state.current_pos.is_some() {
|
||||||
|
let _ = CGDisplay::show_cursor(&CGDisplay::main());
|
||||||
|
state.current_pos = None;
|
||||||
|
}
|
||||||
|
notify_tx
|
||||||
|
.blocking_send(ProducerEvent::EventTapDisabled)
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
log::error!("Failed to send notification: {e}");
|
||||||
|
});
|
||||||
|
return CallbackResult::Keep;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Are we in a client?
|
||||||
|
if let Some(current_pos) = state.current_pos {
|
||||||
|
capture_position = Some(current_pos);
|
||||||
|
get_events(
|
||||||
|
&event_type,
|
||||||
|
cg_ev,
|
||||||
|
&mut res_events,
|
||||||
|
&mut state.modifier_state,
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
log::error!("Failed to get events: {e}");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Keep (hidden) cursor at the edge of the screen
|
||||||
if matches!(
|
if matches!(
|
||||||
event_type,
|
event_type,
|
||||||
CGEventType::TapDisabledByTimeout | CGEventType::TapDisabledByUserInput
|
CGEventType::MouseMoved
|
||||||
|
| CGEventType::LeftMouseDragged
|
||||||
|
| CGEventType::RightMouseDragged
|
||||||
|
| CGEventType::OtherMouseDragged
|
||||||
) {
|
) {
|
||||||
log::error!("CGEventTap disabled");
|
state.reset_cursor().unwrap_or_else(|e| log::warn!("{e}"));
|
||||||
|
}
|
||||||
|
} else if matches!(event_type, CGEventType::MouseMoved) {
|
||||||
|
// Did we cross a barrier?
|
||||||
|
if let Some(new_pos) = state.crossed(cg_ev) {
|
||||||
|
capture_position = Some(new_pos);
|
||||||
|
state
|
||||||
|
.start_capture(cg_ev, new_pos)
|
||||||
|
.unwrap_or_else(|e| log::warn!("{e}"));
|
||||||
|
res_events.push(CaptureEvent::Begin);
|
||||||
notify_tx
|
notify_tx
|
||||||
.blocking_send(ProducerEvent::EventTapDisabled)
|
.blocking_send(ProducerEvent::Grab(new_pos))
|
||||||
.unwrap_or_else(|e| {
|
.expect("Failed to send notification");
|
||||||
log::error!("Failed to send notification: {e}");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Are we in a client?
|
if let Some(pos) = capture_position {
|
||||||
if let Some(current_pos) = state.current_pos {
|
res_events.iter().for_each(|e| {
|
||||||
capture_position = Some(current_pos);
|
// error must be ignored, since the event channel
|
||||||
get_events(
|
// may already be closed when the InputCapture instance is dropped.
|
||||||
&event_type,
|
let _ = event_tx.blocking_send((pos, *e));
|
||||||
cg_ev,
|
});
|
||||||
&mut res_events,
|
// Returning Drop should stop the event from being processed
|
||||||
&mut state.modifier_state,
|
// but core fundation still returns the event
|
||||||
)
|
cg_ev.set_type(CGEventType::Null);
|
||||||
.unwrap_or_else(|e| {
|
CallbackResult::Drop
|
||||||
log::error!("Failed to get events: {e}");
|
} else {
|
||||||
});
|
CallbackResult::Keep
|
||||||
|
}
|
||||||
// Keep (hidden) cursor at the edge of the screen
|
};
|
||||||
if matches!(
|
|
||||||
event_type,
|
|
||||||
CGEventType::MouseMoved
|
|
||||||
| CGEventType::LeftMouseDragged
|
|
||||||
| CGEventType::RightMouseDragged
|
|
||||||
| CGEventType::OtherMouseDragged
|
|
||||||
) {
|
|
||||||
state.reset_cursor().unwrap_or_else(|e| log::warn!("{e}"));
|
|
||||||
}
|
|
||||||
} else if matches!(event_type, CGEventType::MouseMoved) {
|
|
||||||
// Did we cross a barrier?
|
|
||||||
if let Some(new_pos) = state.crossed(cg_ev) {
|
|
||||||
capture_position = Some(new_pos);
|
|
||||||
state
|
|
||||||
.start_capture(cg_ev, new_pos)
|
|
||||||
.unwrap_or_else(|e| log::warn!("{e}"));
|
|
||||||
res_events.push(CaptureEvent::Begin);
|
|
||||||
notify_tx
|
|
||||||
.blocking_send(ProducerEvent::Grab(new_pos))
|
|
||||||
.expect("Failed to send notification");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(pos) = capture_position {
|
|
||||||
res_events.iter().for_each(|e| {
|
|
||||||
// error must be ignored, since the event channel
|
|
||||||
// may already be closed when the InputCapture instance is dropped.
|
|
||||||
let _ = event_tx.blocking_send((pos, *e));
|
|
||||||
});
|
|
||||||
// Returning Drop should stop the event from being processed
|
|
||||||
// but core fundation still returns the event
|
|
||||||
cg_ev.set_type(CGEventType::Null);
|
|
||||||
CallbackResult::Drop
|
|
||||||
} else {
|
|
||||||
CallbackResult::Keep
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let tap = CGEventTap::new(
|
let tap = CGEventTap::new(
|
||||||
CGEventTapLocation::Session,
|
CGEventTapLocation::Session,
|
||||||
@@ -482,6 +553,13 @@ fn create_event_tap<'a>(
|
|||||||
)
|
)
|
||||||
.map_err(|_| MacosCaptureCreationError::EventTapCreation)?;
|
.map_err(|_| MacosCaptureCreationError::EventTapCreation)?;
|
||||||
|
|
||||||
|
// Hand the mach port pointer to the callback so it can re-enable
|
||||||
|
// the tap on TapDisabledByTimeout. The pointer is valid for the
|
||||||
|
// lifetime of `tap` (which lives on the event-tap thread until
|
||||||
|
// the run loop exits).
|
||||||
|
let port_ptr = tap.mach_port().as_concrete_TypeRef() as usize;
|
||||||
|
let _ = tap_mach_port.set(port_ptr);
|
||||||
|
|
||||||
let tap_source: CFRunLoopSource = tap
|
let tap_source: CFRunLoopSource = tap
|
||||||
.mach_port()
|
.mach_port()
|
||||||
.create_runloop_source(0)
|
.create_runloop_source(0)
|
||||||
@@ -501,6 +579,9 @@ fn event_tap_thread(
|
|||||||
ready: std::sync::mpsc::Sender<Result<CFRunLoop, MacosCaptureCreationError>>,
|
ready: std::sync::mpsc::Sender<Result<CFRunLoop, MacosCaptureCreationError>>,
|
||||||
exit: oneshot::Sender<()>,
|
exit: oneshot::Sender<()>,
|
||||||
) {
|
) {
|
||||||
|
// Clone now: create_event_tap consumes notify_tx into its closure.
|
||||||
|
let display_notify_tx = notify_tx.clone();
|
||||||
|
|
||||||
let _tap = match create_event_tap(client_state, notify_tx, event_tx) {
|
let _tap = match create_event_tap(client_state, notify_tx, event_tx) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
ready.send(Err(e)).expect("channel closed");
|
ready.send(Err(e)).expect("channel closed");
|
||||||
@@ -512,13 +593,62 @@ fn event_tap_thread(
|
|||||||
tap
|
tap
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Register a Quartz display-reconfiguration callback so the
|
||||||
|
// capture state's bounds get refreshed when the user plugs in a
|
||||||
|
// monitor, changes resolution, or rearranges displays. The
|
||||||
|
// callback runs on this thread's CFRunLoop. Box-leak the sender
|
||||||
|
// so the C side has a stable user_info pointer; reclaim it after
|
||||||
|
// the run loop exits.
|
||||||
|
let display_user_info = Box::into_raw(Box::new(display_notify_tx)) as *mut c_void;
|
||||||
|
unsafe {
|
||||||
|
CGDisplayRegisterReconfigurationCallback(
|
||||||
|
display_reconfiguration_callback,
|
||||||
|
display_user_info,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
log::debug!("running CFRunLoop...");
|
log::debug!("running CFRunLoop...");
|
||||||
CFRunLoop::run_current();
|
CFRunLoop::run_current();
|
||||||
log::debug!("event tap thread exiting!...");
|
log::debug!("event tap thread exiting!...");
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
CGDisplayRemoveReconfigurationCallback(display_reconfiguration_callback, display_user_info);
|
||||||
|
// Reclaim the leaked sender Box so we don't leak a tokio
|
||||||
|
// channel sender on every capture create/destroy cycle.
|
||||||
|
drop(Box::from_raw(
|
||||||
|
display_user_info as *mut Sender<ProducerEvent>,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let _ = exit.send(());
|
let _ = exit.send(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Quartz display-reconfiguration callback. Fires twice per change:
|
||||||
|
/// once with `kCGDisplayBeginConfigurationFlag` set (BEFORE the
|
||||||
|
/// change is applied — the bounds are still stale at this point),
|
||||||
|
/// then again afterwards with the actual change flags (Add, Remove,
|
||||||
|
/// Mode, DesktopShapeChanged, etc.). Skip the begin phase; on the
|
||||||
|
/// real notification, kick the producer task to refresh bounds.
|
||||||
|
extern "C" fn display_reconfiguration_callback(_display: u32, flags: u32, user_info: *mut c_void) {
|
||||||
|
const K_CG_DISPLAY_BEGIN_CONFIGURATION_FLAG: u32 = 1 << 0;
|
||||||
|
if flags & K_CG_DISPLAY_BEGIN_CONFIGURATION_FLAG != 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if user_info.is_null() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// SAFETY: user_info is a Box::into_raw of Sender<ProducerEvent>
|
||||||
|
// owned by `event_tap_thread`. It's valid for the lifetime of
|
||||||
|
// that thread; the registration is removed before the box is
|
||||||
|
// freed. The callback only fires while the run loop is running
|
||||||
|
// on that thread, so we know the box is live here.
|
||||||
|
let sender = unsafe { &*(user_info as *const Sender<ProducerEvent>) };
|
||||||
|
if let Err(e) = sender.blocking_send(ProducerEvent::DisplayReconfigured) {
|
||||||
|
log::warn!("failed to notify display reconfiguration: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct MacOSInputCapture {
|
pub struct MacOSInputCapture {
|
||||||
event_rx: Receiver<(Position, CaptureEvent)>,
|
event_rx: Receiver<(Position, CaptureEvent)>,
|
||||||
notify_tx: Sender<ProducerEvent>,
|
notify_tx: Sender<ProducerEvent>,
|
||||||
@@ -527,6 +657,8 @@ pub struct MacOSInputCapture {
|
|||||||
|
|
||||||
impl MacOSInputCapture {
|
impl MacOSInputCapture {
|
||||||
pub async fn new() -> Result<Self, MacosCaptureCreationError> {
|
pub async fn new() -> Result<Self, MacosCaptureCreationError> {
|
||||||
|
request_macos_capture_permissions()?;
|
||||||
|
|
||||||
let state = Arc::new(Mutex::new(InputCaptureState::new()?));
|
let state = Arc::new(Mutex::new(InputCaptureState::new()?));
|
||||||
let (event_tx, event_rx) = mpsc::channel(32);
|
let (event_tx, event_rx) = mpsc::channel(32);
|
||||||
let (notify_tx, mut notify_rx) = mpsc::channel(32);
|
let (notify_tx, mut notify_rx) = mpsc::channel(32);
|
||||||
@@ -580,6 +712,38 @@ impl MacOSInputCapture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn request_macos_capture_permissions() -> Result<(), MacosCaptureCreationError> {
|
||||||
|
// Call both request functions unconditionally so macOS surfaces both
|
||||||
|
// TCC prompts on the very first launch. TCC always returns `false` the
|
||||||
|
// first time a permission is requested (the grant only becomes visible
|
||||||
|
// on the next process launch), so returning early on the first failure
|
||||||
|
// would skip the second prompt and force the user through an extra
|
||||||
|
// relaunch just to see it.
|
||||||
|
let accessibility = request_accessibility_permission();
|
||||||
|
let input_monitoring = request_input_monitoring_permission();
|
||||||
|
|
||||||
|
if !accessibility {
|
||||||
|
return Err(MacosCaptureCreationError::AccessibilityPermission);
|
||||||
|
}
|
||||||
|
if !input_monitoring {
|
||||||
|
return Err(MacosCaptureCreationError::InputMonitoringPermission);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn request_accessibility_permission() -> bool {
|
||||||
|
// Silent check. The GUI owns the one-time user-visible prompt at
|
||||||
|
// startup (see lan_mouse_gtk::macos_privacy) so retries triggered by
|
||||||
|
// clicking the "Reenable" button don't pop a fresh Accessibility
|
||||||
|
// alert every time.
|
||||||
|
unsafe { AXIsProcessTrusted() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn request_input_monitoring_permission() -> bool {
|
||||||
|
// Silent check, same reasoning as above.
|
||||||
|
unsafe { CGPreflightListenEventAccess() }
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for MacOSInputCapture {
|
impl Drop for MacOSInputCapture {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.run_loop.stop();
|
self.run_loop.stop();
|
||||||
@@ -651,6 +815,30 @@ extern "C" {
|
|||||||
event_source: CGEventSource,
|
event_source: CGEventSource,
|
||||||
seconds: CFTimeInterval,
|
seconds: CFTimeInterval,
|
||||||
);
|
);
|
||||||
|
fn CGPreflightListenEventAccess() -> bool;
|
||||||
|
/// Re-enable an event tap that was disabled by a
|
||||||
|
/// `kCGEventTapDisabledByTimeout` event. The Apple-documented
|
||||||
|
/// recovery path: see Quartz Event Services Reference. The `tap`
|
||||||
|
/// argument is a `CFMachPortRef`; we pass the raw pointer so we
|
||||||
|
/// can store it as `usize` for cross-thread sharing.
|
||||||
|
fn CGEventTapEnable(tap: *mut c_void, enable: bool);
|
||||||
|
|
||||||
|
/// Register a callback invoked when the display configuration
|
||||||
|
/// changes (monitor add/remove, resolution change, mirror,
|
||||||
|
/// rearrange, etc). See Quartz Display Services Reference.
|
||||||
|
fn CGDisplayRegisterReconfigurationCallback(
|
||||||
|
callback: extern "C" fn(u32, u32, *mut c_void),
|
||||||
|
user_info: *mut c_void,
|
||||||
|
) -> CGError;
|
||||||
|
fn CGDisplayRemoveReconfigurationCallback(
|
||||||
|
callback: extern "C" fn(u32, u32, *mut c_void),
|
||||||
|
user_info: *mut c_void,
|
||||||
|
) -> CGError;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "ApplicationServices", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
fn AXIsProcessTrusted() -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn configure_cf_settings() -> Result<(), MacosCaptureCreationError> {
|
unsafe fn configure_cf_settings() -> Result<(), MacosCaptureCreationError> {
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ reis = { version = "0.5.0", features = ["tokio"], optional = true }
|
|||||||
|
|
||||||
[target.'cfg(target_os="macos")'.dependencies]
|
[target.'cfg(target_os="macos")'.dependencies]
|
||||||
bitflags = "2.6.0"
|
bitflags = "2.6.0"
|
||||||
|
core-foundation = "0.10.0"
|
||||||
|
core-foundation-sys = "0.8.6"
|
||||||
core-graphics = { version = "0.25.0", features = ["highsierra"] }
|
core-graphics = { version = "0.25.0", features = ["highsierra"] }
|
||||||
keycode = "1.0.0"
|
keycode = "1.0.0"
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,10 @@ pub enum X11EmulationCreationError {
|
|||||||
pub enum MacOSEmulationCreationError {
|
pub enum MacOSEmulationCreationError {
|
||||||
#[error("could not create event source")]
|
#[error("could not create event source")]
|
||||||
EventSourceCreation,
|
EventSourceCreation,
|
||||||
|
#[error("accessibility permission is required")]
|
||||||
|
AccessibilityPermission,
|
||||||
|
#[error("input control permission is required")]
|
||||||
|
InputControlPermission,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ unsafe impl Send for MacOSEmulation {}
|
|||||||
|
|
||||||
impl MacOSEmulation {
|
impl MacOSEmulation {
|
||||||
pub(crate) fn new() -> Result<Self, MacOSEmulationCreationError> {
|
pub(crate) fn new() -> Result<Self, MacOSEmulationCreationError> {
|
||||||
|
request_macos_emulation_permissions()?;
|
||||||
|
|
||||||
let event_source = CGEventSource::new(CGEventSourceStateID::CombinedSessionState)
|
let event_source = CGEventSource::new(CGEventSourceStateID::CombinedSessionState)
|
||||||
.map_err(|_| MacOSEmulationCreationError::EventSourceCreation)?;
|
.map_err(|_| MacOSEmulationCreationError::EventSourceCreation)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -119,6 +121,42 @@ impl MacOSEmulation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn request_macos_emulation_permissions() -> Result<(), MacOSEmulationCreationError> {
|
||||||
|
// Request both permissions up front so the user sees both TCC prompts
|
||||||
|
// on the first launch. See the matching comment in input-capture/src/
|
||||||
|
// macos.rs::request_macos_capture_permissions for the rationale.
|
||||||
|
let accessibility = request_accessibility_permission();
|
||||||
|
let input_control = request_input_control_permission();
|
||||||
|
|
||||||
|
if !accessibility {
|
||||||
|
return Err(MacOSEmulationCreationError::AccessibilityPermission);
|
||||||
|
}
|
||||||
|
if !input_control {
|
||||||
|
return Err(MacOSEmulationCreationError::InputControlPermission);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn request_accessibility_permission() -> bool {
|
||||||
|
// Silent check. The GUI owns the one-time user-visible prompt at
|
||||||
|
// startup (see lan_mouse_gtk::macos_privacy).
|
||||||
|
unsafe { AXIsProcessTrusted() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn request_input_control_permission() -> bool {
|
||||||
|
unsafe { CGPreflightPostEventAccess() }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "CoreGraphics", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
fn CGPreflightPostEventAccess() -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "ApplicationServices", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
fn AXIsProcessTrusted() -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
fn key_event(event_source: CGEventSource, key: u16, state: u8, modifiers: XMods) {
|
fn key_event(event_source: CGEventSource, key: u16, state: u8, modifiers: XMods) {
|
||||||
let event = match CGEvent::new_keyboard_event(event_source, key, state != 0) {
|
let event = match CGEvent::new_keyboard_event(event_source, key, state != 0) {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 0 3 c 0 -1.644531 1.355469 -3 3 -3 h 5 c 1.644531 0 3 1.355469 3 3 c 0 0.550781 -0.449219 1 -1 1 s -1 -0.449219 -1 -1 c 0 -0.570312 -0.429688 -1 -1 -1 h -5 c -0.570312 0 -1 0.429688 -1 1 v 5 c 0 0.570312 0.429688 1 1 1 c 0.550781 0 1 0.449219 1 1 s -0.449219 1 -1 1 c -1.644531 0 -3 -1.355469 -3 -3 z m 5 5 c 0 -1.644531 1.355469 -3 3 -3 h 5 c 1.644531 0 3 1.355469 3 3 v 5 c 0 1.644531 -1.355469 3 -3 3 h -5 c -1.644531 0 -3 -1.355469 -3 -3 z m 2 0 v 5 c 0 0.570312 0.429688 1 1 1 h 5 c 0.570312 0 1 -0.429688 1 -1 v -5 c 0 -0.570312 -0.429688 -1 -1 -1 h -5 c -0.570312 0 -1 0.429688 -1 1 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 765 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 8 0 c -4.410156 0 -8 3.589844 -8 8 s 3.589844 8 8 8 s 8 -3.589844 8 -8 s -3.589844 -8 -8 -8 z m 0 2 c 3.332031 0 6 2.667969 6 6 s -2.667969 6 -6 6 s -6 -2.667969 -6 -6 s 2.667969 -6 6 -6 z m -2.03125 2.96875 c -0.265625 0 -0.519531 0.105469 -0.707031 0.292969 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 l 1.292969 1.292969 l -1.292969 1.292969 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 s 1.023437 0.390625 1.414062 0 l 1.292969 -1.292969 l 1.292969 1.292969 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 l -1.292969 -1.292969 l 1.292969 -1.292969 c 0.390625 -0.390625 0.390625 -1.023437 0 -1.414062 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 s -0.519531 0.105469 -0.707031 0.292969 l -1.292969 1.292969 l -1.292969 -1.292969 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 13.753906 4.660156 c 0.175782 -0.199218 0.261719 -0.460937 0.246094 -0.726562 c -0.019531 -0.265625 -0.140625 -0.511719 -0.339844 -0.6875 c -0.199218 -0.175782 -0.460937 -0.261719 -0.726562 -0.246094 c -0.265625 0.019531 -0.511719 0.140625 -0.6875 0.339844 l -6.296875 7.195312 l -2.242188 -2.242187 c -0.390625 -0.390625 -1.023437 -0.390625 -1.414062 0 c -0.1875 0.1875 -0.292969 0.441406 -0.292969 0.707031 s 0.105469 0.519531 0.292969 0.707031 l 3 3 c 0.195312 0.195313 0.464843 0.304688 0.738281 0.292969 c 0.277344 -0.007812 0.539062 -0.132812 0.722656 -0.339844 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 743 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 7 1 v 6 h -6 v 2 h 6 v 6 h 2 v -6 h 6 v -2 h -6 v -6 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 228 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 7.085938 2 c 0.574218 0.007812 1.152343 0.085938 1.726562 0.238281 c 3.054688 0.820313 5.1875 3.597657 5.1875 6.761719 h 2 v 1 h -0.007812 c 0.003906 0.265625 -0.101563 0.519531 -0.285157 0.707031 l -2 2 c -0.390625 0.390625 -1.023437 0.390625 -1.414062 0 l -2 -2 c -0.1875 -0.1875 -0.289063 -0.441406 -0.289063 -0.707031 h -0.003906 v -1 h 2 c 0 -2.269531 -1.515625 -4.242188 -3.707031 -4.832031 c -2.1875 -0.585938 -4.488281 0.367187 -5.625 2.332031 c -1.132813 1.964844 -0.808594 4.429688 0.796875 6.035156 c 0.390625 0.390625 0.390625 1.023438 0 1.414063 s -1.023438 0.390625 -1.414063 0 c -2.238281 -2.238281 -2.695312 -5.710938 -1.113281 -8.449219 c 1.1875 -2.054688 3.304688 -3.324219 5.578125 -3.480469 c 0.1875 -0.015625 0.378906 -0.023437 0.570313 -0.019531 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 943 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 13.753906 4.660156 c 0.175782 -0.199218 0.261719 -0.460937 0.246094 -0.726562 c -0.019531 -0.265625 -0.140625 -0.511719 -0.339844 -0.6875 c -0.199218 -0.175782 -0.460937 -0.261719 -0.726562 -0.246094 c -0.265625 0.019531 -0.511719 0.140625 -0.6875 0.339844 l -6.296875 7.195312 l -2.242188 -2.242187 c -0.390625 -0.390625 -1.023437 -0.390625 -1.414062 0 c -0.1875 0.1875 -0.292969 0.441406 -0.292969 0.707031 s 0.105469 0.519531 0.292969 0.707031 l 3 3 c 0.195312 0.195313 0.464843 0.304688 0.738281 0.292969 c 0.277344 -0.007812 0.539062 -0.132812 0.722656 -0.339844 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 743 B |
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="#2e3436">
|
||||||
|
<path d="m 1 2 h 14 v 2 h -14 z m 0 0"/>
|
||||||
|
<path d="m 1 7 h 14 v 2 h -14 z m 0 0"/>
|
||||||
|
<path d="m 1 12 h 14 v 2 h -14 z m 0 0"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 314 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 3 2 c -0.265625 0 -0.519531 0.105469 -0.707031 0.292969 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 l 4.292969 4.292969 l -4.292969 4.292969 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 s 1.023437 0.390625 1.414062 0 l 4.292969 -4.292969 l 4.292969 4.292969 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 l -4.292969 -4.292969 l 4.292969 -4.292969 c 0.390625 -0.390625 0.390625 -1.023437 0 -1.414062 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 s -0.519531 0.105469 -0.707031 0.292969 l -4.292969 4.292969 l -4.292969 -4.292969 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 822 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 8.074219 0 c -1.203125 -0.0117188 -2.40625 0.285156 -3.492188 0.890625 c -0.480469 0.269531 -0.652343 0.878906 -0.382812 1.359375 c 0.269531 0.484375 0.878906 0.65625 1.359375 0.386719 c 1.550781 -0.867188 3.4375 -0.847657 4.972656 0.050781 c 1.53125 0.898438 2.46875 2.535156 2.46875 4.3125 v 1 c 0 0.550781 0.449219 1 1 1 s 1 -0.449219 1 -1 v -1 c 0 -0.019531 0 -0.039062 -0.003906 -0.054688 c -0.019532 -2.460937 -1.332032 -4.738281 -3.457032 -5.984374 c -1.070312 -0.628907 -2.265624 -0.9492192 -3.46875 -0.960938 z m -5.199219 2.832031 c -0.066406 0 -0.132812 0.007813 -0.195312 0.023438 c -0.257813 0.058593 -0.484376 0.21875 -0.625 0.445312 c -0.6875 1.109375 -1.054688 2.390625 -1.054688 3.699219 v 5.0625 c 0 0.550781 0.449219 1 1 1 s 1 -0.449219 1 -1 v -5.0625 c 0 -0.933594 0.261719 -1.851562 0.753906 -2.644531 c 0.292969 -0.46875 0.148438 -1.082031 -0.320312 -1.375 c -0.167969 -0.105469 -0.363282 -0.15625 -0.558594 -0.148438 z m 5.125 0.167969 c -2.199219 0 -4 1.800781 -4 4 v 1 c 0 0.550781 0.449219 1 1 1 s 1 -0.449219 1 -1 v -1 c 0 -1.117188 0.882812 -2 2 -2 s 2 0.882812 2 2 v 5 s 0.007812 0.441406 0.175781 0.941406 s 0.5 1.148438 1.117188 1.765625 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 c -0.382812 -0.382813 -0.550781 -0.734375 -0.632812 -0.984375 s -0.074219 -0.308594 -0.074219 -0.308594 v -5 c 0 -2.199219 -1.800781 -4 -4 -4 z m 0 3 c -0.550781 0 -1 0.449219 -1 1 v 5 s 0 0.59375 0.144531 1.320312 c 0.144531 0.726563 0.414063 1.652344 1.148438 2.386719 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 c -0.265625 -0.265625 -0.496093 -0.839844 -0.601562 -1.363281 c -0.105469 -0.523438 -0.105469 -0.929688 -0.105469 -0.929688 v -5 c 0 -0.550781 -0.449219 -1 -1 -1 z m -3 4 c -0.550781 0 -1 0.449219 -1 1 v 3 c 0 0.550781 0.449219 1 1 1 s 1 -0.449219 1 -1 v -3 c 0 -0.550781 -0.449219 -1 -1 -1 z m 9 0 c -0.550781 0 -1 0.449219 -1 1 s 0.449219 1 1 1 s 1 -0.449219 1 -1 s -0.449219 -1 -1 -1 z m 0 0" fill="#2e3434"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 6 0.015625 c -0.554688 0 -1 0.445313 -1 1 v 3 c 0 0.554687 0.445312 1 1 1 h 1 v 2 h -7 v 2 h 2 v 2 h -1 c -0.554688 0 -1 0.445313 -1 1 v 3 c 0 0.554687 0.445312 1 1 1 h 4 c 0.554688 0 1 -0.445313 1 -1 v -3 c 0 -0.554687 -0.445312 -1 -1 -1 h -1 v -2 h 8 v 2 h -1 c -0.554688 0 -1 0.445313 -1 1 v 3 c 0 0.554687 0.445312 1 1 1 h 4 c 0.554688 0 1 -0.445313 1 -1 v -3 c 0 -0.554687 -0.445312 -1 -1 -1 h -1 v -2 h 2 v -2 h -7 v -2 h 1 c 0.554688 0 1 -0.445313 1 -1 v -3 c 0 -0.554687 -0.445312 -1 -1 -1 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 673 B |
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="#2e3436">
|
||||||
|
<path d="m 6.5 0 c -1.378906 0 -2.5 1.121094 -2.5 2.5 v 0.5 h -3 c -0.550781 0 -1 0.449219 -1 1 s 0.449219 1 1 1 h 1 v 8 c 0 1.65625 1.34375 3 3 3 h 6 c 1.65625 0 3 -1.34375 3 -3 v -8 h 1 c 0.550781 0 1 -0.449219 1 -1 s -0.449219 -1 -1 -1 h -3.023438 v -0.5 c 0 -1.378906 -1.117187 -2.5 -2.5 -2.5 z m 0 2 h 2.976562 c 0.289063 0 0.5 0.210938 0.5 0.5 v 0.5 h -3.976562 v -0.5 c 0 -0.289062 0.210938 -0.5 0.5 -0.5 z m -2.5 3 h 8 v 8 c 0 0.5625 -0.4375 1 -1 1 h -6 c -0.5625 0 -1 -0.4375 -1 -1 z m 0 0"/>
|
||||||
|
<path d="m 7 7 v 5 c 0 0.277344 -0.222656 0.5 -0.5 0.5 s -0.5 -0.222656 -0.5 -0.5 v -5 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 s 0.5 0.222656 0.5 0.5 z m 0 0"/>
|
||||||
|
<path d="m 10 7 v 5 c 0 0.277344 -0.222656 0.5 -0.5 0.5 s -0.5 -0.222656 -0.5 -0.5 v -5 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 s 0.5 0.222656 0.5 0.5 z m 0 0"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1009 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m 7.90625 0.09375 c -0.527344 -0.0273438 -1.039062 0.28125 -1.4375 0.96875 l -6.25 11.59375 c -0.535156 0.964844 0.046875 2.34375 1.09375 2.34375 h 13.15625 c 0.980469 0 1.902344 -1.160156 1.21875 -2.34375 l -6.3125 -11.53125 c -0.398438 -0.644531 -0.941406 -1.003906 -1.46875 -1.03125 z m 1.09375 3.90625 v 5 c 0.007812 0.527344 -0.472656 1 -1 1 s -1.007812 -0.472656 -1 -1 v -5 z m -1 7 c 0.550781 0 1 0.449219 1 1 s -0.449219 1 -1 1 s -1 -0.449219 -1 -1 s 0.449219 -1 1 -1 z m 0 0" fill="#2e3436"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 649 B |
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="#2e3436">
|
||||||
|
<path d="m 15 10 c 0.265625 0 0.519531 0.105469 0.707031 0.292969 c 0.390625 0.390625 0.390625 1.023437 0 1.414062 l -1.292969 1.292969 l 1.292969 1.292969 c 0.390625 0.390625 0.390625 1.023437 0 1.414062 s -1.023437 0.390625 -1.414062 0 l -1.292969 -1.292969 l -1.292969 1.292969 c -0.390625 0.390625 -1.023437 0.390625 -1.414062 0 s -0.390625 -1.023437 0 -1.414062 l 1.292969 -1.292969 l -1.292969 -1.292969 c -0.390625 -0.390625 -0.390625 -1.023437 0 -1.414062 c 0.1875 -0.1875 0.441406 -0.292969 0.707031 -0.292969 s 0.519531 0.105469 0.707031 0.292969 l 1.292969 1.292969 l 1.292969 -1.292969 c 0.1875 -0.1875 0.441406 -0.292969 0.707031 -0.292969 z m 0 0"/>
|
||||||
|
<path d="m 6 0 c -0.554688 0 -1 0.445312 -1 1 v 3 c 0 0.554688 0.445312 1 1 1 h 1 v 2 h -7 v 2 h 2 v 2 h -1 c -0.554688 0 -1 0.445312 -1 1 v 3 c 0 0.554688 0.445312 1 1 1 h 4 c 0.554688 0 1 -0.445312 1 -1 v -3 c 0 -0.554688 -0.445312 -1 -1 -1 h -1 v -2 h 12 v -2 h -7 v -2 h 1 c 0.554688 0 1 -0.445312 1 -1 v -3 c 0 -0.554688 -0.445312 -1 -1 -1 z m 0 0" fill-opacity="0.34902"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -9,5 +9,23 @@
|
|||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/de/feschber/LanMouse/icons">
|
<gresource prefix="/de/feschber/LanMouse/icons">
|
||||||
<file compressed="true" preprocess="xml-stripblanks">de.feschber.LanMouse.svg</file>
|
<file compressed="true" preprocess="xml-stripblanks">de.feschber.LanMouse.svg</file>
|
||||||
|
<!--
|
||||||
|
Bundled Adwaita symbolic icons so the GTK frontend has a complete icon set
|
||||||
|
on platforms (notably macOS) where the Adwaita icon theme is not installed.
|
||||||
|
Registered via IconTheme::add_resource_path("/de/feschber/LanMouse/icons").
|
||||||
|
-->
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/edit-copy-symbolic.svg">icons/scalable/actions/edit-copy-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/edit-delete-symbolic.svg">icons/scalable/actions/edit-delete-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/emblem-ok-symbolic.svg">icons/scalable/actions/emblem-ok-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/list-add-symbolic.svg">icons/scalable/actions/list-add-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/object-rotate-right-symbolic.svg">icons/scalable/actions/object-rotate-right-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/object-select-symbolic.svg">icons/scalable/actions/object-select-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/open-menu-symbolic.svg">icons/scalable/actions/open-menu-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/actions/process-stop-symbolic.svg">icons/scalable/actions/process-stop-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/devices/auth-fingerprint-symbolic.svg">icons/scalable/devices/auth-fingerprint-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/devices/network-wired-symbolic.svg">icons/scalable/devices/network-wired-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/places/user-trash-symbolic.svg">icons/scalable/places/user-trash-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/status/dialog-warning-symbolic.svg">icons/scalable/status/dialog-warning-symbolic.svg</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks" alias="scalable/status/network-wired-disconnected-symbolic.svg">icons/scalable/status/network-wired-disconnected-symbolic.svg</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
<signal name="clicked" handler="handle_capture" swapped="true"/>
|
<signal name="clicked" handler="handle_capture" swapped="true"/>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="circular"/>
|
<class name="pill"/>
|
||||||
<class name="flat"/>
|
<class name="flat"/>
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<signal name="clicked" handler="handle_emulation" swapped="true"/>
|
<signal name="clicked" handler="handle_emulation" swapped="true"/>
|
||||||
<style>
|
<style>
|
||||||
<class name="circular"/>
|
<class name="pill"/>
|
||||||
<class name="flat"/>
|
<class name="flat"/>
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ mod client_row;
|
|||||||
mod fingerprint_window;
|
mod fingerprint_window;
|
||||||
mod key_object;
|
mod key_object;
|
||||||
mod key_row;
|
mod key_row;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
mod macos_privacy;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
mod macos_status_item;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
use std::{env, process, str};
|
use std::{env, process, str};
|
||||||
@@ -47,6 +51,12 @@ pub fn run() -> Result<(), GtkError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn gtk_main() -> glib::ExitCode {
|
fn gtk_main() -> glib::ExitCode {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
configure_macos_bundle_environment();
|
||||||
|
install_macos_gtk_log_filter();
|
||||||
|
}
|
||||||
|
|
||||||
gio::resources_register_include!("lan-mouse.gresource").expect("Failed to register resources.");
|
gio::resources_register_include!("lan-mouse.gresource").expect("Failed to register resources.");
|
||||||
|
|
||||||
let app = Application::builder()
|
let app = Application::builder()
|
||||||
@@ -64,6 +74,64 @@ fn gtk_main() -> glib::ExitCode {
|
|||||||
app.run_with_args(&args)
|
app.run_with_args(&args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn install_macos_gtk_log_filter() {
|
||||||
|
glib::log_set_writer_func(|level, fields| {
|
||||||
|
if level == glib::LogLevel::Warning && is_gtk_theme_parser_warning(fields) {
|
||||||
|
return glib::LogWriterOutput::Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
glib::log_writer_default(level, fields)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn is_gtk_theme_parser_warning(fields: &[glib::LogField<'_>]) -> bool {
|
||||||
|
let mut domain = None;
|
||||||
|
let mut message = None;
|
||||||
|
|
||||||
|
for field in fields {
|
||||||
|
match field.key() {
|
||||||
|
"GLIB_DOMAIN" => domain = field.value_str(),
|
||||||
|
"MESSAGE" => message = field.value_str(),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
domain == Some("Gtk")
|
||||||
|
&& message.is_some_and(|message| message.starts_with("Theme parser warning: gtk.css:"))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn configure_macos_bundle_environment() {
|
||||||
|
let Ok(exe) = env::current_exe() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(contents) = exe
|
||||||
|
.parent()
|
||||||
|
.and_then(|dir| dir.parent())
|
||||||
|
.map(std::path::Path::to_owned)
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let share = contents.join("Resources").join("share");
|
||||||
|
if !share.exists() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let schemas = share.join("glib-2.0").join("schemas");
|
||||||
|
if schemas.exists() {
|
||||||
|
env::set_var("GSETTINGS_SCHEMA_DIR", schemas);
|
||||||
|
}
|
||||||
|
|
||||||
|
env::set_var("XDG_DATA_DIRS", &share);
|
||||||
|
env::set_var(
|
||||||
|
"GTK_DATA_PREFIX",
|
||||||
|
contents.join("Resources").to_string_lossy().as_ref(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn load_icons() {
|
fn load_icons() {
|
||||||
let display = &Display::default().expect("Could not connect to a display.");
|
let display = &Display::default().expect("Could not connect to a display.");
|
||||||
let icon_theme = IconTheme::for_display(display);
|
let icon_theme = IconTheme::for_display(display);
|
||||||
@@ -123,6 +191,41 @@ fn build_ui(app: &Application) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let window = Window::new(app, frontend_tx);
|
let window = Window::new(app, frontend_tx);
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
window.connect_close_request(|window| {
|
||||||
|
window.set_visible(false);
|
||||||
|
glib::Propagation::Stop
|
||||||
|
});
|
||||||
|
macos_status_item::setup(app, &window);
|
||||||
|
// First-launch TCC prompts. No-op when already granted.
|
||||||
|
macos_privacy::fire_initial_prompts();
|
||||||
|
// Watch the Accessibility grant continuously for the lifetime
|
||||||
|
// of the process. On a grant, swap the warning row into its
|
||||||
|
// "relaunch required" state (the daemon subprocess already
|
||||||
|
// bailed and can't recover without a restart). On a REVOKE,
|
||||||
|
// quit immediately — an active CGEventTap at
|
||||||
|
// HeadInsertEventTap can wedge system input if the process
|
||||||
|
// lingers after losing AX, and forcing the process to exit is
|
||||||
|
// the only bulletproof way to guarantee the kernel tears the
|
||||||
|
// tap down.
|
||||||
|
let window_weak = window.downgrade();
|
||||||
|
let app_weak = app.downgrade();
|
||||||
|
macos_privacy::watch_accessibility_state(move |change| match change {
|
||||||
|
macos_privacy::AccessibilityChange::Granted => {
|
||||||
|
if let Some(window) = window_weak.upgrade() {
|
||||||
|
window.present();
|
||||||
|
window.refresh_capture_emulation_status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
macos_privacy::AccessibilityChange::Revoked => {
|
||||||
|
log::warn!("Accessibility revoked — quitting to avoid wedging system input");
|
||||||
|
if let Some(app) = app_weak.upgrade() {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
glib::spawn_future_local(clone!(
|
glib::spawn_future_local(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
@@ -171,5 +274,18 @@ fn build_ui(app: &Application) {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
window.present();
|
window.present();
|
||||||
|
|
||||||
|
// On macOS, default to presenting the main window on every launch
|
||||||
|
// so the user gets a visible confirmation that the app is running
|
||||||
|
// — including the post-grant relaunch and normal Dock/Finder/`open`
|
||||||
|
// launches. Opt out by setting `LAN_MOUSE_HIDDEN=1` in the
|
||||||
|
// environment (useful for a LaunchAgent / login-item configuration
|
||||||
|
// where the user wants the app to come up quietly into the menu
|
||||||
|
// bar only, with no window on boot).
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
if env::var_os("LAN_MOUSE_HIDDEN").is_none() {
|
||||||
|
window.present();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
256
lan-mouse-gtk/src/macos_privacy.rs
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
//! Tiny macOS Privacy-pane helpers used by the GUI.
|
||||||
|
//!
|
||||||
|
//! On macOS 13+, the Accessibility grant transitively confers the
|
||||||
|
//! listen-only event-tap privilege that Input Monitoring gates and the
|
||||||
|
//! synthesize-event privilege that Post Event gates, and the bundle
|
||||||
|
//! typically isn't even listed in those separate panes. So the single
|
||||||
|
//! user-facing action for any missing-capture or missing-emulation
|
||||||
|
//! scenario is "re-toggle Accessibility" — we don't route elsewhere.
|
||||||
|
|
||||||
|
use std::ffi::{c_uchar, c_void};
|
||||||
|
use std::process::Command;
|
||||||
|
use std::sync::Once;
|
||||||
|
|
||||||
|
use gtk::glib;
|
||||||
|
|
||||||
|
// Apple declares `AXIsProcessTrusted` as returning `Boolean` (`unsigned char`),
|
||||||
|
// NOT C's `bool`. Rust's `bool` has a strict bit pattern (0 or 1) so binding
|
||||||
|
// a `Boolean`-returning function as `-> bool` is technically UB if Apple ever
|
||||||
|
// returns a non-canonical true value. Keep these as `c_uchar` and normalize.
|
||||||
|
#[link(name = "ApplicationServices", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
fn AXIsProcessTrusted() -> c_uchar;
|
||||||
|
fn AXIsProcessTrustedWithOptions(options: *const c_void) -> c_uchar;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "CoreFoundation", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
static kCFAllocatorDefault: *const c_void;
|
||||||
|
static kCFTypeDictionaryKeyCallBacks: *const c_void;
|
||||||
|
static kCFTypeDictionaryValueCallBacks: *const c_void;
|
||||||
|
static kCFBooleanTrue: *const c_void;
|
||||||
|
fn CFDictionaryCreate(
|
||||||
|
allocator: *const c_void,
|
||||||
|
keys: *const *const c_void,
|
||||||
|
values: *const *const c_void,
|
||||||
|
num: isize,
|
||||||
|
key_callbacks: *const c_void,
|
||||||
|
value_callbacks: *const c_void,
|
||||||
|
) -> *const c_void;
|
||||||
|
fn CFRelease(cf: *const c_void);
|
||||||
|
}
|
||||||
|
|
||||||
|
// kAXTrustedCheckOptionPrompt is a CFStringRef exported from ApplicationServices.
|
||||||
|
#[link(name = "ApplicationServices", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
static kAXTrustedCheckOptionPrompt: *const c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "CoreGraphics", kind = "framework")]
|
||||||
|
extern "C" {
|
||||||
|
fn CGRequestListenEventAccess() -> c_uchar;
|
||||||
|
fn CGRequestPostEventAccess() -> c_uchar;
|
||||||
|
|
||||||
|
// CFMachPortRef CGEventTapCreate(
|
||||||
|
// CGEventTapLocation tap, CGEventTapPlacement place,
|
||||||
|
// CGEventTapOptions options, CGEventMask eventsOfInterest,
|
||||||
|
// CGEventTapCallBack callback, void *userInfo);
|
||||||
|
fn CGEventTapCreate(
|
||||||
|
tap: u32,
|
||||||
|
place: u32,
|
||||||
|
options: u32,
|
||||||
|
events_of_interest: u64,
|
||||||
|
callback: *const c_void,
|
||||||
|
user_info: *const c_void,
|
||||||
|
) -> *const c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn accessibility_granted() -> bool {
|
||||||
|
let raw = unsafe { AXIsProcessTrusted() };
|
||||||
|
log::debug!("AXIsProcessTrusted() = {raw}");
|
||||||
|
raw != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum AccessibilityChange {
|
||||||
|
/// AX was missing at startup and the user has now granted it.
|
||||||
|
/// Capture/emulation still need a relaunch to take effect, since
|
||||||
|
/// the daemon subprocess already bailed.
|
||||||
|
Granted,
|
||||||
|
/// AX was granted and the user has now revoked it. Quit immediately
|
||||||
|
/// — leaving the process alive with an active CGEventTap at
|
||||||
|
/// HeadInsertEventTap can wedge system input (clicks/keys silently
|
||||||
|
/// consumed) until the process dies. See
|
||||||
|
/// macos-cgeventtap-drop-fallthrough-tcc-revoke skill for the
|
||||||
|
/// underlying event-tap-disable footgun.
|
||||||
|
Revoked,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Poll for Accessibility grant/revoke transitions. Starts a 1-second
|
||||||
|
/// GLib timer that fires `on_change` every time `AXIsProcessTrusted()`
|
||||||
|
/// flips, and keeps running for the lifetime of the process.
|
||||||
|
///
|
||||||
|
/// We rely on polling rather than AXObserver because the AX notification
|
||||||
|
/// API requires a trusted process to subscribe — the precondition we
|
||||||
|
/// can't assume. This runs on the GTK main thread (via
|
||||||
|
/// `timeout_add_seconds_local`).
|
||||||
|
pub fn watch_accessibility_state<F>(mut on_change: F)
|
||||||
|
where
|
||||||
|
F: FnMut(AccessibilityChange) + 'static,
|
||||||
|
{
|
||||||
|
let mut last = accessibility_granted();
|
||||||
|
log::info!("watching Accessibility state (initial = {last})");
|
||||||
|
glib::timeout_add_seconds_local(1, move || {
|
||||||
|
let current = accessibility_granted();
|
||||||
|
if current != last {
|
||||||
|
log::info!("Accessibility state flip: {last} -> {current}");
|
||||||
|
on_change(if current {
|
||||||
|
AccessibilityChange::Granted
|
||||||
|
} else {
|
||||||
|
AccessibilityChange::Revoked
|
||||||
|
});
|
||||||
|
last = current;
|
||||||
|
}
|
||||||
|
glib::ControlFlow::Continue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn open_accessibility_settings() {
|
||||||
|
open_url("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spawn a fresh instance of the current `.app` bundle via Launch Services
|
||||||
|
/// after a 1-second delay, so the new instance starts *after* the current
|
||||||
|
/// process has exited — otherwise Launch Services reactivates the existing
|
||||||
|
/// process instead of launching a fresh one, and the stale IPC socket
|
||||||
|
/// would block the new daemon subprocess. The caller is responsible for
|
||||||
|
/// quitting the current process (e.g. `Application::quit()`) after this.
|
||||||
|
pub fn relaunch_bundle() {
|
||||||
|
// Resolve the .app bundle path from the current executable: it lives
|
||||||
|
// at <bundle>/Contents/MacOS/lan-mouse, so three parents up is the
|
||||||
|
// bundle root we hand to `open`.
|
||||||
|
let Ok(exe) = std::env::current_exe() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(bundle) = exe
|
||||||
|
.parent()
|
||||||
|
.and_then(std::path::Path::parent)
|
||||||
|
.and_then(std::path::Path::parent)
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Trailing `&` backgrounds the sleep+open so our shell call returns
|
||||||
|
// immediately; the spawned shell is adopted by launchd once we exit.
|
||||||
|
let cmd = format!("(sleep 1 && open {bundle:?}) &");
|
||||||
|
let _ = Command::new("sh").arg("-c").arg(cmd).spawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Make sure the app appears in System Settings → Privacy → Input Monitoring.
|
||||||
|
///
|
||||||
|
/// `CGRequestListenEventAccess()` is *supposed* to register the app in the
|
||||||
|
/// list (and prompt) on first call, but in practice — particularly after a
|
||||||
|
/// `tccutil reset ListenEvent <bundle>` — it often silently no-ops and the
|
||||||
|
/// app never gets added. The reliable way to force registration is to
|
||||||
|
/// attempt a protected action: create a `CGEventTap`. If permission is
|
||||||
|
/// missing the call returns null, but the attempt itself causes TCC to add
|
||||||
|
/// the bundle to the Input Monitoring pane so the user can toggle it on.
|
||||||
|
/// If permission already exists the tap is created successfully, and we
|
||||||
|
/// tear it down immediately so it doesn't intercept events.
|
||||||
|
unsafe fn ensure_listed_in_input_monitoring() {
|
||||||
|
let req = CGRequestListenEventAccess();
|
||||||
|
log::debug!("CGRequestListenEventAccess() = {req}");
|
||||||
|
let cb = input_monitoring_noop_tap_callback as *const c_void;
|
||||||
|
// Use kCGSessionEventTap (1), NOT kCGHIDEventTap (0). The HID tap sits
|
||||||
|
// below window-server input and requires Accessibility in addition to
|
||||||
|
// Input Monitoring, so attempting it when Accessibility isn't granted
|
||||||
|
// surfaces an Accessibility prompt as a side effect — which is confusing
|
||||||
|
// on top of the real Accessibility prompt we already fire explicitly.
|
||||||
|
// The session tap requires only Input Monitoring, so its failure is a
|
||||||
|
// clean "Input Monitoring missing" signal that TCC uses to list the
|
||||||
|
// bundle under the Input Monitoring pane.
|
||||||
|
// kCGHeadInsertEventTap = 0, kCGEventTapOptionListenOnly = 1,
|
||||||
|
// mask kCGEventKeyDown = 1 << 10.
|
||||||
|
let tap = CGEventTapCreate(1, 0, 1, 1 << 10, cb, std::ptr::null());
|
||||||
|
log::debug!("CGEventTapCreate(kCGSessionEventTap) -> {tap:?}");
|
||||||
|
if !tap.is_null() {
|
||||||
|
CFRelease(tap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" fn input_monitoring_noop_tap_callback(
|
||||||
|
_proxy: *const c_void,
|
||||||
|
_ty: u32,
|
||||||
|
event: *const c_void,
|
||||||
|
_refcon: *const c_void,
|
||||||
|
) -> *const c_void {
|
||||||
|
// Pass through unchanged. This tap is never added to a run loop, so
|
||||||
|
// in practice the callback never fires — it exists only so the tap
|
||||||
|
// can be created (and the attempt is what forces TCC registration).
|
||||||
|
event
|
||||||
|
}
|
||||||
|
|
||||||
|
fn open_url(url: &str) {
|
||||||
|
if let Err(e) = Command::new("open").arg(url).spawn() {
|
||||||
|
log::warn!("failed to open {url}: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One-shot, at GUI startup: if a permission is missing, fire the system
|
||||||
|
/// prompt. This is where the familiar first-launch "Lan Mouse.app would
|
||||||
|
/// like to control this computer" alert comes from. Subsequent clicks on
|
||||||
|
/// the Reenable button use URL-scheme navigation instead, so we never
|
||||||
|
/// double up alerts on retries.
|
||||||
|
///
|
||||||
|
/// Guarded with a `Once` because GApplication::activate can fire more
|
||||||
|
/// than once in a process (reactivation, window presentation) and we
|
||||||
|
/// must not re-pop the TCC alert on each activation — that looks like a
|
||||||
|
/// bug to the user.
|
||||||
|
pub fn fire_initial_prompts() {
|
||||||
|
static FIRED: Once = Once::new();
|
||||||
|
FIRED.call_once(fire_initial_prompts_inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fire_initial_prompts_inner() {
|
||||||
|
if !accessibility_granted() {
|
||||||
|
// When Accessibility isn't granted yet, ONLY fire the Accessibility
|
||||||
|
// prompt. Do NOT also try to register Input Monitoring or Post Event
|
||||||
|
// — those paths have been observed to surface a second Accessibility
|
||||||
|
// dialog on top of the one we fire explicitly (Post Event is part of
|
||||||
|
// the Accessibility category on modern macOS, and CGEventTap attempts
|
||||||
|
// can bail on Accessibility before they reach the Input Monitoring
|
||||||
|
// check). Once the user grants Accessibility and relaunches, this
|
||||||
|
// branch is skipped and we register the other grants cleanly below.
|
||||||
|
log::info!("firing first-launch Accessibility prompt");
|
||||||
|
unsafe {
|
||||||
|
let key = kAXTrustedCheckOptionPrompt;
|
||||||
|
let value = kCFBooleanTrue;
|
||||||
|
let options = CFDictionaryCreate(
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
&key as *const _,
|
||||||
|
&value as *const _,
|
||||||
|
1,
|
||||||
|
kCFTypeDictionaryKeyCallBacks,
|
||||||
|
kCFTypeDictionaryValueCallBacks,
|
||||||
|
);
|
||||||
|
AXIsProcessTrustedWithOptions(options);
|
||||||
|
CFRelease(options);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Accessibility is granted. Attempt Input Monitoring registration
|
||||||
|
// unconditionally — even if preflight returns true — so the bundle gets
|
||||||
|
// listed in System Settings under its own identity (otherwise launches
|
||||||
|
// from a parent process that already has Input Monitoring, e.g. Terminal,
|
||||||
|
// inherit the grant but the bundle is never listed for the user to
|
||||||
|
// toggle persistently).
|
||||||
|
log::info!("ensuring Lan Mouse is listed under Input Monitoring");
|
||||||
|
unsafe {
|
||||||
|
ensure_listed_in_input_monitoring();
|
||||||
|
}
|
||||||
|
// Same for Post Event: now that Accessibility is present, this call is
|
||||||
|
// safe — it won't surface the generic Accessibility prompt.
|
||||||
|
log::info!("ensuring Lan Mouse is listed under Accessibility > Post Event");
|
||||||
|
unsafe {
|
||||||
|
CGRequestPostEventAccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
346
lan-mouse-gtk/src/macos_status_item.rs
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
#![allow(clashing_extern_declarations)]
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
cell::RefCell,
|
||||||
|
ffi::{CStr, CString, c_char, c_double, c_uint, c_void},
|
||||||
|
sync::OnceLock,
|
||||||
|
};
|
||||||
|
|
||||||
|
use adw::prelude::*;
|
||||||
|
use gtk::{gio, glib};
|
||||||
|
|
||||||
|
use crate::window::Window;
|
||||||
|
|
||||||
|
type Id = *mut c_void;
|
||||||
|
type Class = *mut c_void;
|
||||||
|
type Sel = *mut c_void;
|
||||||
|
type Bool = i8;
|
||||||
|
|
||||||
|
struct StatusItem {
|
||||||
|
app: glib::WeakRef<adw::Application>,
|
||||||
|
window: glib::WeakRef<Window>,
|
||||||
|
_hold: gio::ApplicationHoldGuard,
|
||||||
|
_delegate: Id,
|
||||||
|
_status_item: Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_local! {
|
||||||
|
static STATUS_ITEM: RefCell<Option<StatusItem>> = const { RefCell::new(None) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setup(app: &adw::Application, window: &Window) {
|
||||||
|
log::debug!("macos_status_item::setup entered");
|
||||||
|
STATUS_ITEM.with(|item| {
|
||||||
|
let already_initialized = item.borrow().is_some();
|
||||||
|
if already_initialized {
|
||||||
|
let mut cell = item.borrow_mut();
|
||||||
|
if let Some(existing) = cell.as_mut() {
|
||||||
|
existing.app.set(Some(app));
|
||||||
|
existing.window.set(Some(window));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let hold = app.hold();
|
||||||
|
|
||||||
|
let ns_app = msg_send_id(class(c"NSApplication"), sel(c"sharedApplication"));
|
||||||
|
assert!(
|
||||||
|
!ns_app.is_null(),
|
||||||
|
"NSApplication sharedApplication returned null"
|
||||||
|
);
|
||||||
|
msg_send_bool_usize(ns_app, sel(c"setActivationPolicy:"), 1);
|
||||||
|
|
||||||
|
let delegate = new_delegate();
|
||||||
|
let menu = menu(&[
|
||||||
|
menu_item(c"Open Lan Mouse", c"showLanMouse:"),
|
||||||
|
separator_item(),
|
||||||
|
menu_item(c"Quit Lan Mouse", c"quitLanMouse:"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
let status_bar = msg_send_id(class(c"NSStatusBar"), sel(c"systemStatusBar"));
|
||||||
|
assert!(
|
||||||
|
!status_bar.is_null(),
|
||||||
|
"NSStatusBar systemStatusBar returned null"
|
||||||
|
);
|
||||||
|
let status_item = msg_send_id_f64(status_bar, sel(c"statusItemWithLength:"), -1.0);
|
||||||
|
assert!(!status_item.is_null(), "statusItemWithLength returned null");
|
||||||
|
// Retain so the status item survives autorelease pool drain.
|
||||||
|
let status_item = msg_send_id(status_item, sel(c"retain"));
|
||||||
|
|
||||||
|
let button = msg_send_id(status_item, sel(c"button"));
|
||||||
|
assert!(!button.is_null(), "NSStatusItem.button was null");
|
||||||
|
set_button_image(button);
|
||||||
|
msg_send_void_id(button, sel(c"setToolTip:"), nsstring(c"Lan Mouse"));
|
||||||
|
msg_send_void_id(status_item, sel(c"setMenu:"), menu);
|
||||||
|
|
||||||
|
for item in menu_items(menu) {
|
||||||
|
msg_send_void_id(item, sel(c"setTarget:"), delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
install_reopen_handler(delegate);
|
||||||
|
|
||||||
|
log::debug!("macos_status_item ready at {status_item:p}");
|
||||||
|
|
||||||
|
item.replace(Some(StatusItem {
|
||||||
|
app: app.downgrade(),
|
||||||
|
window: window.downgrade(),
|
||||||
|
_hold: hold,
|
||||||
|
_delegate: delegate,
|
||||||
|
_status_item: status_item,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prefer a pre-rendered template PNG (black silhouette with alpha) so macOS
|
||||||
|
// auto-tints the glyph to match the menu bar in light and dark modes.
|
||||||
|
// Falls back to the full-color icns, then to "LM" text.
|
||||||
|
unsafe fn set_button_image(button: Id) {
|
||||||
|
if let Some(image) = load_menubar_template() {
|
||||||
|
msg_send_void_bool(image, sel(c"setTemplate:"), 1);
|
||||||
|
msg_send_void_id(button, sel(c"setImage:"), image);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if let Some(image) = load_app_icon() {
|
||||||
|
msg_send_void_id(button, sel(c"setImage:"), image);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log::warn!("no menu bar image available; falling back to text title");
|
||||||
|
msg_send_void_id(button, sel(c"setTitle:"), nsstring(c"LM"));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn load_menubar_template() -> Option<Id> {
|
||||||
|
load_resource_image(c"menubar-template", c"png", MENUBAR_ICON_SIZE)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn load_app_icon() -> Option<Id> {
|
||||||
|
load_resource_image(c"icon", c"icns", MENUBAR_ICON_SIZE)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn load_resource_image(name: &CStr, ext: &CStr, size_pt: c_double) -> Option<Id> {
|
||||||
|
let bundle = msg_send_id(class(c"NSBundle"), sel(c"mainBundle"));
|
||||||
|
if bundle.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let path = msg_send_id_id_id(
|
||||||
|
bundle,
|
||||||
|
sel(c"pathForResource:ofType:"),
|
||||||
|
nsstring(name),
|
||||||
|
nsstring(ext),
|
||||||
|
);
|
||||||
|
if path.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let image = msg_send_id_id(
|
||||||
|
msg_send_id(class(c"NSImage"), sel(c"alloc")),
|
||||||
|
sel(c"initWithContentsOfFile:"),
|
||||||
|
path,
|
||||||
|
);
|
||||||
|
if image.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
// Render at menu bar height; 22pt is the full status bar icon height.
|
||||||
|
msg_send_void_size(image, sel(c"setSize:"), size_pt, size_pt);
|
||||||
|
Some(image)
|
||||||
|
}
|
||||||
|
|
||||||
|
const MENUBAR_ICON_SIZE: c_double = 22.0;
|
||||||
|
|
||||||
|
unsafe fn menu(items: &[Id]) -> Id {
|
||||||
|
let menu = msg_send_id(msg_send_id(class(c"NSMenu"), sel(c"alloc")), sel(c"init"));
|
||||||
|
for item in items {
|
||||||
|
msg_send_void_id(menu, sel(c"addItem:"), *item);
|
||||||
|
}
|
||||||
|
menu
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn menu_item(title: &CStr, action: &CStr) -> Id {
|
||||||
|
msg_send_id_id_sel_id(
|
||||||
|
msg_send_id(class(c"NSMenuItem"), sel(c"alloc")),
|
||||||
|
sel(c"initWithTitle:action:keyEquivalent:"),
|
||||||
|
nsstring(title),
|
||||||
|
sel(action),
|
||||||
|
nsstring(c""),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn separator_item() -> Id {
|
||||||
|
msg_send_id(class(c"NSMenuItem"), sel(c"separatorItem"))
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn menu_items(menu: Id) -> Vec<Id> {
|
||||||
|
let count = msg_send_usize(menu, sel(c"numberOfItems"));
|
||||||
|
(0..count)
|
||||||
|
.map(|idx| msg_send_id_usize(menu, sel(c"itemAtIndex:"), idx))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn new_delegate() -> Id {
|
||||||
|
let class = delegate_class();
|
||||||
|
msg_send_id(msg_send_id(class, sel(c"alloc")), sel(c"init"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn delegate_class() -> Class {
|
||||||
|
static CLASS: OnceLock<usize> = OnceLock::new();
|
||||||
|
|
||||||
|
*CLASS.get_or_init(|| unsafe {
|
||||||
|
let superclass = class(c"NSObject");
|
||||||
|
let class_name = CString::new("LanMouseStatusItemDelegate").unwrap();
|
||||||
|
let class = objc_allocateClassPair(superclass, class_name.as_ptr(), 0);
|
||||||
|
assert!(!class.is_null(), "failed to allocate status item delegate");
|
||||||
|
|
||||||
|
class_addMethod(
|
||||||
|
class,
|
||||||
|
sel(c"showLanMouse:"),
|
||||||
|
show_lan_mouse as *const c_void,
|
||||||
|
c"v@:@".as_ptr(),
|
||||||
|
);
|
||||||
|
class_addMethod(
|
||||||
|
class,
|
||||||
|
sel(c"quitLanMouse:"),
|
||||||
|
quit_lan_mouse as *const c_void,
|
||||||
|
c"v@:@".as_ptr(),
|
||||||
|
);
|
||||||
|
// kAEReopenApplication handler — fires when the user re-launches
|
||||||
|
// the .app while it's already running (Finder, `open`, Dock).
|
||||||
|
class_addMethod(
|
||||||
|
class,
|
||||||
|
sel(c"handleReopenEvent:withReplyEvent:"),
|
||||||
|
handle_reopen_event as *const c_void,
|
||||||
|
c"v@:@@".as_ptr(),
|
||||||
|
);
|
||||||
|
objc_registerClassPair(class);
|
||||||
|
class as usize
|
||||||
|
}) as Class
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" fn show_lan_mouse(_this: Id, _cmd: Sel, _sender: Id) {
|
||||||
|
present_window();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" fn handle_reopen_event(_this: Id, _cmd: Sel, _event: Id, _reply: Id) {
|
||||||
|
log::debug!("kAEReopenApplication received — presenting main window");
|
||||||
|
present_window();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn present_window() {
|
||||||
|
STATUS_ITEM.with(|item| {
|
||||||
|
let item = item.borrow();
|
||||||
|
let Some(item) = item.as_ref() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if let Some(window) = item.window.upgrade() {
|
||||||
|
window.present();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let ns_app = msg_send_id(class(c"NSApplication"), sel(c"sharedApplication"));
|
||||||
|
msg_send_void_bool(ns_app, sel(c"activateIgnoringOtherApps:"), 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the status-item delegate as the handler for the
|
||||||
|
// kAEReopenApplication Apple Event ('aevt'/'rapp'). NSApplication
|
||||||
|
// installs a default handler at -finishLaunching that just delegates to
|
||||||
|
// applicationShouldHandleReopen:hasVisibleWindows: — which is a no-op
|
||||||
|
// here because GApplication owns NSApp's delegate. Replacing it lets us
|
||||||
|
// re-present the window when the user double-clicks the .app while
|
||||||
|
// we're already running.
|
||||||
|
unsafe fn install_reopen_handler(delegate: Id) {
|
||||||
|
const K_CORE_EVENT_CLASS: c_uint = 0x6165_7674; // 'aevt'
|
||||||
|
const K_AE_REOPEN_APPLICATION: c_uint = 0x7261_7070; // 'rapp'
|
||||||
|
|
||||||
|
let manager = msg_send_id(
|
||||||
|
class(c"NSAppleEventManager"),
|
||||||
|
sel(c"sharedAppleEventManager"),
|
||||||
|
);
|
||||||
|
if manager.is_null() {
|
||||||
|
log::warn!("NSAppleEventManager unavailable; re-launch will not re-open window");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg_send_void_id_sel_u32_u32(
|
||||||
|
manager,
|
||||||
|
sel(c"setEventHandler:andSelector:forEventClass:andEventID:"),
|
||||||
|
delegate,
|
||||||
|
sel(c"handleReopenEvent:withReplyEvent:"),
|
||||||
|
K_CORE_EVENT_CLASS,
|
||||||
|
K_AE_REOPEN_APPLICATION,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" fn quit_lan_mouse(_this: Id, _cmd: Sel, _sender: Id) {
|
||||||
|
STATUS_ITEM.with(|item| {
|
||||||
|
if let Some(app) = item.borrow().as_ref().and_then(|item| item.app.upgrade()) {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn class(name: &CStr) -> Class {
|
||||||
|
let class = objc_getClass(name.as_ptr());
|
||||||
|
assert!(!class.is_null(), "missing Objective-C class {name:?}");
|
||||||
|
class
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn sel(name: &CStr) -> Sel {
|
||||||
|
sel_registerName(name.as_ptr())
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn nsstring(value: &CStr) -> Id {
|
||||||
|
msg_send_id_ptr(
|
||||||
|
class(c"NSString"),
|
||||||
|
sel(c"stringWithUTF8String:"),
|
||||||
|
value.as_ptr(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "objc")]
|
||||||
|
extern "C" {
|
||||||
|
fn objc_allocateClassPair(superclass: Class, name: *const c_char, extra_bytes: usize) -> Class;
|
||||||
|
fn objc_getClass(name: *const c_char) -> Class;
|
||||||
|
fn objc_registerClassPair(class: Class);
|
||||||
|
fn sel_registerName(name: *const c_char) -> Sel;
|
||||||
|
fn class_addMethod(class: Class, name: Sel, imp: *const c_void, types: *const c_char) -> Bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "AppKit", kind = "framework")]
|
||||||
|
extern "C" {}
|
||||||
|
|
||||||
|
#[link(name = "objc")]
|
||||||
|
extern "C" {
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id(receiver: Id, selector: Sel) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id_f64(receiver: Id, selector: Sel, value: c_double) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id_id_sel_id(receiver: Id, selector: Sel, a: Id, b: Sel, c: Id) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id_id_id(receiver: Id, selector: Sel, a: Id, b: Id) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id_id(receiver: Id, selector: Sel, a: Id) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_void_size(receiver: Id, selector: Sel, width: c_double, height: c_double);
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id_ptr(receiver: Id, selector: Sel, value: *const c_char) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_id_usize(receiver: Id, selector: Sel, value: usize) -> Id;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_usize(receiver: Id, selector: Sel) -> usize;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_void_bool(receiver: Id, selector: Sel, value: Bool);
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_void_id(receiver: Id, selector: Sel, value: Id);
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_bool_usize(receiver: Id, selector: Sel, value: usize) -> Bool;
|
||||||
|
#[link_name = "objc_msgSend"]
|
||||||
|
fn msg_send_void_id_sel_u32_u32(
|
||||||
|
receiver: Id,
|
||||||
|
selector: Sel,
|
||||||
|
a: Id,
|
||||||
|
b: Sel,
|
||||||
|
c: c_uint,
|
||||||
|
d: c_uint,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -22,6 +22,17 @@ use crate::{
|
|||||||
|
|
||||||
use super::{client_object::ClientObject, client_row::ClientRow};
|
use super::{client_object::ClientObject, client_row::ClientRow};
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn set_button_content_label(button: >k::Button, label: &str) {
|
||||||
|
// The Reenable/Grant/Relaunch button wraps its icon+label in an
|
||||||
|
// AdwButtonContent (see window.ui). Walk into it and swap the label
|
||||||
|
// rather than GtkButton::set_label, which would replace the content
|
||||||
|
// widget and drop the icon.
|
||||||
|
if let Some(content) = button.child().and_downcast::<adw::ButtonContent>() {
|
||||||
|
content.set_label(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Window(ObjectSubclass<imp::Window>)
|
pub struct Window(ObjectSubclass<imp::Window>)
|
||||||
@extends adw::ApplicationWindow, gtk::Window, gtk::Widget,
|
@extends adw::ApplicationWindow, gtk::Window, gtk::Widget,
|
||||||
@@ -432,6 +443,10 @@ impl Window {
|
|||||||
|
|
||||||
pub(super) fn show_toast(&self, msg: &str) {
|
pub(super) fn show_toast(&self, msg: &str) {
|
||||||
let toast = adw::Toast::new(msg);
|
let toast = adw::Toast::new(msg);
|
||||||
|
self.add_toast(toast);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn add_toast(&self, toast: adw::Toast) {
|
||||||
let toast_overlay = &self.imp().toast_overlay;
|
let toast_overlay = &self.imp().toast_overlay;
|
||||||
toast_overlay.add_toast(toast);
|
toast_overlay.add_toast(toast);
|
||||||
}
|
}
|
||||||
@@ -446,14 +461,61 @@ impl Window {
|
|||||||
self.update_capture_emulation_status();
|
self.update_capture_emulation_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub(super) fn refresh_capture_emulation_status(&self) {
|
||||||
|
self.update_capture_emulation_status();
|
||||||
|
}
|
||||||
|
|
||||||
fn update_capture_emulation_status(&self) {
|
fn update_capture_emulation_status(&self) {
|
||||||
let capture = self.imp().capture_active.get();
|
let capture = self.imp().capture_active.get();
|
||||||
let emulation = self.imp().emulation_active.get();
|
let emulation = self.imp().emulation_active.get();
|
||||||
self.imp().capture_status_row.set_visible(!capture);
|
|
||||||
self.imp().emulation_status_row.set_visible(!emulation);
|
#[cfg(target_os = "macos")]
|
||||||
self.imp()
|
{
|
||||||
.capture_emulation_group
|
// On macOS, capture and emulation share the same TCC gate
|
||||||
.set_visible(!capture || !emulation);
|
// (Accessibility). Collapse to a single warning row —
|
||||||
|
// emulation_status_row stays hidden and capture_status_row
|
||||||
|
// doubles as the shared status indicator. Its text and
|
||||||
|
// button mutate based on whether we're waiting for AX or
|
||||||
|
// waiting for the user to relaunch the app.
|
||||||
|
let anything_off = !capture || !emulation;
|
||||||
|
self.imp().emulation_status_row.set_visible(false);
|
||||||
|
self.imp().capture_status_row.set_visible(anything_off);
|
||||||
|
self.imp().capture_emulation_group.set_visible(anything_off);
|
||||||
|
|
||||||
|
if anything_off {
|
||||||
|
self.update_macos_warning_row_text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
self.imp().capture_status_row.set_visible(!capture);
|
||||||
|
self.imp().emulation_status_row.set_visible(!emulation);
|
||||||
|
self.imp()
|
||||||
|
.capture_emulation_group
|
||||||
|
.set_visible(!capture || !emulation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn update_macos_warning_row_text(&self) {
|
||||||
|
let row = &self.imp().capture_status_row;
|
||||||
|
let button = &self.imp().input_capture_button;
|
||||||
|
|
||||||
|
if crate::macos_privacy::accessibility_granted() {
|
||||||
|
// AX granted but capture/emulation still off → the daemon
|
||||||
|
// subprocess bailed at startup and needs a fresh process to
|
||||||
|
// re-initialize with the new grant in place.
|
||||||
|
row.set_title("relaunch required");
|
||||||
|
row.set_subtitle("Accessibility granted — restart to activate capture and emulation");
|
||||||
|
set_button_content_label(button, "Relaunch");
|
||||||
|
} else {
|
||||||
|
// AX missing → send the user to System Settings.
|
||||||
|
row.set_title("input capture is disabled");
|
||||||
|
row.set_subtitle("grant Accessibility permission to enable");
|
||||||
|
set_button_content_label(button, "Grant");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn set_authorized_keys(&self, fingerprints: HashMap<String, String>) {
|
pub(super) fn set_authorized_keys(&self, fingerprints: HashMap<String, String>) {
|
||||||
|
|||||||
@@ -142,11 +142,32 @@ impl Window {
|
|||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn handle_emulation(&self) {
|
fn handle_emulation(&self) {
|
||||||
|
// On macOS the emulation_status_row is hidden — capture_status_row
|
||||||
|
// acts as the shared warning (see update_capture_emulation_status).
|
||||||
|
// This handler still fires for the non-macOS platforms where the
|
||||||
|
// emulation row is distinct.
|
||||||
self.obj().request_emulation();
|
self.obj().request_emulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn handle_capture(&self) {
|
fn handle_capture(&self) {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use crate::macos_privacy;
|
||||||
|
if macos_privacy::accessibility_granted() {
|
||||||
|
// AX granted but the row is still visible => the daemon
|
||||||
|
// subprocess bailed before AX was in place and needs a
|
||||||
|
// fresh process. Quit + relaunch via Launch Services.
|
||||||
|
log::info!("capture row clicked in relaunch-required state");
|
||||||
|
macos_privacy::relaunch_bundle();
|
||||||
|
if let Some(app) = self.obj().application() {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log::info!("capture row clicked in AX-missing state, opening pane");
|
||||||
|
macos_privacy::open_accessibility_settings();
|
||||||
|
}
|
||||||
self.obj().request_capture();
|
self.obj().request_capture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ bundle_path=$(dirname "$(dirname "$(dirname "$exec_path")")")
|
|||||||
# Path to the Frameworks directory
|
# Path to the Frameworks directory
|
||||||
fwks_path="$bundle_path/Contents/Frameworks"
|
fwks_path="$bundle_path/Contents/Frameworks"
|
||||||
mkdir -p "$fwks_path"
|
mkdir -p "$fwks_path"
|
||||||
|
# Path to bundled GTK/GSettings data
|
||||||
|
resources_path="$bundle_path/Contents/Resources"
|
||||||
|
share_path="$resources_path/share"
|
||||||
|
|
||||||
# Copy and fix references for a binary (executable or dylib)
|
# Copy and fix references for a binary (executable or dylib)
|
||||||
#
|
#
|
||||||
@@ -58,6 +61,10 @@ fix_references() {
|
|||||||
libs=$(otool -L "$bin" | awk -v homebrew="$homebrew_path" '$0 ~ homebrew {print $1}')
|
libs=$(otool -L "$bin" | awk -v homebrew="$homebrew_path" '$0 ~ homebrew {print $1}')
|
||||||
|
|
||||||
echo "$libs" | while IFS= read -r old_path; do
|
echo "$libs" | while IFS= read -r old_path; do
|
||||||
|
if [ -z "$old_path" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
local base_name="$(basename "$old_path")"
|
local base_name="$(basename "$old_path")"
|
||||||
local dest="$fwks_path/$base_name"
|
local dest="$fwks_path/$base_name"
|
||||||
|
|
||||||
@@ -81,6 +88,42 @@ fix_references() {
|
|||||||
|
|
||||||
fix_references "$exec_path"
|
fix_references "$exec_path"
|
||||||
|
|
||||||
|
copy_runtime_data() {
|
||||||
|
mkdir -p "$share_path"
|
||||||
|
|
||||||
|
if [ -d "$homebrew_path/share/glib-2.0/schemas" ]; then
|
||||||
|
mkdir -p "$share_path/glib-2.0"
|
||||||
|
rm -rf "$share_path/glib-2.0/schemas"
|
||||||
|
cp -RL "$homebrew_path/share/glib-2.0/schemas" "$share_path/glib-2.0/schemas"
|
||||||
|
if command -v glib-compile-schemas >/dev/null 2>&1; then
|
||||||
|
glib-compile-schemas "$share_path/glib-2.0/schemas"
|
||||||
|
elif [ -x "$homebrew_path/bin/glib-compile-schemas" ]; then
|
||||||
|
"$homebrew_path/bin/glib-compile-schemas" "$share_path/glib-2.0/schemas"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$homebrew_path/share/gtk-4.0" ]; then
|
||||||
|
rm -rf "$share_path/gtk-4.0"
|
||||||
|
cp -RL "$homebrew_path/share/gtk-4.0" "$share_path/gtk-4.0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$homebrew_path/share/icons/Adwaita" ]; then
|
||||||
|
mkdir -p "$share_path/icons"
|
||||||
|
rm -rf "$share_path/icons/Adwaita"
|
||||||
|
cp -RL "$homebrew_path/share/icons/Adwaita" "$share_path/icons/Adwaita"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_runtime_data
|
||||||
|
|
||||||
|
# cargo-bundle preserves the source path under Contents/Resources (so
|
||||||
|
# `target/menubar-template.png` lands at `Resources/target/...`). Flatten it
|
||||||
|
# so NSBundle pathForResource: finds the file at the Resources root.
|
||||||
|
if [ -f "$resources_path/target/menubar-template.png" ]; then
|
||||||
|
mv "$resources_path/target/menubar-template.png" "$resources_path/menubar-template.png"
|
||||||
|
rmdir "$resources_path/target" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Ensure the main executable has our Frameworks path in its RPATH
|
# Ensure the main executable has our Frameworks path in its RPATH
|
||||||
if ! otool -l "$exec_path" | grep -q "@executable_path/../Frameworks"; then
|
if ! otool -l "$exec_path" | grep -q "@executable_path/../Frameworks"; then
|
||||||
echo "Adding RPATH to $exec_path"
|
echo "Adding RPATH to $exec_path"
|
||||||
|
|||||||
@@ -3,8 +3,15 @@ set -e
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$0: Make a macOS icns file from an SVG with ImageMagick and iconutil.
|
$0: Make a macOS icns file from an SVG with rsvg-convert, ImageMagick and iconutil.
|
||||||
usage: $0 [SVG [ICNS [ICONSET]]
|
|
||||||
|
Follows the Big Sur+ icon template:
|
||||||
|
- 1024x1024 canvas with a rounded-square (squircle) background
|
||||||
|
- Icon artwork scaled to fit inside an 824x824 content area, centered
|
||||||
|
- Transparent padding outside the squircle so the Dock/Finder render it
|
||||||
|
like other first-party macOS apps.
|
||||||
|
|
||||||
|
usage: $0 [SVG [ICNS [ICONSET]]]
|
||||||
|
|
||||||
ARGUMENTS
|
ARGUMENTS
|
||||||
SVG The SVG file to convert
|
SVG The SVG file to convert
|
||||||
@@ -28,15 +35,103 @@ iconset="${3:-./target/icon.iconset}"
|
|||||||
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
mkdir -p "$iconset"
|
workdir="$(dirname "$iconset")/icon-work"
|
||||||
magick "$svg" -background none -resize 1024x1024 "$iconset"/icon_512x512@2x.png
|
rm -rf "$iconset" "$workdir"
|
||||||
magick "$svg" -background none -resize 512x512 "$iconset"/icon_512x512.png
|
mkdir -p "$iconset" "$workdir"
|
||||||
magick "$svg" -background none -resize 256x256 "$iconset"/icon_256x256.png
|
|
||||||
magick "$svg" -background none -resize 128x128 "$iconset"/icon_128x128.png
|
# Big Sur+ macOS icon template proportions (in a 1024 canvas):
|
||||||
magick "$svg" -background none -resize 64x64 "$iconset"/icon_32x32@2x.png
|
# canvas = 1024
|
||||||
magick "$svg" -background none -resize 32x32 "$iconset"/icon_32x32.png
|
# squircle = 824 (the white rounded-square background, inset 100px)
|
||||||
magick "$svg" -background none -resize 16x16 "$iconset"/icon_16x16.png
|
# content = 560 (artwork inside the squircle, with generous margin)
|
||||||
cp "$iconset"/icon_512x512.png "$iconset"/icon_256x256@2x.png
|
# radius = 185 (~22.5% of the squircle, the characteristic curvature)
|
||||||
cp "$iconset"/icon_256x256.png "$iconset"/icon_128x128@2x.png
|
CANVAS=1024
|
||||||
cp "$iconset"/icon_32x32.png "$iconset"/icon_16x16@2x.png
|
SQUIRCLE=824
|
||||||
iconutil -c icns "$iconset" -o "$icns"
|
CONTENT=560
|
||||||
|
RADIUS=185
|
||||||
|
BG_COLOR="#FFFFFF"
|
||||||
|
SQUIRCLE_OFFSET=$(( (CANVAS - SQUIRCLE) / 2 ))
|
||||||
|
CONTENT_OFFSET=$(( (CANVAS - CONTENT) / 2 ))
|
||||||
|
|
||||||
|
# 1) Render the SVG to the content size at full fidelity.
|
||||||
|
# rsvg-convert handles our SVG correctly; ImageMagick sometimes crops it.
|
||||||
|
rsvg-convert -w "$CONTENT" -h "$CONTENT" "$svg" -o "$workdir/content.png"
|
||||||
|
|
||||||
|
# 2) Draw the rounded-square (squircle) background on a transparent canvas.
|
||||||
|
# The squircle is inset from the canvas edges (transparent padding), so the
|
||||||
|
# Dock/Finder render it at the same visual size as other first-party apps.
|
||||||
|
magick -size ${CANVAS}x${CANVAS} xc:none \
|
||||||
|
-fill "$BG_COLOR" \
|
||||||
|
-draw "roundrectangle ${SQUIRCLE_OFFSET},${SQUIRCLE_OFFSET} $((CANVAS-SQUIRCLE_OFFSET-1)),$((CANVAS-SQUIRCLE_OFFSET-1)) $RADIUS,$RADIUS" \
|
||||||
|
"$workdir/background.png"
|
||||||
|
|
||||||
|
# 3) Composite the artwork onto the background, centered inside the content area.
|
||||||
|
magick "$workdir/background.png" \
|
||||||
|
"$workdir/content.png" -geometry +${CONTENT_OFFSET}+${CONTENT_OFFSET} -composite \
|
||||||
|
-colorspace sRGB -type TrueColorAlpha PNG32:"$workdir/icon-1024.png"
|
||||||
|
|
||||||
|
# 4) Generate each iconset size from the master so all sizes share the same
|
||||||
|
# squircle proportions and look consistent at every resolution.
|
||||||
|
for size in 1024 512 256 128 64 32 16; do
|
||||||
|
magick "$workdir/icon-1024.png" -resize ${size}x${size} \
|
||||||
|
-colorspace sRGB -type TrueColorAlpha PNG32:"$workdir/${size}.png"
|
||||||
|
done
|
||||||
|
|
||||||
|
cp "$workdir/1024.png" "$iconset"/icon_512x512@2x.png
|
||||||
|
cp "$workdir/512.png" "$iconset"/icon_512x512.png
|
||||||
|
cp "$workdir/512.png" "$iconset"/icon_256x256@2x.png
|
||||||
|
cp "$workdir/256.png" "$iconset"/icon_256x256.png
|
||||||
|
cp "$workdir/256.png" "$iconset"/icon_128x128@2x.png
|
||||||
|
cp "$workdir/128.png" "$iconset"/icon_128x128.png
|
||||||
|
cp "$workdir/64.png" "$iconset"/icon_32x32@2x.png
|
||||||
|
cp "$workdir/32.png" "$iconset"/icon_32x32.png
|
||||||
|
cp "$workdir/32.png" "$iconset"/icon_16x16@2x.png
|
||||||
|
cp "$workdir/16.png" "$iconset"/icon_16x16.png
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$icns")"
|
||||||
|
|
||||||
|
# Menu bar template icon: flatten all RGB channels to 0 (black) while keeping
|
||||||
|
# alpha so the artwork reads as a clean silhouette. NSStatusBarButton tints
|
||||||
|
# template images to match the menu bar appearance in light and dark modes.
|
||||||
|
menubar_template="$(dirname "$icns")/menubar-template.png"
|
||||||
|
rsvg-convert -w 44 -h 44 "$svg" -o "$workdir/menubar-44.png"
|
||||||
|
magick "$workdir/menubar-44.png" -channel RGB -evaluate set 0 +channel \
|
||||||
|
"$menubar_template"
|
||||||
|
|
||||||
|
if ! iconutil -c icns "$iconset" -o "$icns"; then
|
||||||
|
if ! command -v perl >/dev/null 2>&1; then
|
||||||
|
echo "iconutil failed and perl is not available for the fallback icns writer" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "iconutil rejected the iconset; writing icns directly" >&2
|
||||||
|
perl - "$icns" "$iconset" <<'PERL'
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my ($icns, $iconset) = @ARGV;
|
||||||
|
my @icons = (
|
||||||
|
[ 'icp4', "$iconset/icon_16x16.png" ],
|
||||||
|
[ 'ic11', "$iconset/icon_16x16\@2x.png" ],
|
||||||
|
[ 'icp5', "$iconset/icon_32x32.png" ],
|
||||||
|
[ 'ic12', "$iconset/icon_32x32\@2x.png" ],
|
||||||
|
[ 'ic07', "$iconset/icon_128x128.png" ],
|
||||||
|
[ 'ic13', "$iconset/icon_128x128\@2x.png" ],
|
||||||
|
[ 'ic08', "$iconset/icon_256x256.png" ],
|
||||||
|
[ 'ic14', "$iconset/icon_256x256\@2x.png" ],
|
||||||
|
[ 'ic09', "$iconset/icon_512x512.png" ],
|
||||||
|
[ 'ic10', "$iconset/icon_512x512\@2x.png" ],
|
||||||
|
);
|
||||||
|
|
||||||
|
my $body = '';
|
||||||
|
for my $icon (@icons) {
|
||||||
|
my ($type, $path) = @$icon;
|
||||||
|
open my $fh, '<:raw', $path or die "$path: $!";
|
||||||
|
local $/;
|
||||||
|
my $png = <$fh>;
|
||||||
|
$body .= $type . pack('N', length($png) + 8) . $png;
|
||||||
|
}
|
||||||
|
|
||||||
|
open my $out, '>:raw', $icns or die "$icns: $!";
|
||||||
|
print {$out} 'icns' . pack('N', length($body) + 8) . $body;
|
||||||
|
PERL
|
||||||
|
fi
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use futures::StreamExt;
|
|||||||
use input_capture::{
|
use input_capture::{
|
||||||
CaptureError, CaptureEvent, CaptureHandle, InputCapture, InputCaptureError, Position,
|
CaptureError, CaptureEvent, CaptureHandle, InputCapture, InputCaptureError, Position,
|
||||||
};
|
};
|
||||||
use input_event::scancode;
|
use input_event::{Event, KeyboardEvent, scancode};
|
||||||
use lan_mouse_proto::ProtoEvent;
|
use lan_mouse_proto::ProtoEvent;
|
||||||
use local_channel::mpsc::{Receiver, Sender, channel};
|
use local_channel::mpsc::{Receiver, Sender, channel};
|
||||||
use tokio::task::{JoinHandle, spawn_local};
|
use tokio::task::{JoinHandle, spawn_local};
|
||||||
@@ -49,7 +49,7 @@ pub(crate) enum CaptureType {
|
|||||||
EnterOnly,
|
EnterOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
enum CaptureRequest {
|
enum CaptureRequest {
|
||||||
/// capture must release the mouse
|
/// capture must release the mouse
|
||||||
Release,
|
Release,
|
||||||
@@ -59,6 +59,8 @@ enum CaptureRequest {
|
|||||||
Destroy(CaptureHandle),
|
Destroy(CaptureHandle),
|
||||||
/// reenable input capture
|
/// reenable input capture
|
||||||
Reenable,
|
Reenable,
|
||||||
|
/// set release bind
|
||||||
|
SetReleaseBind(Vec<scancode::Linux>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Capture {
|
impl Capture {
|
||||||
@@ -131,6 +133,10 @@ impl Capture {
|
|||||||
pub(crate) async fn event(&mut self) -> ICaptureEvent {
|
pub(crate) async fn event(&mut self) -> ICaptureEvent {
|
||||||
self.event_rx.recv().await.expect("channel closed")
|
self.event_rx.recv().await.expect("channel closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_release_bind(&mut self, bind: Vec<scancode::Linux>) {
|
||||||
|
let _ = self.request_tx.send(CaptureRequest::SetReleaseBind(bind));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// debounce a statement `$st`, i.e. the statement is executed only if the
|
/// debounce a statement `$st`, i.e. the statement is executed only if the
|
||||||
@@ -205,6 +211,9 @@ impl CaptureTask {
|
|||||||
CaptureRequest::Create(h, p, t) => self.add_capture(h, p, t),
|
CaptureRequest::Create(h, p, t) => self.add_capture(h, p, t),
|
||||||
CaptureRequest::Destroy(h) => self.remove_capture(h),
|
CaptureRequest::Destroy(h) => self.remove_capture(h),
|
||||||
CaptureRequest::Release => { /* nothing to do */ }
|
CaptureRequest::Release => { /* nothing to do */ }
|
||||||
|
CaptureRequest::SetReleaseBind(bind) => {
|
||||||
|
self.release_bind.borrow_mut().clone_from(&bind);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ = self.cancellation_token.cancelled() => return,
|
_ = self.cancellation_token.cancelled() => return,
|
||||||
}
|
}
|
||||||
@@ -295,6 +304,9 @@ impl CaptureTask {
|
|||||||
self.remove_capture(h);
|
self.remove_capture(h);
|
||||||
capture.destroy(h).await?;
|
capture.destroy(h).await?;
|
||||||
}
|
}
|
||||||
|
CaptureRequest::SetReleaseBind(bind) => {
|
||||||
|
self.release_bind.borrow_mut().clone_from(&bind);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ = self.cancellation_token.cancelled() => break,
|
_ = self.cancellation_token.cancelled() => break,
|
||||||
}
|
}
|
||||||
@@ -364,6 +376,41 @@ impl CaptureTask {
|
|||||||
async fn release_capture(&mut self, capture: &mut InputCapture) -> Result<(), CaptureError> {
|
async fn release_capture(&mut self, capture: &mut InputCapture) -> Result<(), CaptureError> {
|
||||||
// If we have an active client, notify them we're leaving
|
// If we have an active client, notify them we're leaving
|
||||||
if let Some(handle) = self.active_client.take() {
|
if let Some(handle) = self.active_client.take() {
|
||||||
|
// Synthesize key-up events for every key still held in the
|
||||||
|
// capture's pressed_keys set BEFORE sending Leave. Without
|
||||||
|
// this, pressing the release-bind chord (typically all four
|
||||||
|
// modifiers) leaves the peer with phantom held modifiers:
|
||||||
|
// the down events were forwarded while capture was active,
|
||||||
|
// but the matching up events arrive after the local tap
|
||||||
|
// flips to passthrough and never reach the peer. The peer
|
||||||
|
// then runs every subsequent keystroke through those held
|
||||||
|
// mods until its watchdog times out (1+ s) or our Leave
|
||||||
|
// arrives — and Leave can be lost over UDP/DTLS.
|
||||||
|
for key in capture.take_pressed_keys() {
|
||||||
|
let key_up = ProtoEvent::Input(Event::Keyboard(KeyboardEvent::Key {
|
||||||
|
time: 0,
|
||||||
|
key: key as u32,
|
||||||
|
state: 0,
|
||||||
|
}));
|
||||||
|
if let Err(e) = self.conn.send(key_up, handle).await {
|
||||||
|
log::warn!("failed to send key-up to client {handle}: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Reset the modifier mask too. The peer's input-emulation
|
||||||
|
// layer keeps a separate XKB-style modifier state that's
|
||||||
|
// updated by KeyboardEvent::Modifiers, distinct from the
|
||||||
|
// pressed_keys set drained above. Without this, an
|
||||||
|
// already-locked CapsLock would survive the release.
|
||||||
|
let mods_zero = ProtoEvent::Input(Event::Keyboard(KeyboardEvent::Modifiers {
|
||||||
|
depressed: 0,
|
||||||
|
latched: 0,
|
||||||
|
locked: 0,
|
||||||
|
group: 0,
|
||||||
|
}));
|
||||||
|
if let Err(e) = self.conn.send(mods_zero, handle).await {
|
||||||
|
log::warn!("failed to reset modifiers on client {handle}: {e}");
|
||||||
|
}
|
||||||
|
|
||||||
log::info!("sending Leave event to client {handle}");
|
log::info!("sending Leave event to client {handle}");
|
||||||
if let Err(e) = self.conn.send(ProtoEvent::Leave(0), handle).await {
|
if let Err(e) = self.conn.send(ProtoEvent::Leave(0), handle).await {
|
||||||
log::warn!("failed to send Leave to client {handle}: {e}");
|
log::warn!("failed to send Leave to client {handle}: {e}");
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ use slab::Slab;
|
|||||||
|
|
||||||
use lan_mouse_ipc::{ClientConfig, ClientHandle, ClientState, Position};
|
use lan_mouse_ipc::{ClientConfig, ClientHandle, ClientState, Position};
|
||||||
|
|
||||||
|
use crate::config::ConfigClient;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct ClientManager {
|
pub struct ClientManager {
|
||||||
clients: Rc<RefCell<Slab<(ClientConfig, ClientState)>>>,
|
clients: Rc<RefCell<Slab<(ClientConfig, ClientState)>>>,
|
||||||
@@ -24,6 +26,25 @@ impl ClientManager {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_with_config(&self, config_client: ConfigClient) -> ClientHandle {
|
||||||
|
let config = ClientConfig {
|
||||||
|
hostname: config_client.hostname,
|
||||||
|
fix_ips: config_client.ips.into_iter().collect(),
|
||||||
|
port: config_client.port,
|
||||||
|
pos: config_client.pos,
|
||||||
|
cmd: config_client.enter_hook,
|
||||||
|
};
|
||||||
|
let state = ClientState {
|
||||||
|
active: config_client.active,
|
||||||
|
ips: HashSet::from_iter(config.fix_ips.iter().cloned()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let handle = self.add_client();
|
||||||
|
self.set_config(handle, config);
|
||||||
|
self.set_state(handle, state);
|
||||||
|
handle
|
||||||
|
}
|
||||||
|
|
||||||
/// add a new client to this manager
|
/// add a new client to this manager
|
||||||
pub fn add_client(&self) -> ClientHandle {
|
pub fn add_client(&self) -> ClientHandle {
|
||||||
self.clients.borrow_mut().insert(Default::default()) as ClientHandle
|
self.clients.borrow_mut().insert(Default::default()) as ClientHandle
|
||||||
@@ -230,6 +251,15 @@ impl ClientManager {
|
|||||||
.and_then(|(c, _)| c.cmd.clone())
|
.and_then(|(c, _)| c.cmd.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// returns all clients that are currently registered
|
||||||
|
pub(crate) fn registered_clients(&self) -> Vec<ClientHandle> {
|
||||||
|
self.clients
|
||||||
|
.borrow()
|
||||||
|
.iter()
|
||||||
|
.map(|(h, _)| h as ClientHandle)
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// returns all clients that are currently active
|
/// returns all clients that are currently active
|
||||||
pub(crate) fn active_clients(&self) -> Vec<ClientHandle> {
|
pub(crate) fn active_clients(&self) -> Vec<ClientHandle> {
|
||||||
self.clients
|
self.clients
|
||||||
|
|||||||
120
src/config.rs
@@ -1,6 +1,7 @@
|
|||||||
use crate::capture_test::TestCaptureArgs;
|
use crate::capture_test::TestCaptureArgs;
|
||||||
use crate::emulation_test::TestEmulationArgs;
|
use crate::emulation_test::TestEmulationArgs;
|
||||||
use clap::{Parser, Subcommand, ValueEnum};
|
use clap::{Parser, Subcommand, ValueEnum};
|
||||||
|
use notify::{EventKind, RecommendedWatcher, Watcher};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env::{self, VarError};
|
use std::env::{self, VarError};
|
||||||
@@ -46,7 +47,7 @@ fn default_path() -> Result<PathBuf, VarError> {
|
|||||||
Ok(PathBuf::from(default_path))
|
Ok(PathBuf::from(default_path))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
|
||||||
struct ConfigToml {
|
struct ConfigToml {
|
||||||
capture_backend: Option<CaptureBackend>,
|
capture_backend: Option<CaptureBackend>,
|
||||||
emulation_backend: Option<EmulationBackend>,
|
emulation_backend: Option<EmulationBackend>,
|
||||||
@@ -244,8 +245,14 @@ pub struct Config {
|
|||||||
cert_path: PathBuf,
|
cert_path: PathBuf,
|
||||||
/// path to the config file used
|
/// path to the config file used
|
||||||
config_path: PathBuf,
|
config_path: PathBuf,
|
||||||
|
/// path to config directory (parent of above)
|
||||||
|
config_dir: PathBuf,
|
||||||
/// the (optional) toml config and it's path
|
/// the (optional) toml config and it's path
|
||||||
config_toml: Option<ConfigToml>,
|
config_toml: Option<ConfigToml>,
|
||||||
|
// filesystem watcher
|
||||||
|
watcher: notify::RecommendedWatcher,
|
||||||
|
// channel for filesystem events
|
||||||
|
watch_rx: tokio::sync::mpsc::Receiver<Result<notify::Event, notify::Error>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ConfigClient {
|
pub struct ConfigClient {
|
||||||
@@ -311,6 +318,8 @@ pub enum ConfigError {
|
|||||||
Io(#[from] io::Error),
|
Io(#[from] io::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Var(#[from] VarError),
|
Var(#[from] VarError),
|
||||||
|
#[error(transparent)]
|
||||||
|
Watcher(#[from] notify::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_RELEASE_KEYS: [scancode::Linux; 4] =
|
const DEFAULT_RELEASE_KEYS: [scancode::Linux; 4] =
|
||||||
@@ -325,6 +334,23 @@ impl Config {
|
|||||||
.config
|
.config
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or(default_path()?.join(CONFIG_FILE_NAME));
|
.unwrap_or(default_path()?.join(CONFIG_FILE_NAME));
|
||||||
|
let config_dir = config_path
|
||||||
|
.parent()
|
||||||
|
.expect("config directory")
|
||||||
|
.to_path_buf();
|
||||||
|
|
||||||
|
// Ensure the config directory exists and write a default config file
|
||||||
|
// if none is present. Runs on every Config::new(), regardless of which
|
||||||
|
// entry path (GUI main, spawned daemon, CLI, test commands) we're on,
|
||||||
|
// so a fresh Mac never hits "No such file or directory" on config.toml
|
||||||
|
// and notify::Watcher (which requires the dir to exist on macOS
|
||||||
|
// FSEvents and some Linux backends) has a concrete path to watch.
|
||||||
|
fs::create_dir_all(&config_dir)?;
|
||||||
|
if !config_path.exists() {
|
||||||
|
let default_toml = toml::to_string_pretty(&ConfigToml::default())
|
||||||
|
.expect("default ConfigToml serialization cannot fail");
|
||||||
|
fs::write(&config_path, default_toml)?;
|
||||||
|
}
|
||||||
|
|
||||||
let config_toml = match ConfigToml::new(&config_path) {
|
let config_toml = match ConfigToml::new(&config_path) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -342,12 +368,51 @@ impl Config {
|
|||||||
.or(config_toml.as_ref().and_then(|c| c.cert_path.clone()))
|
.or(config_toml.as_ref().and_then(|c| c.cert_path.clone()))
|
||||||
.unwrap_or(default_path()?.join(CERT_FILE_NAME));
|
.unwrap_or(default_path()?.join(CERT_FILE_NAME));
|
||||||
|
|
||||||
Ok(Config {
|
let (tx, watch_rx) = tokio::sync::mpsc::channel(16);
|
||||||
|
let watcher = RecommendedWatcher::new(
|
||||||
|
move |res| {
|
||||||
|
let _ = tx.blocking_send(res);
|
||||||
|
},
|
||||||
|
notify::Config::default(),
|
||||||
|
)?;
|
||||||
|
let mut config = Config {
|
||||||
args,
|
args,
|
||||||
cert_path,
|
cert_path,
|
||||||
config_path,
|
config_path,
|
||||||
|
config_dir,
|
||||||
config_toml,
|
config_toml,
|
||||||
})
|
watcher,
|
||||||
|
watch_rx,
|
||||||
|
};
|
||||||
|
config.watch()?;
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn watch(&mut self) -> Result<(), notify::Error> {
|
||||||
|
self.watcher
|
||||||
|
.watch(&self.config_dir, notify::RecursiveMode::NonRecursive)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unwatch(&mut self) -> Result<(), notify::Error> {
|
||||||
|
self.watcher.unwatch(&self.config_dir)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn changed(&mut self) -> Result<(), notify::Error> {
|
||||||
|
loop {
|
||||||
|
let event = self.watch_rx.recv().await.expect("channel closed");
|
||||||
|
let event = event.expect("filesystem event");
|
||||||
|
if event.paths.contains(&self.config_path)
|
||||||
|
&& matches!(
|
||||||
|
event.kind,
|
||||||
|
EventKind::Create(_) | EventKind::Modify(_) | EventKind::Remove(_)
|
||||||
|
)
|
||||||
|
&& self.read_from_disk()?
|
||||||
|
{
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the command to run
|
/// the command to run
|
||||||
@@ -428,9 +493,6 @@ impl Config {
|
|||||||
|
|
||||||
/// set authorized keys
|
/// set authorized keys
|
||||||
pub fn set_authorized_keys(&mut self, fingerprints: HashMap<String, String>) {
|
pub fn set_authorized_keys(&mut self, fingerprints: HashMap<String, String>) {
|
||||||
if fingerprints.is_empty() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if self.config_toml.is_none() {
|
if self.config_toml.is_none() {
|
||||||
self.config_toml = Some(Default::default());
|
self.config_toml = Some(Default::default());
|
||||||
}
|
}
|
||||||
@@ -440,38 +502,58 @@ impl Config {
|
|||||||
.authorized_fingerprints = Some(fingerprints);
|
.authorized_fingerprints = Some(fingerprints);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_back(&self) -> Result<(), io::Error> {
|
pub fn read_from_disk(&mut self) -> Result<bool, io::Error> {
|
||||||
log::info!("writing config to {:?}", &self.config_path);
|
log::info!("reading config from {:?}", &self.config_path);
|
||||||
/* load the current configuration file */
|
|
||||||
let current_config = match fs::read_to_string(&self.config_path) {
|
let current_config = fs::read_to_string(&self.config_path)?;
|
||||||
Ok(c) => c.parse::<DocumentMut>().unwrap_or_default(),
|
let current_config = match current_config.parse::<DocumentMut>() {
|
||||||
|
Ok(c) => c,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::info!("{:?} {e} => creating new config", self.config_path());
|
log::warn!("{:?} {e}", self.config_path());
|
||||||
Default::default()
|
return Ok(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let _current_config =
|
let mut changed = false;
|
||||||
toml_edit::de::from_document::<ConfigToml>(current_config).unwrap_or_default();
|
match toml_edit::de::from_document::<ConfigToml>(current_config) {
|
||||||
|
Ok(current_config) => {
|
||||||
|
changed = self
|
||||||
|
.config_toml
|
||||||
|
.as_ref()
|
||||||
|
.is_none_or(|c| c != ¤t_config);
|
||||||
|
self.config_toml.replace(current_config);
|
||||||
|
}
|
||||||
|
Err(e) => log::warn!("{:?} {e}", self.config_path()),
|
||||||
|
};
|
||||||
|
Ok(changed)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write_back(&mut self) -> Result<(), io::Error> {
|
||||||
|
log::info!("writing config to {:?}", &self.config_path);
|
||||||
/* the new config */
|
/* the new config */
|
||||||
let new_config = self.config_toml.clone().unwrap_or_default();
|
let new_config = self.config_toml.clone().unwrap_or_default();
|
||||||
// let new_config = toml_edit::ser::to_document::<ConfigToml>(&new_config).expect("fixme");
|
|
||||||
let new_config = toml_edit::ser::to_string_pretty(&new_config).expect("config");
|
let new_config = toml_edit::ser::to_string_pretty(&new_config).expect("config");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO merge documents => eventually we might want to split this up into clients configured
|
* TODO merge with current config file to preserve comments
|
||||||
|
* => eventually we might want to split this up into clients configured
|
||||||
* via the config file and clients managed through the GUI / frontend.
|
* via the config file and clients managed through the GUI / frontend.
|
||||||
* The latter should be saved to $XDG_DATA_HOME instead of $XDG_CONFIG_HOME,
|
* The latter should be saved to $XDG_DATA_HOME instead of $XDG_CONFIG_HOME,
|
||||||
* and clients configured through .config could be made permanent.
|
* and clients configured through .config could be made permanent.
|
||||||
* For now we just override the config file.
|
* For now we just override the config file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
let _ = self.unwatch();
|
||||||
/* write new config to file */
|
/* write new config to file */
|
||||||
if let Some(p) = self.config_path().parent() {
|
if let Some(p) = self.config_path().parent() {
|
||||||
fs::create_dir_all(p)?;
|
fs::create_dir_all(p)?;
|
||||||
}
|
}
|
||||||
let mut f = File::create(self.config_path())?;
|
{
|
||||||
f.write_all(new_config.as_bytes())?;
|
let mut f = File::create(self.config_path())?;
|
||||||
|
f.write_all(new_config.as_bytes())?;
|
||||||
|
f.sync_all()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = self.watch();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ use crate::{
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use hickory_resolver::ResolveError;
|
use hickory_resolver::ResolveError;
|
||||||
use lan_mouse_ipc::{
|
use lan_mouse_ipc::{
|
||||||
AsyncFrontendListener, ClientConfig, ClientHandle, ClientState, FrontendEvent, FrontendRequest,
|
AsyncFrontendListener, ClientHandle, FrontendEvent, FrontendRequest, IpcError,
|
||||||
IpcError, IpcListenerCreationError, Position, Status,
|
IpcListenerCreationError, Position, Status,
|
||||||
};
|
};
|
||||||
use log;
|
use log;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -83,21 +83,7 @@ impl Service {
|
|||||||
pub async fn new(config: Config) -> Result<Self, ServiceError> {
|
pub async fn new(config: Config) -> Result<Self, ServiceError> {
|
||||||
let client_manager = ClientManager::default();
|
let client_manager = ClientManager::default();
|
||||||
for client in config.clients() {
|
for client in config.clients() {
|
||||||
let config = ClientConfig {
|
client_manager.add_with_config(client);
|
||||||
hostname: client.hostname,
|
|
||||||
fix_ips: client.ips.into_iter().collect(),
|
|
||||||
port: client.port,
|
|
||||||
pos: client.pos,
|
|
||||||
cmd: client.enter_hook,
|
|
||||||
};
|
|
||||||
let state = ClientState {
|
|
||||||
active: client.active,
|
|
||||||
ips: HashSet::from_iter(config.fix_ips.iter().cloned()),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let handle = client_manager.add_client();
|
|
||||||
client_manager.set_config(handle, config);
|
|
||||||
client_manager.set_state(handle, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load certificate
|
// load certificate
|
||||||
@@ -164,6 +150,7 @@ impl Service {
|
|||||||
event = self.emulation.event() => self.handle_emulation_event(event),
|
event = self.emulation.event() => self.handle_emulation_event(event),
|
||||||
event = self.capture.event() => self.handle_capture_event(event),
|
event = self.capture.event() => self.handle_capture_event(event),
|
||||||
event = self.resolver.event() => self.handle_resolver_event(event),
|
event = self.resolver.event() => self.handle_resolver_event(event),
|
||||||
|
_ = self.config.changed() => self.handle_config_change(),
|
||||||
r = signal::ctrl_c() => break r.expect("failed to wait for CTRL+C"),
|
r = signal::ctrl_c() => break r.expect("failed to wait for CTRL+C"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,6 +242,30 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_config_change(&mut self) {
|
||||||
|
for h in self.client_manager.registered_clients() {
|
||||||
|
self.remove_client(h);
|
||||||
|
}
|
||||||
|
for c in self.config.clients() {
|
||||||
|
let handle = self.client_manager.add_with_config(c);
|
||||||
|
log::info!("added client {handle}");
|
||||||
|
let (c, s) = self.client_manager.get_state(handle).unwrap();
|
||||||
|
if s.active {
|
||||||
|
self.client_manager.deactivate_client(handle);
|
||||||
|
self.activate_client(handle);
|
||||||
|
}
|
||||||
|
self.notify_frontend(FrontendEvent::Created(handle, c, s));
|
||||||
|
}
|
||||||
|
let release_bind = self.config.release_bind();
|
||||||
|
self.capture.set_release_bind(release_bind);
|
||||||
|
let authorized_keys = self.config.authorized_fingerprints();
|
||||||
|
self.authorized_keys
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.clone_from(&authorized_keys);
|
||||||
|
self.sync_frontend();
|
||||||
|
}
|
||||||
|
|
||||||
async fn handle_frontend_pending(&mut self) {
|
async fn handle_frontend_pending(&mut self) {
|
||||||
while let Some(event) = self.pending_frontend_events.pop_front() {
|
while let Some(event) = self.pending_frontend_events.pop_front() {
|
||||||
self.frontend_listener.broadcast(event).await;
|
self.frontend_listener.broadcast(event).await;
|
||||||
@@ -477,7 +488,7 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn activate_client(&mut self, handle: ClientHandle) {
|
fn activate_client(&mut self, handle: ClientHandle) {
|
||||||
log::debug!("activating client");
|
log::debug!("activating client {handle}");
|
||||||
|
|
||||||
/* resolve dns on activate */
|
/* resolve dns on activate */
|
||||||
self.resolve(handle);
|
self.resolve(handle);
|
||||||
|
|||||||
3
wix/bundle/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/bin
|
||||||
|
/obj
|
||||||
|
icon.ico
|
||||||
16
wix/bundle/Bundle.wixproj
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="WixToolset.Sdk/5.0.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Bundle</OutputType>
|
||||||
|
<TargetExt>.exe</TargetExt>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
<InstallerPlatform>x64</InstallerPlatform>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="WixToolset.Heat">
|
||||||
|
<Version>5.0.2</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="WixToolset.Bal.wixext">
|
||||||
|
<Version>5.0.2</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
42
wix/bundle/Bundle.wxs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
||||||
|
xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
|
||||||
|
|
||||||
|
<Bundle
|
||||||
|
Name="Lan Mouse"
|
||||||
|
Version="0.10.0"
|
||||||
|
UpgradeCode="{39A9744D-9D6E-4CD3-A84F-9E034786A7B1}"
|
||||||
|
Compressed="no"
|
||||||
|
SplashScreenSourceFile="icon.ico">
|
||||||
|
|
||||||
|
<BootstrapperApplication>
|
||||||
|
<bal:WixStandardBootstrapperApplication
|
||||||
|
LicenseUrl=""
|
||||||
|
Theme="hyperlinkLicense" />
|
||||||
|
</BootstrapperApplication>
|
||||||
|
|
||||||
|
<Chain>
|
||||||
|
<!-- Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810 -->
|
||||||
|
<ExePackage
|
||||||
|
Id="VC_REDIST_X64"
|
||||||
|
DisplayName="Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810"
|
||||||
|
PerMachine="yes"
|
||||||
|
Permanent="yes"
|
||||||
|
Protocol="burn"
|
||||||
|
InstallCondition="VersionNT64 AND (ARCH_NAME = "AMD64")"
|
||||||
|
DetectCondition="(VCRUNTIME_X64_VER >= VCRUNTIME_VER) AND VersionNT64 AND (ARCH_NAME = "AMD64")"
|
||||||
|
InstallArguments="/install /quiet /norestart"
|
||||||
|
RepairArguments="/repair /quiet /norestart"
|
||||||
|
UninstallArguments="/uninstall /quiet /norestart">
|
||||||
|
<ExePackagePayload
|
||||||
|
Name="VC_redist.x64.exe"
|
||||||
|
ProductName="Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810"
|
||||||
|
Description="Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810"
|
||||||
|
Hash="5935B69F5138AC3FBC33813C74DA853269BA079F910936AEFA95E230C6092B92F6225BFFB594E5DD35FF29BF260E4B35F91ADEDE90FDF5F062030D8666FD0104"
|
||||||
|
Size="25397512"
|
||||||
|
Version="14.40.33810.0"
|
||||||
|
DownloadUrl="https://download.visualstudio.microsoft.com/download/pr/1754ea58-11a6-44ab-a262-696e194ce543/3642E3F95D50CC193E4B5A0B0FFBF7FE2C08801517758B4C8AEB7105A091208A/VC_redist.x64.exe" />
|
||||||
|
</ExePackage>
|
||||||
|
<MsiPackage SourceFile="..\lan-mouse\bin\Debug\en-US\LanMouse.msi" Compressed="yes"/>
|
||||||
|
</Chain>
|
||||||
|
</Bundle>
|
||||||
|
</Wix>
|
||||||
3
wix/lan-mouse/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/bin
|
||||||
|
/obj
|
||||||
|
icon.ico
|
||||||
13
wix/lan-mouse/Folders.wxs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||||
|
<Fragment>
|
||||||
|
<StandardDirectory Id="ProgramFiles64Folder">
|
||||||
|
<Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)">
|
||||||
|
<Directory Id="SHARE" Name="share"/>
|
||||||
|
<Directory Id="LIB" Name="lib"/>
|
||||||
|
</Directory>
|
||||||
|
</StandardDirectory>
|
||||||
|
<StandardDirectory Id="ProgramMenuFolder">
|
||||||
|
<Directory Id="ApplicationProgramsFolder" Name="!(bind.Property.ProductName)"/>
|
||||||
|
</StandardDirectory>
|
||||||
|
</Fragment>
|
||||||
|
</Wix>
|
||||||
34
wix/lan-mouse/LanMouse.wixproj
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<Project Sdk="WixToolset.Sdk/5.0.2">
|
||||||
|
<PropertyGroup>
|
||||||
|
<InstallerPlatform>x64</InstallerPlatform>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="WixToolset.Heat">
|
||||||
|
<Version>5.0.2</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<HarvestDirectory Include="C:\gtk-build\gtk\x64\release\bin">
|
||||||
|
<ComponentGroupName>GTKBIN</ComponentGroupName>
|
||||||
|
<DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
|
||||||
|
<SuppressRegistry>true</SuppressRegistry>
|
||||||
|
</HarvestDirectory>
|
||||||
|
<BindPath Include="C:\gtk-build\gtk\x64\release\bin" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<HarvestDirectory Include="C:\gtk-build\gtk\x64\release\share\icons">
|
||||||
|
<ComponentGroupName>GTKICONS</ComponentGroupName>
|
||||||
|
<DirectoryRefId>SHARE</DirectoryRefId>
|
||||||
|
<SuppressRegistry>true</SuppressRegistry>
|
||||||
|
</HarvestDirectory>
|
||||||
|
<BindPath Include="C:\gtk-build\gtk\x64\release\share\icons" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<HarvestDirectory Include="C:\gtk-build\gtk\x64\release\lib\gdk-pixbuf-2.0">
|
||||||
|
<ComponentGroupName>GTKLIBS</ComponentGroupName>
|
||||||
|
<DirectoryRefId>LIB</DirectoryRefId>
|
||||||
|
<SuppressRegistry>true</SuppressRegistry>
|
||||||
|
</HarvestDirectory>
|
||||||
|
<BindPath Include="C:\gtk-build\gtk\x64\release\lib\gdk-pixbuf-2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
32
wix/lan-mouse/LanMouseComponents.wxs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||||
|
<Fragment>
|
||||||
|
<ComponentGroup Id="LanMouseComponents" Directory="INSTALLFOLDER" Subdirectory="bin">
|
||||||
|
<Component Guid="{ECB52D3E-28AD-4BEC-B9DF-E01CCAB356BE}">
|
||||||
|
<!-- the main binary -->
|
||||||
|
<File Source="..\..\target\release\lan-mouse.exe"/>
|
||||||
|
|
||||||
|
<!-- visual c runtime dll -->
|
||||||
|
<!--<File Source="C:\windows\system32\VCRUNTIME140.dll"/>-->
|
||||||
|
<!--<File Source="C:\windows\system32\VCRUNTIME140_1.dll"/>-->
|
||||||
|
</Component>
|
||||||
|
<!-- start menu entry-->
|
||||||
|
<Component Id="ApplicationShortcut" Directory="ApplicationProgramsFolder">
|
||||||
|
<Shortcut Id="ApplicationStartMenuShortcut"
|
||||||
|
Name="!(bind.Property.ProductName)"
|
||||||
|
Description ="Mouse and Keyboard sharing Software"
|
||||||
|
Target="[INSTALLFOLDER]bin\lan-mouse.exe"
|
||||||
|
WorkingDirectory="INSTALLFOLDER">
|
||||||
|
<Icon Id="LanMouse" SourceFile=".\icon.ico"/>
|
||||||
|
</Shortcut>
|
||||||
|
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
|
||||||
|
<RegistryValue
|
||||||
|
Root="HKCU"
|
||||||
|
Key="Software\Feschber\LanMouse"
|
||||||
|
Name="installed"
|
||||||
|
Type="integer"
|
||||||
|
Value="1"
|
||||||
|
KeyPath="yes"/>
|
||||||
|
</Component>
|
||||||
|
</ComponentGroup>
|
||||||
|
</Fragment>
|
||||||
|
</Wix>
|
||||||
8
wix/lan-mouse/Package.en-us.wxl
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!--
|
||||||
|
This file contains the declaration of all the localizable strings.
|
||||||
|
-->
|
||||||
|
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
|
||||||
|
|
||||||
|
<String Id="DowngradeError" Value="A newer version of [ProductName] is already installed." />
|
||||||
|
|
||||||
|
</WixLocalization>
|
||||||
16
wix/lan-mouse/Package.wxs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||||
|
<Package Name="Lan Mouse"
|
||||||
|
Manufacturer="Ferdinand Schober"
|
||||||
|
Version="0.10.0.0"
|
||||||
|
UpgradeCode="{a330cd60-4c35-4a54-8bb6-75b3049b46c6}">
|
||||||
|
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
|
||||||
|
|
||||||
|
<MediaTemplate EmbedCab="yes"/>
|
||||||
|
<Feature Id="Main">
|
||||||
|
<ComponentGroupRef Id="GTKBIN"/>
|
||||||
|
<ComponentGroupRef Id="GTKICONS"/>
|
||||||
|
<ComponentGroupRef Id="GTKLIBS"/>
|
||||||
|
<ComponentGroupRef Id="LanMouseComponents"/>
|
||||||
|
</Feature>
|
||||||
|
</Package>
|
||||||
|
</Wix>
|
||||||
2
wix/lan-mouse/build.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
magick -background none -density 384 ..\lan-mouse-gtk\resources\de.feschber.LanMouse.svg -trim -define icon:auto-resize icon.ico
|
||||||
|
dotnet build
|
||||||