Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: improve Windows GPUI desktop integration
Richie McIlroybe4bfb2ef117
diff --git a/apps/desktop-gpui/Cargo.lock b/apps/desktop-gpui/Cargo.lockindex 7c0f28053..9dda7ec44 100644--- a/apps/desktop-gpui/Cargo.lock+++ b/apps/desktop-gpui/Cargo.lock@@ -719,6 +719,29 @@ dependencies = ["syn 3.0.3",]+[[package]]+name = "atk"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"+dependencies = [+ "atk-sys",+ "glib",+ "libc",+]++[[package]]+name = "atk-sys"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"+dependencies = [+ "glib-sys",+ "gobject-sys",+ "libc",+ "system-deps 6.2.2",+]+[[package]]name = "atomic"version = "0.5.3"@@ -1297,6 +1320,31 @@ dependencies = ["libbz2-rs-sys",]+[[package]]+name = "cairo-rs"+version = "0.18.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"+dependencies = [+ "bitflags 2.13.1",+ "cairo-sys-rs",+ "glib",+ "libc",+ "once_cell",+ "thiserror 1.0.69",+]++[[package]]+name = "cairo-sys-rs"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"+dependencies = [+ "glib-sys",+ "libc",+ "system-deps 6.2.2",+]+[[package]]name = "calloop"version = "0.14.4"@@ -1517,11 +1565,13 @@ dependencies = ["serde_json","sha2","smallvec",+ "tauri-winres","tiny-skia","tokio","tracing","tracing-appender","tracing-subscriber",+ "tray-icon","unicode-segmentation","wgpu 25.0.2","whisper-rs",@@ -2013,6 +2063,16 @@ dependencies = ["uuid",]+[[package]]+name = "cfg-expr"+version = "0.15.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"+dependencies = [+ "smallvec",+ "target-lexicon 0.12.16",+]+[[package]]name = "cfg-expr"version = "0.20.8"@@ -2020,7 +2080,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "fb693542bcafa528e198be0ebd9d3632ca5b7c93dbe7237460e199910835997c"dependencies = ["smallvec",- "target-lexicon",+ "target-lexicon 0.13.5",][[package]]@@ -3204,6 +3264,12 @@ version = "2.0.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc"+[[package]]+name = "dpi"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76"+[[package]]name = "dtoa"version = "1.0.11"@@ -3502,6 +3568,16 @@ dependencies = ["vcpkg",]+[[package]]+name = "field-offset"+version = "0.3.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"+dependencies = [+ "memoffset",+ "rustc_version",+]+[[package]]name = "filedescriptor"version = "0.8.3"@@ -3890,6 +3966,64 @@ dependencies = ["byteorder",]+[[package]]+name = "gdk"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691"+dependencies = [+ "cairo-rs",+ "gdk-pixbuf",+ "gdk-sys",+ "gio",+ "glib",+ "libc",+ "pango",+]++[[package]]+name = "gdk-pixbuf"+version = "0.18.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"+dependencies = [+ "gdk-pixbuf-sys",+ "gio",+ "glib",+ "libc",+ "once_cell",+]++[[package]]+name = "gdk-pixbuf-sys"+version = "0.18.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"+dependencies = [+ "gio-sys",+ "glib-sys",+ "gobject-sys",+ "libc",+ "system-deps 6.2.2",+]++[[package]]+name = "gdk-sys"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"+dependencies = [+ "cairo-sys-rs",+ "gdk-pixbuf-sys",+ "gio-sys",+ "glib-sys",+ "gobject-sys",+ "libc",+ "pango-sys",+ "pkg-config",+ "system-deps 6.2.2",+]+[[package]]name = "generic-array"version = "0.14.7"@@ -4027,6 +4161,38 @@ version = "0.32.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"+[[package]]+name = "gio"+version = "0.18.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-io",+ "futures-util",+ "gio-sys",+ "glib",+ "libc",+ "once_cell",+ "pin-project-lite",+ "smallvec",+ "thiserror 1.0.69",+]++[[package]]+name = "gio-sys"+version = "0.18.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"+dependencies = [+ "glib-sys",+ "gobject-sys",+ "libc",+ "system-deps 6.2.2",+ "winapi",+]+[[package]]name = "gl_generator"version = "0.14.0"@@ -4038,6 +4204,53 @@ dependencies = ["xml-rs",]+[[package]]+name = "glib"+version = "0.18.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5"+dependencies = [+ "bitflags 2.13.1",+ "futures-channel",+ "futures-core",+ "futures-executor",+ "futures-task",+ "futures-util",+ "gio-sys",+ "glib-macros",+ "glib-sys",+ "gobject-sys",+ "libc",+ "memchr",+ "once_cell",+ "smallvec",+ "thiserror 1.0.69",+]++[[package]]+name = "glib-macros"+version = "0.18.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc"+dependencies = [+ "heck 0.4.1",+ "proc-macro-crate 2.0.0",+ "proc-macro-error",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "glib-sys"+version = "0.18.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"+dependencies = [+ "libc",+ "system-deps 6.2.2",+]+[[package]]name = "glob"version = "0.3.4"@@ -4107,6 +4320,17 @@ dependencies = ["wgpu 25.0.2",]+[[package]]+name = "gobject-sys"+version = "0.18.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"+dependencies = [+ "glib-sys",+ "libc",+ "system-deps 6.2.2",+]+[[package]]name = "gpu-alloc"version = "0.6.2"@@ -4486,6 +4710,58 @@ version = "1.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b40ca9252762c466af32d0b1002e91e4e1bc5398f77455e55474deb466355ff5"+[[package]]+name = "gtk"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a"+dependencies = [+ "atk",+ "cairo-rs",+ "field-offset",+ "futures-channel",+ "gdk",+ "gdk-pixbuf",+ "gio",+ "glib",+ "gtk-sys",+ "gtk3-macros",+ "libc",+ "pango",+ "pkg-config",+]++[[package]]+name = "gtk-sys"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414"+dependencies = [+ "atk-sys",+ "cairo-sys-rs",+ "gdk-pixbuf-sys",+ "gdk-sys",+ "gio-sys",+ "glib-sys",+ "gobject-sys",+ "libc",+ "pango-sys",+ "system-deps 6.2.2",+]++[[package]]+name = "gtk3-macros"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d"+dependencies = [+ "proc-macro-crate 1.3.1",+ "proc-macro-error",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]+[[package]]name = "guardian"version = "1.3.0"@@ -5505,6 +5781,30 @@ version = "0.5.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"+[[package]]+name = "libappindicator"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"+dependencies = [+ "glib",+ "gtk",+ "gtk-sys",+ "libappindicator-sys",+ "log",+]++[[package]]+name = "libappindicator-sys"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf"+dependencies = [+ "gtk-sys",+ "libloading 0.7.4",+ "once_cell",+]+[[package]]name = "libbz2-rs-sys"version = "0.2.5"@@ -5527,6 +5827,16 @@ dependencies = ["cc",]+[[package]]+name = "libloading"+version = "0.7.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"+dependencies = [+ "cfg-if",+ "winapi",+]+[[package]]name = "libloading"version = "0.8.9"@@ -5575,7 +5885,7 @@ dependencies = ["libspa-sys","nom 8.0.0","rustix 1.1.4",- "system-deps",+ "system-deps 7.0.8",][[package]]@@ -5586,7 +5896,7 @@ checksum = "69ad52764fca54818486f3cf75afec844d1f1a1568c24dcee25d41b1ab007dda"dependencies = ["bindgen 0.72.1","cc",- "system-deps",+ "system-deps 7.0.8",][[package]]@@ -6069,6 +6379,26 @@ dependencies = ["thiserror 1.0.69",]+[[package]]+name = "muda"+version = "0.17.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7c9fec5a4e89860383d778d10563a605838f8f0b2f9303868937e5ff32e86177"+dependencies = [+ "crossbeam-channel",+ "dpi",+ "gtk",+ "keyboard-types",+ "objc2 0.6.4",+ "objc2-app-kit 0.3.2",+ "objc2-core-foundation",+ "objc2-foundation 0.3.2",+ "once_cell",+ "png 0.17.16",+ "thiserror 2.0.20",+ "windows-sys 0.60.2",+]+[[package]]name = "naga"version = "25.0.1"@@ -6466,7 +6796,7 @@ version = "0.7.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"dependencies = [- "proc-macro-crate",+ "proc-macro-crate 3.5.0","proc-macro2","quote","syn 2.0.119",@@ -7170,6 +7500,31 @@ dependencies = ["windows-sys 0.61.2",]+[[package]]+name = "pango"+version = "0.18.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"+dependencies = [+ "gio",+ "glib",+ "libc",+ "once_cell",+ "pango-sys",+]++[[package]]+name = "pango-sys"+version = "0.18.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"+dependencies = [+ "glib-sys",+ "gobject-sys",+ "libc",+ "system-deps 6.2.2",+]+[[package]]name = "parakeet-rs"version = "0.3.4"@@ -7531,7 +7886,7 @@ checksum = "f2089f245b548723e60325773c27f586b7a2372c79ea941b246cd0d654706adc"dependencies = ["bindgen 0.72.1","libspa-sys",- "system-deps",+ "system-deps 7.0.8",][[package]]@@ -7701,6 +8056,25 @@ dependencies = ["num-integer",]+[[package]]+name = "proc-macro-crate"+version = "1.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"+dependencies = [+ "once_cell",+ "toml_edit 0.19.15",+]++[[package]]+name = "proc-macro-crate"+version = "2.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"+dependencies = [+ "toml_edit 0.20.7",+]+[[package]]name = "proc-macro-crate"version = "3.5.0"@@ -7710,6 +8084,30 @@ dependencies = ["toml_edit 0.25.13+spec-1.1.0",]+[[package]]+name = "proc-macro-error"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"+dependencies = [+ "proc-macro-error-attr",+ "proc-macro2",+ "quote",+ "syn 1.0.109",+ "version_check",+]++[[package]]+name = "proc-macro-error-attr"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"+dependencies = [+ "proc-macro2",+ "quote",+ "version_check",+]+[[package]]name = "proc-macro-error-attr2"version = "2.0.0"@@ -10043,13 +10441,26 @@ dependencies = ["libc",]+[[package]]+name = "system-deps"+version = "6.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"+dependencies = [+ "cfg-expr 0.15.8",+ "heck 0.5.0",+ "pkg-config",+ "toml 0.8.23",+ "version-compare",+]+[[package]]name = "system-deps"version = "7.0.8"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7"dependencies = [- "cfg-expr",+ "cfg-expr 0.20.8","heck 0.5.0","pkg-config","toml 1.1.4+spec-1.1.0",@@ -10080,6 +10491,12 @@ dependencies = ["objc",]+[[package]]+name = "target-lexicon"+version = "0.12.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"+[[package]]name = "target-lexicon"version = "0.13.5"@@ -10125,6 +10542,17 @@ dependencies = ["walkdir",]+[[package]]+name = "tauri-winres"+version = "0.3.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cc65d45c68858bfe420dd29e834b5d15dbecf8a07a8a16cf4d532c7b1f69d4b6"+dependencies = [+ "dunce",+ "embed-resource",+ "toml 1.1.4+spec-1.1.0",+]+[[package]]name = "tauri-winrt-notification"version = "0.7.3"@@ -10486,6 +10914,28 @@ dependencies = ["serde_core",]+[[package]]+name = "toml_edit"+version = "0.19.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"+dependencies = [+ "indexmap 2.14.0",+ "toml_datetime 0.6.11",+ "winnow 0.5.40",+]++[[package]]+name = "toml_edit"+version = "0.20.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"+dependencies = [+ "indexmap 2.14.0",+ "toml_datetime 0.6.11",+ "winnow 0.5.40",+]+[[package]]name = "toml_edit"version = "0.22.27"@@ -10664,6 +11114,27 @@ dependencies = ["strength_reduce",]+[[package]]+name = "tray-icon"+version = "0.21.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a5e85aa143ceb072062fc4d6356c1b520a51d636e7bc8e77ec94be3608e5e80c"+dependencies = [+ "crossbeam-channel",+ "dirs 6.0.0",+ "libappindicator",+ "muda",+ "objc2 0.6.4",+ "objc2-app-kit 0.3.2",+ "objc2-core-foundation",+ "objc2-core-graphics",+ "objc2-foundation 0.3.2",+ "once_cell",+ "png 0.17.16",+ "thiserror 2.0.20",+ "windows-sys 0.60.2",+]+[[package]]name = "try-lock"version = "0.2.5"@@ -12316,6 +12787,15 @@ dependencies = ["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]]name = "windows-sys"version = "0.61.2"@@ -12364,13 +12844,30 @@ dependencies = ["windows_aarch64_gnullvm 0.52.6","windows_aarch64_msvc 0.52.6","windows_i686_gnu 0.52.6",- "windows_i686_gnullvm",+ "windows_i686_gnullvm 0.52.6","windows_i686_msvc 0.52.6","windows_x86_64_gnu 0.52.6","windows_x86_64_gnullvm 0.52.6","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]]name = "windows-threading"version = "0.1.0"@@ -12416,6 +12913,12 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"+[[package]]+name = "windows_aarch64_gnullvm"+version = "0.53.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"+[[package]]name = "windows_aarch64_msvc"version = "0.42.2"@@ -12434,6 +12937,12 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"+[[package]]+name = "windows_aarch64_msvc"+version = "0.53.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"+[[package]]name = "windows_i686_gnu"version = "0.42.2"@@ -12452,12 +12961,24 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"+[[package]]+name = "windows_i686_gnu"+version = "0.53.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"+[[package]]name = "windows_i686_gnullvm"version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"+[[package]]+name = "windows_i686_gnullvm"+version = "0.53.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"+[[package]]name = "windows_i686_msvc"version = "0.42.2"@@ -12476,6 +12997,12 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"+[[package]]+name = "windows_i686_msvc"+version = "0.53.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"+[[package]]name = "windows_x86_64_gnu"version = "0.42.2"@@ -12494,6 +13021,12 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"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]]name = "windows_x86_64_gnullvm"version = "0.42.2"@@ -12512,6 +13045,12 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"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]]name = "windows_x86_64_msvc"version = "0.42.2"@@ -12530,6 +13069,21 @@ version = "0.52.6"source = "registry+https://github.com/rust-lang/crates.io-index"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]]+name = "winnow"+version = "0.5.40"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"+dependencies = [+ "memchr",+]+[[package]]name = "winnow"version = "0.7.15"@@ -12880,7 +13434,7 @@ version = "5.19.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"dependencies = [- "proc-macro-crate",+ "proc-macro-crate 3.5.0","proc-macro2","quote","syn 3.0.3",@@ -13177,7 +13731,7 @@ version = "5.14.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d496a145685283b67e232bd9e47377f6b60ad9d51e3601b23867f77c42477f96"dependencies = [- "proc-macro-crate",+ "proc-macro-crate 3.5.0","proc-macro2","quote","syn 3.0.3",diff --git a/apps/desktop-gpui/Cargo.toml b/apps/desktop-gpui/Cargo.tomlindex 8d00a8f39..b63436605 100644--- a/apps/desktop-gpui/Cargo.toml+++ b/apps/desktop-gpui/Cargo.toml@@ -153,6 +153,9 @@ dirs = "6"# downloaded by either app loads identically in both.whisper-rs = "0.11.0"+[build-dependencies]+tauri-winres = "0.3.5"+[dev-dependencies]# The editor smoke (`tests/editor_frame0.rs`) drives `EditorInstance`, whose# decoders, renderer and preview tasks are all tokio-spawned -- a current-thread@@ -167,6 +170,7 @@ libc = "0.2"[target.'cfg(windows)'.dependencies]raw-window-handle = "0.6"+tray-icon = { version = "0.21.1", default-features = false }windows-sys = { version = "0.59", features = ["Win32_Foundation","Win32_Security",diff --git a/apps/desktop-gpui/build.rs b/apps/desktop-gpui/build.rsnew file mode 100644index 000000000..202980b60--- /dev/null+++ b/apps/desktop-gpui/build.rs@@ -0,0 +1,15 @@+fn main() {+ if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {+ return;+ }++ let icon = "../desktop/src-tauri/icons/icon.ico";+ println!("cargo:rerun-if-changed={icon}");+ tauri_winres::WindowsResource::new()+ .set_icon_with_id(icon, "1")+ .set("ProductName", "Cap")+ .set("FileDescription", "Cap")+ .set("OriginalFilename", "cap-gpui.exe")+ .compile()+ .expect("failed to compile the Cap Windows icon resource");+}diff --git a/apps/desktop-gpui/patches/zed-windows.patch b/apps/desktop-gpui/patches/zed-windows.patchindex 06c1a5a17..856b1cbd6 100644--- a/apps/desktop-gpui/patches/zed-windows.patch+++ b/apps/desktop-gpui/patches/zed-windows.patch@@ -85,25 +85,50 @@+ color.a *= sprite.opacity * saturate(0.5 - distance) * edge_fade_alpha(input.position.xy, sprite.fade);--- a/crates/gpui_windows/src/window.rs+++ b/crates/gpui_windows/src/window.rs-@@ -216 +216,5 @@+@@ -95,0 +96 @@++ pub(crate) custom_frame: bool,+@@ -216 +217,5 @@- placement.rcNormalPosition,+ translate_rect(+ placement.rcNormalPosition,+ workspace_offset(self.hwnd, self.display.get(), self.scale_factor.get()),+ 1,+ ),-@@ -463 +467 @@+@@ -265,0 +271 @@++ custom_frame: context.custom_frame,+@@ -388,0 +395 @@++ custom_frame: bool,+@@ -405,0 +413,4 @@++}++++fn custom_frame_enabled(normal_window: bool, transparent_titlebar: Option<bool>) -> bool {++ normal_window && transparent_titlebar == Some(true)+@@ -452,0 +464,7 @@++ let custom_frame = custom_frame_enabled(++ params.kind == WindowKind::Normal,++ params++ .titlebar++ .as_ref()++ .map(|titlebar| titlebar.appears_transparent),++ );+@@ -463 +481 @@- (WS_EX_TOOLWINDOW, WINDOW_STYLE(0x0))+ (WS_EX_TOOLWINDOW, WS_POPUP)-@@ -465,0 +470,5 @@-+ if hide_title_bar {+@@ -465,0 +484,5 @@++ if hide_title_bar && !custom_frame {+ dwstyle |= WS_POPUP;+ } else {+ dwstyle |= WS_CAPTION;+ }-@@ -550,0 +560 @@+@@ -482,0 +506,3 @@++ if custom_frame {++ dwexstyle |= WS_EX_WINDOWEDGE;++ }+@@ -499,0 +526 @@++ custom_frame,+@@ -550,0 +578 @@+ params.window_min_size,-@@ -621,2 +631,30 @@+@@ -621,2 +649,30 @@- let bounds = gpui::bounds(self.bounds().origin, size).to_device_pixels(self.scale_factor());- let rect = calculate_window_rect(bounds, &self.state.border_offset);+ let size = size.to_device_pixels(self.scale_factor());@@ -136,15 +161,15 @@+ if !movable {+ flags |= SWP_NOMOVE;+ }-@@ -631,2 +669,2 @@+@@ -631,2 +687,2 @@- bounds.origin.x.0,- bounds.origin.y.0,+ rect.left,+ rect.top,-@@ -635 +673 @@+@@ -635 +691 @@- SWP_NOMOVE,+ flags,-@@ -637,0 +676,29 @@+@@ -637,0 +694,29 @@+ .log_err();+ }+ })@@ -174,9 +199,9 @@+ LPARAM(position as isize),+ )+ .context("unable to start window move")-@@ -1510,0 +1578 @@+@@ -1510,0 +1596 @@+ minimum_size: Option<Size<Pixels>>,-@@ -1524 +1592,10 @@+@@ -1524 +1610,10 @@- placement.rcNormalPosition = calculate_window_rect(bounds, border_offset);+ let mut rect = calculate_window_rect(bounds, border_offset);+ if !is_tool_window(hwnd) {@@ -188,7 +213,7 @@+ }+ placement.rcNormalPosition =+ translate_rect(rect, workspace_offset(hwnd, display, scale_factor), -1);-@@ -1525,0 +1603,54 @@+@@ -1525,0 +1621,54 @@+}++fn is_tool_window(hwnd: HWND) -> bool {@@ -243,15 +268,29 @@+ right: left + width,+ bottom: top + height,+ }-@@ -1612,2 +1743,2 @@+@@ -1612,2 +1761,2 @@- use super::ClickState;- use gpui::{DevicePixels, MouseButton, point};-+ use super::{ClickState, fit_window_rect, translate_rect};++ use super::{ClickState, custom_frame_enabled, fit_window_rect, translate_rect};+ use gpui::{Bounds, DevicePixels, MouseButton, point, size};-@@ -1614,0 +1746,66 @@+@@ -1614,0 +1764,80 @@+ use windows::Win32::Foundation::RECT;++ #[test]++ fn custom_frame_requires_a_normal_window_with_an_explicit_transparent_titlebar() {++ assert!(custom_frame_enabled(true, Some(true)));++ for (normal_window, transparent_titlebar) in [++ (true, Some(false)),++ (true, None),++ (false, Some(true)),++ (false, Some(false)),++ (false, None),++ ] {++ assert!(!custom_frame_enabled(normal_window, transparent_titlebar));++ }++ }++++ #[test]+ fn expanded_window_moves_above_bottom_taskbar() {+ let work = Bounds {+ origin: point(DevicePixels(0), DevicePixels(0)),@@ -317,17 +356,30 @@+ }--- a/crates/gpui_windows/src/events.rs+++ b/crates/gpui_windows/src/events.rs-@@ -847,5 +846,0 @@+@@ -716,0 +717,12 @@++ if self.custom_frame && !self.state.is_maximized() {++ let dpi = unsafe { GetDpiForWindow(handle) };++ let (frame, top) =++ custom_frame_insets(get_frame_thicknessx(dpi), dpi, windows_build_number());++ let params = unsafe { &mut *(lparam.0 as *mut NCCALCSIZE_PARAMS) };++ params.rgrc[0].left += frame;++ params.rgrc[0].top += top;++ params.rgrc[0].right -= frame;++ params.rgrc[0].bottom -= frame;++ return Some(0);++ }+++@@ -847,5 +858,0 @@-- // SetWindowPos may not send WM_SIZE for maximized windows in some cases,- // so we manually update the size to ensure proper rendering- let device_size = size(DevicePixels(width), DevicePixels(height));- self.handle_size_change(device_size, new_scale_factor, true);-@@ -858,3 +852,0 @@+@@ -858,3 +864,0 @@- // this will emit `WM_SIZE` and `WM_MOVE` right here- // even before this function returns- // the new size is handled in `WM_SIZE`-@@ -873,0 +866,15 @@+@@ -873,0 +878,15 @@+ }++ // SetWindowPos can omit a final WM_SIZE; its outer bounds also include native captions.@@ -343,3 +395,68 @@+ DevicePixels((client_rect.bottom - client_rect.top).max(1)),+ );+ self.handle_size_change(device_size, self.state.scale_factor.get(), true);+@@ -1652,0 +1672,26 @@++fn custom_frame_insets(frame: i32, dpi: u32, windows_build: u32) -> (i32, i32) {++ let top = if windows_build >= 22000 {++ (dpi as f32 / 96.).round() as i32++ } else {++ 0++ };++ (frame, top)++}++++fn windows_build_number() -> u32 {++ use windows::Win32::System::SystemInformation::OSVERSIONINFOW;++++ static BUILD: std::sync::OnceLock<u32> = std::sync::OnceLock::new();++ *BUILD.get_or_init(|| {++ let mut version = OSVERSIONINFOW {++ dwOSVersionInfoSize: std::mem::size_of::<OSVERSIONINFOW>() as u32,++ ..Default::default()++ };++ if unsafe { windows::Wdk::System::SystemServices::RtlGetVersion(&mut version) }.is_ok() {++ version.dwBuildNumber++ } else {++ 0++ }++ })++}+++@@ -1690,0 +1736,37 @@++++#[cfg(test)]++mod tests {++ use super::custom_frame_insets;++++ #[test]++ fn windows_10_has_no_top_inset_at_any_scale() {++ for build in [19045, 21999] {++ for (frame, dpi) in [(8, 96), (10, 120), (12, 144), (16, 192), (24, 288)] {++ assert_eq!(custom_frame_insets(frame, dpi, build), (frame, 0));++ }++ }++ }++++ #[test]++ fn windows_11_preserves_the_first_client_row_at_each_scale() {++ for build in [22000, 22621, 26100] {++ for (frame, dpi, top) in [++ (8, 96, 1),++ (10, 120, 1),++ (12, 144, 2),++ (14, 168, 2),++ (16, 192, 2),++ (20, 240, 3),++ (24, 288, 3),++ ] {++ assert_eq!(custom_frame_insets(frame, dpi, build), (frame, top));++ }++ }++ }++++ #[test]++ fn unknown_windows_build_does_not_restore_a_native_titlebar() {++ assert_eq!(custom_frame_insets(8, 96, 0), (8, 0));++ assert_eq!(custom_frame_insets(16, 192, 0), (16, 0));++ }++}diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rsindex 655475184..c86d6097b 100644--- a/apps/desktop-gpui/src/app_windows.rs+++ b/apps/desktop-gpui/src/app_windows.rs@@ -613,7 +613,7 @@ pub fn open_settings(page: Page, cx: &mut App) {// hand-draws its own.)titlebar: Some(gpui::TitlebarOptions {title: Some("Cap Settings".into()),- appears_transparent: !cfg!(target_os = "windows"),+ appears_transparent: true,traffic_light_position: Some(settings_window::TRAFFIC_LIGHTS),}),// A normal window, not a panel: the Tauri Settings window is an@@ -758,7 +758,7 @@ pub fn open_onboarding(cx: &mut App) {window_bounds: Some(WindowBounds::Windowed(bounds)),titlebar: Some(gpui::TitlebarOptions {title: Some("Welcome to Cap".into()),- appears_transparent: !cfg!(target_os = "windows"),+ appears_transparent: true,traffic_light_position: Some(onboarding_window::TRAFFIC_LIGHTS),}),kind: WindowKind::Normal,@@ -892,7 +892,7 @@ pub fn open_mode_select(cx: &mut App) -> bool {// `TitleBarStyle::Overlay`).titlebar: Some(gpui::TitlebarOptions {title: Some("Cap Mode Selection".into()),- appears_transparent: !cfg!(target_os = "windows"),+ appears_transparent: true,traffic_light_position: mode_select_window::TRAFFIC_LIGHTS,}),// An ordinary window that activates the dock icon@@ -1007,7 +1007,7 @@ pub fn open_teleprompter(cx: &mut App) {// buttons, moved, as on the settings window.titlebar: Some(gpui::TitlebarOptions {title: Some("Cap Teleprompter".into()),- appears_transparent: !cfg!(target_os = "windows"),+ appears_transparent: true,traffic_light_position: Some(teleprompter_window::TRAFFIC_LIGHTS),}),// `alwaysOnTop: true` + `visibleOnAllWorkspaces: true` are applied@@ -2457,7 +2457,7 @@ pub fn open_editor(project_path: PathBuf, cx: &mut App) {// left group reserves an `h-full w-16` spacer for them.titlebar: Some(gpui::TitlebarOptions {title: Some("Cap Editor".into()),- appears_transparent: !cfg!(target_os = "windows"),+ appears_transparent: true,traffic_light_position: editor_window::TRAFFIC_LIGHTS,}),// An ordinary window that activates the dock icon@@ -3642,7 +3642,7 @@ pub fn open_screenshot_editor(path: PathBuf, cx: &mut App) {window_bounds: Some(WindowBounds::Windowed(bounds)),titlebar: Some(gpui::TitlebarOptions {title: Some("Cap Screenshot Editor".into()),- appears_transparent: !cfg!(target_os = "windows"),+ appears_transparent: true,traffic_light_position: None,}),kind: WindowKind::Normal,diff --git a/apps/desktop-gpui/src/editor_export.rs b/apps/desktop-gpui/src/editor_export.rsindex 5969858a5..2deb563b2 100644--- a/apps/desktop-gpui/src/editor_export.rs+++ b/apps/desktop-gpui/src/editor_export.rs@@ -131,6 +131,7 @@ impl ExportResolution {#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum ExportPhase {Idle,+ ChoosingFile,Starting,Rendering,Copying,@@ -143,9 +144,13 @@ impl ExportPhase {pub(crate) fn is_busy(self) -> bool {matches!(self,- Self::Starting | Self::Rendering | Self::Copying | Self::Uploading+ Self::ChoosingFile | Self::Starting | Self::Rendering | Self::Copying | Self::Uploading)}++ fn shows_progress(self) -> bool {+ !matches!(self, Self::Idle | Self::ChoosingFile)+ }}pub struct PreviewStats {@@ -514,9 +519,15 @@ impl EditorWindow {let project = self.project.clone();ui.cancel.store(false, Ordering::Relaxed);let cancel = ui.cancel.clone();- ui.phase = ExportPhase::Starting;+ ui.phase = if destination == ExportDestination::File {+ ExportPhase::ChoosingFile+ } else {+ ExportPhase::Starting+ };ui.error = None;ui.rendered = 0;+ ui.total_frames = 0;+ ui.output_path = None;cx.notify();ui.export_task = Some(cx.spawn_in(window, async move |this, cx| {@@ -546,12 +557,22 @@ impl EditorWindow {None};- let _ = this.update(cx, |this, cx| {- if let Some(ui) = this.export.as_mut() {- ui.phase = ExportPhase::Rendering;+ let started = this.update(cx, |this, cx| {+ let Some(ui) = this.export.as_mut() else {+ return false;+ };+ if cancel.load(Ordering::Relaxed) {+ ui.phase = ExportPhase::Idle;+ cx.notify();+ return false;}+ ui.phase = ExportPhase::Starting;cx.notify();+ true});+ if !started.unwrap_or(false) {+ return;+ }let (progress_tx, progress_rx) = flume::unbounded::<(u32, u32)>();let export_cancel = cancel.clone();@@ -774,6 +795,7 @@ impl EditorWindow {ui.share_link = None;ui.upload_progress = 0.0;ui.rendered = 0;+ ui.total_frames = 0;cx.notify();ui.export_task = Some(cx.spawn_in(window, async move |this, cx| {@@ -994,9 +1016,12 @@ impl EditorWindow {.child(self.render_export_preview_pane(ui)).child(self.render_export_sidebar(ui, cx)),)- .when(ui.phase != ExportPhase::Idle, |this| {+ .when(ui.phase.shows_progress(), |this| {this.child(self.render_export_overlay(ui, cx))})+ .when(ui.phase == ExportPhase::ChoosingFile, |this| {+ this.child(div().absolute().inset_0().occlude())+ }).into_any_element()}@@ -1253,6 +1278,7 @@ impl EditorWindow {ui::ButtonSize::Lg,).label(label)+ .disabled(ui.phase.is_busy()).full_width().on_click(cx.listener(|this, _, window, cx| this.start_export(window, cx)));if let Some(icon) = icon {@@ -1771,7 +1797,7 @@ impl EditorWindow {ExportPhase::Done if ui.destination == ExportDestination::Link => "Upload complete",ExportPhase::Done => "Export complete",ExportPhase::Failed => "Export failed",- ExportPhase::Idle => "",+ ExportPhase::Idle | ExportPhase::ChoosingFile => "",};let mut wash: Hsla = theme.gray(1);@@ -2074,3 +2100,34 @@ async fn run_export(.await}}++#[cfg(test)]+mod tests {+ use super::ExportPhase;++ #[test]+ fn choosing_a_file_blocks_duplicate_exports_without_showing_progress() {+ assert!(ExportPhase::ChoosingFile.is_busy());+ assert!(!ExportPhase::ChoosingFile.shows_progress());+ }++ #[test]+ fn cancelling_file_selection_returns_to_the_idle_page() {+ assert!(!ExportPhase::Idle.is_busy());+ assert!(!ExportPhase::Idle.shows_progress());+ }++ #[test]+ fn export_work_and_results_remain_visible() {+ for phase in [+ ExportPhase::Starting,+ ExportPhase::Rendering,+ ExportPhase::Copying,+ ExportPhase::Uploading,+ ExportPhase::Done,+ ExportPhase::Failed,+ ] {+ assert!(phase.shows_progress());+ }+ }+}diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rsindex 0a8fcad7d..6b8517ab3 100644--- a/apps/desktop-gpui/src/editor_window.rs+++ b/apps/desktop-gpui/src/editor_window.rs@@ -6984,7 +6984,7 @@ impl EditorWindow {let theme = self.theme;let name_focused = self.name_input.read(cx).focus_handle().is_focused(window);- div()+ let header = div().relative().flex().flex_row()@@ -6992,6 +6992,9 @@ impl EditorWindow {.w_full().h(px(HEADER_HEIGHT)).flex_none()+ .when(cfg!(target_os = "windows"), |header| {+ header.window_control_area(gpui::WindowControlArea::Drag)+ })// Left group: `flex flex-row flex-1 gap-2 items-center px-4 h-full`..child(div()@@ -7003,8 +7006,11 @@ impl EditorWindow {.items_center().px(px(16.)).h_full()+ .when(cfg!(target_os = "windows"), |group| group.occlude())// The macOS spacer for the inset traffic lights: `h-full w-16`.- .child(div().h_full().w(px(64.)).flex_none())+ .when(!cfg!(target_os = "windows"), |group| {+ group.child(div().h_full().w(px(64.)).flex_none())+ }).child(ui::EditorButton::plain(&theme, "delete-recording").left_icon("icons/trash.svg")@@ -7065,7 +7071,15 @@ impl EditorWindow {.child(".cap"),),)- .child(div().flex_1().h_full()),+ .child(+ div()+ .flex_1()+ .h_full()+ .when(cfg!(target_os = "windows"), |area| {+ area.occlude()+ .window_control_area(gpui::WindowControlArea::Drag)+ }),+ ),)// Centre group: `flex flex-row items-center justify-center gap-2// px-4 border-x border-black-transparent-10`.@@ -7081,6 +7095,7 @@ impl EditorWindow {.border_l_1().border_r_1().border_color(gpui::hsla(0., 0., 0., 0.1))+ .when(cfg!(target_os = "windows"), |group| group.occlude()).child(ui::EditorButton::plain(&theme, "presets").left_icon("icons/presets.svg")@@ -7111,9 +7126,18 @@ impl EditorWindow {.pl(px(8.)).pr(px(8.)).h_full()+ .when(cfg!(target_os = "windows"), |group| group.occlude()).child(self.history_button("editor-undo", "icons/undo.svg", true, cx)).child(self.history_button("editor-redo", "icons/redo.svg", false, cx))- .child(div().flex_1().h_full())+ .child(+ div()+ .flex_1()+ .h_full()+ .when(cfg!(target_os = "windows"), |area| {+ area.occlude()+ .window_control_area(gpui::WindowControlArea::Drag)+ }),+ )// `Button` (gray), `flex gap-1.5 justify-center h-[40px]`..child(self.render_clips_pill(cx))// `<Show when={hasTranscript()}>` (`Header.tsx:74-77,@@ -7132,7 +7156,18 @@ impl EditorWindow {.then(|| self.header_pill("icons/captions.svg", "Captions")),).child(self.render_export_button(cx)),- )+ );++ #[cfg(target_os = "windows")]+ let header = header.child(ui::windows_caption_controls(+ theme,+ window.is_window_active(),+ window.is_maximized(),+ true,+ true,+ ));++ header}/// The Captions toggle: `Button variant="gray"` atdiff --git a/apps/desktop-gpui/src/main.rs b/apps/desktop-gpui/src/main.rsindex 13b984fda..b0b10d00b 100644--- a/apps/desktop-gpui/src/main.rs+++ b/apps/desktop-gpui/src/main.rs@@ -3,6 +3,8 @@//! Milestone 1 is the main recording window (compact + expanded) with real//! device enumeration. No tauri, no webview: the whole UI is gpui.+#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]+mod app_windows;mod assets;mod auth;diff --git a/apps/desktop-gpui/src/main_window.rs b/apps/desktop-gpui/src/main_window.rsindex 07a854424..e033b5acf 100644--- a/apps/desktop-gpui/src/main_window.rs+++ b/apps/desktop-gpui/src/main_window.rs@@ -2103,6 +2103,9 @@ impl MainWindow {let theme = self.theme;let header = div()+ .when(cfg!(target_os = "windows"), |header| {+ header.window_control_area(gpui::WindowControlArea::Drag)+ }).flex().flex_row().items_center()@@ -2180,6 +2183,7 @@ impl MainWindow {};div()+ .occlude().flex().h_full().flex_shrink_0()@@ -2327,17 +2331,14 @@ impl MainWindow {)// Keep drag handlers off the header root: starting native dragging// on a button's mouse-down consumes its later click.- .child(- div()- .id("drag-region")- .flex_1()- .min_w_0()- .h_full()- .when(cfg!(target_os = "windows"), |region| region.h(px(20.)))- .on_mouse_down(gpui::MouseButton::Left, |_, window, _| {+ .child(div().id("drag-region").flex_1().min_w_0().h_full().when(+ !cfg!(target_os = "windows"),+ |region| {+ region.on_mouse_down(gpui::MouseButton::Left, |_, window, _| {window.start_window_move();- }),- )+ })+ },+ )).child(div().flex()@@ -2413,26 +2414,7 @@ impl MainWindow {);#[cfg(target_os = "windows")]- let actions = {- let drag_strip = |id: &'static str| {- div()- .id(id)- .absolute()- .left_0()- .right_0()- .h(px(6.))- .on_mouse_down(gpui::MouseButton::Left, |_, window, cx| {- window.start_window_move();- cx.stop_propagation();- })- };-- actions- .relative()- .h_full()- .child(drag_strip("header-drag-top").top_0())- .child(drag_strip("header-drag-bottom").bottom_0())- };+ let actions = actions.h_full();actions}diff --git a/apps/desktop-gpui/src/mode_select_window.rs b/apps/desktop-gpui/src/mode_select_window.rsindex 85c29f5e6..b9e7402b3 100644--- a/apps/desktop-gpui/src/mode_select_window.rs+++ b/apps/desktop-gpui/src/mode_select_window.rs@@ -238,7 +238,7 @@ impl Render for ModeSelectWindow {self.sync_appearance(window, cx);let theme = self.theme;- div()+ let shell = div().track_focus(&self.focus)// `flex flex-col relative justify-center items-center min-h-screen// bg-gray-1`@@ -302,7 +302,29 @@ impl Render for ModeSelectWindow {.child(self.render_card(Mode::Studio, cx)).child(self.render_card(Mode::Screenshot, cx)),),- )+ );++ #[cfg(target_os = "windows")]+ let shell = shell.child(+ div()+ .absolute()+ .top_0()+ .left_0()+ .right_0()+ .h(px(36.))+ .flex()+ .justify_end()+ .window_control_area(gpui::WindowControlArea::Drag)+ .child(crate::ui::windows_caption_controls(+ theme,+ window.is_window_active(),+ window.is_maximized(),+ true,+ false,+ )),+ );++ shell}}diff --git a/apps/desktop-gpui/src/onboarding_window.rs b/apps/desktop-gpui/src/onboarding_window.rsindex 04f8a776f..5f11deb2b 100644--- a/apps/desktop-gpui/src/onboarding_window.rs+++ b/apps/desktop-gpui/src/onboarding_window.rs@@ -780,6 +780,24 @@ impl Render for OnboardingWindow {self.theme.refresh(window, cx, false);let theme = self.theme;+ let header = div().h(px(52.)).w_full().flex_shrink_0();+ #[cfg(target_os = "windows")]+ let header = header+ .flex()+ .justify_end()+ .window_control_area(gpui::WindowControlArea::Drag)+ .child(div().h(px(36.)).child(ui::windows_caption_controls(+ theme,+ window.is_window_active(),+ window.is_maximized(),+ true,+ false,+ )));+ #[cfg(not(target_os = "windows"))]+ let header = header.on_mouse_down(gpui::MouseButton::Left, |_, window, _| {+ window.start_window_move();+ });+div().size_full().flex()@@ -788,12 +806,7 @@ impl Render for OnboardingWindow {.bg(Hsla::from(theme.gray_1)).text_color(Hsla::from(theme.gray_12)).track_focus(&self.focus)- .child(div().h(px(52.)).w_full().flex_shrink_0().on_mouse_down(- gpui::MouseButton::Left,- |_, window, _| {- window.start_window_move();- },- ))+ .child(header).child(match self.step {Step::Welcome => self.render_welcome(cx).into_any_element(),Step::Permissions => self.render_permissions(cx).into_any_element(),diff --git a/apps/desktop-gpui/src/screenshot_editor.rs b/apps/desktop-gpui/src/screenshot_editor.rsindex 0f44043c2..50d904da0 100644--- a/apps/desktop-gpui/src/screenshot_editor.rs+++ b/apps/desktop-gpui/src/screenshot_editor.rs@@ -2763,7 +2763,7 @@ impl ScreenshotEditorWindow {}/// `Header.tsx:109-216`.- fn render_header(&self, cx: &mut Context<Self>) -> impl IntoElement {+ fn render_header(&self, _window: &Window, cx: &mut Context<Self>) -> impl IntoElement {let theme = self.theme;let crop_enabled = self.image_size.is_some();let exporting = self.exporting;@@ -2774,7 +2774,89 @@ impl ScreenshotEditorWindow {ExportStatus::Idle => "Create shareable link",};- div()+ let tools = div()+ .flex()+ .flex_row()+ .items_center()+ .justify_center()+ .gap(px(8.))+ .child(+ self.anchored(+ Anchor::Aspect,+ ui::EditorButton::plain(&theme, "screenshot-aspect")+ .width(px(80.))+ .left_icon("icons/layout.svg")+ .icon_size(px(16.))+ .label(self.aspect_label())+ .right_icon("icons/chevron-down.svg")+ .right_icon_end(true)+ .pressed(+ self.menu+ .as_ref()+ .is_some_and(|(kind, _)| *kind == MenuKind::Aspect),+ )+ .tooltip(&theme, "Aspect Ratio")+ .on_click(cx.listener(|this, _, window, cx| {+ cx.stop_propagation();+ this.toggle_menu(MenuKind::Aspect, Anchor::Aspect, window, cx);+ })),+ ),+ )+ .child(+ ui::EditorButton::plain(&theme, "screenshot-crop")+ .left_icon("icons/crop.svg")+ .icon_size(px(16.))+ .disabled(!crop_enabled)+ .tooltip(&theme, "Crop Image")+ .on_click(cx.listener(|this, _, window, cx| {+ cx.stop_propagation();+ this.open_crop_dialog(window, cx);+ })),+ )+ .child(divider(&theme, 24.))+ .child(self.render_annotation_tools(cx))+ .child(divider(&theme, 24.))+ .children(+ [+ Popover::Background,+ Popover::Padding,+ Popover::Rounding,+ Popover::Shadow,+ Popover::Border,+ ]+ .map(|popover| {+ let button = ui::EditorButton::plain(&theme, popover.id())+ .left_icon(popover.icon())+ .icon_size(px(16.))+ .pressed(self.active_popover == Some(popover))+ .on_click(cx.listener(move |this, _, window, cx| {+ cx.stop_propagation();+ this.toggle_popover(popover, window, cx);+ }));+ // The `kbd` prop rides the tooltip, which+ // `ui::EditorButton` does not carry, so the wrapper the+ // popover anchors against owns it instead.+ self.anchored(+ popover.anchor(),+ kbd_tooltip(&theme, popover.tooltip(), popover.keys(), button),+ )+ .into_any_element()+ }),+ );+ #[cfg(not(target_os = "windows"))]+ let tools = tools.absolute().top_0().left_0().size_full();+ #[cfg(target_os = "windows")]+ let tools = div()+ .id("screenshot-header-tools")+ .flex()+ .flex_1()+ .min_w_0()+ .h(px(32.))+ .overflow_x_scroll()+ .occlude()+ .child(tools.flex_shrink_0().mx_auto());++ let header = div().relative().flex().flex_row()@@ -2783,6 +2865,12 @@ impl ScreenshotEditorWindow {.w_full().h(px(HEADER_HEIGHT)).px(px(16.))+ .when(cfg!(target_os = "windows"), |header| {+ header+ .pr_0()+ .gap(px(8.))+ .window_control_area(gpui::WindowControlArea::Drag)+ }).flex_shrink_0().border_b_1().border_color(theme.gray_3)@@ -2792,86 +2880,14 @@ impl ScreenshotEditorWindow {theme.gray_1})// The inset traffic lights' spacer (`Header.tsx:115`).- .child(div().flex().items_center().child(div().w(px(56.))))+ .when(!cfg!(target_os = "windows"), |header| {+ header.child(div().flex().items_center().child(div().w(px(56.))))+ })// `absolute left-1/2 -translate-x-1/2` -- a full-width centred row// is the same placement without a transform, and it is not// interactive itself, so the right cluster painted after it still// takes its own clicks.- .child(- div()- .absolute()- .top_0()- .left_0()- .size_full()- .flex()- .flex_row()- .items_center()- .justify_center()- .gap(px(8.))- .child(- self.anchored(- Anchor::Aspect,- ui::EditorButton::plain(&theme, "screenshot-aspect")- .width(px(80.))- .left_icon("icons/layout.svg")- .icon_size(px(16.))- .label(self.aspect_label())- .right_icon("icons/chevron-down.svg")- .right_icon_end(true)- .pressed(- self.menu- .as_ref()- .is_some_and(|(kind, _)| *kind == MenuKind::Aspect),- )- .tooltip(&theme, "Aspect Ratio")- .on_click(cx.listener(|this, _, window, cx| {- cx.stop_propagation();- this.toggle_menu(MenuKind::Aspect, Anchor::Aspect, window, cx);- })),- ),- )- .child(- ui::EditorButton::plain(&theme, "screenshot-crop")- .left_icon("icons/crop.svg")- .icon_size(px(16.))- .disabled(!crop_enabled)- .tooltip(&theme, "Crop Image")- .on_click(cx.listener(|this, _, window, cx| {- cx.stop_propagation();- this.open_crop_dialog(window, cx);- })),- )- .child(divider(&theme, 24.))- .child(self.render_annotation_tools(cx))- .child(divider(&theme, 24.))- .children(- [- Popover::Background,- Popover::Padding,- Popover::Rounding,- Popover::Shadow,- Popover::Border,- ]- .map(|popover| {- let button = ui::EditorButton::plain(&theme, popover.id())- .left_icon(popover.icon())- .icon_size(px(16.))- .pressed(self.active_popover == Some(popover))- .on_click(cx.listener(move |this, _, window, cx| {- cx.stop_propagation();- this.toggle_popover(popover, window, cx);- }));- // The `kbd` prop rides the tooltip, which- // `ui::EditorButton` does not carry, so the wrapper the- // popover anchors against owns it instead.- self.anchored(- popover.anchor(),- kbd_tooltip(&theme, popover.tooltip(), popover.keys(), button),- )- .into_any_element()- }),- ),- )+ .child(tools).child(div().flex()@@ -2880,6 +2896,9 @@ impl ScreenshotEditorWindow {.gap(px(8.)).h_full().pr(px(8.))+ .when(cfg!(target_os = "windows"), |actions| {+ actions.h(px(32.)).flex_shrink_0().occlude()+ }).child(divider(&theme, 24.)).child(ui::EditorButton::plain(&theme, "screenshot-copy")@@ -2933,7 +2952,18 @@ impl ScreenshotEditorWindow {})),),),- )+ );++ #[cfg(target_os = "windows")]+ let header = header.child(ui::windows_caption_controls(+ theme,+ _window.is_window_active(),+ _window.is_maximized(),+ true,+ true,+ ));++ header}// -- Layers panel -----------------------------------------------------------@@ -4267,7 +4297,7 @@ impl ScreenshotEditorWindow {/// `ScreenshotEditorSkeleton` (`screenshot-editor-skeleton.tsx`): the/// header's three clusters as `rounded-lg` placeholders, and the Cap logo/// spinning over a flat preview.- fn render_skeleton(&self) -> impl IntoElement {+ fn render_skeleton(&self, _window: &Window) -> impl IntoElement {let theme = self.theme;let block = move |width: f32| {div()@@ -4281,95 +4311,118 @@ impl ScreenshotEditorWindow {})};- div()- .size_full()+ let tools = div().flex()- .flex_col()+ .flex_row()+ .items_center()+ .justify_center()+ .gap(px(8.))+ .child(block(96.))+ .child(block(36.))+ .child(divider(&theme, 24.))+ .children((0..5).map(|_| block(36.)))+ .child(divider(&theme, 24.))+ .children((0..5).map(|_| block(36.)));+ #[cfg(not(target_os = "windows"))]+ let tools = tools.absolute().top_0().left_0().size_full();+ #[cfg(target_os = "windows")]+ let tools = div()+ .id("screenshot-skeleton-tools")+ .flex()+ .flex_1()+ .min_w_0()+ .h(px(36.))+ .overflow_x_scroll()+ .occlude()+ .child(tools.flex_shrink_0().mx_auto());++ let header = div()+ .relative()+ .flex()+ .flex_row()+ .items_center()+ .justify_between()+ .w_full()+ .h(px(HEADER_HEIGHT))+ .px(px(16.))+ .when(cfg!(target_os = "windows"), |header| {+ header+ .pr_0()+ .gap(px(8.))+ .window_control_area(gpui::WindowControlArea::Drag)+ })+ .flex_shrink_0()+ .border_b_1()+ .border_color(theme.gray_3)+ .bg(if theme.is_dark() {+ theme.gray_2+ } else {+ theme.gray_1+ })+ .when(!cfg!(target_os = "windows"), |header| {+ header.child(div().w(px(56.)))+ })+ .child(tools).child(div()- .relative().flex().flex_row().items_center()- .justify_between()- .w_full()- .h(px(HEADER_HEIGHT))- .px(px(16.))- .flex_shrink_0()- .border_b_1()- .border_color(theme.gray_3)- .bg(if theme.is_dark() {- theme.gray_2- } else {- theme.gray_1- })- .child(div().w(px(56.)))- .child(- div()- .absolute()- .top_0()- .left_0()- .size_full()- .flex()- .flex_row()- .items_center()- .justify_center()- .gap(px(8.))- .child(block(96.))- .child(block(36.))- .child(divider(&theme, 24.))- .children((0..5).map(|_| block(36.)))- .child(divider(&theme, 24.))- .children((0..5).map(|_| block(36.))),- )- .child(- div()- .flex()- .flex_row()- .items_center()- .gap(px(8.))- .pr(px(8.))- .child(divider(&theme, 24.))- .children((0..3).map(|_| block(36.))),- ),- )- .child(- div()- .flex_1()- .min_h_0()- .relative()- .flex()- .items_center()- .justify_center()- .bg(if theme.is_dark() {- theme.gray_3- } else {- theme.gray_2+ .gap(px(8.))+ .pr(px(8.))+ .when(cfg!(target_os = "windows"), |actions| {+ actions.flex_shrink_0()})- .child(- div()- .absolute()- .left(px(16.))- .bottom(px(16.))- .flex()- .flex_row()- .items_center()- .gap(px(8.))- .p(px(4.))- .rounded(px(8.))- .border_1()- .border_color(theme.gray_4)- .bg(if theme.is_dark() {- theme.gray_3- } else {- theme.gray_1- })- .child(block(36.))- .child(div().w(px(80.)).h(px(8.)).rounded_full().bg(theme.gray_4))- .child(block(36.)),- )- .child(spinning_logo(&theme)),- )+ .child(divider(&theme, 24.))+ .children((0..3).map(|_| block(36.))),+ );++ #[cfg(target_os = "windows")]+ let header = header.child(ui::windows_caption_controls(+ theme,+ _window.is_window_active(),+ _window.is_maximized(),+ true,+ true,+ ));++ div().size_full().flex().flex_col().child(header).child(+ div()+ .flex_1()+ .min_h_0()+ .relative()+ .flex()+ .items_center()+ .justify_center()+ .bg(if theme.is_dark() {+ theme.gray_3+ } else {+ theme.gray_2+ })+ .child(+ div()+ .absolute()+ .left(px(16.))+ .bottom(px(16.))+ .flex()+ .flex_row()+ .items_center()+ .gap(px(8.))+ .p(px(4.))+ .rounded(px(8.))+ .border_1()+ .border_color(theme.gray_4)+ .bg(if theme.is_dark() {+ theme.gray_3+ } else {+ theme.gray_1+ })+ .child(block(36.))+ .child(div().w(px(80.)).h(px(8.)).rounded_full().bg(theme.gray_4))+ .child(block(36.)),+ )+ .child(spinning_logo(&theme)),+ )}}@@ -4407,10 +4460,10 @@ impl Render for ScreenshotEditorWindow {.text_color(theme.gray_12);if !self.ready {- return root.child(self.render_skeleton());+ return root.child(self.render_skeleton(window));}- root.child(self.render_header(cx))+ root.child(self.render_header(window, cx)).child(div().flex()diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rsindex 7339090da..8f69b4faa 100644--- a/apps/desktop-gpui/src/settings_window.rs+++ b/apps/desktop-gpui/src/settings_window.rs@@ -1456,7 +1456,7 @@ impl Render for SettingsWindow {self.sync_appearance(window, cx);let theme = self.theme;- div()+ let shell = div().track_focus(&self.focus)// `(window-chrome).tsx` binds Cmd-W to `getCurrentWindow().close()`// for every chrome window. Escape is not bound there and is not@@ -1488,9 +1488,47 @@ impl Render for SettingsWindow {.font_family("Geist")// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`)..font_weight(FontWeight::MEDIUM)- .text_color(theme.settings_text())+ .text_color(theme.settings_text());++ #[cfg(target_os = "windows")]+ let shell = shell+ .flex_col()+ .child(+ div()+ .h(px(36.))+ .w_full()+ .flex_shrink_0()+ .flex()+ .justify_end()+ .bg(theme.header_bg())+ .border_b_1()+ .border_color(theme.header_border())+ .window_control_area(gpui::WindowControlArea::Drag)+ .child(ui::windows_caption_controls(+ theme,+ window.is_window_active(),+ window.is_maximized(),+ true,+ true,+ )),+ )+ .child(+ div()+ .flex()+ .flex_row()+ .flex_1()+ .min_h_0()+ .w_full()+ .child(self.render_sidebar(cx))+ .child(self.render_content(window, cx)),+ );++ #[cfg(not(target_os = "windows"))]+ let shell = shell.child(self.render_sidebar(cx))- .child(self.render_content(window, cx))+ .child(self.render_content(window, cx));++ shell// Painted last so it lands over the page: the select menus, and// the drag layer the zoom slider needs while the button is held..children(self.render_menu(cx))diff --git a/apps/desktop-gpui/src/teleprompter_window.rs b/apps/desktop-gpui/src/teleprompter_window.rsindex 3cc033e89..67885e840 100644--- a/apps/desktop-gpui/src/teleprompter_window.rs+++ b/apps/desktop-gpui/src/teleprompter_window.rs@@ -529,7 +529,7 @@ impl Render for TeleprompterWindow {// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`)..font_weight(FontWeight::MEDIUM).text_color(Hsla::from(theme.gray_12))- .child(self.render_header())+ .child(self.render_header(window)).child(self.render_body(window, cx)).child(self.render_footer(cx))// `z-30` on the popover, over a footer that makes no stacking@@ -553,10 +553,10 @@ impl TeleprompterWindow {/// `cap-window-header flex h-9 shrink-0 items-center` with the note pushed/// to the trailing edge. The traffic lights are AppKit's, at (14, 14).- fn render_header(&self) -> impl IntoElement {+ fn render_header(&self, _window: &Window) -> impl IntoElement {let theme = self.theme;- div()+ let header = div().flex().flex_row().items_center()@@ -570,6 +570,14 @@ impl TeleprompterWindow {div().ml_auto().mr(px(12.))+ .when(cfg!(target_os = "windows"), |note| {+ note.flex_1()+ .min_w_0()+ .ml(px(12.))+ .mr(px(4.))+ .overflow_hidden()+ .whitespace_nowrap()+ }).flex().flex_row().items_center()@@ -584,7 +592,20 @@ impl TeleprompterWindow {.text_color(Hsla::from(theme.gray_9)),).child("This window is hidden from Cap recordings"),- )+ );++ #[cfg(target_os = "windows")]+ let header = header+ .window_control_area(gpui::WindowControlArea::Drag)+ .child(ui::windows_caption_controls(+ theme,+ _window.is_window_active(),+ _window.is_maximized(),+ true,+ true,+ ));++ header}/// `cap-window-body relative min-h-0 flex-1 overflow-hidden`: the scriptdiff --git a/apps/desktop-gpui/src/tray.rs b/apps/desktop-gpui/src/tray.rsindex 4c991e2c1..5cff0be65 100644--- a/apps/desktop-gpui/src/tray.rs+++ b/apps/desktop-gpui/src/tray.rs@@ -446,10 +446,16 @@ fn open_previous_item(path: PathBuf, cx: &mut App) {}RecordingMetaInner::Instant(_) => {if let Some(sharing) = &meta.sharing {+ #[cfg(target_os = "windows")]+ cx.open_url(&sharing.link);+ #[cfg(not(target_os = "windows"))]open_with_finder(&sharing.link);} else {let mp4 = path.join("content/output.mp4");if mp4.exists() {+ #[cfg(target_os = "windows")]+ cx.open_with_system(&mp4);+ #[cfg(not(target_os = "windows"))]open_with_finder(&mp4.to_string_lossy());}}@@ -459,6 +465,7 @@ fn open_previous_item(path: PathBuf, cx: &mut App) {/// `tauri_plugin_opener`'s `open_url` / `open_path`, which on macOS are both/// `open <thing>` -- the same spawn `library::open_recording_folder` uses.+#[cfg(not(target_os = "windows"))]fn open_with_finder(target: &str) {#[cfg(target_os = "macos")]if let Err(error) = std::process::Command::new("open").arg(target).spawn() {@@ -1069,7 +1076,13 @@ mod mac {}}-#[cfg(not(target_os = "macos"))]+#[cfg(target_os = "windows")]+mod windows;++#[cfg(target_os = "windows")]+pub use windows::*;++#[cfg(not(any(target_os = "macos", target_os = "windows")))]mod stub {use gpui::App;@@ -1092,7 +1105,7 @@ mod stub {}}-#[cfg(not(target_os = "macos"))]+#[cfg(not(any(target_os = "macos", target_os = "windows")))]pub use stub::*;/// Keeps the `Global` import honest on non-mac builds.diff --git a/apps/desktop-gpui/src/tray/windows.rs b/apps/desktop-gpui/src/tray/windows.rsnew file mode 100644index 000000000..04de18705--- /dev/null+++ b/apps/desktop-gpui/src/tray/windows.rs@@ -0,0 +1,337 @@+use std::collections::HashMap;++use gpui::{App, Global};+use tray_icon::{+ Icon, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent,+ menu::{+ self, IconMenuItem, IsMenuItem, Menu, MenuEvent, MenuId, MenuItem, PredefinedMenuItem,+ Submenu,+ },+};++use super::{+ Entry, PreviousItem, TrayItem, current_menu_entries, handle_item, scan_previous, stop_recording,+};+use crate::main_window::Mode;++const TRAY_ID: &str = "cap-gpui-tray";+const DEFAULT_ICON: &[u8] =+ include_bytes!("../../../desktop/src-tauri/icons/tray-default-icon.png");+const STOP_ICON: &[u8] = include_bytes!("../../assets/tray/tray-stop-icon.png");++enum Event {+ Menu(MenuId),+ Click,+}++struct NativeMenu {+ menu: Menu,+ actions: HashMap<MenuId, TrayItem>,+}++struct Tray {+ icon: TrayIcon,+ native_menu: NativeMenu,+ mode: Mode,+ previous: Vec<PreviousItem>,+ recording: bool,+ previous_generation: u64,+}++impl Global for Tray {}++pub fn init(cx: &mut App) {+ if cx.has_global::<Tray>() {+ return;+ }++ let mode = Mode::from_store();+ let entries = current_menu_entries(cx, mode, &[]);+ let tray = match create_tray(mode, &entries) {+ Ok(tray) => tray,+ Err(error) => {+ tracing::error!("failed to create the Windows tray: {error:#}");+ return;+ }+ };+ let (tx, rx) = flume::unbounded();+ let menu_tx = tx.clone();+ MenuEvent::set_event_handler(Some(move |event: MenuEvent| {+ let _ = menu_tx.send(Event::Menu(event.id));+ }));+ TrayIconEvent::set_event_handler(Some(move |event| {+ if activates_tray(&event) {+ let _ = tx.send(Event::Click);+ }+ }));+ cx.set_global(tray);++ cx.spawn(async move |cx| {+ while let Ok(event) = rx.recv_async().await {+ cx.update(|cx| {+ if !cx.has_global::<Tray>() {+ return;+ }+ match event {+ Event::Menu(id) => {+ let item = cx.global::<Tray>().native_menu.actions.get(&id).cloned();+ if let Some(item) = item {+ handle_item(item, cx);+ }+ }+ Event::Click => {+ if cx.global::<Tray>().recording {+ stop_recording(cx);+ }+ }+ }+ });+ }+ })+ .detach();++ refresh_previous(cx);+}++fn create_tray(mode: Mode, entries: &[Entry]) -> anyhow::Result<Tray> {+ let native_menu = build_native_menu(entries)?;+ let icon = TrayIconBuilder::new()+ .with_id(TRAY_ID)+ .with_tooltip("Cap")+ .with_icon(decode_tray_icon(DEFAULT_ICON)?)+ .with_menu(Box::new(native_menu.menu.clone()))+ .build()?;++ Ok(Tray {+ icon,+ native_menu,+ mode,+ previous: Vec::new(),+ recording: false,+ previous_generation: 0,+ })+}++fn activates_tray(event: &TrayIconEvent) -> bool {+ matches!(+ event,+ TrayIconEvent::Click {+ id,+ button_state: MouseButtonState::Up,+ ..+ } if id.as_ref() == TRAY_ID+ )+}++fn decode_tray_icon(bytes: &[u8]) -> anyhow::Result<Icon> {+ let image = image::load_from_memory(bytes)?.into_rgba8();+ let (width, height) = image.dimensions();+ Ok(Icon::from_rgba(image.into_raw(), width, height)?)+}++fn decode_menu_icon(bytes: &[u8]) -> anyhow::Result<menu::Icon> {+ let image = image::load_from_memory(bytes)?.into_rgba8();+ let (width, height) = image.dimensions();+ Ok(menu::Icon::from_rgba(image.into_raw(), width, height)?)+}++fn menu_text(title: &str) -> String {+ title.replace('&', "&&")+}++fn build_native_menu(entries: &[Entry]) -> anyhow::Result<NativeMenu> {+ let menu = Menu::new();+ let mut actions = HashMap::new();+ for entry in entries {+ let item = build_native_item(entry, &mut actions)?;+ menu.append(item.as_ref())?;+ }+ Ok(NativeMenu { menu, actions })+}++fn build_native_item(+ entry: &Entry,+ actions: &mut HashMap<MenuId, TrayItem>,+) -> anyhow::Result<Box<dyn IsMenuItem>> {+ match entry {+ Entry::Separator => Ok(Box::new(PredefinedMenuItem::separator())),+ Entry::Item {+ title,+ item,+ enabled,+ icon,+ } => {+ let icon = icon+ .as_deref()+ .and_then(|bytes| match decode_menu_icon(bytes) {+ Ok(icon) => Some(icon),+ Err(error) => {+ tracing::warn!("failed to load a Windows tray thumbnail: {error:#}");+ None+ }+ });+ let enabled = *enabled && item.is_some();+ let native_item: Box<dyn IsMenuItem> = match icon {+ Some(icon) => Box::new(IconMenuItem::new(+ menu_text(title),+ enabled,+ Some(icon),+ None,+ )),+ None => Box::new(MenuItem::new(menu_text(title), enabled, None)),+ };+ if enabled && let Some(item) = item {+ let _ = actions.insert(native_item.id().clone(), item.clone());+ }+ Ok(native_item)+ }+ Entry::Submenu {+ title,+ enabled,+ items,+ } => {+ let submenu = Submenu::new(menu_text(title), *enabled);+ for entry in items {+ let item = build_native_item(entry, actions)?;+ submenu.append(item.as_ref())?;+ }+ Ok(Box::new(submenu))+ }+ }+}++pub fn set_recording(recording: bool, cx: &mut App) {+ if !cx.has_global::<Tray>() {+ return;+ }+ let tray = cx.global_mut::<Tray>();+ tray.recording = recording;+ if recording {+ tray.icon.set_menu(None);+ } else {+ tray.icon+ .set_menu(Some(Box::new(tray.native_menu.menu.clone())));+ }+ let bytes = if recording { STOP_ICON } else { DEFAULT_ICON };+ match decode_tray_icon(bytes) {+ Ok(icon) => {+ if let Err(error) = tray.icon.set_icon(Some(icon)) {+ tracing::warn!("failed to update the Windows tray icon: {error}");+ }+ }+ Err(error) => tracing::warn!("failed to decode the Windows tray icon: {error:#}"),+ }+ let tooltip = if recording {+ "Cap - Stop Recording"+ } else {+ "Cap"+ };+ if let Err(error) = tray.icon.set_tooltip(Some(tooltip)) {+ tracing::warn!("failed to update the Windows tray tooltip: {error}");+ }+}++pub fn mode_changed(mode: Mode, cx: &mut App) {+ if !cx.has_global::<Tray>() {+ return;+ }+ cx.global_mut::<Tray>().mode = mode;+ refresh_menu(cx);+}++pub fn refresh_previous(cx: &mut App) {+ if !cx.has_global::<Tray>() {+ return;+ }+ let tray = cx.global_mut::<Tray>();+ tray.previous_generation = tray.previous_generation.wrapping_add(1);+ let generation = tray.previous_generation;+ cx.spawn(async move |cx| {+ let previous = cx+ .background_executor()+ .spawn(async { scan_previous(true) })+ .await;+ cx.update(|cx| {+ if !cx.has_global::<Tray>() || cx.global::<Tray>().previous_generation != generation {+ return;+ }+ cx.global_mut::<Tray>().previous = previous;+ refresh_menu(cx);+ });+ })+ .detach();+}++pub fn previous_items(cx: &App) -> Vec<PreviousItem> {+ if !cx.has_global::<Tray>() {+ return Vec::new();+ }+ cx.global::<Tray>().previous.clone()+}++pub fn menu_snapshot(cx: &App) -> Vec<Entry> {+ if !cx.has_global::<Tray>() {+ return Vec::new();+ }+ let tray = cx.global::<Tray>();+ current_menu_entries(cx, tray.mode, &tray.previous)+}++pub fn refresh_menu(cx: &mut App) {+ if !cx.has_global::<Tray>() {+ return;+ }+ let entries = menu_snapshot(cx);+ let native_menu = match build_native_menu(&entries) {+ Ok(menu) => menu,+ Err(error) => {+ tracing::warn!("failed to rebuild the Windows tray menu: {error:#}");+ return;+ }+ };+ let tray = cx.global_mut::<Tray>();+ if !tray.recording {+ tray.icon.set_menu(Some(Box::new(native_menu.menu.clone())));+ }+ tray.native_menu = native_menu;+}++#[cfg(test)]+mod tests {+ use super::*;+ use tray_icon::{MouseButton, Rect};++ #[test]+ fn menu_titles_preserve_literal_ampersands() {+ assert_eq!(+ menu_text("Research & Development"),+ "Research && Development"+ );+ assert_eq!(menu_text("Studio"), "Studio");+ }++ #[test]+ fn recording_stop_uses_one_click_event_for_this_tray() {+ for button in [MouseButton::Left, MouseButton::Right, MouseButton::Middle] {+ let event = |id: &str, button_state| TrayIconEvent::Click {+ id: id.into(),+ position: Default::default(),+ rect: Rect::default(),+ button,+ button_state,+ };+ assert!(activates_tray(&event(TRAY_ID, MouseButtonState::Up)));+ assert!(!activates_tray(&event(TRAY_ID, MouseButtonState::Down)));+ assert!(!activates_tray(&event(+ "another-tray",+ MouseButtonState::Up+ )));+ }+ assert!(!activates_tray(&TrayIconEvent::DoubleClick {+ id: TRAY_ID.into(),+ position: Default::default(),+ rect: Rect::default(),+ button: MouseButton::Left,+ }));+ }+}diff --git a/apps/desktop-gpui/src/ui/button.rs b/apps/desktop-gpui/src/ui/button.rsindex e5c588c73..ec8f750a5 100644--- a/apps/desktop-gpui/src/ui/button.rs+++ b/apps/desktop-gpui/src/ui/button.rs@@ -503,6 +503,7 @@ pub struct IconButton {border: Option<Hsla>,active: bool,disabled: bool,+ occlude: bool,rounded: Option<Pixels>,on_click: Option<ClickHandler>,}@@ -523,6 +524,7 @@ impl IconButton {border: None,active: false,disabled: false,+ occlude: false,rounded: None,on_click: None,}@@ -532,6 +534,7 @@ impl IconButton {/// all, `text-gray-11` going to `text-gray-12` on hover.pub fn header(theme: &Theme, id: impl Into<ElementId>, icon: impl Into<SharedString>) -> Self {Self {+ occlude: cfg!(target_os = "windows"),size: px(20.),icon_size: px(16.),idle: theme.gray(11),@@ -634,12 +637,14 @@ impl RenderOnce for IconButton {border,active,disabled,+ occlude,rounded,on_click,} = self;div().id(id)+ .when(occlude, |this| this.occlude()).tab_index(0).flex().items_center()diff --git a/apps/desktop-gpui/src/ui/mod.rs b/apps/desktop-gpui/src/ui/mod.rsindex e1fd14303..8035936d7 100644--- a/apps/desktop-gpui/src/ui/mod.rs+++ b/apps/desktop-gpui/src/ui/mod.rs@@ -63,6 +63,7 @@ mod tab_rail;pub mod text_input;mod toggle;mod tooltip;+mod windows_caption;// Some of these have no call site in this rev. They are the foundation tier// the editor's sidebar unit was blocked on -- `KbdChip` for `EditorButton`'s@@ -121,3 +122,5 @@ pub use text_input::{pub use toggle::{Toggle, ToggleSize};#[allow(unused_imports)]pub use tooltip::{Tooltip, TooltipStyle};+#[cfg(target_os = "windows")]+pub use windows_caption::windows_caption_controls;diff --git a/apps/desktop-gpui/src/ui/progress.rs b/apps/desktop-gpui/src/ui/progress.rsindex 953a398fd..35e175c05 100644--- a/apps/desktop-gpui/src/ui/progress.rs+++ b/apps/desktop-gpui/src/ui/progress.rs@@ -61,17 +61,24 @@ impl CircularProgress {self.text_size = size;self}++ fn percentage_label(&self) -> Option<String> {+ self.progress+ .filter(|_| self.label)+ .map(|fraction| format!("{}%", (fraction * 100.).round() as u32))+ }}impl RenderOnce for CircularProgress {fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {+ let percentage_label = self.percentage_label();let CircularProgress {progress,size,stroke,track,fill,- label,+ label: _,text_color,text_size,} = self;@@ -131,12 +138,12 @@ impl RenderOnce for CircularProgress {)})}))- .when(label, |this| {+ .when_some(percentage_label, |this, label| {this.child(div().text_size(text_size).text_color(text_color)- .child(format!("{}%", (fraction * 100.).round() as u32)),+ .child(label),)})}@@ -144,6 +151,26 @@ impl RenderOnce for CircularProgress {#[cfg(test)]mod tests {+ use super::*;++ #[test]+ fn indeterminate_progress_has_no_percentage_label() {+ let ring = CircularProgress::new(px(80.), px(6.), gpui::black(), gpui::white())+ .label(gpui::white(), px(14.))+ .indeterminate();+ assert_eq!(ring.percentage_label(), None);+ }++ #[test]+ fn determinate_progress_labels_only_measured_progress() {+ for (fraction, expected) in [(0., "0%"), (0.25, "25%"), (1., "100%")] {+ let ring = CircularProgress::new(px(80.), px(6.), gpui::black(), gpui::white())+ .label(gpui::white(), px(14.))+ .progress(fraction);+ assert_eq!(ring.percentage_label().as_deref(), Some(expected));+ }+ }+#[test]fn quadrant_shares_split_the_fraction_evenly() {let share =diff --git a/apps/desktop-gpui/src/ui/windows_caption.rs b/apps/desktop-gpui/src/ui/windows_caption.rsnew file mode 100644index 000000000..598b66c34--- /dev/null+++ b/apps/desktop-gpui/src/ui/windows_caption.rs@@ -0,0 +1,114 @@+use gpui::{+ Div, InteractiveElement, ParentElement, StatefulInteractiveElement, Styled, div,+ prelude::FluentBuilder, px, rgb, rgba, svg,+};++use crate::theme::Theme;++pub fn windows_caption_controls(+ theme: Theme,+ active: bool,+ maximized: bool,+ minimizable: bool,+ resizable: bool,+) -> Div {+ let dark = theme.is_dark();+ let hover = rgba(if dark { 0xffffff0d } else { 0x0000000d });+ let pressed = rgba(if dark { 0xe9e9e908 } else { 0x00000008 });+ let button = |id: &'static str, icon: &'static str, height: f32, enabled: bool| {+ let foreground = Theme::with_alpha(+ rgb(if dark { 0xffffff } else { 0x12161f }),+ if active && enabled { 0.8 } else { 0.4 },+ );++ div()+ .id(id)+ .group(id)+ .when(enabled, |button| button.tab_index(0))+ .w(px(46.))+ .h_full()+ .flex_shrink_0()+ .flex()+ .items_center()+ .justify_center()+ .cursor_default()+ .occlude()+ .on_mouse_down(gpui::MouseButton::Left, |_, _, cx| cx.stop_propagation())+ .when(enabled, |button| {+ button+ .hover(move |style| {+ style.bg(if id == "caption-close" {+ rgb(0xc42b1c)+ } else {+ hover+ })+ })+ .active(move |style| {+ style.bg(if id == "caption-close" {+ rgba(0xc42b1ce6)+ } else {+ pressed+ })+ })+ })+ .child(+ svg()+ .path(icon)+ .id("caption-glyph")+ .w(px(10.))+ .h(px(height))+ .text_color(foreground)+ .when(id == "caption-close", |icon| {+ icon.group_hover("caption-close", |style| style.text_color(gpui::white()))+ .group_active("caption-close", |style| style.text_color(gpui::white()))+ }),+ )+ };++ div()+ .flex()+ .h_full()+ .flex_shrink_0()+ .occlude()+ .child(+ button(+ "caption-minimize",+ "icons/caption-minimize-windows.svg",+ 1.,+ minimizable,+ )+ .when(minimizable, |button| {+ button.on_click(|_, window, _| window.minimize_window())+ }),+ )+ .when(resizable, |row| {+ row.child(+ button(+ "caption-maximize",+ if maximized {+ "icons/caption-restore-windows.svg"+ } else {+ "icons/caption-maximize-windows.svg"+ },+ if maximized { 11. } else { 10. },+ true,+ )+ .on_click(|_, window, _| {+ if let Some(native) = crate::platform::native_window(window) {+ crate::platform::zoom_native(&native);+ }+ }),+ )+ })+ .child(+ button(+ "caption-close",+ "icons/caption-close-windows.svg",+ 10.,+ true,+ )+ .on_click(|_, window, cx| {+ crate::menus::close_window_by_handle(window.window_handle(), cx);+ }),+ )+}