From 9c1c77f9b13aabe6c3d0eeec692a4f7326d7da65 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 20 Nov 2023 06:32:58 -0800 Subject: [PATCH] Updated winit --- Cargo.lock | 322 ++++++++++++++++++++----------------------- examples/gameui.rs | 4 +- examples/tilemap.rs | 9 +- src/widgets/input.rs | 16 +-- src/window.rs | 14 +- 5 files changed, 169 insertions(+), 196 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89d7f40..cc4a83b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,22 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ab_glyph" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225" -dependencies = [ - "ab_glyph_rasterizer", - "owned_ttf_parser", -] - -[[package]] -name = "ab_glyph_rasterizer" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" - [[package]] name = "addr2line" version = "0.21.0" @@ -106,9 +90,8 @@ dependencies = [ [[package]] name = "appit" version = "0.1.0" -source = "git+https://github.com/khonsulabs/appit#5ed0d923ded6520950d14b3b869cbcac89452f5c" +source = "git+https://github.com/khonsulabs/appit#125e9f7c463d59e500089155d5433583302bb72a" dependencies = [ - "raw-window-handle 0.5.2", "winit", ] @@ -128,7 +111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc" dependencies = [ "clipboard-win", - "core-graphics", + "core-graphics 0.22.3", "image", "log", "objc", @@ -140,12 +123,6 @@ dependencies = [ "x11rb 0.10.1", ] -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - [[package]] name = "arrayvec" version = "0.7.4" @@ -314,16 +291,28 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "calloop" -version = "0.10.6" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e0d00eb1ea24371a97d2da6201c6747a633dc6dc1988ef503403b4c59504a8" +checksum = "7b50b5a44d59a98c55a9eeb518f39bf7499ba19fd98ee7d22618687f3f10adbf" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "log", - "nix 0.25.1", - "slotmap", + "polling", + "rustix", + "slab", "thiserror", - "vec_map", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" +dependencies = [ + "calloop", + "rustix", + "wayland-backend", + "wayland-client", ] [[package]] @@ -403,6 +392,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "concurrent-queue" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.7" @@ -444,6 +442,19 @@ dependencies = [ "libc", ] +[[package]] +name = "core-graphics" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types 0.5.0", + "libc", +] + [[package]] name = "core-graphics-types" version = "0.1.2" @@ -485,6 +496,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + [[package]] name = "cursor-icon" version = "1.1.0" @@ -660,12 +680,6 @@ dependencies = [ "spin", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "fontconfig-parser" version = "0.5.3" @@ -841,7 +855,7 @@ version = "0.1.0" dependencies = [ "attribute-derive", "insta", - "manyhow 0.10.0", + "manyhow 0.10.2", "prettyplease", "proc-macro2", "quote", @@ -927,12 +941,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - [[package]] name = "hexf-parse" version = "0.2.1" @@ -1006,17 +1014,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8" -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "jni" version = "0.21.1" @@ -1089,7 +1086,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" [[package]] name = "kludgine" version = "0.1.0" -source = "git+https://github.com/khonsulabs/kludgine#6b56d6524a8843f9a1a598e4d344407798971732" +source = "git+https://github.com/khonsulabs/kludgine#267c42d9454b31ebfe944e49522da33811e93772" dependencies = [ "ahash", "alot", @@ -1239,11 +1236,11 @@ dependencies = [ [[package]] name = "manyhow" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4efde575f79afb9c637eb4663aa451f0bf227413aa734fbbec077cab5900be85" +checksum = "69c6f16c208a6c61edc7b44896fc49b674af4b6b0d66a548770b9518f6aea41a" dependencies = [ - "manyhow-macros 0.10.0", + "manyhow-macros 0.10.2", "proc-macro2", "quote", "syn", @@ -1262,9 +1259,9 @@ dependencies = [ [[package]] name = "manyhow-macros" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcee04599474650eb26ae5a5c7837e30e55242267ff1bf0adc760b6fcdc3fa2a" +checksum = "6f44d5b16145f87728fcf137729f1959252619ec4d7d1f19eacb3f558bc5567a" dependencies = [ "proc-macro-utils", "proc-macro2", @@ -1288,18 +1285,18 @@ checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" -version = "0.5.10" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" dependencies = [ "libc", ] [[package]] name = "memmap2" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" +checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" dependencies = [ "libc", ] @@ -1393,6 +1390,7 @@ dependencies = [ "log", "ndk-sys", "num_enum", + "raw-window-handle 0.5.2", "raw-window-handle 0.6.0", "thiserror", ] @@ -1424,19 +1422,6 @@ dependencies = [ "memoffset 0.6.5", ] -[[package]] -name = "nix" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.26.4" @@ -1612,15 +1597,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "owned_ttf_parser" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7" -dependencies = [ - "ttf-parser 0.20.0", -] - [[package]] name = "palette" version = "0.7.3" @@ -1746,6 +1722,20 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "polling" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix", + "tracing", + "windows-sys 0.48.0", +] + [[package]] name = "pollster" version = "0.3.0" @@ -1805,9 +1795,9 @@ checksum = "f89dff0959d98c9758c88826cc002e2c3d0b9dfac4139711d1f30de442f1139b" [[package]] name = "quick-xml" -version = "0.28.2" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" dependencies = [ "memchr", ] @@ -2023,19 +2013,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sctk-adwaita" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b1ea0ce9e629064237c642f344cc2d9d8028e9b8367d894d2aa7f9243872176" -dependencies = [ - "ab_glyph", - "log", - "memmap2 0.5.10", - "smithay-client-toolkit", - "tiny-skia", -] - [[package]] name = "self_cell" version = "1.0.2" @@ -2089,6 +2066,15 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "slotmap" version = "1.0.6" @@ -2106,24 +2092,27 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smithay-client-toolkit" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1476c3d89bb67079264b88aaf4f14358353318397e083b7c4e8c14517f55de7" +checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "calloop", - "dlib", - "lazy_static", + "calloop-wayland-source", + "cursor-icon", + "libc", "log", - "memmap2 0.5.10", - "nix 0.26.4", + "memmap2 0.9.0", + "rustix", "thiserror", "wayland-backend", "wayland-client", + "wayland-csd-frame", "wayland-cursor", "wayland-protocols", "wayland-protocols-wlr", "wayland-scanner", + "xkeysym", ] [[package]] @@ -2166,12 +2155,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" -[[package]] -name = "strict-num" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" - [[package]] name = "svg_fmt" version = "0.4.1" @@ -2258,31 +2241,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "tiny-skia" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b72a92a05db376db09fe6d50b7948d106011761c05a6a45e23e17ee9b556222" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "log", - "tiny-skia-path", -] - -[[package]] -name = "tiny-skia-path" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac3865b9708fc7e1961a65c3a4fa55e984272f33092d3c859929f887fceb647" -dependencies = [ - "arrayref", - "bytemuck", - "strict-num", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -2454,12 +2412,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -2550,13 +2502,12 @@ checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "wayland-backend" -version = "0.1.2" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b48e27457e8da3b2260ac60d0a94512f5cba36448679f3747c0865b7893ed8" +checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" dependencies = [ "cc", "downcast-rs", - "io-lifetimes", "nix 0.26.4", "scoped-tls", "smallvec", @@ -2565,22 +2516,32 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.30.2" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489c9654770f674fc7e266b3c579f4053d7551df0ceb392f153adb1f9ed06ac8" +checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" dependencies = [ - "bitflags 1.3.2", - "calloop", + "bitflags 2.4.1", "nix 0.26.4", "wayland-backend", "wayland-scanner", ] [[package]] -name = "wayland-cursor" -version = "0.30.0" +name = "wayland-csd-frame" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0c3a0d5b4b688b07b0442362d3ed6bf04724fcc16cd69ab6285b90dbc487aa" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.4.1", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" dependencies = [ "nix 0.26.4", "wayland-client", @@ -2589,23 +2550,36 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.30.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b28101e5ca94f70461a6c2d610f76d85ad223d042dd76585ab23d3422dd9b4d" +checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "wayland-backend", "wayland-client", "wayland-scanner", ] [[package]] -name = "wayland-protocols-wlr" -version = "0.1.0" +name = "wayland-protocols-plasma" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce991093320e4a6a525876e6b629ab24da25f9baef0c2e0080ad173ec89588a" +checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" +dependencies = [ + "bitflags 2.4.1", "wayland-backend", "wayland-client", "wayland-protocols", @@ -2614,9 +2588,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.30.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b873b257fbc32ec909c0eb80dea312076a67014e65e245f5eb69a6b8ab330e" +checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" dependencies = [ "proc-macro2", "quick-xml", @@ -2625,13 +2599,13 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.30.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06" +checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", - "lazy_static", "log", + "once_cell", "pkg-config", ] @@ -2962,10 +2936,11 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winit" -version = "0.29.1-beta" +version = "0.29.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab977231134a3123c5382f0358b728118e70c216ec99017aa24e9eed35d5e3e1" +checksum = "161598019a9da35ab6c34dc46cd13546cba9dbf9816475d4dd9a639455016563" dependencies = [ + "ahash", "android-activity", "atomic-waker", "bitflags 2.4.1", @@ -2973,14 +2948,13 @@ dependencies = [ "calloop", "cfg_aliases", "core-foundation", - "core-graphics", + "core-graphics 0.23.1", "cursor-icon", - "fnv", "icrate", "js-sys", "libc", "log", - "memmap2 0.5.10", + "memmap2 0.9.0", "ndk", "ndk-sys", "objc2", @@ -2990,7 +2964,6 @@ dependencies = [ "raw-window-handle 0.5.2", "redox_syscall 0.3.5", "rustix", - "sctk-adwaita", "smithay-client-toolkit", "smol_str", "unicode-segmentation", @@ -2999,6 +2972,7 @@ dependencies = [ "wayland-backend", "wayland-client", "wayland-protocols", + "wayland-protocols-plasma", "web-sys", "web-time", "windows-sys 0.48.0", diff --git a/examples/gameui.rs b/examples/gameui.rs index 045f976..50ae582 100644 --- a/examples/gameui.rs +++ b/examples/gameui.rs @@ -4,7 +4,7 @@ use gooey::widgets::input::InputValue; use gooey::widgets::Space; use gooey::Run; use kludgine::app::winit::event::ElementState; -use kludgine::app::winit::keyboard::Key; +use kludgine::app::winit::keyboard::{Key, NamedKey}; use kludgine::Color; fn main() -> gooey::Result { @@ -20,7 +20,7 @@ fn main() -> gooey::Result { .expand() .and(chat_message.clone().into_input().on_key(move |input| { match (input.state, input.logical_key) { - (ElementState::Pressed, Key::Enter) => { + (ElementState::Pressed, Key::Named(NamedKey::Enter)) => { let new_message = chat_message.map_mut(std::mem::take); chat_log.map_mut(|chat_log| { chat_log.push_str(&new_message); diff --git a/examples/tilemap.rs b/examples/tilemap.rs index 850ca9d..dc5d4d6 100644 --- a/examples/tilemap.rs +++ b/examples/tilemap.rs @@ -8,6 +8,7 @@ use gooey::kludgine::Color; use gooey::value::Dynamic; use gooey::widgets::TileMap; use gooey::{Run, Tick}; +use kludgine::app::winit::keyboard::NamedKey; use kludgine::figures::FloatConversion; use kludgine::DrawableExt; @@ -46,16 +47,16 @@ fn main() -> gooey::Result { }) .tick(Tick::times_per_second(60, move |elapsed, input| { let mut direction = Point::new(0., 0.); - if input.keys.contains(&Key::ArrowDown) { + if input.keys.contains(&Key::Named(NamedKey::ArrowDown)) { direction.y += 1.0; } - if input.keys.contains(&Key::ArrowUp) { + if input.keys.contains(&Key::Named(NamedKey::ArrowUp)) { direction.y -= 1.0; } - if input.keys.contains(&Key::ArrowRight) { + if input.keys.contains(&Key::Named(NamedKey::ArrowRight)) { direction.x += 1.0; } - if input.keys.contains(&Key::ArrowLeft) { + if input.keys.contains(&Key::Named(NamedKey::ArrowLeft)) { direction.x -= 1.0; } diff --git a/src/widgets/input.rs b/src/widgets/input.rs index 332ca22..6a35b96 100644 --- a/src/widgets/input.rs +++ b/src/widgets/input.rs @@ -11,7 +11,7 @@ use std::time::Duration; use intentional::Cast; use kludgine::app::winit::event::{ElementState, Ime, KeyEvent}; -use kludgine::app::winit::keyboard::Key; +use kludgine::app::winit::keyboard::{Key, NamedKey}; use kludgine::app::winit::window::ImePurpose; use kludgine::figures::units::{Lp, Px, UPx}; use kludgine::figures::{ @@ -355,18 +355,18 @@ where fn handle_key(&mut self, input: KeyEvent, context: &mut EventContext<'_, '_>) -> EventHandling { match (input.state, input.logical_key, input.text.as_deref()) { - (ElementState::Pressed, key @ (Key::Backspace | Key::Delete), _) => { + (ElementState::Pressed, Key::Named(key @ (NamedKey::Backspace| NamedKey::Delete)), _) => { match key { - Key::Backspace => self.delete(), - Key::Delete => self.forward_delete(), + NamedKey::Backspace => self.delete(), + NamedKey::Delete => self.forward_delete(), _ => unreachable!("previously matched"), } HANDLED } - (ElementState::Pressed, key @ (Key::ArrowLeft | Key::ArrowDown | Key::ArrowUp | Key::ArrowRight), _) => { + (ElementState::Pressed, Key::Named(key @ (NamedKey::ArrowLeft | NamedKey::ArrowDown | NamedKey::ArrowUp | NamedKey::ArrowRight)), _) => { let modifiers = context.modifiers(); - let affinity = if matches!(key, Key::ArrowLeft | Key::ArrowUp) { + let affinity = if matches!(key, NamedKey::ArrowLeft | NamedKey::ArrowUp) { Affinity::Before } else { Affinity::After @@ -383,8 +383,8 @@ where match key { // Key::ArrowLeft | Key::ArrowRight if modifiers.primary() => self.move_cursor(affinity, CursorNavigationMode::LineExtent), - Key::ArrowLeft | Key::ArrowRight if modifiers.word_select() => self.move_cursor(affinity, CursorNavigationMode::Word), - Key::ArrowLeft | Key::ArrowRight => self.move_cursor(affinity, CursorNavigationMode::Grapheme), + NamedKey::ArrowLeft | NamedKey::ArrowRight if modifiers.word_select() => self.move_cursor(affinity, CursorNavigationMode::Word), + NamedKey::ArrowLeft | NamedKey::ArrowRight => self.move_cursor(affinity, CursorNavigationMode::Grapheme), // Key::ArrowDown | Key::ArrowUp => self.move_cursor(affinity, CursorNavigationMode::Line), _ => tracing::warn!("unhandled key: {key:?}"), } diff --git a/src/window.rs b/src/window.rs index 23b7d39..a67e7a8 100644 --- a/src/window.rs +++ b/src/window.rs @@ -15,7 +15,7 @@ use kludgine::app::winit::dpi::{PhysicalPosition, PhysicalSize}; use kludgine::app::winit::event::{ DeviceId, ElementState, Ime, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase, }; -use kludgine::app::winit::keyboard::Key; +use kludgine::app::winit::keyboard::{Key, NamedKey}; use kludgine::app::winit::window; use kludgine::app::WindowBehavior as _; use kludgine::cosmic_text::FamilyOwned; @@ -105,7 +105,7 @@ impl<'window> DerefMut for RunningWindow<'window> { } /// The attributes of a Gooey window. -pub type WindowAttributes = kludgine::app::WindowAttributes; +pub type WindowAttributes = kludgine::app::WindowAttributes; /// A Gooey window that is not yet running. #[must_use] @@ -681,9 +681,7 @@ where !self.should_close } - fn initial_window_attributes( - context: &Self::Context, - ) -> kludgine::app::WindowAttributes { + fn initial_window_attributes(context: &Self::Context) -> kludgine::app::WindowAttributes { let mut attrs = context .settings .borrow_mut() @@ -800,7 +798,7 @@ where window.set_needs_redraw(); } } - Key::Tab if !window.modifiers().possible_shortcut() => { + Key::Named(NamedKey::Tab) if !window.modifiers().possible_shortcut() => { if input.state.is_pressed() { let reverse = window.modifiers().state().shift_key(); @@ -828,7 +826,7 @@ where } } } - Key::Enter => { + Key::Named(NamedKey::Enter) => { self.keyboard_activate_widget( input.state.is_pressed(), self.root.tree.default_widget(), @@ -836,7 +834,7 @@ where kludgine, ); } - Key::Escape => { + Key::Named(NamedKey::Escape) => { self.keyboard_activate_widget( input.state.is_pressed(), self.root.tree.escape_widget(),