Jason Lee 2024-10-08 17:01:52 +08:00 committed by GitHub
parent 007288487e
commit 33200aa685
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 55 additions and 126 deletions

155
Cargo.lock generated
View file

@ -132,7 +132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52bca67b61cb81e5553babde81b8211f713cb6db79766f80168f3e5f40ea6c82"
dependencies = [
"ash",
"raw-window-handle 0.6.2",
"raw-window-handle",
"raw-window-metal",
]
@ -474,7 +474,7 @@ dependencies = [
"bitflags 2.6.0",
"cexpr",
"clang-sys",
"itertools 0.11.0",
"itertools 0.13.0",
"log",
"prettyplease",
"proc-macro2",
@ -548,7 +548,7 @@ dependencies = [
"mint",
"naga",
"objc",
"raw-window-handle 0.6.2",
"raw-window-handle",
"slab",
"wasm-bindgen",
"web-sys",
@ -2263,7 +2263,7 @@ dependencies = [
"postage",
"profiling",
"rand 0.8.5",
"raw-window-handle 0.6.2",
"raw-window-handle",
"refineable",
"resvg",
"schemars",
@ -2288,7 +2288,7 @@ dependencies = [
"wayland-cursor",
"wayland-protocols",
"wayland-protocols-plasma",
"windows 0.58.0",
"windows",
"windows-core 0.58.0",
"x11-clipboard",
"x11rb",
@ -2873,7 +2873,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
dependencies = [
"cfg-if",
"windows-targets 0.52.6",
"windows-targets 0.48.5",
]
[[package]]
@ -3120,29 +3120,24 @@ dependencies = [
[[package]]
name = "ndk"
version = "0.7.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.6.0",
"jni-sys",
"log",
"ndk-sys",
"num_enum",
"raw-window-handle 0.5.2",
"raw-window-handle",
"thiserror",
]
[[package]]
name = "ndk-context"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
[[package]]
name = "ndk-sys"
version = "0.4.1+23.1.7779620"
version = "0.6.0+11769913"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"
checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873"
dependencies = [
"jni-sys",
]
@ -3311,23 +3306,23 @@ dependencies = [
[[package]]
name = "num_enum"
version = "0.5.11"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.5.11"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.71",
]
[[package]]
@ -4023,12 +4018,6 @@ dependencies = [
"rgb",
]
[[package]]
name = "raw-window-handle"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
[[package]]
name = "raw-window-handle"
version = "0.6.2"
@ -4044,7 +4033,7 @@ dependencies = [
"cocoa 0.25.0",
"core-graphics 0.23.2",
"objc",
"raw-window-handle 0.6.2",
"raw-window-handle",
]
[[package]]
@ -5873,23 +5862,23 @@ dependencies = [
[[package]]
name = "webview2-com"
version = "0.31.0"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6516cfa64c6b3212686080eeec378e662c2af54bb2a5b2a22749673f5cb2226f"
checksum = "6f61ff3d9d0ee4efcb461b14eb3acfda2702d10dc329f339303fc3e57215ae2c"
dependencies = [
"webview2-com-macros",
"webview2-com-sys",
"windows 0.57.0",
"windows-core 0.57.0",
"windows-implement 0.57.0",
"windows-interface 0.57.0",
"windows",
"windows-core 0.58.0",
"windows-implement",
"windows-interface",
]
[[package]]
name = "webview2-com-macros"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc"
checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431"
dependencies = [
"proc-macro2",
"quote",
@ -5898,13 +5887,13 @@ dependencies = [
[[package]]
name = "webview2-com-sys"
version = "0.31.0"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c76d5b77320ff155660be1df3e6588bc85c75f1a9feef938cc4dc4dd60d1d7cf"
checksum = "a3a3e2eeb58f82361c93f9777014668eb3d07e7d174ee4c819575a9208011886"
dependencies = [
"thiserror",
"windows 0.57.0",
"windows-core 0.57.0",
"windows",
"windows-core 0.58.0",
]
[[package]]
@ -5944,16 +5933,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[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"
@ -5973,42 +5952,19 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
dependencies = [
"windows-implement 0.58.0",
"windows-interface 0.58.0",
"windows-result 0.2.0",
"windows-implement",
"windows-interface",
"windows-result",
"windows-strings",
"windows-targets 0.52.6",
]
[[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.71",
]
[[package]]
name = "windows-implement"
version = "0.58.0"
@ -6020,17 +5976,6 @@ dependencies = [
"syn 2.0.71",
]
[[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.71",
]
[[package]]
name = "windows-interface"
version = "0.58.0"
@ -6042,15 +5987,6 @@ dependencies = [
"syn 2.0.71",
]
[[package]]
name = "windows-result"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-result"
version = "0.2.0"
@ -6066,7 +6002,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
dependencies = [
"windows-result 0.2.0",
"windows-result",
"windows-targets 0.52.6",
]
@ -6342,19 +6278,18 @@ dependencies = [
"serde",
"smallvec",
"ui",
"windows 0.58.0",
"windows",
]
[[package]]
name = "wry"
version = "0.41.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b00c945786b02d7805d09a969fa36d0eee4e0bd4fb3ec2a79d2bf45a1b44cd"
version = "0.45.0"
source = "git+https://github.com/huacnlee/wry.git?branch=add-blur-method#7f2f270e7b459e5218ec64319ba2568cc30fc95d"
dependencies = [
"base64",
"block",
"cocoa 0.25.0",
"core-graphics 0.23.2",
"cocoa 0.26.0",
"core-graphics 0.24.0",
"crossbeam-channel",
"dpi",
"dunce",
@ -6367,13 +6302,11 @@ dependencies = [
"kuchikiki",
"libc",
"ndk",
"ndk-context",
"ndk-sys",
"objc",
"objc_id",
"once_cell",
"percent-encoding",
"raw-window-handle 0.6.2",
"raw-window-handle",
"sha2",
"soup3",
"tao-macros",
@ -6381,8 +6314,8 @@ dependencies = [
"webkit2gtk",
"webkit2gtk-sys",
"webview2-com",
"windows 0.57.0",
"windows-core 0.57.0",
"windows",
"windows-core 0.58.0",
"windows-version",
"x11-dl",
]

View file

@ -6,7 +6,11 @@ resolver = "2"
[workspace.dependencies]
gpui = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" }
windows = { version = "0.58.0", features = ["Wdk", "Wdk_System", "Wdk_System_SystemServices"] }
windows = { version = "0.58.0", features = [
"Wdk",
"Wdk_System",
"Wdk_System_SystemServices",
] }
ui = { path = "crates/ui" }
story = { path = "crates/story" }
workspace = { path = "crates/workspace" }

View file

@ -6,7 +6,7 @@ use std::{sync::Arc, time::Duration};
use story::{
ButtonStory, CalendarStory, DropdownStory, IconStory, ImageStory, InputStory, ListStory,
ModalStory, PopupStory, ProgressStory, ResizableStory, ScrollableStory, StoryContainer,
SwitchStory, TableStory, TextStory, TooltipStory,
SwitchStory, TableStory, TextStory, TooltipStory, WebViewStory,
};
use ui::{
button::{Button, ButtonStyled as _},
@ -194,6 +194,7 @@ impl StoryWorkspace {
Arc::new(StoryContainer::panel::<CalendarStory>(cx)),
Arc::new(StoryContainer::panel::<ResizableStory>(cx)),
Arc::new(StoryContainer::panel::<ScrollableStory>(cx)),
Arc::new(StoryContainer::panel::<WebViewStory>(cx)),
],
None,
&dock_area,

View file

@ -49,10 +49,6 @@ impl super::Story for InputStory {
"Input"
}
fn description() -> &'static str {
"A control that allows the user to input text."
}
fn closeable() -> bool {
false
}

View file

@ -41,7 +41,7 @@ impl WebViewStory {
let address_input = cx.new_view(|cx| {
let mut input = TextInput::new(cx);
input.set_text("https://github.com/explore", cx);
input.set_text("https://google.com", cx);
input
});

View file

@ -22,7 +22,7 @@ resvg = { version = "0.41.0", default-features = false }
usvg = { version = "0.41.0", default-features = false }
paste = "1"
once_cell = "1.19.0"
wry = "0"
wry = { git = "https://github.com/huacnlee/wry.git", branch = "add-blur-method" }
smol = "1"
regex = "1"
rust-i18n = "3"

View file

@ -166,15 +166,10 @@ impl Element for WebViewElement {
cx.on_mouse_event(move |event: &MouseDownEvent, _, cx| {
if !bounds.contains(&event.position) {
// Click white space to blur the input focus
webview
.evaluate_script(
r#"
document.querySelectorAll("input,textarea").forEach(input => input.blur());
"#,
)
.expect("failed to evaluate_script to blur input");
let _ = webview.blur();
} else {
cx.blur();
let _ = webview.focus();
}
});
});