Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: rebuild the gpui macOS app menu

Ilya1aab84b00932
diff --git a/apps/desktop-gpui/Cargo.lock b/apps/desktop-gpui/Cargo.lock
index 949e7bbb5..bc4cef361 100644
--- a/apps/desktop-gpui/Cargo.lock
+++ b/apps/desktop-gpui/Cargo.lock
@@ -1184,7 +1184,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
]
[[package]]
@@ -1541,7 +1541,7 @@ dependencies = [
"anyhow",
"ashpd 0.11.1",
"base64 0.22.1",
- "block2 0.5.1",
+ "block2 0.6.2",
"bytes",
"cap-audio",
"cap-camera",
@@ -1582,9 +1582,9 @@ dependencies = [
"libc",
"lyon_tessellation",
"minisign-verify",
- "objc2 0.5.2",
- "objc2-app-kit 0.2.2",
- "objc2-foundation 0.2.2",
+ "objc2 0.6.5",
+ "objc2-app-kit 0.3.2",
+ "objc2-foundation 0.3.2",
"parakeet-rs",
"raw-window-handle",
"reqwest 0.12.28",
@@ -1901,7 +1901,7 @@ dependencies = [
"kameo",
"libc",
"objc",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"parking_lot",
"pipewire",
@@ -1959,7 +1959,7 @@ dependencies = [
"libloading 0.8.9",
"log",
"metal 0.31.0",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"rayon",
"reactive_graph",
"resvg 0.45.1",
@@ -2314,7 +2314,7 @@ checksum = "afede46921767868c5c7f8f55202bdd8bec0bab6bc9605174200f45924f93c62"
dependencies = [
"clipboard-win",
"image 0.25.10",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"objc2-foundation 0.3.2",
"windows 0.59.0",
@@ -3356,7 +3356,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users 0.5.2",
- "windows-sys 0.61.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -3374,7 +3374,7 @@ dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
"libc",
- "objc2 0.6.4",
+ "objc2 0.6.5",
]
[[package]]
@@ -3592,7 +3592,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -4428,7 +4428,7 @@ checksum = "b9247516746aa8e53411a0db9b62b0e24efbcf6a76e0ba73e5a91b512ddabed7"
dependencies = [
"crossbeam-channel",
"keyboard-types",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"once_cell",
"thiserror 2.0.20",
@@ -4726,7 +4726,7 @@ dependencies = [
"media",
"metal 0.33.0",
"objc",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"objc2-foundation 0.3.2",
"objc2-user-notifications",
@@ -4865,7 +4865,7 @@ dependencies = [
"windows 0.61.3",
"windows-core 0.61.2",
"windows-numerics 0.2.0",
- "windows-registry 0.5.3",
+ "windows-registry",
]
[[package]]
@@ -5278,7 +5278,7 @@ dependencies = [
"tokio",
"tower-service",
"tracing",
- "windows-registry 0.6.1",
+ "windows-registry",
]
[[package]]
@@ -6254,7 +6254,7 @@ checksum = "fd604973958ddcc11b561193c0fb96ba146506ef2f231ef2e7c35fd2cbc9beca"
dependencies = [
"cc",
"log",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
"time",
"uuid",
@@ -6567,15 +6567,15 @@ dependencies = [
[[package]]
name = "muda"
-version = "0.17.2"
+version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7c9fec5a4e89860383d778d10563a605838f8f0b2f9303868937e5ff32e86177"
+checksum = "01c1738382f66ed56b3b9c8119e794a2e23148ac8ea214eda86622d4cb9d415a"
dependencies = [
"crossbeam-channel",
"dpi",
"gtk",
"keyboard-types",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
@@ -6844,7 +6844,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -7027,9 +7027,9 @@ dependencies = [
[[package]]
name = "objc2"
-version = "0.6.4"
+version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f"
+checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8"
dependencies = [
"objc2-encode",
"objc2-exception-helper",
@@ -7060,7 +7060,7 @@ dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
"libc",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-cloud-kit",
"objc2-core-data 0.3.2",
"objc2-core-foundation",
@@ -7081,7 +7081,7 @@ dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
"dispatch2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-avf-audio",
"objc2-core-audio-types",
"objc2-core-foundation",
@@ -7101,7 +7101,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
]
@@ -7112,7 +7112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
]
@@ -7123,7 +7123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1eebcea8b0dbff5f7c8504f3107c68fc061a3eb44932051c8cf8a68d969c3b2"
dependencies = [
"dispatch2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-audio-types",
"objc2-core-foundation",
]
@@ -7135,7 +7135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
]
[[package]]
@@ -7157,7 +7157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
]
@@ -7169,7 +7169,7 @@ checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
dependencies = [
"bitflags 2.13.1",
"dispatch2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
]
[[package]]
@@ -7180,7 +7180,7 @@ checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
dependencies = [
"bitflags 2.13.1",
"dispatch2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-io-surface",
]
@@ -7203,7 +7203,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
]
@@ -7213,7 +7213,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
]
@@ -7225,7 +7225,7 @@ checksum = "05ec576860167a15dd9fce7fbee7512beb4e31f532159d3482d1f9c6caedf31d"
dependencies = [
"bitflags 2.13.1",
"dispatch2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-audio",
"objc2-core-audio-types",
"objc2-core-foundation",
@@ -7239,7 +7239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-core-graphics",
]
@@ -7251,7 +7251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-io-surface",
@@ -7293,7 +7293,7 @@ dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
"libc",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
]
@@ -7303,7 +7303,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32b0446e98cf4a784cc7a0177715ff317eeaa8463841c616cfc78aa4f953c4ea"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-core-graphics",
]
@@ -7325,7 +7325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
]
@@ -7335,7 +7335,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd9fdde720df3da7046bb9097811000c1e7ab5cd579fa89d96b27d56781fb30"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-audio-types",
"objc2-core-foundation",
"objc2-core-media",
@@ -7361,7 +7361,7 @@ checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794"
dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
]
@@ -7385,7 +7385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
dependencies = [
"bitflags 2.13.1",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
"objc2-metal 0.3.2",
@@ -7399,7 +7399,7 @@ checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"
dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-cloud-kit",
"objc2-core-data 0.3.2",
"objc2-core-foundation",
@@ -7420,7 +7420,7 @@ checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e"
dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-location",
"objc2-foundation 0.3.2",
]
@@ -7646,15 +7646,6 @@ dependencies = [
"num-traits",
]
-[[package]]
-name = "ordered-float"
-version = "5.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7d950ca161dc355eaf28f82b11345ed76c6e1f6eb1f4f4479e0323b9e2fbd0e"
-dependencies = [
- "num-traits",
-]
-
[[package]]
name = "ordered-stream"
version = "0.2.0"
@@ -7699,7 +7690,7 @@ dependencies = [
"android_system_properties",
"log",
"nix 0.31.3",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-foundation 0.3.2",
"objc2-ui-kit",
"serde",
@@ -8278,7 +8269,7 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [
- "toml_edit 0.20.7",
+ "toml_edit 0.20.2",
]
[[package]]
@@ -8502,7 +8493,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -8745,7 +8736,7 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135"
dependencies = [
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
"objc2-quartz-core 0.3.2",
@@ -9130,7 +9121,7 @@ dependencies = [
"dispatch2",
"js-sys",
"log",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
@@ -9268,7 +9259,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.12.1",
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -9411,7 +9402,7 @@ version = "0.1.0"
dependencies = [
"cidre",
"futures",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"objc2-foundation 0.3.2",
"tracing",
@@ -10672,7 +10663,7 @@ dependencies = [
"memchr",
"ntapi",
"rayon",
- "windows 0.57.0",
+ "windows 0.54.0",
]
[[package]]
@@ -10686,7 +10677,7 @@ dependencies = [
"memchr",
"ntapi",
"rayon",
- "windows 0.57.0",
+ "windows 0.54.0",
]
[[package]]
@@ -10854,10 +10845,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
- "getrandom 0.4.3",
+ "getrandom 0.3.4",
"once_cell",
"rustix 1.1.4",
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -11220,9 +11211,9 @@ dependencies = [
[[package]]
name = "toml_edit"
-version = "0.20.7"
+version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
+checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
dependencies = [
"indexmap 2.14.0",
"toml_datetime 0.6.11",
@@ -11430,7 +11421,7 @@ dependencies = [
"dirs 6.0.0",
"libappindicator",
"muda",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-app-kit 0.3.2",
"objc2-core-foundation",
"objc2-core-graphics",
@@ -12427,7 +12418,7 @@ dependencies = [
"naga 25.0.1",
"ndk-sys 0.5.0+25.2.9519653",
"objc",
- "ordered-float 4.6.0",
+ "ordered-float",
"parking_lot",
"portable-atomic",
"profiling",
@@ -12470,13 +12461,13 @@ dependencies = [
"log",
"naga 29.0.4",
"ndk-sys 0.6.0+11769913",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
"objc2-metal 0.3.2",
"objc2-quartz-core 0.3.2",
"once_cell",
- "ordered-float 5.3.0",
+ "ordered-float",
"parking_lot",
"portable-atomic",
"portable-atomic-util",
@@ -12611,7 +12602,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -12639,16 +12630,6 @@ dependencies = [
"windows-targets 0.52.6",
]
-[[package]]
-name = "windows"
-version = "0.57.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
-dependencies = [
- "windows-core 0.57.0",
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows"
version = "0.58.0"
@@ -12757,18 +12738,6 @@ dependencies = [
"windows-targets 0.52.6",
]
-[[package]]
-name = "windows-core"
-version = "0.57.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
-dependencies = [
- "windows-implement 0.57.0",
- "windows-interface 0.57.0",
- "windows-result 0.1.2",
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows-core"
version = "0.58.0"
@@ -12866,17 +12835,6 @@ dependencies = [
"windows-threading 0.2.1",
]
-[[package]]
-name = "windows-implement"
-version = "0.57.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.119",
-]
-
[[package]]
name = "windows-implement"
version = "0.58.0"
@@ -12910,17 +12868,6 @@ dependencies = [
"syn 2.0.119",
]
-[[package]]
-name = "windows-interface"
-version = "0.57.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.119",
-]
-
[[package]]
name = "windows-interface"
version = "0.58.0"
@@ -12996,17 +12943,6 @@ dependencies = [
"windows-strings 0.4.2",
]
-[[package]]
-name = "windows-registry"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"
-dependencies = [
- "windows-link 0.2.1",
- "windows-result 0.4.1",
- "windows-strings 0.5.1",
-]
-
[[package]]
name = "windows-result"
version = "0.1.2"
@@ -13511,7 +13447,7 @@ dependencies = [
"num-complex",
"num-integer",
"num-rational",
- "objc2 0.6.4",
+ "objc2 0.6.5",
"objc2-core-foundation",
"objc2-core-graphics",
"open",
diff --git a/apps/desktop-gpui/Cargo.toml b/apps/desktop-gpui/Cargo.toml
index 36dad10d0..aef97037c 100644
--- a/apps/desktop-gpui/Cargo.toml
+++ b/apps/desktop-gpui/Cargo.toml
@@ -62,7 +62,10 @@ cap-project = { path = "../../crates/project" }
# a `RenderImage` (`src/editor_sidebar/cursor.rs`).
cap-cursor-info = { path = "../../crates/cursor-info" }
resvg = "0.45"
-rodio = { version = "0.19.0", default-features = false, features = ["mp3", "vorbis"] }
+rodio = { version = "0.19.0", default-features = false, features = [
+ "mp3",
+ "vorbis",
+] }
# The editor stack. `cap-rendering` is not a new subtree -- cap-recording
# already depends on it, so wgpu 25 and its vendored wgpu-hal have been built
# by this workspace since the recording unit; naming it here only makes the
@@ -100,7 +103,11 @@ ffmpeg = { package = "ffmpeg-next", git = "https://github.com/CapSoftware/rust-f
# `webp` is the config sidebar's four background-source illustrations, which
# the app ships as webp; features are additive, so enabling it here does not
# move gpui's own pin.
-image = { version = "0.25.1", default-features = false, features = ["jpeg", "png", "webp"] }
+image = { version = "0.25.1", default-features = false, features = [
+ "jpeg",
+ "png",
+ "webp",
+] }
jpeg-decoder = "0.3"
smallvec = "1"
# Grapheme boundaries for `ui::TextInput`: Backspace deletes a user-perceived
@@ -128,7 +135,10 @@ sanitize-filename = "0.6.0"
semver = "1"
base64 = "0.22"
minisign-verify = "0.2.4"
-rfd = { version = "0.15", default-features = false, features = ["xdg-portal", "tokio"] }
+rfd = { version = "0.15", default-features = false, features = [
+ "xdg-portal",
+ "tokio",
+] }
# The screenshot export compositor (`src/screenshot_export.rs`): the canvas-2d
# work `renderScreenshotExportCanvas` does in the webview -- shape rasterizing,
# text, and the share fingerprint. All three are already in this lockfile
@@ -173,7 +183,14 @@ tauri-winres = "0.3.5"
# decoders, renderer and preview tasks are all tokio-spawned -- a current-thread
# runtime would deadlock the moment the test thread blocks on a frame. Kept in
# dev-dependencies so the shipped binary's tokio features are unchanged.
-tokio = { version = "1", features = ["rt-multi-thread", "time", "test-util", "net", "io-util", "macros"] }
+tokio = { version = "1", features = [
+ "rt-multi-thread",
+ "time",
+ "test-util",
+ "net",
+ "io-util",
+ "macros",
+] }
# Caption oracles (`src/transcription/verify_tests.rs`): fixture projects and
# audio markers for the fake transcriber.
cap-verify = { path = "../../crates/verify" }
@@ -206,15 +223,31 @@ x11rb = "0.13"
[target.'cfg(target_os = "macos")'.dependencies]
# Native window treatment (panel levels, Spaces) gpui does not expose. Same
-# versions gpui's own tree compiles, so no second objc2 universe gets built.
-objc2 = { version = "0.5.2", features = ["exception"] }
+# direct 0.6 line used by this app's class definitions and AppKit bindings.
+objc2 = { version = "0.6.5", features = ["exception"] }
# `NSVisualEffectView` is the pre-macOS-26 window-material fallback. Features
# only -- the versions stay pinned, or a second objc2 universe gets built.
-objc2-app-kit = { version = "0.2.2", features = ["NSAppearance", "NSWindow", "NSView", "NSResponder", "NSGraphics", "NSPasteboard", "NSVisualEffectView", "NSWorkspace", "NSAccessibility"] }
+objc2-app-kit = { version = "0.3.2", features = [
+ "NSAppearance",
+ "NSWindow",
+ "NSView",
+ "NSResponder",
+ "NSGraphics",
+ "NSPasteboard",
+ "NSMenuItemBadge",
+ "NSVisualEffectView",
+ "NSWorkspace",
+ "NSAccessibility",
+] }
# NSRect/NSPoint/NSSize for `setFrame:display:`. Already in the tree as
# objc2-app-kit's own dependency, so this adds nothing to the build.
-objc2-foundation = { version = "0.2.2", features = ["NSNotification", "NSOperation", "NSString", "block2"] }
-block2 = "0.5.1"
+objc2-foundation = { version = "0.3.2", features = [
+ "NSNotification",
+ "NSOperation",
+ "NSString",
+ "block2",
+] }
+block2 = "0.6"
raw-window-handle = "0.6"
core-foundation = "0.10"
core-video = { version = "0.5.2", features = ["metal"] }
diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs
index b5aebb1b2..f9fb9a8e7 100644
--- a/apps/desktop-gpui/src/app_windows.rs
+++ b/apps/desktop-gpui/src/app_windows.rs
@@ -4708,6 +4708,8 @@ fn open_editor_window(
return None;
}
+ cx.add_recent_document(&project_path);
+
if let Some(window_id) = cx
.global::<AppWindows>()
.editors
@@ -6599,6 +6601,8 @@ pub fn open_screenshot_editor(path: PathBuf, cx: &mut App) {
};
let key = editor_key(&bundle);
+ cx.add_recent_document(&bundle);
+
if let Some(handle) = cx
.global::<AppWindows>()
.screenshot_editors
diff --git a/apps/desktop-gpui/src/menus.rs b/apps/desktop-gpui/src/menus.rs
index 8e3996369..93f5f6c23 100644
--- a/apps/desktop-gpui/src/menus.rs
+++ b/apps/desktop-gpui/src/menus.rs
@@ -7,8 +7,9 @@
//! Tauri app decides between Regular and Accessory from exactly the set of
//! windows ⌘W changes.
//!
-//! The menu itself is [`build_menus`], a byte-for-byte transcription of
-//! `build_macos_app_menu` (`apps/desktop/src-tauri/src/lib.rs:479-566`). gpui
+//! The menu itself is [`build_menus`], the GPUI model for the native menu bar.
+//! macOS standard menu items are upgraded in `platform` after GPUI installs it.
+//! gpui
//! builds the real `NSMenu` from it and takes each item's key equivalent from
//! the *keymap*, so an action with no `KeyBinding` renders without a shortcut
//! and an action with no live handler renders disabled
@@ -37,6 +38,68 @@ use crate::{
/// submenu to and what the About/Hide/Quit labels interpolate.
pub const APP_NAME: &str = "Cap";
+struct MenuRegistration(UpdateRow);
+
+impl Global for MenuRegistration {}
+
+/// What the Check for Update row currently says. Download progress only moves
+/// the badge, and only macOS applies it without rebuilding the menu bar, so a
+/// percentage tick never touches the menu on the other platforms.
+#[derive(Clone, PartialEq)]
+struct UpdateRow {
+ title: &'static str,
+ enabled: bool,
+ badge: Option<String>,
+}
+
+const CHECK_TITLE: &str = "Check for Update";
+const CHECKING_TITLE: &str = "Checking for Update…";
+const DOWNLOAD_TITLE: &str = "Download update…";
+const RESTART_TITLE: &str = "Restart to update…";
+
+impl UpdateRow {
+ fn of(status: &crate::updates::UpdateStatus) -> Self {
+ use crate::updates::UpdateStatus;
+
+ let title = match status {
+ UpdateStatus::Idle => CHECK_TITLE,
+ UpdateStatus::Checking => CHECKING_TITLE,
+ UpdateStatus::Downloading { .. } | UpdateStatus::Installing { .. } => DOWNLOAD_TITLE,
+ UpdateStatus::Ready { .. } | UpdateStatus::Installed { .. } => RESTART_TITLE,
+ };
+ Self {
+ title,
+ enabled: !matches!(status, UpdateStatus::Checking),
+ badge: update_menu_badge(status),
+ }
+ }
+}
+
+#[cfg(target_os = "macos")]
+fn update_menu_badge(status: &crate::updates::UpdateStatus) -> Option<String> {
+ use crate::updates::UpdateStatus;
+
+ match status {
+ UpdateStatus::Downloading {
+ version,
+ fraction: Some(fraction),
+ } => Some(format!(
+ "v{version} · {}%",
+ (fraction * 100.0).round() as u32
+ )),
+ UpdateStatus::Downloading { version, .. }
+ | UpdateStatus::Ready { version }
+ | UpdateStatus::Installing { version }
+ | UpdateStatus::Installed { version, .. } => Some(format!("v{version}")),
+ UpdateStatus::Idle | UpdateStatus::Checking => None,
+ }
+}
+
+#[cfg(not(target_os = "macos"))]
+fn update_menu_badge(_: &crate::updates::UpdateStatus) -> Option<String> {
+ None
+}
+
/// `env!("CARGO_PKG_VERSION")`, exactly as `build_tray_menu` spells it -- this
/// crate's version, which is the gpui app's own (0.1.x) rather than the
/// shipping desktop app's. Noted as a deviation in the report: there is no
@@ -50,12 +113,29 @@ actions!(
[
/// `PredefinedMenuItem::about` -- `orderFrontStandardAboutPanel`.
About,
+ /// Manually check for or install a Cap update.
+ CheckForUpdate,
/// `PredefinedMenuItem::hide` -- ⌘H.
HideSelf,
/// `PredefinedMenuItem::hide_others` -- ⌥⌘H.
HideOthers,
/// The Cap menu's explicit Quit item -- ⌘Q.
Quit,
+ /// Open General settings from the application menu.
+ Preferences,
+ /// Choose a Cap recording to open.
+ OpenFile,
+ /// Import a video or image into the library.
+ ImportMedia,
+ /// Open the Changelog from the Help menu.
+ Changelog,
+ HelpDashboard,
+ HelpDocs,
+ HelpFaq,
+ HelpSelfHosting,
+ HelpCenter,
+ HelpStatus,
+ HelpDiscord,
/// `PredefinedMenuItem::close_window` -- ⌘W. Present twice in the
/// Tauri menu (File and Window), one action either way.
CloseWindow,
@@ -79,6 +159,7 @@ pub fn init(cx: &mut App) {
// `on_key_down` project-undo). A global binding here would shadow both.
cx.bind_keys([
KeyBinding::new("cmd-q", Quit, None),
+ KeyBinding::new("cmd-,", Preferences, None),
KeyBinding::new("cmd-h", HideSelf, None),
KeyBinding::new("alt-cmd-h", HideOthers, None),
KeyBinding::new("cmd-w", CloseWindow, None),
@@ -86,16 +167,49 @@ pub fn init(cx: &mut App) {
KeyBinding::new("ctrl-cmd-f", ToggleFullscreen, None),
]);
- cx.on_action(|_: &About, cx: &mut App| {
- // Ordering a window front re-enters gpui's window callbacks, so it runs
- // from a task with no borrow held (`platform::place_overlay_panel`'s
- // rule).
- cx.spawn(async move |_| platform::show_about_panel(APP_NAME, app_version()))
- .detach();
+ cx.on_action(|_: &CheckForUpdate, cx: &mut App| {
+ crate::updates::check_manually(cx);
});
cx.on_action(|_: &HideSelf, cx: &mut App| cx.hide());
cx.on_action(|_: &HideOthers, cx: &mut App| cx.hide_other_apps());
cx.on_action(|_: &Quit, cx: &mut App| quit(cx));
+ cx.on_action(|_: &Preferences, cx: &mut App| {
+ cx.defer(|cx| app_windows::open_settings(crate::settings_window::Page::General, cx));
+ });
+ cx.on_action(|_: &OpenFile, cx: &mut App| {
+ let (files, directories) = if cfg!(target_os = "macos") {
+ (true, false)
+ } else {
+ (false, true)
+ };
+ let paths = cx.prompt_for_paths(gpui::PathPromptOptions {
+ files,
+ directories,
+ multiple: false,
+ prompt: Some("Open Recording".into()),
+ });
+ cx.spawn(async move |cx| {
+ if let Ok(Ok(Some(paths))) = paths.await
+ && let Some(path) = paths.into_iter().next()
+ {
+ cx.update(|cx| crate::tray::open_previous_item(path, cx));
+ }
+ })
+ .detach();
+ });
+ cx.on_action(|_: &ImportMedia, cx: &mut App| {
+ crate::import::pick_and_import_media(cx);
+ });
+ cx.on_action(|_: &Changelog, cx: &mut App| {
+ app_windows::open_settings(crate::settings_window::Page::Changelog, cx)
+ });
+ cx.on_action(|_: &HelpDashboard, cx: &mut App| cx.open_url("https://cap.so/dashboard"));
+ cx.on_action(|_: &HelpDocs, cx: &mut App| cx.open_url("https://cap.so/docs"));
+ cx.on_action(|_: &HelpFaq, cx: &mut App| cx.open_url("https://cap.so/faq"));
+ cx.on_action(|_: &HelpSelfHosting, cx: &mut App| cx.open_url("https://cap.so/self-hosting"));
+ cx.on_action(|_: &HelpCenter, cx: &mut App| cx.open_url("https://help.cap.so/"));
+ cx.on_action(|_: &HelpStatus, cx: &mut App| cx.open_url("https://cap.openstatus.dev/"));
+ cx.on_action(|_: &HelpDiscord, cx: &mut App| cx.open_url("https://cap.link/discord"));
cx.on_action(|_: &CloseWindow, cx: &mut App| close_key_window(cx));
cx.on_action(|_: &Minimize, cx: &mut App| with_key_native(cx, platform::minimize_native));
cx.on_action(|_: &Zoom, cx: &mut App| with_key_native(cx, platform::zoom_native));
@@ -110,20 +224,46 @@ pub fn init(cx: &mut App) {
with_key_native(cx, platform::toggle_fullscreen_native)
});
- cx.set_menus(build_menus());
+ cx.set_global(MenuRegistration(UpdateRow::of(&crate::updates::status(cx))));
+ install_menus(cx);
}
-/// The menu bar model.
-///
-/// One-to-one with `build_macos_app_menu`, including the empty Help submenu
-/// (`Submenu::with_id_and_items(.., HELP_SUBMENU_ID, "Help", true, &[])`).
-pub fn build_menus() -> Vec<Menu> {
+pub(crate) fn refresh_update_menu(cx: &mut App) {
+ if !cx.has_global::<MenuRegistration>() {
+ return;
+ }
+
+ let row = UpdateRow::of(&crate::updates::status(cx));
+ if cx.global::<MenuRegistration>().0 == row {
+ return;
+ }
+ cx.global_mut::<MenuRegistration>().0 = row.clone();
+
+ #[cfg(target_os = "macos")]
+ platform::set_update_menu_item(row.title, row.badge.as_deref(), row.enabled);
+ #[cfg(not(target_os = "macos"))]
+ install_menus(cx);
+}
+
+fn install_menus(cx: &mut App) {
+ let update_status = crate::updates::status(cx);
+ cx.set_menus(build_menus(&update_status));
+ #[cfg(target_os = "macos")]
+ platform::patch_standard_application_menu();
+}
+
+/// The menu bar hierarchy and app-specific destinations.
+fn build_menus(update_status: &crate::updates::UpdateStatus) -> Vec<Menu> {
+ let update_row = UpdateRow::of(update_status);
vec![
Menu {
name: APP_NAME.into(),
disabled: false,
items: vec![
MenuItem::action(format!("About {APP_NAME}"), About),
+ MenuItem::action(update_row.title, CheckForUpdate).disabled(!update_row.enabled),
+ MenuItem::separator(),
+ MenuItem::action("Preferences…", Preferences),
MenuItem::separator(),
MenuItem::os_submenu("Services", SystemMenuType::Services),
MenuItem::separator(),
@@ -136,7 +276,12 @@ pub fn build_menus() -> Vec<Menu> {
Menu {
name: "File".into(),
disabled: false,
- items: vec![MenuItem::action("Close Window", CloseWindow)],
+ items: vec![
+ MenuItem::action("Open File…", OpenFile),
+ MenuItem::action("Import Media…", ImportMedia),
+ MenuItem::separator(),
+ MenuItem::action("Close Window", CloseWindow),
+ ],
},
Menu {
name: "Edit".into(),
@@ -180,7 +325,17 @@ pub fn build_menus() -> Vec<Menu> {
Menu {
name: "Help".into(),
disabled: false,
- items: vec![],
+ items: vec![
+ MenuItem::action("Changelog", Changelog),
+ MenuItem::separator(),
+ MenuItem::action("Dashboard", HelpDashboard),
+ MenuItem::action("Documentation", HelpDocs),
+ MenuItem::action("FAQ", HelpFaq),
+ MenuItem::action("Self-hosting", HelpSelfHosting),
+ MenuItem::action("Help Center", HelpCenter),
+ MenuItem::action("System Status", HelpStatus),
+ MenuItem::action("Join Discord Community", HelpDiscord),
+ ],
},
]
}
@@ -880,8 +1035,7 @@ mod tests {
assert!(gate.pending.is_none());
}
- /// The menu bar, transcribed from `build_macos_app_menu`. Separators are
- /// spelled `"-"` so the ordering is checked too.
+ /// Separators are spelled `"-"` so the ordering is checked too.
fn describe(menu: &Menu) -> (String, Vec<String>) {
let items = menu
.items
@@ -897,8 +1051,17 @@ mod tests {
}
#[test]
- fn menu_bar_matches_the_tauri_structure() {
- let menus: Vec<_> = build_menus().iter().map(describe).collect();
+ fn menu_bar_includes_native_and_cap_destinations() {
+ let menus: Vec<_> = build_menus(&crate::updates::UpdateStatus::Idle)
+ .iter()
+ .map(describe)
+ .collect();
+ let expected_file_items = vec![
+ "Open File…".into(),
+ "Import Media…".into(),
+ "-".into(),
+ "Close Window".into(),
+ ];
assert_eq!(
menus,
vec![
@@ -906,6 +1069,9 @@ mod tests {
"Cap".to_string(),
vec![
"About Cap".to_string(),
+ "Check for Update".into(),
+ "-".into(),
+ "Preferences…".into(),
"-".into(),
"Services".into(),
"-".into(),
@@ -915,7 +1081,7 @@ mod tests {
"Quit Cap".into(),
]
),
- ("File".into(), vec!["Close Window".into()]),
+ ("File".into(), expected_file_items,),
(
"Edit".into(),
vec![
@@ -938,11 +1104,117 @@ mod tests {
"Close Window".into(),
]
),
- ("Help".into(), vec![]),
+ (
+ "Help".into(),
+ vec![
+ "Changelog".into(),
+ "-".into(),
+ "Dashboard".into(),
+ "Documentation".into(),
+ "FAQ".into(),
+ "Self-hosting".into(),
+ "Help Center".into(),
+ "System Status".into(),
+ "Join Discord Community".into(),
+ ],
+ ),
]
);
}
+ /// The row is the second item of the App menu (`menu_bar_...` pins that
+ /// order); it greys out for the duration of a check so a second click
+ /// cannot fire another one.
+ #[test]
+ fn the_update_row_greys_out_while_checking() {
+ fn row(status: &crate::updates::UpdateStatus) -> (String, bool) {
+ let menus = build_menus(status);
+ match &menus[0].items[1] {
+ MenuItem::Action { name, disabled, .. } => (name.to_string(), *disabled),
+ _ => panic!("the update row is an action"),
+ }
+ }
+
+ assert_eq!(
+ row(&crate::updates::UpdateStatus::Idle),
+ ("Check for Update".to_string(), false)
+ );
+ assert_eq!(
+ row(&crate::updates::UpdateStatus::Checking),
+ ("Checking for Update…".to_string(), true)
+ );
+ }
+
+ /// The version lives only in the badge, and a percentage tick changes
+ /// nothing else -- that is what keeps a download from reinstalling the
+ /// menu bar on every progress event.
+ #[test]
+ fn the_update_row_keeps_the_version_out_of_the_title() {
+ use crate::updates::UpdateStatus;
+ use semver::Version;
+
+ let version = Version::parse("0.4.0").unwrap();
+ let downloading = |fraction| UpdateStatus::Downloading {
+ version: version.clone(),
+ fraction,
+ };
+
+ let cold = UpdateRow::of(&downloading(None));
+ let warm = UpdateRow::of(&downloading(Some(0.42)));
+ assert_eq!(cold.title, "Download update…");
+ assert!(cold.enabled);
+ assert_eq!(warm.title, cold.title);
+
+ let ready = UpdateRow::of(&UpdateStatus::Ready {
+ version: version.clone(),
+ });
+ let installed = UpdateRow::of(&UpdateStatus::Installed {
+ version: version.clone(),
+ executable: std::path::PathBuf::from("/Applications/Cap.app"),
+ });
+ assert_eq!(ready.title, "Restart to update…");
+ assert_eq!(installed.title, ready.title);
+ assert_eq!(installed.badge, ready.badge);
+
+ let installing = UpdateRow::of(&UpdateStatus::Installing {
+ version: version.clone(),
+ });
+ assert_eq!(installing.title, cold.title);
+ }
+
+ #[cfg(target_os = "macos")]
+ #[test]
+ fn the_update_badge_shows_the_version_and_live_progress() {
+ use crate::updates::UpdateStatus;
+ use semver::Version;
+
+ let version = Version::parse("0.4.0").unwrap();
+ let badge = |status| UpdateRow::of(&status).badge;
+
+ assert_eq!(
+ badge(UpdateStatus::Downloading {
+ version: version.clone(),
+ fraction: None,
+ }),
+ Some("v0.4.0".to_string())
+ );
+ assert_eq!(
+ badge(UpdateStatus::Downloading {
+ version: version.clone(),
+ fraction: Some(0.42),
+ }),
+ Some("v0.4.0 · 42%".to_string())
+ );
+ assert_eq!(
+ badge(UpdateStatus::Ready {
+ version: version.clone(),
+ }),
+ Some("v0.4.0".to_string())
+ );
+ assert_eq!(badge(UpdateStatus::Idle), None);
+ assert_eq!(badge(UpdateStatus::Checking), None);
+ }
+
/// `sync_macos_dock_visibility`'s three branches.
#[test]
fn dock_policy_matches_the_tauri_rule() {
diff --git a/apps/desktop-gpui/src/platform.rs b/apps/desktop-gpui/src/platform.rs
index 7c05c4f6b..2e90f470d 100644
--- a/apps/desktop-gpui/src/platform.rs
+++ b/apps/desktop-gpui/src/platform.rs
@@ -641,9 +641,13 @@ mod mac {
}
use gpui::Window;
- use objc2::rc::Id;
+ use objc2::rc::Retained;
use objc2::runtime::{AnyObject, Sel};
- use objc2_app_kit::{NSView, NSWindow, NSWindowCollectionBehavior};
+ use objc2_app_kit::{
+ NSApplication, NSDocumentController, NSMenu, NSMenuItem, NSView, NSWindow,
+ NSWindowCollectionBehavior,
+ };
+ use objc2_foundation::{NSObjectNSKeyValueCoding, NSString};
use raw_window_handle::{HasWindowHandle, RawWindowHandle};
use super::{ForcedAppearance, MaterialKind, PanelBehavior};
@@ -651,6 +655,150 @@ mod mac {
static NATIVE_QUIT_REQUESTS: std::sync::OnceLock<super::NativeQuitRequests> =
std::sync::OnceLock::new();
+ /// Rows of `menus::build_menus`' Cap and File menus. Both menus are built
+ /// from that model in this order, so the positions are fixed.
+ const APP_MENU: isize = 0;
+ const ABOUT_ROW: isize = 0;
+ const UPDATE_ROW: isize = 1;
+ const PREFERENCES_ROW: isize = 3;
+ const FILE_MENU: isize = 1;
+ const OPEN_RECENT_ROW: isize = 1;
+
+ pub fn patch_standard_application_menu() {
+ use objc2::{exception, msg_send, runtime::AnyObject, sel};
+ use std::panic::AssertUnwindSafe;
+
+ let Some(main_thread) = objc2_foundation::MainThreadMarker::new() else {
+ tracing::error!("Cannot patch the application menu off the main thread");
+ return;
+ };
+ let app = NSApplication::sharedApplication(main_thread);
+ let Some(main_menu) = app.mainMenu() else {
+ tracing::warn!("GPUI did not install an application menu");
+ return;
+ };
+ let Some(app_menu) = main_menu
+ .itemAtIndex(APP_MENU)
+ .and_then(|item| item.submenu())
+ else {
+ return;
+ };
+ // gpui's `validateMenuItem:` answers only "is this action available?",
+ // which is always yes for Cap's global listeners -- so AppKit's
+ // auto-enable pass overwrites `MenuItem::Action`'s `disabled` every
+ // time the menu opens. The model's enabled state has to be
+ // authoritative instead, as it already is for the tray menu and for
+ // muda.
+ app_menu.setAutoenablesItems(false);
+
+ if let Some(about) = app_menu.itemAtIndex(ABOUT_ROW) {
+ unsafe {
+ about.setAction(Some(sel!(orderFrontStandardAboutPanel:)));
+ about.setTarget(None);
+ about.setAllowsAutomaticKeyEquivalentLocalization(true);
+ }
+ }
+ if let Some(preferences) = app_menu.itemAtIndex(PREFERENCES_ROW) {
+ preferences.setAllowsAutomaticKeyEquivalentLocalization(true);
+ }
+ if let Some(quit) = app_menu
+ .numberOfItems()
+ .checked_sub(1)
+ .and_then(|index| app_menu.itemAtIndex(index))
+ {
+ unsafe {
+ quit.setAction(Some(sel!(terminate:)));
+ quit.setTarget(None);
+ quit.setAllowsAutomaticKeyEquivalentLocalization(true);
+ }
+ }
+
+ let Some(file_menu) = main_menu
+ .itemAtIndex(FILE_MENU)
+ .and_then(|item| item.submenu())
+ else {
+ return;
+ };
+ let has_recent_menu = file_menu.itemAtIndex(OPEN_RECENT_ROW).is_some_and(|item| {
+ item.title()
+ .isEqualToString(&NSString::from_str("Open Recent"))
+ });
+ if has_recent_menu {
+ return;
+ }
+
+ let recent_menu = NSMenu::new(main_thread);
+ recent_menu.setTitle(&NSString::from_str("Open Recent"));
+ let name = NSString::from_str("NSRecentDocumentsMenu");
+ let key = NSString::from_str("menuName");
+ let registered = exception::catch(AssertUnwindSafe(|| {
+ unsafe { recent_menu.setValue_forKey(Some(&*name as &AnyObject), &key) };
+ }));
+ if let Err(error) = registered {
+ tracing::warn!("Could not register Open Recent menu name: {error:?}");
+ }
+
+ let clear_item = NSMenuItem::new(main_thread);
+ clear_item.setTitle(&NSString::from_str("Clear Menu"));
+ unsafe { clear_item.setAction(Some(sel!(clearRecentDocuments:))) };
+ recent_menu.addItem(&clear_item);
+
+ let recent_item = NSMenuItem::new(main_thread);
+ recent_item.setTitle(&NSString::from_str("Open Recent"));
+ recent_item.setSubmenu(Some(&recent_menu));
+ file_menu.insertItem_atIndex(&recent_item, OPEN_RECENT_ROW);
+
+ let controller = NSDocumentController::sharedDocumentController(main_thread);
+ let can_install_menu: bool =
+ unsafe { msg_send![&*controller, respondsToSelector: sel!(_installOpenRecentMenus)] };
+ if can_install_menu {
+ unsafe {
+ let _: () = msg_send![&*controller, _installOpenRecentMenus];
+ }
+ } else {
+ tracing::warn!("NSDocumentController cannot install the Open Recent menu");
+ }
+ }
+
+ /// Rewrites the Check for Update row in place. A menu item edited this way
+ /// keeps whatever menu the user has open on screen; reinstalling the menu
+ /// bar for every download-percentage tick would close it.
+ pub fn set_update_menu_item(title: &str, badge: Option<&str>, enabled: bool) {
+ use objc2::runtime::AnyClass;
+ use objc2_app_kit::NSMenuItemBadge;
+ use objc2_foundation::MainThreadMarker;
+
+ let Some(main_thread) = MainThreadMarker::new() else {
+ return;
+ };
+ let Some(item) = update_menu_item(main_thread) else {
+ tracing::warn!("The update row is missing from the application menu");
+ return;
+ };
+ item.setTitle(&NSString::from_str(title));
+ item.setEnabled(enabled);
+
+ // `NSMenuItemBadge` and `setBadge:` are macOS 14+, and objc2's class
+ // lookup panics when the class is absent.
+ if AnyClass::get(c"NSMenuItemBadge").is_none() {
+ return;
+ }
+ let badge = badge.map(|text| {
+ NSMenuItemBadge::initWithString(main_thread.alloc(), &NSString::from_str(text))
+ });
+ item.setBadge(badge.as_deref());
+ }
+
+ fn update_menu_item(
+ main_thread: objc2_foundation::MainThreadMarker,
+ ) -> Option<Retained<NSMenuItem>> {
+ NSApplication::sharedApplication(main_thread)
+ .mainMenu()?
+ .itemAtIndex(APP_MENU)?
+ .submenu()?
+ .itemAtIndex(UPDATE_ROW)
+ }
+
unsafe extern "C-unwind" fn application_should_terminate(
_: &AnyObject,
_: Sel,
@@ -682,7 +830,7 @@ mod mac {
.as_ref()
.ok_or("Application delegate is unavailable")?;
let delegate_class = delegate.class();
- if delegate_class.name() != "GPUIApplicationDelegate" {
+ if delegate_class.name() != c"GPUIApplicationDelegate" {
return Err("Native Quit requires the owned GPUI application delegate".into());
}
let selector = sel!(applicationShouldTerminate:);
@@ -697,12 +845,12 @@ mod mac {
unsafe extern "C-unwind" fn(&AnyObject, Sel, *mut AnyObject) -> usize,
Imp,
>(application_should_terminate);
- if !objc2::runtime::Bool::from_raw(ffi::class_addMethod(
+ if !ffi::class_addMethod(
delegate_class as *const _ as *mut _,
- selector.as_ptr(),
- Some(implementation),
+ selector,
+ implementation,
c"Q@:@".as_ptr(),
- ))
+ )
.as_bool()
{
return Err("Could not install the native Quit handler".into());
@@ -856,12 +1004,12 @@ mod mac {
// `NSGlassEffectView` exists only on macOS 26+; its absence is what
// sends `macos-window-material.ts` down the vibrancy branch.
if material_override.as_deref() != Some("vibrancy")
- && let Some(glass_class) = AnyClass::get("NSGlassEffectView")
+ && let Some(glass_class) = AnyClass::get(c"NSGlassEffectView")
{
unsafe {
let glass: *mut AnyObject = msg_send![glass_class, alloc];
let glass: *mut AnyObject = msg_send![glass, initWithFrame: bounds];
- if let Some(glass) = Id::from_raw(glass) {
+ if let Some(glass) = Retained::from_raw(glass) {
set_clip_radius(radius);
let identifier = NSString::from_str(LIQUID_GLASS_IDENTIFIER);
let _: () = msg_send![&*glass, setIdentifier: &*identifier];
@@ -878,7 +1026,7 @@ mod mac {
let _: () = msg_send![
&*content_view,
addSubview: &*glass,
- positioned: NSWindowOrderingMode::NSWindowBelow,
+ positioned: NSWindowOrderingMode::Below,
relativeTo: std::ptr::null_mut::<AnyObject>(),
];
return Some(MaterialKind::LiquidGlass);
@@ -897,12 +1045,12 @@ mod mac {
vibrancy.setBlendingMode(NSVisualEffectBlendingMode::BehindWindow);
vibrancy.setState(NSVisualEffectState::FollowsWindowActiveState);
vibrancy.setAutoresizingMask(
- NSAutoresizingMaskOptions::NSViewWidthSizable
- | NSAutoresizingMaskOptions::NSViewHeightSizable,
+ NSAutoresizingMaskOptions::ViewWidthSizable
+ | NSAutoresizingMaskOptions::ViewHeightSizable,
);
content_view.addSubview_positioned_relativeTo(
&vibrancy,
- NSWindowOrderingMode::NSWindowBelow,
+ NSWindowOrderingMode::Below,
None,
);
}
@@ -951,7 +1099,7 @@ mod mac {
use objc2::ffi::class_addMethod;
use objc2_foundation::NSRect;
- unsafe extern "C" fn constrain_shim(
+ unsafe extern "C-unwind" fn constrain_shim(
_this: *mut AnyObject,
_sel: Sel,
frame: NSRect,
@@ -961,22 +1109,30 @@ mod mac {
}
for name in ["GPUIWindow", "GPUIPanel"] {
- let Some(class) = objc2::runtime::AnyClass::get(name) else {
+ let Some(class) = objc2::runtime::AnyClass::get(match name {
+ "GPUIWindow" => c"GPUIWindow",
+ "GPUIPanel" => c"GPUIPanel",
+ _ => continue,
+ }) else {
continue;
};
let added = unsafe {
class_addMethod(
- (class as *const objc2::runtime::AnyClass as *mut objc2::ffi::objc_class)
- .cast(),
- objc2::sel!(constrainFrameRect:toScreen:).as_ptr(),
- Some(std::mem::transmute::<
- unsafe extern "C" fn(*mut AnyObject, Sel, NSRect, *mut AnyObject) -> NSRect,
- unsafe extern "C" fn(),
- >(constrain_shim)),
+ (class as *const objc2::runtime::AnyClass).cast_mut(),
+ objc2::sel!(constrainFrameRect:toScreen:),
+ std::mem::transmute::<
+ unsafe extern "C-unwind" fn(
+ *mut AnyObject,
+ Sel,
+ NSRect,
+ *mut AnyObject,
+ ) -> NSRect,
+ objc2::runtime::Imp,
+ >(constrain_shim),
c"{CGRect={CGPoint=dd}{CGSize=dd}}@:{CGRect={CGPoint=dd}{CGSize=dd}}@".as_ptr(),
)
};
- if objc2::runtime::Bool::from_raw(added).as_bool() {
+ if added.as_bool() {
tracing::info!("installed frame-constraint shim on {name}");
}
}
@@ -1049,7 +1205,7 @@ mod mac {
/// A retained `NSWindow` that can outlive a `&Window` borrow -- what
/// [`place_overlay_panel`] operates on.
- pub struct NativeWindow(Id<NSWindow>);
+ pub struct NativeWindow(Retained<NSWindow>);
/// The retained `NSWindow` behind a gpui window, for AppKit calls that
/// must run *outside* any gpui update (see [`place_overlay_panel`]).
@@ -1306,7 +1462,7 @@ mod mac {
}
/// The `NSWindow` behind a gpui window.
- pub fn ns_window(window: &Window) -> Option<Id<NSWindow>> {
+ pub fn ns_window(window: &Window) -> Option<Retained<NSWindow>> {
// Fully qualified: `Window` also has an inherent `window_handle()`
// returning gpui's own `AnyWindowHandle`.
let handle = HasWindowHandle::window_handle(window).ok()?;
@@ -1513,7 +1669,7 @@ mod mac {
static SOURCE: OnceLock<usize> = OnceLock::new();
*SOURCE.get_or_init(|| {
- let Some(mut builder) = ClassBuilder::new("CapFileDragSource", NSObject::class())
+ let Some(mut builder) = ClassBuilder::new(c"CapFileDragSource", NSObject::class())
else {
return 0;
};
@@ -1529,7 +1685,7 @@ mod mac {
) -> usize,
);
}
- if let Some(protocol) = AnyProtocol::get("NSDraggingSource") {
+ if let Some(protocol) = AnyProtocol::get(c"NSDraggingSource") {
builder.add_protocol(protocol);
}
let class = builder.register();
@@ -1676,7 +1832,7 @@ mod mac {
use objc2::{class, msg_send};
use objc2_foundation::NSString;
unsafe {
- let mut image: Option<Id<AnyObject>> = None;
+ let mut image: Option<Retained<AnyObject>> = None;
let cap_app = NSString::from_str("/Applications/Cap.app");
let exists: bool = {
@@ -1688,7 +1844,7 @@ mod mac {
if !workspace.is_null() {
let raw: *mut AnyObject = msg_send![workspace, iconForFile: &*cap_app];
// `iconForFile:` is autoreleased; retain for the setter.
- image = Id::retain(raw);
+ image = Retained::retain(raw);
if let Some(image) = &image {
// The workspace icon's nominal size is small (32pt);
// the reps go up to 1024. Ask for dock resolution.
@@ -1709,7 +1865,7 @@ mod mac {
if !data.is_null() {
let alloc: *mut AnyObject = msg_send![class!(NSImage), alloc];
let raw: *mut AnyObject = msg_send![alloc, initWithData: data];
- image = Id::from_raw(raw);
+ image = Retained::from_raw(raw);
}
}
@@ -2044,11 +2200,11 @@ mod mac {
let _: () = msg_send![panel, setCanCreateDirectories: true];
let _: () = msg_send![panel, setNameFieldStringValue: &*NSString::from_str(suggested)];
if !extensions.is_empty() {
- let types: Vec<Id<NSString>> = extensions
+ let types: Vec<Retained<NSString>> = extensions
.iter()
.map(|extension| NSString::from_str(extension))
.collect();
- let types = NSArray::from_vec(types);
+ let types = NSArray::from_retained_slice(&types);
let _: () = msg_send![panel, setAllowedFileTypes: &*types];
}
let response: isize = msg_send![panel, runModal];
@@ -2116,7 +2272,7 @@ mod mac {
let data = NSData::with_bytes(bytes);
let image: *mut AnyObject = msg_send![class!(NSImage), alloc];
let image: *mut AnyObject = msg_send![image, initWithData: &*data];
- let image = Id::from_raw(image).ok_or("Failed to load image")?;
+ let image = Retained::from_raw(image).ok_or("Failed to load image")?;
let objects: *mut AnyObject = msg_send![class!(NSArray), arrayWithObject: &*image];
let _: isize = msg_send![pasteboard, clearContents];
let ok: Bool = msg_send![pasteboard, writeObjects: objects];
@@ -2141,11 +2297,11 @@ mod mac {
let _: () = msg_send![panel, setCanChooseDirectories: false];
let _: () = msg_send![panel, setAllowsMultipleSelection: false];
- let types: Vec<Id<NSString>> = extensions
+ let types: Vec<Retained<NSString>> = extensions
.iter()
.map(|extension| NSString::from_str(extension))
.collect();
- let types = NSArray::from_vec(types);
+ let types = NSArray::from_retained_slice(&types);
let _: () = msg_send![panel, setAllowedFileTypes: &*types];
// `NSModalResponseOK`.
@@ -2186,7 +2342,7 @@ mod mac {
cancel: &str,
warning: bool,
) -> bool {
- use objc2::{class, msg_send, msg_send_id};
+ use objc2::{class, msg_send};
use objc2_foundation::NSString;
/// `NSAlertStyle`: `Warning = 0`, `Informational = 1`. `NSUInteger`,
@@ -2199,7 +2355,7 @@ mod mac {
const NS_ALERT_FIRST_BUTTON_RETURN: isize = 1000;
unsafe {
- let alert: Id<AnyObject> = msg_send_id![class!(NSAlert), new];
+ let alert: Retained<AnyObject> = msg_send![class!(NSAlert), new];
let _: () = msg_send![&*alert, setMessageText: &*NSString::from_str(title)];
let _: () = msg_send![&*alert, setInformativeText: &*NSString::from_str(message)];
let _: () = msg_send![
@@ -2222,13 +2378,13 @@ mod mac {
}
pub fn alert_dialog(title: &str, message: &str) {
- use objc2::{class, msg_send, msg_send_id};
+ use objc2::{class, msg_send};
use objc2_foundation::NSString;
const NS_ALERT_STYLE_INFORMATIONAL: usize = 1;
unsafe {
- let alert: Id<AnyObject> = msg_send_id![class!(NSAlert), new];
+ let alert: Retained<AnyObject> = msg_send![class!(NSAlert), new];
let _: () = msg_send![&*alert, setMessageText: &*NSString::from_str(title)];
let _: () = msg_send![&*alert, setInformativeText: &*NSString::from_str(message)];
let _: () = msg_send![&*alert, setAlertStyle: NS_ALERT_STYLE_INFORMATIONAL];
@@ -2485,48 +2641,6 @@ mod mac {
}
}
- // -- The About panel ------------------------------------------------------
-
- /// `PredefinedMenuItem::about(.., AboutMetadata { name, version, .. })`,
- /// which on macOS is `orderFrontStandardAboutPanelWithOptions:`.
- ///
- /// The Tauri metadata also carries `copyright` and `publisher` from
- /// `tauri.conf.json` -- neither key exists in that file, so both are `None`
- /// there and there is nothing to pass here either.
- ///
- /// Spins no modal run loop of its own (the panel is an ordinary window), but
- /// ordering a window front re-enters gpui's window callbacks, so it keeps
- /// the [`place_overlay_panel`] rule: call it from a task, never inside an
- /// update.
- pub fn show_about_panel(name: &str, version: &str) {
- use objc2::{class, msg_send};
- use objc2_foundation::{NSArray, NSString};
-
- unsafe {
- let app: *mut AnyObject = msg_send![class!(NSApplication), sharedApplication];
- if app.is_null() {
- return;
- }
- // `dictionaryWithObjects:forKeys:` rather than a typed
- // `NSDictionary` constructor, for the reason
- // [`desktop_picture_path`] gives: the typed binding needs another
- // objc2-app-kit/foundation feature, and the rule here is that those
- // versions stay pinned to gpui's.
- let values =
- NSArray::from_vec(vec![NSString::from_str(name), NSString::from_str(version)]);
- let keys = NSArray::from_vec(vec![
- NSString::from_str("ApplicationName"),
- NSString::from_str("ApplicationVersion"),
- ]);
- let options: *mut AnyObject = msg_send![
- class!(NSDictionary),
- dictionaryWithObjects: &*values,
- forKeys: &*keys,
- ];
- let _: () = msg_send![app, orderFrontStandardAboutPanelWithOptions: options];
- }
- }
-
/// One-line diagnostic of everything AppKit weighs into occlusion
/// visibility -- how the macOS 26 display-link failure was diagnosed; keep
/// it for the next platform mystery.
@@ -2840,7 +2954,6 @@ mod stub {
pub fn activation_policy() -> isize {
-1
}
- pub fn show_about_panel(_name: &str, _version: &str) {}
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
diff --git a/apps/desktop-gpui/src/platform/macos_exception_guard.rs b/apps/desktop-gpui/src/platform/macos_exception_guard.rs
index 0348df865..e3c1f875d 100644
--- a/apps/desktop-gpui/src/platform/macos_exception_guard.rs
+++ b/apps/desktop-gpui/src/platform/macos_exception_guard.rs
@@ -16,7 +16,7 @@ use std::sync::OnceLock;
use objc2::{
ffi, msg_send,
- rc::Id,
+ rc::Retained,
runtime::{AnyClass, AnyObject, Imp, Sel},
sel,
};
@@ -46,9 +46,7 @@ impl GuardedMethod {
if self.original.get().is_some() || class.verify_sel::<(), ()>(selector).is_err() {
return false;
}
- let method = unsafe {
- ffi::class_getInstanceMethod((class as *const AnyClass).cast(), selector.as_ptr())
- };
+ let method = unsafe { ffi::class_getInstanceMethod(class, selector) };
if method.is_null() {
return false;
}
@@ -63,7 +61,7 @@ impl GuardedMethod {
if self.original.set(original).is_err() {
return false;
}
- unsafe { ffi::method_setImplementation(method, Some(guard_imp)) };
+ let _ = unsafe { ffi::method_setImplementation(method, guard_imp) };
true
}
@@ -72,12 +70,12 @@ impl GuardedMethod {
return false;
};
let exception = unsafe { cap_call_void_imp_catching(original, receiver, selector) };
- let Some(exception) = (unsafe { Id::from_raw(exception) }) else {
+ let Some(exception) = (unsafe { Retained::from_raw(exception) }) else {
return false;
};
tracing::warn!(
exception = %describe(&exception),
- selector = %selector.name(),
+ selector = %selector.name().to_string_lossy(),
"ignored an AppKit exception that would have crashed the app"
);
true
@@ -110,7 +108,7 @@ unsafe extern "C" fn touch_bar_finder_invalidate(receiver: *mut AnyObject, selec
/// Call once on the main thread, before the app's run loop starts.
pub(super) fn install() {
- let Some(class) = AnyClass::get("_NSTouchBarFinderObservation") else {
+ let Some(class) = AnyClass::get(c"_NSTouchBarFinderObservation") else {
tracing::info!("AppKit has no Touch Bar finder observation class; nothing to guard");
return;
};
@@ -124,7 +122,7 @@ mod tests {
use std::sync::atomic::{AtomicUsize, Ordering};
use objc2::{
- ClassType, msg_send, msg_send_id,
+ ClassType, msg_send,
runtime::{ClassBuilder, NSObject},
};
@@ -145,7 +143,7 @@ mod tests {
static CLASS: OnceLock<&'static AnyClass> = OnceLock::new();
CLASS.get_or_init(|| {
let mut builder =
- ClassBuilder::new("CapExceptionGuardTestObservation", NSObject::class()).unwrap();
+ ClassBuilder::new(c"CapExceptionGuardTestObservation", NSObject::class()).unwrap();
unsafe {
builder.add_method(
sel!(invalidate),
@@ -170,7 +168,7 @@ mod tests {
sel!(invalidate),
)
};
- let exception = unsafe { Id::from_raw(exception) }
+ let exception = unsafe { Retained::from_raw(exception) }
.expect("removing an unregistered observer must throw");
let description = describe(&exception);
assert!(
@@ -186,7 +184,7 @@ mod tests {
assert!(TEST_GUARD.install(class, sel!(invalidate), guarded));
assert!(!TEST_GUARD.install(class, sel!(invalidate), guarded));
- let instance: Id<NSObject> = unsafe { msg_send_id![class, new] };
+ let instance: Retained<NSObject> = unsafe { msg_send![class, new] };
for _ in 0..3 {
let before = removal_calls();
let _: () = unsafe { msg_send![&instance, invalidate] };
@@ -197,10 +195,10 @@ mod tests {
#[test]
fn appkit_still_has_the_touch_bar_finder_method_this_guards() {
assert!(
- AnyClass::get("NSApplication").is_some(),
+ AnyClass::get(c"NSApplication").is_some(),
"AppKit is not loaded"
);
- let class = AnyClass::get("_NSTouchBarFinderObservation")
+ let class = AnyClass::get(c"_NSTouchBarFinderObservation")
.expect("AppKit renamed _NSTouchBarFinderObservation; re-check the guard");
assert!(class.verify_sel::<(), ()>(sel!(invalidate)).is_ok());
}
diff --git a/apps/desktop-gpui/src/platform/macos_occlusion.rs b/apps/desktop-gpui/src/platform/macos_occlusion.rs
index 0c4405979..6e6dc8fff 100644
--- a/apps/desktop-gpui/src/platform/macos_occlusion.rs
+++ b/apps/desktop-gpui/src/platform/macos_occlusion.rs
@@ -7,7 +7,7 @@ use objc2::{
sel,
};
-type OcclusionStateFn = unsafe extern "C" fn(*mut AnyObject, Sel) -> usize;
+type OcclusionStateFn = unsafe extern "C-unwind" fn(*mut AnyObject, Sel) -> usize;
struct OcclusionShim {
original: OnceLock<OcclusionStateFn>,
@@ -46,15 +46,12 @@ impl OcclusionShim {
let added = unsafe {
class_addMethod(
(class as *const AnyClass).cast_mut().cast(),
- selector.as_ptr(),
- Some(std::mem::transmute::<
- OcclusionStateFn,
- unsafe extern "C" fn(),
- >(shim)),
+ selector,
+ std::mem::transmute::<OcclusionStateFn, Imp>(shim),
c"Q@:".as_ptr(),
)
};
- Ok(Bool::from_raw(added).as_bool())
+ Ok(added.as_bool())
}
unsafe fn state(&self, receiver: *mut AnyObject, selector: Sel) -> usize {
@@ -121,23 +118,29 @@ unsafe fn is_visible(receiver: *mut AnyObject) -> bool {
static WINDOW_SHIM: OcclusionShim = OcclusionShim::new();
static PANEL_SHIM: OcclusionShim = OcclusionShim::new();
-unsafe extern "C" fn window_occlusion_state(receiver: *mut AnyObject, selector: Sel) -> usize {
+unsafe extern "C-unwind" fn window_occlusion_state(
+ receiver: *mut AnyObject,
+ selector: Sel,
+) -> usize {
unsafe { WINDOW_SHIM.state(receiver, selector) }
}
-unsafe extern "C" fn panel_occlusion_state(receiver: *mut AnyObject, selector: Sel) -> usize {
+unsafe extern "C-unwind" fn panel_occlusion_state(
+ receiver: *mut AnyObject,
+ selector: Sel,
+) -> usize {
unsafe { PANEL_SHIM.state(receiver, selector) }
}
pub(super) fn install() {
for (name, state, implementation) in [
(
- "GPUIWindow",
+ c"GPUIWindow",
&WINDOW_SHIM,
window_occlusion_state as OcclusionStateFn,
),
(
- "GPUIPanel",
+ c"GPUIPanel",
&PANEL_SHIM,
panel_occlusion_state as OcclusionStateFn,
),
@@ -146,20 +149,27 @@ pub(super) fn install() {
continue;
};
match state.install(class, implementation) {
- Ok(true) => tracing::info!("installed macOS occlusion shim on {name}"),
+ Ok(true) => {
+ tracing::info!(name = %name.to_string_lossy(), "installed macOS occlusion shim")
+ }
Ok(false) => {}
- Err(error) => tracing::warn!(%error, name, "could not install macOS occlusion shim"),
+ Err(error) => {
+ tracing::warn!(%error, name = %name.to_string_lossy(), "could not install macOS occlusion shim")
+ }
}
}
}
#[cfg(test)]
mod tests {
- use std::cell::Cell;
+ use std::{
+ cell::Cell,
+ ffi::{CStr, CString},
+ };
use objc2::{
- ClassType, msg_send_id,
- rc::Id,
+ ClassType, msg_send,
+ rc::Retained,
runtime::{ClassBuilder, NSObject},
};
@@ -181,37 +191,49 @@ mod tests {
overridden_panel: &'static AnyClass,
}
- unsafe extern "C" fn native_window_state(_receiver: *mut AnyObject, _selector: Sel) -> usize {
+ unsafe extern "C-unwind" fn native_window_state(
+ _receiver: *mut AnyObject,
+ _selector: Sel,
+ ) -> usize {
WINDOW_CALLS.set(WINDOW_CALLS.get() + 1);
RAW_STATE.get()
}
- unsafe extern "C" fn native_is_visible(_receiver: *mut AnyObject, _selector: Sel) -> Bool {
+ unsafe extern "C-unwind" fn native_is_visible(
+ _receiver: *mut AnyObject,
+ _selector: Sel,
+ ) -> Bool {
Bool::new(VISIBLE.get())
}
- unsafe extern "C" fn native_panel_state(_receiver: *mut AnyObject, _selector: Sel) -> usize {
+ unsafe extern "C-unwind" fn native_panel_state(
+ _receiver: *mut AnyObject,
+ _selector: Sel,
+ ) -> usize {
PANEL_CALLS.set(PANEL_CALLS.get() + 1);
RAW_STATE.get()
}
- unsafe extern "C" fn overriding_window_state(
+ unsafe extern "C-unwind" fn overriding_window_state(
receiver: *mut AnyObject,
_selector: Sel,
) -> usize {
unsafe { msg_send![super(receiver, classes().window), occlusionState] }
}
- unsafe extern "C" fn overriding_panel_state(receiver: *mut AnyObject, _selector: Sel) -> usize {
+ unsafe extern "C-unwind" fn overriding_panel_state(
+ receiver: *mut AnyObject,
+ _selector: Sel,
+ ) -> usize {
unsafe { msg_send![super(receiver, classes().panel), occlusionState] }
}
- fn inherit(name: &str, superclass: &AnyClass) -> &'static AnyClass {
+ fn inherit(name: &CStr, superclass: &AnyClass) -> &'static AnyClass {
ClassBuilder::new(name, superclass).unwrap().register()
}
fn with_method(
- name: &str,
+ name: &CStr,
superclass: &AnyClass,
implementation: OcclusionStateFn,
) -> &'static AnyClass {
@@ -225,7 +247,7 @@ mod tests {
CLASSES.get_or_init(|| {
let native_window = {
let mut builder =
- ClassBuilder::new("CapOcclusionTestNativeWindow", NSObject::class()).unwrap();
+ ClassBuilder::new(c"CapOcclusionTestNativeWindow", NSObject::class()).unwrap();
unsafe {
builder.add_method(
sel!(occlusionState),
@@ -233,40 +255,38 @@ mod tests {
);
builder.add_method(
sel!(isVisible),
- native_is_visible as unsafe extern "C" fn(_, _) -> _,
+ native_is_visible as unsafe extern "C-unwind" fn(_, _) -> _,
);
}
builder.register()
};
let native_panel = with_method(
- "CapOcclusionTestNativePanel",
+ c"CapOcclusionTestNativePanel",
native_window,
native_panel_state,
);
- let window = inherit("CapOcclusionTestWindow", native_window);
- let panel = inherit("CapOcclusionTestPanel", native_panel);
+ let window = inherit(c"CapOcclusionTestWindow", native_window);
+ let panel = inherit(c"CapOcclusionTestPanel", native_panel);
assert!(WINDOW_SHIM.install(window, window_occlusion_state).unwrap());
assert!(PANEL_SHIM.install(panel, panel_occlusion_state).unwrap());
let mut inherited_window = window;
let mut inherited_panel = panel;
for depth in 0..4 {
- inherited_window = inherit(
- &format!("CapOcclusionTestWindowSubclass{depth}"),
- inherited_window,
- );
- inherited_panel = inherit(
- &format!("CapOcclusionTestPanelSubclass{depth}"),
- inherited_panel,
- );
+ let window_name =
+ CString::new(format!("CapOcclusionTestWindowSubclass{depth}")).unwrap();
+ inherited_window = inherit(&window_name, inherited_window);
+ let panel_name =
+ CString::new(format!("CapOcclusionTestPanelSubclass{depth}")).unwrap();
+ inherited_panel = inherit(&panel_name, inherited_panel);
}
let window_override = with_method(
- "CapOcclusionTestWindowOverride",
+ c"CapOcclusionTestWindowOverride",
window,
overriding_window_state,
);
let panel_override = with_method(
- "CapOcclusionTestPanelOverride",
+ c"CapOcclusionTestPanelOverride",
panel,
overriding_panel_state,
);
@@ -276,16 +296,19 @@ mod tests {
inherited_window,
inherited_panel,
overridden_window: inherit(
- "CapOcclusionTestInheritedWindowOverride",
+ c"CapOcclusionTestInheritedWindowOverride",
window_override,
),
- overridden_panel: inherit("CapOcclusionTestInheritedPanelOverride", panel_override),
+ overridden_panel: inherit(
+ c"CapOcclusionTestInheritedPanelOverride",
+ panel_override,
+ ),
}
})
}
fn verify_states(class: &AnyClass, expected_window_calls: usize, expected_panel_calls: usize) {
- let instance: Id<NSObject> = unsafe { msg_send_id![class, new] };
+ let instance: Retained<NSObject> = unsafe { msg_send![class, new] };
for visible in [true, false] {
VISIBLE.set(visible);
for raw in [0, 0x2, 0x2000, 0x2002] {
@@ -372,7 +395,7 @@ mod tests {
#[test]
fn promoting_a_window_switches_to_the_panel_implementation() {
let classes = classes();
- let instance: Id<NSObject> = unsafe { msg_send_id![classes.window, new] };
+ let instance: Retained<NSObject> = unsafe { msg_send![classes.window, new] };
RAW_STATE.set(0x2000);
WINDOW_CALLS.set(0);
PANEL_CALLS.set(0);
@@ -392,17 +415,20 @@ mod tests {
#[test]
fn incompatible_native_method_does_not_install_a_shim() {
- unsafe extern "C" fn wrong_signature(_receiver: *mut AnyObject, _selector: Sel) -> f64 {
+ unsafe extern "C-unwind" fn wrong_signature(
+ _receiver: *mut AnyObject,
+ _selector: Sel,
+ ) -> f64 {
0.0
}
let state = OcclusionShim::new();
let mut builder =
- ClassBuilder::new("CapOcclusionTestWrongSignature", NSObject::class()).unwrap();
+ ClassBuilder::new(c"CapOcclusionTestWrongSignature", NSObject::class()).unwrap();
unsafe {
builder.add_method(
sel!(occlusionState),
- wrong_signature as unsafe extern "C" fn(_, _) -> _,
+ wrong_signature as unsafe extern "C-unwind" fn(_, _) -> _,
);
}
let class = builder.register();
@@ -414,12 +440,12 @@ mod tests {
fn existing_class_override_is_not_replaced() {
let state = OcclusionShim::new();
let class = with_method(
- "CapOcclusionTestExistingOverride",
+ c"CapOcclusionTestExistingOverride",
NSObject::class(),
native_window_state,
);
assert!(!state.install(class, window_occlusion_state).unwrap());
- let instance: Id<NSObject> = unsafe { msg_send_id![class, new] };
+ let instance: Retained<NSObject> = unsafe { msg_send![class, new] };
RAW_STATE.set(0x2000);
let raw: usize = unsafe { msg_send![&*instance, occlusionState] };
assert_eq!(raw, 0x2000);
@@ -428,7 +454,7 @@ mod tests {
#[test]
fn missing_native_method_does_not_install_a_shim() {
let state = OcclusionShim::new();
- let class = inherit("CapOcclusionTestMissingMethod", NSObject::class());
+ let class = inherit(c"CapOcclusionTestMissingMethod", NSObject::class());
assert!(state.install(class, window_occlusion_state).is_err());
assert!(state.original.get().is_none());
assert!(class.instance_method(sel!(occlusionState)).is_none());
diff --git a/apps/desktop-gpui/src/platform/windows.rs b/apps/desktop-gpui/src/platform/windows.rs
index 60ef53662..e4a762749 100644
--- a/apps/desktop-gpui/src/platform/windows.rs
+++ b/apps/desktop-gpui/src/platform/windows.rs
@@ -671,8 +671,6 @@ pub fn activation_policy() -> isize {
-1
}
-pub fn show_about_panel(_name: &str, _version: &str) {}
-
pub fn escape_hotkey_events() -> flume::Receiver<()> {
flume::unbounded().1
}
diff --git a/apps/desktop-gpui/src/settings_pages.rs b/apps/desktop-gpui/src/settings_pages.rs
index c0d5d6bb4..7ffc0113a 100644
--- a/apps/desktop-gpui/src/settings_pages.rs
+++ b/apps/desktop-gpui/src/settings_pages.rs
@@ -20,12 +20,12 @@ use std::{
time::Duration,
};
+use cap_cli_install as cli_install;
use gpui::{
AppContext as _, Context, Entity, FontWeight, Hsla, InteractiveElement, IntoElement,
MouseButton, ParentElement, SharedString, StatefulInteractiveElement, Styled, Window, div,
prelude::FluentBuilder, px, rgb, svg,
};
-use cap_cli_install as cli_install;
use serde::Deserialize;
use serde_json::{Map, Value, json};
diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rs
index cd7dd5b65..0fdb185e2 100644
--- a/apps/desktop-gpui/src/settings_window.rs
+++ b/apps/desktop-gpui/src/settings_window.rs
@@ -1832,6 +1832,7 @@ impl SettingsWindow {
let theme = self.theme;
let (update_label, update_ready) = match crate::updates::status(cx) {
crate::updates::UpdateStatus::Idle => ("Check for updates".to_string(), false),
+ crate::updates::UpdateStatus::Checking => ("Checking for updates…".to_string(), false),
crate::updates::UpdateStatus::Downloading {
version,
fraction: Some(fraction),
diff --git a/apps/desktop-gpui/src/snapshot.rs b/apps/desktop-gpui/src/snapshot.rs
index ea53a80bf..791333fe3 100644
--- a/apps/desktop-gpui/src/snapshot.rs
+++ b/apps/desktop-gpui/src/snapshot.rs
@@ -38,10 +38,10 @@ pub fn arm_from_env(cx: &mut App) {
} else if target == "main" {
Some(cx.global::<crate::app_windows::AppWindows>().main.into())
} else {
- cx.global::<crate::app_windows::AppWindows>()
- .onboarding
- .map(Into::into)
- };
+ cx.global::<crate::app_windows::AppWindows>()
+ .onboarding
+ .map(Into::into)
+ };
let Some(handle) = handle else {
tracing::warn!("snapshot: window handle missing");
return None;
diff --git a/apps/desktop-gpui/src/updates.rs b/apps/desktop-gpui/src/updates.rs
index ae48b344e..c866bae6e 100644
--- a/apps/desktop-gpui/src/updates.rs
+++ b/apps/desktop-gpui/src/updates.rs
@@ -21,6 +21,7 @@ const BUSY_MESSAGE: &str =
pub(crate) enum UpdateStatus {
#[default]
Idle,
+ Checking,
Downloading {
version: Version,
fraction: Option<f32>,
@@ -173,6 +174,7 @@ fn set_status(status: UpdateStatus, cx: &mut App) {
}
scheduler.status = status;
crate::app_windows::refresh_settings(cx);
+ crate::menus::refresh_update_menu(cx);
}
pub(crate) fn check_manually(cx: &mut App) {
@@ -196,7 +198,7 @@ pub(crate) fn check_manually(cx: &mut App) {
.detach();
return;
}
- UpdateStatus::Idle => {}
+ UpdateStatus::Idle | UpdateStatus::Checking => {}
}
let scheduler = cx.global_mut::<UpdateScheduler>();
@@ -221,7 +223,7 @@ pub(crate) fn update_channel_changed(channel: UpdateChannel, cx: &mut App) {
fn channel_switch_drops_pending_package(status: &UpdateStatus) -> bool {
matches!(
status,
- UpdateStatus::Downloading { .. } | UpdateStatus::Ready { .. }
+ UpdateStatus::Checking | UpdateStatus::Downloading { .. } | UpdateStatus::Ready { .. }
)
}
@@ -313,7 +315,7 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {
if let Some(next_channel) = request.channel {
channel = next_channel;
ignored_version = None;
- let _ = cx.update(drop_pending_update_from_previous_channel);
+ cx.update(drop_pending_update_from_previous_channel);
}
let manual = request.manual;
@@ -333,6 +335,8 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {
continue;
}
+ cx.update(|cx| set_status(UpdateStatus::Checking, cx));
+
let result = match cx
.update(|cx| gpui_tokio::Tokio::spawn(cx, available_release(channel)))
.await
@@ -351,12 +355,14 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {
channel_changed || (!manual && scheduler.pending.manual)
});
if superseded {
+ cx.update(|cx| set_status(UpdateStatus::Idle, cx));
continue;
}
let release = match result {
Ok(Some(release)) => release,
Ok(None) => {
+ cx.update(|cx| set_status(UpdateStatus::Idle, cx));
if manual {
crate::platform::activate_app();
crate::platform::alert_dialog(
@@ -368,6 +374,7 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {
continue;
}
Err(error) => {
+ cx.update(|cx| set_status(UpdateStatus::Idle, cx));
tracing::warn!("update check failed: {error}");
if manual {
crate::platform::activate_app();
@@ -382,6 +389,7 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {
};
if !manual && ignored_version.as_ref() == Some(&release.version) {
+ cx.update(|cx| set_status(UpdateStatus::Idle, cx));
continue;
}
@@ -409,6 +417,8 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {
continue;
}
+ cx.update(|cx| set_status(UpdateStatus::Idle, cx));
+
crate::platform::activate_app();
let accepted = crate::platform::confirm_dialog(
"Update Cap",