From 1885aa4eccd58b5bbcbb13327e0035240813809b Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Thu, 25 Jan 2024 20:39:55 -0500 Subject: [PATCH 1/4] Remove menu bar. --- src/app_main.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/app_main.rs b/src/app_main.rs index a05610892..740e084e1 100644 --- a/src/app_main.rs +++ b/src/app_main.rs @@ -16,8 +16,8 @@ use std::any::Any; use accesskit::TreeUpdate; use glazier::{ - Application, Cursor, HotKey, IdleToken, Menu, PointerEvent, Region, Scalable, SysMods, - WinHandler, WindowBuilder, WindowHandle, + Application, Cursor, IdleToken, PointerEvent, Region, Scalable, WinHandler, WindowBuilder, + WindowHandle, }; use vello::{ kurbo::{Affine, Size}, @@ -46,8 +46,6 @@ struct MainState> { counter: u64, } -const QUIT_MENU_ID: u32 = 0x100; - impl + 'static> AppLauncher { pub fn new(app: App) -> Self { AppLauncher { @@ -63,23 +61,11 @@ impl + 'static> AppLauncher { pub fn run(self) { let glazier_app = Application::new().unwrap(); - let mut file_menu = Menu::new(); - file_menu.add_item( - QUIT_MENU_ID, - "E&xit", - Some(&HotKey::new(SysMods::Cmd, "q")), - Some(false), - true, - ); - let mut menubar = Menu::new(); - menubar.add_dropdown(Menu::new(), "Application", true); - menubar.add_dropdown(file_menu, "&File", true); let _guard = self.app.rt.enter(); let main_state = MainState::new(self.app); let window = WindowBuilder::new(glazier_app.clone()) .handler(Box::new(main_state)) .title(self.title) - .menu(menubar) .size(Size::new(1024., 768.)) .build() .unwrap(); @@ -106,10 +92,6 @@ impl + 'static> WinHandler for MainState { fn command(&mut self, id: u32) { match id { - QUIT_MENU_ID => { - self.handle.close(); - Application::global().quit() - } _ => println!("unexpected id {}", id), } } From 5638f58f13de3bd35b76f1ad5ea01e8da452ccdc Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Tue, 6 Feb 2024 11:28:19 -0500 Subject: [PATCH 2/4] Add PointerCrusher --- Cargo.lock | 1 + Cargo.toml | 1 + src/app_main.rs | 27 ++++++-- src/widget/mod.rs | 2 +- src/widget/raw_event.rs | 139 +++++++++++++++++++++++++++++++++++----- 5 files changed, 147 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d93faa3b..ff4bf0cdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3299,6 +3299,7 @@ dependencies = [ "fnv", "futures-task", "glazier", + "instant", "parley", "taffy", "test-log", diff --git a/Cargo.toml b/Cargo.toml index 9520417ef..b72dc1a85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,7 @@ bitflags = "2" tracing = "0.1.37" accesskit = "0.12" fnv = "1.0.7" +instant = { version = "0.1.6", features = ["wasm-bindgen"] } [dependencies.glazier] git = "https://github.com/linebender/glazier" diff --git a/src/app_main.rs b/src/app_main.rs index 740e084e1..ddd849a93 100644 --- a/src/app_main.rs +++ b/src/app_main.rs @@ -16,8 +16,8 @@ use std::any::Any; use accesskit::TreeUpdate; use glazier::{ - Application, Cursor, IdleToken, PointerEvent, Region, Scalable, WinHandler, WindowBuilder, - WindowHandle, + Application, Cursor, IdleToken, PointerEvent, PointerType, Region, Scalable, WinHandler, + WindowBuilder, WindowHandle, }; use vello::{ kurbo::{Affine, Size}, @@ -26,7 +26,7 @@ use vello::{ AaSupport, RenderParams, Renderer, RendererOptions, Scene, }; -use crate::{app::App, view::View, widget::Event}; +use crate::{app::App, view::View, widget::Event, widget::PointerCrusher}; // This is a bit of a hack just to get a window launched. The real version // would deal with multiple windows and have other ways to configure things. @@ -44,6 +44,7 @@ struct MainState> { renderer: Option, scene: Scene, counter: u64, + main_pointer: PointerCrusher, } impl + 'static> AppLauncher { @@ -108,23 +109,34 @@ impl + 'static> WinHandler for MainState { } fn pointer_down(&mut self, event: &PointerEvent) { - self.app.window_event(Event::MouseDown(event.into())); + self.main_pointer.mods(event.modifiers); + self.app + .window_event(Event::MouseDown(self.main_pointer.pressed(event.button))); self.handle.invalidate(); } fn pointer_up(&mut self, event: &PointerEvent) { - self.app.window_event(Event::MouseUp(event.into())); + self.main_pointer.mods(event.modifiers); + self.app + .window_event(Event::MouseUp(self.main_pointer.released(event.button))); self.handle.invalidate(); } fn pointer_move(&mut self, event: &PointerEvent) { - self.app.window_event(Event::MouseMove(event.into())); + self.main_pointer.mods(event.modifiers); + self.app + .window_event(Event::MouseMove(self.main_pointer.moved(event.pos))); self.handle.invalidate(); self.handle.set_cursor(&Cursor::Arrow); } fn wheel(&mut self, event: &PointerEvent) { - self.app.window_event(Event::MouseWheel(event.into())); + self.main_pointer.mods(event.modifiers); + if let PointerType::Mouse(ref info) = event.pointer_type { + self.app + .window_event(Event::MouseWheel(self.main_pointer.wheel(info.wheel_delta))); + } + self.handle.invalidate(); } @@ -164,6 +176,7 @@ where renderer: None, scene: Scene::default(), counter: 0, + main_pointer: PointerCrusher::new(), } } diff --git a/src/widget/mod.rs b/src/widget/mod.rs index a2b73c6c5..326c5d0c6 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -33,7 +33,7 @@ pub use box_constraints::BoxConstraints; pub use button::Button; pub use contexts::{AccessCx, CxState, EventCx, LayoutCx, LifeCycleCx, PaintCx, UpdateCx}; pub use linear_layout::LinearLayout; -pub use raw_event::{Event, LifeCycle, MouseEvent, ViewContext}; +pub use raw_event::{Event, LifeCycle, MouseEvent, PointerCrusher, ViewContext}; pub use switch::Switch; pub use text::TextWidget; pub use widget::{AnyWidget, Widget}; diff --git a/src/widget/raw_event.rs b/src/widget/raw_event.rs index f4049663d..b8258ed35 100644 --- a/src/widget/raw_event.rs +++ b/src/widget/raw_event.rs @@ -17,7 +17,7 @@ //! Note: arguably this module should be renamed, perhaps we should use //! "event" for this level and maybe "message" at the View level. -use glazier::{Modifiers, PointerButton, PointerButtons, PointerType}; +use glazier::{Modifiers, PointerButton, PointerButtons}; use vello::kurbo::{Point, Rect, Vec2}; #[derive(Debug, Clone)] @@ -58,21 +58,17 @@ pub struct ViewContext { pub mouse_position: Option, } -impl<'a> From<&'a glazier::PointerEvent> for MouseEvent { - fn from(src: &glazier::PointerEvent) -> MouseEvent { +impl Default for MouseEvent { + fn default() -> Self { MouseEvent { - pos: src.pos, - window_pos: src.pos, - buttons: src.buttons, - mods: src.modifiers, - count: src.count, - focus: src.focus, - button: src.button, - wheel_delta: if let PointerType::Mouse(ref info) = src.pointer_type { - info.wheel_delta - } else { - Vec2::ZERO - }, + pos: Point::ZERO, + window_pos: Point::ZERO, + buttons: PointerButtons::new(), + mods: Modifiers::default(), + count: 0, + focus: false, + button: PointerButton::None, + wheel_delta: Vec2::ZERO, } } } @@ -87,3 +83,116 @@ impl ViewContext { } } } + +/// Crush all pointer events into a single pointer that counts clicks +/// and attaches positions to events that don't contain them. +#[derive(Default)] +pub struct PointerCrusher { + e: MouseEvent, + counter: ClickCounter, +} + +impl PointerCrusher { + pub fn new() -> Self { + PointerCrusher::default() + } + + pub fn mods(&mut self, mods: Modifiers) { + self.e.mods = mods; + } + + pub fn pressed(&mut self, button: PointerButton) -> MouseEvent { + self.e.wheel_delta = Vec2::ZERO; + self.e.buttons.insert(button); + self.e.count = self.counter.count_for_click(self.e.pos); + self.e.button = button; + self.e.clone() + } + + pub fn released(&mut self, button: PointerButton) -> MouseEvent { + self.e.wheel_delta = Vec2::ZERO; + self.e.buttons.remove(button); + self.e.count = self.counter.count_for_click(self.e.pos); + self.e.button = button; + self.e.clone() + } + + pub fn moved(&mut self, pos: Point) -> MouseEvent { + self.e.wheel_delta = Vec2::ZERO; + self.e.button = PointerButton::None; + self.e.pos = pos; + self.e.window_pos = pos; + self.e.clone() + } + + pub fn wheel(&mut self, wheel_delta: Vec2) -> MouseEvent { + self.e.wheel_delta = wheel_delta; + self.e.button = PointerButton::None; + self.e.clone() + } +} + +use instant::Instant; +use std::cell::Cell; +use std::time::Duration; + +// This is the default timing on windows. +const MULTI_CLICK_INTERVAL: Duration = Duration::from_millis(500); +// the max distance between two clicks for them to count as a multi-click +const MULTI_CLICK_MAX_DISTANCE: f64 = 5.0; + +/// A small helper for determining the click-count of a mouse-down event. +/// +/// Click-count is incremented if both the duration and distance between a pair +/// of clicks are below some threshold. +#[derive(Debug, Clone)] +struct ClickCounter { + max_interval: Cell, + max_distance: Cell, + last_click: Cell, + last_pos: Cell, + click_count: Cell, +} + +#[allow(dead_code)] +impl ClickCounter { + /// Create a new `ClickCounter` with the given interval and distance. + pub fn new(max_interval: Duration, max_distance: f64) -> ClickCounter { + ClickCounter { + max_interval: Cell::new(max_interval), + max_distance: Cell::new(max_distance), + last_click: Cell::new(Instant::now()), + click_count: Cell::new(0), + last_pos: Cell::new(Point::new(f64::MAX, 0.0)), + } + } + + pub fn set_interval_ms(&self, millis: u64) { + self.max_interval.set(Duration::from_millis(millis)); + } + + pub fn set_distance(&self, distance: f64) { + self.max_distance.set(distance); + } + + /// Return the click count for a click occurring now, at the provided position. + pub fn count_for_click(&self, click_pos: Point) -> u8 { + let click_time = Instant::now(); + let last_time = self.last_click.replace(click_time); + let last_pos = self.last_pos.replace(click_pos); + let elapsed = click_time - last_time; + let distance = last_pos.distance(click_pos); + if elapsed > self.max_interval.get() || distance > self.max_distance.get() { + self.click_count.set(0); + } + let click_count = self.click_count.get().saturating_add(1); + self.click_count.set(click_count); + click_count + } +} + +impl Default for ClickCounter { + fn default() -> Self { + ClickCounter::new(MULTI_CLICK_INTERVAL, MULTI_CLICK_MAX_DISTANCE) + } +} From 8497ef8d67575e8dae8d872de12565d58d0a150d Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Sat, 17 Feb 2024 18:15:02 -0500 Subject: [PATCH 3/4] Implement basic winit event handling. --- Cargo.lock | 793 ++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 1 + src/app_main.rs | 247 +++++++------ src/widget/raw_event.rs | 1 - 4 files changed, 884 insertions(+), 158 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff4bf0cdd..796733410 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,22 @@ # 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 = "accesskit" version = "0.12.2" @@ -25,7 +41,7 @@ checksum = "cd3b6ae1eabbfbced10e840fd3fce8a93ae84f174b3e4ba892ab7bcb42e477a7" dependencies = [ "accesskit", "accesskit_consumer", - "objc2", + "objc2 0.3.0-beta.3.patch-leaks.3", "once_cell", ] @@ -65,6 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -85,6 +102,33 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "android-activity" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" +dependencies = [ + "android-properties", + "bitflags 2.4.2", + "cc", + "cesu8", + "jni", + "jni-sys", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -100,6 +144,12 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +[[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" @@ -460,7 +510,16 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" dependencies = [ - "objc-sys", + "objc-sys 0.2.0-beta.2", +] + +[[package]] +name = "block-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" +dependencies = [ + "objc-sys 0.3.2", ] [[package]] @@ -469,8 +528,18 @@ version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" dependencies = [ - "block-sys", - "objc2-encode", + "block-sys 0.1.0-beta.1", + "objc2-encode 2.0.0-pre.2", +] + +[[package]] +name = "block2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" +dependencies = [ + "block-sys 0.2.1", + "objc2 0.4.1", ] [[package]] @@ -541,15 +610,48 @@ dependencies = [ "vec_map", ] +[[package]] +name = "calloop" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" +dependencies = [ + "bitflags 2.4.2", + "log", + "polling 3.4.0", + "rustix 0.38.31", + "slab", + "thiserror", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" +dependencies = [ + "calloop 0.12.4", + "rustix 0.38.31", + "wayland-backend 0.3.3", + "wayland-client 0.31.2", +] + [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cexpr" version = "0.6.0" @@ -565,6 +667,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "clang-sys" version = "1.7.0" @@ -622,6 +730,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -726,6 +844,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "cursor-icon" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" + [[package]] name = "d3d12" version = "0.7.0" @@ -758,6 +882,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + [[package]] name = "dlib" version = "0.5.2" @@ -1099,6 +1229,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "gethostname" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818" +dependencies = [ + "libc", + "windows-targets 0.48.5", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -1156,16 +1296,16 @@ dependencies = [ "objc", "once_cell", "pkg-config", - "raw-window-handle", + "raw-window-handle 0.5.2", "scopeguard", - "smithay-client-toolkit", + "smithay-client-toolkit 0.17.0", "tracing", "wasm-bindgen", - "wayland-backend", + "wayland-backend 0.1.2", "web-sys", "winapi", "wio", - "x11rb", + "x11rb 0.12.0", ] [[package]] @@ -1367,6 +1507,17 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "icrate" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" +dependencies = [ + "block2 0.3.0", + "dispatch", + "objc2 0.4.1", +] + [[package]] name = "idna" version = "0.5.0" @@ -1427,6 +1578,37 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jobserver" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.68" @@ -1529,6 +1711,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "libredox" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" +dependencies = [ + "bitflags 2.4.2", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -1594,6 +1787,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -1691,6 +1893,37 @@ dependencies = [ "getrandom", ] +[[package]] +name = "ndk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +dependencies = [ + "bitflags 2.4.2", + "jni-sys", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", + "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.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys", +] + [[package]] name = "nix" version = "0.25.1" @@ -1746,6 +1979,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "objc" version = "0.2.7" @@ -1762,15 +2016,31 @@ version = "0.2.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" +[[package]] +name = "objc-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" + [[package]] name = "objc2" version = "0.3.0-beta.3.patch-leaks.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" dependencies = [ - "block2", - "objc-sys", - "objc2-encode", + "block2 0.2.0-alpha.6", + "objc-sys 0.2.0-beta.2", + "objc2-encode 2.0.0-pre.2", +] + +[[package]] +name = "objc2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" +dependencies = [ + "objc-sys 0.3.2", + "objc2-encode 3.0.0", ] [[package]] @@ -1779,9 +2049,15 @@ version = "2.0.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" dependencies = [ - "objc-sys", + "objc-sys 0.2.0-beta.2", ] +[[package]] +name = "objc2-encode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" + [[package]] name = "objc_exception" version = "0.1.2" @@ -1806,6 +2082,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "orbclient" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166" +dependencies = [ + "libredox", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -1816,6 +2101,15 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "owned_ttf_parser" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7" +dependencies = [ + "ttf-parser", +] + [[package]] name = "parking" version = "2.2.0" @@ -1840,7 +2134,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -2006,6 +2300,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.35" @@ -2057,6 +2360,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +[[package]] +name = "raw-window-handle" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" + [[package]] name = "read-fonts" version = "0.15.3" @@ -2066,6 +2375,15 @@ dependencies = [ "font-types", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -2155,6 +2473,15 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2167,6 +2494,19 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sctk-adwaita" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550" +dependencies = [ + "ab_glyph", + "log", + "memmap2 0.9.4", + "smithay-client-toolkit 0.18.1", + "tiny-skia", +] + [[package]] name = "serde" version = "1.0.196" @@ -2284,19 +2624,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1476c3d89bb67079264b88aaf4f14358353318397e083b7c4e8c14517f55de7" dependencies = [ "bitflags 1.3.2", - "calloop", + "calloop 0.10.6", "dlib", "lazy_static", "log", - "memmap2", + "memmap2 0.5.10", "nix 0.26.4", "thiserror", - "wayland-backend", - "wayland-client", - "wayland-cursor", - "wayland-protocols", - "wayland-protocols-wlr", - "wayland-scanner", + "wayland-backend 0.1.2", + "wayland-client 0.30.2", + "wayland-cursor 0.30.0", + "wayland-protocols 0.30.1", + "wayland-protocols-wlr 0.1.0", + "wayland-scanner 0.30.1", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" +dependencies = [ + "bitflags 2.4.2", + "calloop 0.12.4", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2 0.9.4", + "rustix 0.38.31", + "thiserror", + "wayland-backend 0.3.3", + "wayland-client 0.31.2", + "wayland-csd-frame", + "wayland-cursor 0.31.1", + "wayland-protocols 0.31.2", + "wayland-protocols-wlr 0.2.0", + "wayland-scanner 0.31.1", + "xkeysym", +] + +[[package]] +name = "smol_str" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6845563ada680337a52d43bb0b29f396f2d911616f6573012645b9e3d048a49" +dependencies = [ + "serde", ] [[package]] @@ -2344,6 +2718,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[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" @@ -2478,6 +2858,31 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2608,6 +3013,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "ttf-parser" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" + [[package]] name = "typenum" version = "1.17.0" @@ -2646,6 +3057,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-width" version = "0.1.11" @@ -2690,7 +3107,7 @@ dependencies = [ "bytemuck", "futures-intrusive", "peniko 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-window-handle", + "raw-window-handle 0.5.2", "skrifa", "vello_encoding", "wgpu", @@ -2719,6 +3136,16 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2803,7 +3230,21 @@ dependencies = [ "nix 0.26.4", "scoped-tls", "smallvec", - "wayland-sys", + "wayland-sys 0.30.1", +] + +[[package]] +name = "wayland-backend" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d50fa61ce90d76474c87f5fc002828d81b32677340112b4ef08079a9d459a40" +dependencies = [ + "cc", + "downcast-rs", + "rustix 0.38.31", + "scoped-tls", + "smallvec", + "wayland-sys 0.31.1", ] [[package]] @@ -2813,10 +3254,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "489c9654770f674fc7e266b3c579f4053d7551df0ceb392f153adb1f9ed06ac8" dependencies = [ "bitflags 1.3.2", - "calloop", + "calloop 0.10.6", "nix 0.26.4", - "wayland-backend", - "wayland-scanner", + "wayland-backend 0.1.2", + "wayland-scanner 0.30.1", +] + +[[package]] +name = "wayland-client" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" +dependencies = [ + "bitflags 2.4.2", + "rustix 0.38.31", + "wayland-backend 0.3.3", + "wayland-scanner 0.31.1", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.4.2", + "cursor-icon", + "wayland-backend 0.3.3", ] [[package]] @@ -2826,7 +3290,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d0c3a0d5b4b688b07b0442362d3ed6bf04724fcc16cd69ab6285b90dbc487aa" dependencies = [ "nix 0.26.4", - "wayland-client", + "wayland-client 0.30.2", + "xcursor", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" +dependencies = [ + "rustix 0.38.31", + "wayland-client 0.31.2", "xcursor", ] @@ -2837,9 +3312,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b28101e5ca94f70461a6c2d610f76d85ad223d042dd76585ab23d3422dd9b4d" dependencies = [ "bitflags 1.3.2", - "wayland-backend", - "wayland-client", - "wayland-scanner", + "wayland-backend 0.1.2", + "wayland-client 0.30.2", + "wayland-scanner 0.30.1", +] + +[[package]] +name = "wayland-protocols" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" +dependencies = [ + "bitflags 2.4.2", + "wayland-backend 0.3.3", + "wayland-client 0.31.2", + "wayland-scanner 0.31.1", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" +dependencies = [ + "bitflags 2.4.2", + "wayland-backend 0.3.3", + "wayland-client 0.31.2", + "wayland-protocols 0.31.2", + "wayland-scanner 0.31.1", ] [[package]] @@ -2849,10 +3349,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fce991093320e4a6a525876e6b629ab24da25f9baef0c2e0080ad173ec89588a" dependencies = [ "bitflags 1.3.2", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", + "wayland-backend 0.1.2", + "wayland-client 0.30.2", + "wayland-protocols 0.30.1", + "wayland-scanner 0.30.1", +] + +[[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.2", + "wayland-backend 0.3.3", + "wayland-client 0.31.2", + "wayland-protocols 0.31.2", + "wayland-scanner 0.31.1", ] [[package]] @@ -2862,7 +3375,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9b873b257fbc32ec909c0eb80dea312076a67014e65e245f5eb69a6b8ab330e" dependencies = [ "proc-macro2", - "quick-xml", + "quick-xml 0.28.2", + "quote", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b3a62929287001986fb58c789dce9b67604a397c15c611ad9f747300b6c283" +dependencies = [ + "proc-macro2", + "quick-xml 0.31.0", "quote", ] @@ -2877,6 +3401,18 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "wayland-sys" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.64" @@ -2887,6 +3423,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "wgpu" version = "0.18.0" @@ -2901,7 +3447,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle", + "raw-window-handle 0.5.2", "smallvec", "static_assertions", "wasm-bindgen", @@ -2926,7 +3472,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle", + "raw-window-handle 0.5.2", "rustc-hash", "smallvec", "thiserror", @@ -2967,7 +3513,7 @@ dependencies = [ "parking_lot", "profiling", "range-alloc", - "raw-window-handle", + "raw-window-handle 0.5.2", "renderdoc-sys", "rustc-hash", "smallvec", @@ -3099,6 +3645,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -3117,6 +3672,21 @@ dependencies = [ "windows-targets 0.52.0", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -3147,6 +3717,12 @@ dependencies = [ "windows_x86_64_msvc 0.52.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -3159,6 +3735,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -3171,6 +3753,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -3183,6 +3771,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -3195,6 +3789,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -3207,6 +3807,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -3219,6 +3825,12 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -3231,6 +3843,55 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "winit" +version = "0.29.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c824f11941eeae66ec71111cc2674373c772f482b58939bb4066b642aa2ffcf" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.4.2", + "bytemuck", + "calloop 0.12.4", + "cfg_aliases", + "core-foundation", + "core-graphics", + "cursor-icon", + "icrate", + "js-sys", + "libc", + "log", + "memmap2 0.9.4", + "ndk", + "ndk-sys", + "objc2 0.4.1", + "once_cell", + "orbclient", + "percent-encoding", + "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", + "redox_syscall 0.3.5", + "rustix 0.38.31", + "sctk-adwaita", + "smithay-client-toolkit 0.18.1", + "smol_str", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend 0.3.3", + "wayland-client 0.31.2", + "wayland-protocols 0.31.2", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.48.0", + "x11-dl", + "x11rb 0.13.0", + "xkbcommon-dl", +] + [[package]] name = "winnow" version = "0.5.39" @@ -3249,6 +3910,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + [[package]] name = "x11rb" version = "0.12.0" @@ -3256,12 +3928,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" dependencies = [ "as-raw-xcb-connection", - "gethostname", + "gethostname 0.3.0", "libc", "nix 0.26.4", "winapi", "winapi-wsapoll", - "x11rb-protocol", + "x11rb-protocol 0.12.0", +] + +[[package]] +name = "x11rb" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a" +dependencies = [ + "as-raw-xcb-connection", + "gethostname 0.4.3", + "libc", + "libloading 0.8.1", + "once_cell", + "rustix 0.38.31", + "x11rb-protocol 0.13.0", ] [[package]] @@ -3273,6 +3960,12 @@ dependencies = [ "nix 0.26.4", ] +[[package]] +name = "x11rb-protocol" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34" + [[package]] name = "xcursor" version = "0.3.5" @@ -3307,6 +4000,7 @@ dependencies = [ "tracing", "vello", "wgpu", + "winit", "xilem_core", ] @@ -3329,6 +4023,25 @@ dependencies = [ "xilem_core", ] +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.4.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" + [[package]] name = "xml-rs" version = "0.8.19" diff --git a/Cargo.toml b/Cargo.toml index b72dc1a85..c2ce89fe5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ tracing = "0.1.37" accesskit = "0.12" fnv = "1.0.7" instant = { version = "0.1.6", features = ["wasm-bindgen"] } +winit = { version = "0.29", features = ["rwh_05"] } [dependencies.glazier] git = "https://github.com/linebender/glazier" diff --git a/src/app_main.rs b/src/app_main.rs index ddd849a93..639bd8bca 100644 --- a/src/app_main.rs +++ b/src/app_main.rs @@ -12,19 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::any::Any; - -use accesskit::TreeUpdate; -use glazier::{ - Application, Cursor, IdleToken, PointerEvent, PointerType, Region, Scalable, WinHandler, - WindowBuilder, WindowHandle, -}; +use glazier::{Modifiers, PointerButton}; use vello::{ - kurbo::{Affine, Size}, + kurbo::{Affine, Point, Size}, peniko::Color, util::{RenderContext, RenderSurface}, AaSupport, RenderParams, Renderer, RendererOptions, Scene, }; +use winit::{ + event::WindowEvent, + event_loop::{ControlFlow, EventLoop}, + window::{Window, WindowBuilder}, +}; use crate::{app::App, view::View, widget::Event, widget::PointerCrusher}; @@ -37,7 +36,7 @@ pub struct AppLauncher> { // The logic of this struct is mostly parallel to DruidHandler in win_handler.rs. struct MainState> { - handle: WindowHandle, + window: Window, app: App, render_cx: RenderContext, surface: Option, @@ -61,144 +60,159 @@ impl + 'static> AppLauncher { } pub fn run(self) { - let glazier_app = Application::new().unwrap(); + let event_loop = EventLoop::new().unwrap(); + event_loop.set_control_flow(ControlFlow::Wait); let _guard = self.app.rt.enter(); - let main_state = MainState::new(self.app); - let window = WindowBuilder::new(glazier_app.clone()) - .handler(Box::new(main_state)) - .title(self.title) - .size(Size::new(1024., 768.)) - .build() + let window = WindowBuilder::new() + .with_inner_size(winit::dpi::LogicalSize { + width: 1024., + height: 768., + }) + .build(&event_loop) .unwrap(); - window.show(); - glazier_app.run(None); - } -} - -impl + 'static> WinHandler for MainState { - fn connect(&mut self, handle: &WindowHandle) { - self.handle = handle.clone(); - self.app.connect(handle.clone()); - } - - fn prepare_paint(&mut self) {} + let mut main_state = MainState::new(self.app, window); - fn paint(&mut self, _: &Region) { - self.app.paint(); - self.render(); - self.schedule_render(); + event_loop + .run(move |event, elwt| match event { + winit::event::Event::WindowEvent { + event: WindowEvent::CloseRequested, + .. + } => elwt.exit(), + winit::event::Event::WindowEvent { + event: WindowEvent::RedrawRequested, + .. + } => main_state.paint(), + winit::event::Event::WindowEvent { + event: WindowEvent::Resized(winit::dpi::PhysicalSize { width, height }), + .. + } => main_state.size(Size { + width: width.into(), + height: height.into(), + }), + winit::event::Event::WindowEvent { + event: WindowEvent::ModifiersChanged(modifiers), + .. + } => { + let mut m = Modifiers::empty(); + let ms = modifiers.state(); + if ms.contains(winit::keyboard::ModifiersState::SHIFT) { + m |= Modifiers::SHIFT; + } + if ms.contains(winit::keyboard::ModifiersState::CONTROL) { + m |= Modifiers::CONTROL; + } + if ms.contains(winit::keyboard::ModifiersState::SUPER) { + m |= Modifiers::SUPER; + } + if ms.contains(winit::keyboard::ModifiersState::ALT) { + m |= Modifiers::ALT; + } + main_state.mods(m); + } + winit::event::Event::WindowEvent { + event: + WindowEvent::CursorMoved { + position: winit::dpi::PhysicalPosition { x, y }, + .. + }, + .. + } => main_state.pointer_move(Point { x, y }), + winit::event::Event::WindowEvent { + event: WindowEvent::CursorLeft { .. }, + .. + } => main_state.pointer_leave(), + winit::event::Event::WindowEvent { + event: WindowEvent::MouseInput { state, button, .. }, + .. + } => { + let b = match button { + winit::event::MouseButton::Left => PointerButton::Primary, + winit::event::MouseButton::Right => PointerButton::Secondary, + winit::event::MouseButton::Middle => PointerButton::Auxiliary, + winit::event::MouseButton::Back => PointerButton::X1, + winit::event::MouseButton::Forward => PointerButton::X2, + winit::event::MouseButton::Other(_) => PointerButton::None, + }; + match state { + winit::event::ElementState::Pressed => main_state.pointer_down(b), + winit::event::ElementState::Released => main_state.pointer_up(b), + } + } + _ => (), + }) + .unwrap(); } +} - fn idle(&mut self, _: IdleToken) {} - - fn command(&mut self, id: u32) { - match id { - _ => println!("unexpected id {}", id), +impl + 'static> MainState +where + T: Send + 'static, +{ + fn new(app: App, window: Window) -> Self { + let render_cx = RenderContext::new().unwrap(); + MainState { + window, + app, + render_cx, + surface: None, + renderer: None, + scene: Scene::default(), + counter: 0, + main_pointer: PointerCrusher::new(), } } - fn accesskit_tree(&mut self) -> TreeUpdate { - self.app.accesskit_connected = true; - self.app.accessibility() + fn size(&mut self, size: Size) { + self.app.size(size * 1.0 / self.window.scale_factor()); } - fn accesskit_action(&mut self, request: accesskit::ActionRequest) { - self.app - .window_event(Event::TargetedAccessibilityAction(request)); - self.handle.invalidate(); + fn mods(&mut self, mods: Modifiers) { + self.main_pointer.mods(mods); } - fn pointer_down(&mut self, event: &PointerEvent) { - self.main_pointer.mods(event.modifiers); + fn pointer_move(&mut self, pos: Point) { + let scale_coefficient = 1.0 / self.window.scale_factor(); self.app - .window_event(Event::MouseDown(self.main_pointer.pressed(event.button))); - self.handle.invalidate(); + .window_event(Event::MouseMove(self.main_pointer.moved(Point { + x: pos.x * scale_coefficient, + y: pos.y * scale_coefficient, + }))); + self.window.request_redraw(); } - fn pointer_up(&mut self, event: &PointerEvent) { - self.main_pointer.mods(event.modifiers); + fn pointer_down(&mut self, button: PointerButton) { self.app - .window_event(Event::MouseUp(self.main_pointer.released(event.button))); - self.handle.invalidate(); + .window_event(Event::MouseDown(self.main_pointer.pressed(button))); + self.window.request_redraw(); } - fn pointer_move(&mut self, event: &PointerEvent) { - self.main_pointer.mods(event.modifiers); + fn pointer_up(&mut self, button: PointerButton) { self.app - .window_event(Event::MouseMove(self.main_pointer.moved(event.pos))); - self.handle.invalidate(); - self.handle.set_cursor(&Cursor::Arrow); - } - - fn wheel(&mut self, event: &PointerEvent) { - self.main_pointer.mods(event.modifiers); - if let PointerType::Mouse(ref info) = event.pointer_type { - self.app - .window_event(Event::MouseWheel(self.main_pointer.wheel(info.wheel_delta))); - } - - self.handle.invalidate(); + .window_event(Event::MouseUp(self.main_pointer.released(button))); + self.window.request_redraw(); } fn pointer_leave(&mut self) { self.app.window_event(Event::MouseLeft()); - self.handle.invalidate(); - } - - fn size(&mut self, size: Size) { - self.app.size(size); - } - - fn request_close(&mut self) { - self.handle.close(); - } - - fn destroy(&mut self) { - Application::global().quit() - } - - fn as_any(&mut self) -> &mut dyn Any { - self - } -} - -impl> MainState -where - T: Send, -{ - fn new(app: App) -> Self { - let render_cx = RenderContext::new().unwrap(); - MainState { - handle: Default::default(), - app, - render_cx, - surface: None, - renderer: None, - scene: Scene::default(), - counter: 0, - main_pointer: PointerCrusher::new(), - } + self.window.request_redraw(); } - fn schedule_render(&self) { - self.handle.invalidate(); + fn paint(&mut self) { + self.app.paint(); + self.render(); } fn render(&mut self) { let fragment = self.app.fragment(); - let handle = &self.handle; - let scale = handle.get_scale().unwrap_or_default(); - let insets = handle.content_insets().to_px(scale); - let mut size = handle.get_size().to_px(scale); - size.width -= insets.x_value(); - size.height -= insets.y_value(); - let width = size.width as u32; - let height = size.height as u32; + let scale = self.window.scale_factor(); + let size = self.window.inner_size(); + let width = size.width; + let height = size.height; if self.surface.is_none() { //println!("render size: {:?}", size); self.surface = Some( tokio::runtime::Handle::current() - .block_on(self.render_cx.create_surface(handle, width, height)) + .block_on(self.render_cx.create_surface(&self.window, width, height)) .unwrap(), ); } @@ -206,9 +220,8 @@ where if surface.config.width != width || surface.config.height != height { self.render_cx.resize_surface(surface, width, height); } - let (scale_x, scale_y) = (scale.x(), scale.y()); - let transform = if scale_x != 1.0 || scale_y != 1.0 { - Some(Affine::scale_non_uniform(scale_x, scale_y)) + let transform = if scale != 1.0 { + Some(Affine::scale(scale)) } else { None }; diff --git a/src/widget/raw_event.rs b/src/widget/raw_event.rs index b8258ed35..d44047637 100644 --- a/src/widget/raw_event.rs +++ b/src/widget/raw_event.rs @@ -112,7 +112,6 @@ impl PointerCrusher { pub fn released(&mut self, button: PointerButton) -> MouseEvent { self.e.wheel_delta = Vec2::ZERO; self.e.buttons.remove(button); - self.e.count = self.counter.count_for_click(self.e.pos); self.e.button = button; self.e.clone() } From 623f18a34f0359e4d449aafda4c6e98d2f2c97ff Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Wed, 21 Feb 2024 15:01:55 -0500 Subject: [PATCH 4/4] Remove now-inert accessibility and idle code. --- Cargo.lock | 141 +++--------------------------------- Cargo.toml | 2 - src/app.rs | 81 ++------------------- src/bloom.rs | 1 + src/id.rs | 18 ----- src/lib.rs | 1 - src/widget/button.rs | 19 +---- src/widget/contexts.rs | 76 +------------------ src/widget/core.rs | 32 +------- src/widget/linear_layout.rs | 20 +---- src/widget/mod.rs | 2 +- src/widget/raw_event.rs | 1 - src/widget/switch.rs | 16 +--- src/widget/taffy_layout.rs | 24 +----- src/widget/text.rs | 6 -- src/widget/widget.rs | 9 +-- 16 files changed, 29 insertions(+), 420 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 796733410..282539a20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,47 +18,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" -[[package]] -name = "accesskit" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb10ed32c63247e4e39a8f42e8e30fb9442fbf7878c8e4a9849e7e381619bea" - -[[package]] -name = "accesskit_consumer" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c17cca53c09fbd7288667b22a201274b9becaa27f0b91bf52a526db95de45e6" -dependencies = [ - "accesskit", -] - -[[package]] -name = "accesskit_macos" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3b6ae1eabbfbced10e840fd3fce8a93ae84f174b3e4ba892ab7bcb42e477a7" -dependencies = [ - "accesskit", - "accesskit_consumer", - "objc2 0.3.0-beta.3.patch-leaks.3", - "once_cell", -] - -[[package]] -name = "accesskit_windows" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcae27ec0974fc7c3b0b318783be89fd1b2e66dd702179fe600166a38ff4a0b" -dependencies = [ - "accesskit", - "accesskit_consumer", - "once_cell", - "paste", - "static_assertions", - "windows 0.48.0", -] - [[package]] name = "addr2line" version = "0.21.0" @@ -504,32 +463,13 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-sys" -version = "0.1.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" -dependencies = [ - "objc-sys 0.2.0-beta.2", -] - [[package]] name = "block-sys" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" dependencies = [ - "objc-sys 0.3.2", -] - -[[package]] -name = "block2" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" -dependencies = [ - "block-sys 0.1.0-beta.1", - "objc2-encode 2.0.0-pre.2", + "objc-sys", ] [[package]] @@ -538,8 +478,8 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" dependencies = [ - "block-sys 0.2.1", - "objc2 0.4.1", + "block-sys", + "objc2", ] [[package]] @@ -1274,9 +1214,6 @@ name = "glazier" version = "0.1.0" source = "git+https://github.com/linebender/glazier?rev=8d2a4b2cafd5e6be49bfb4ac8d0bd26fe02f036e#8d2a4b2cafd5e6be49bfb4ac8d0bd26fe02f036e" dependencies = [ - "accesskit", - "accesskit_macos", - "accesskit_windows", "anyhow", "ashpd", "bindgen", @@ -1410,7 +1347,7 @@ dependencies = [ "presser", "thiserror", "winapi", - "windows 0.51.1", + "windows", ] [[package]] @@ -1513,9 +1450,9 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" dependencies = [ - "block2 0.3.0", + "block2", "dispatch", - "objc2 0.4.1", + "objc2", ] [[package]] @@ -2010,46 +1947,20 @@ dependencies = [ "objc_exception", ] -[[package]] -name = "objc-sys" -version = "0.2.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" - [[package]] name = "objc-sys" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" -[[package]] -name = "objc2" -version = "0.3.0-beta.3.patch-leaks.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" -dependencies = [ - "block2 0.2.0-alpha.6", - "objc-sys 0.2.0-beta.2", - "objc2-encode 2.0.0-pre.2", -] - [[package]] name = "objc2" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" dependencies = [ - "objc-sys 0.3.2", - "objc2-encode 3.0.0", -] - -[[package]] -name = "objc2-encode" -version = "2.0.0-pre.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" -dependencies = [ - "objc-sys 0.2.0-beta.2", + "objc-sys", + "objc2-encode", ] [[package]] @@ -3593,17 +3504,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-targets 0.48.5", -] - [[package]] name = "windows" version = "0.51.1" @@ -3623,28 +3523,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-implement" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "windows-interface" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "windows-sys" version = "0.45.0" @@ -3866,7 +3744,7 @@ dependencies = [ "memmap2 0.9.4", "ndk", "ndk-sys", - "objc2 0.4.1", + "objc2", "once_cell", "orbclient", "percent-encoding", @@ -3986,7 +3864,6 @@ dependencies = [ name = "xilem" version = "0.1.0" dependencies = [ - "accesskit", "bitflags 2.4.2", "env_logger", "fnv", diff --git a/Cargo.toml b/Cargo.toml index c2ce89fe5..6a97c135e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,6 @@ tokio = { version = "1.35", features = ["full"] } futures-task = "0.3" bitflags = "2" tracing = "0.1.37" -accesskit = "0.12" fnv = "1.0.7" instant = { version = "0.1.6", features = ["wasm-bindgen"] } winit = { version = "0.29", features = ["rwh_05"] } @@ -65,7 +64,6 @@ winit = { version = "0.29", features = ["rwh_05"] } git = "https://github.com/linebender/glazier" rev = "8d2a4b2cafd5e6be49bfb4ac8d0bd26fe02f036e" default-features = false -features = ["accesskit"] [dev-dependencies] env_logger = "0.10.0" diff --git a/src/app.rs b/src/app.rs index c332a65b3..6f9e48b10 100644 --- a/src/app.rs +++ b/src/app.rs @@ -13,11 +13,8 @@ // limitations under the License. use std::collections::HashSet; -use std::sync::{Arc, Mutex}; use std::time::Duration; -use accesskit::TreeUpdate; -use glazier::{IdleHandle, IdleToken, WindowHandle}; use parley::FontContext; use tokio::runtime::Runtime; use vello::{ @@ -27,8 +24,8 @@ use vello::{ use xilem_core::{AsyncWake, MessageResult}; use crate::widget::{ - AccessCx, BoxConstraints, CxState, EventCx, LayoutCx, LifeCycle, LifeCycleCx, PaintCx, Pod, - PodFlags, UpdateCx, ViewContext, WidgetState, + BoxConstraints, CxState, EventCx, LayoutCx, LifeCycle, LifeCycleCx, PaintCx, Pod, PodFlags, + UpdateCx, ViewContext, WidgetState, }; use crate::{ view::{Cx, Id, View}, @@ -46,7 +43,6 @@ pub struct App> { return_chan: tokio::sync::mpsc::Sender<(V, V::State, HashSet)>, id: Option, events: Vec, - window_handle: WindowHandle, root_state: WidgetState, root_pod: Option, size: Size, @@ -55,11 +51,6 @@ pub struct App> { cx: Cx, font_cx: FontContext, pub(crate) rt: Runtime, - // This is allocated an id for AccessKit, but as we get multi-window, - // there should be a real window object with id. - window_id: crate::id::Id, - pub(crate) accesskit_connected: bool, - node_classes: accesskit::NodeClassSet, } /// The standard delay for waiting for async futures. @@ -79,14 +70,12 @@ struct AppTask, F: FnMut(&mut T) -> V> { app_logic: F, view: Option, state: Option, - idle_handle: Option, pending_async: HashSet, ui_state: UiState, } /// A message sent from the main UI thread ([`App`]) to the [`AppTask`]. pub(crate) enum AppReq { - SetIdleHandle(IdleHandle), Events(Vec), Wake(IdPath), // Parameter indicates whether it should be delayed for async @@ -115,9 +104,6 @@ enum UiState { WokeUI, } -#[derive(Clone, Default)] -pub struct WakeQueue(Arc>>); - impl + 'static> App where V::State: 'static, @@ -159,7 +145,6 @@ where app_logic, view: None, state: None, - idle_handle: None, pending_async: HashSet::new(), ui_state: UiState::Start, }; @@ -172,7 +157,6 @@ where id: None, root_pod: None, events: Vec::new(), - window_handle: Default::default(), root_state: WidgetState::new(), size: Default::default(), new_size: Default::default(), @@ -180,18 +164,6 @@ where cx, font_cx: FontContext::new(), rt, - window_id: crate::id::Id::next(), - accesskit_connected: false, - node_classes: accesskit::NodeClassSet::new(), - } - } - - pub fn connect(&mut self, window_handle: WindowHandle) { - self.window_handle = window_handle.clone(); - if let Some(idle_handle) = window_handle.get_idle_handle() { - let _ = self - .req_chan - .blocking_send(AppReq::SetIdleHandle(idle_handle)); } } @@ -199,37 +171,6 @@ where self.new_size = size; } - pub fn accessibility(&mut self) -> TreeUpdate { - let mut update = TreeUpdate { - nodes: vec![], - tree: None, - focus: accesskit::NodeId(0), - }; - self.ensure_root(); - let root_pod = self.root_pod.as_mut().unwrap(); - let mut window_node_builder = accesskit::NodeBuilder::new(accesskit::Role::Window); - window_node_builder.set_name("xilem window"); - window_node_builder.set_children(vec![root_pod.id().into()]); - if let Ok(scale) = self.window_handle.get_scale() { - window_node_builder.set_transform(Box::new(accesskit::Affine::scale_non_uniform( - scale.x(), - scale.y(), - ))); - } - let window_node = window_node_builder.build(&mut self.node_classes); - update.nodes.push((self.window_id.into(), window_node)); - update.tree = Some(accesskit::Tree::new(self.window_id.into())); - let mut cx_state = CxState::new(&self.window_handle, &mut self.font_cx, &mut self.events); - let mut access_cx = AccessCx { - cx_state: &mut cx_state, - widget_state: &mut self.root_state, - update: &mut update, - node_classes: &mut self.node_classes, - }; - root_pod.accessibility(&mut access_cx); - update - } - /// Run a paint cycle for the application. /// /// This is not just painting, but involves processing events, doing layout @@ -240,8 +181,7 @@ where // TODO: be more lazy re-rendering self.render(); let root_pod = self.root_pod.as_mut().unwrap(); - let mut cx_state = - CxState::new(&self.window_handle, &mut self.font_cx, &mut self.events); + let mut cx_state = CxState::new(&mut self.font_cx, &mut self.events); let mut lifecycle_cx = LifeCycleCx::new(&mut cx_state, &mut self.root_state); root_pod.lifecycle(&mut lifecycle_cx, &LifeCycle::TreeUpdate); @@ -282,16 +222,10 @@ where continue; } - if self.accesskit_connected { - let update = self.accessibility(); - // TODO: it would be cleaner to not use a closure here. - self.window_handle.update_accesskit_if_active(|| update); - } // Borrow again to avoid multiple borrows. // TODO: maybe make accessibility a method on CxState? let root_pod = self.root_pod.as_mut().unwrap(); - let mut cx_state = - CxState::new(&self.window_handle, &mut self.font_cx, &mut self.events); + let mut cx_state = CxState::new(&mut self.font_cx, &mut self.events); let mut paint_cx = PaintCx::new(&mut cx_state, &mut self.root_state); root_pod.paint_impl(&mut paint_cx); break; @@ -309,12 +243,11 @@ where Event::MouseLeft() => { self.cursor_pos = None; } - _ => {} } self.ensure_root(); let root_pod = self.root_pod.as_mut().unwrap(); - let mut cx_state = CxState::new(&self.window_handle, &mut self.font_cx, &mut self.events); + let mut cx_state = CxState::new(&mut self.font_cx, &mut self.events); let mut event_cx = EventCx::new(&mut cx_state, &mut self.root_state); root_pod.event(&mut event_cx, &event); self.send_events(); @@ -399,7 +332,6 @@ impl, F: FnMut(&mut T) -> V> AppTask { }; match req { Ok(Some(req)) => match req { - AppReq::SetIdleHandle(handle) => self.idle_handle = Some(handle), AppReq::Events(events) => { for event in events { let id_path = &event.id_path[1..]; @@ -426,9 +358,6 @@ impl, F: FnMut(&mut T) -> V> AppTask { if needs_rebuild { // request re-render from UI thread if self.ui_state == UiState::Start { - if let Some(handle) = self.idle_handle.as_mut() { - handle.schedule_idle(IdleToken::new(42)); - } self.ui_state = UiState::WokeUI; } let id = id_path.last().unwrap(); diff --git a/src/bloom.rs b/src/bloom.rs index 1571ef330..205ed2f58 100644 --- a/src/bloom.rs +++ b/src/bloom.rs @@ -71,6 +71,7 @@ impl Bloom { /// This can return false positives, but never false negatives. /// Thus `true` means that the item may have been added - or not, /// while `false` means that the item has definitely not been added. + #[allow(unused)] pub fn may_contain(&self, item: &T) -> bool { let mask = self.make_bit_mask(item); self.bits & mask == mask diff --git a/src/id.rs b/src/id.rs index 77ab6ead2..82b61fd97 100644 --- a/src/id.rs +++ b/src/id.rs @@ -29,7 +29,6 @@ impl Id { .unwrap()) } - #[allow(unused)] pub fn to_raw(self) -> u64 { self.0.into() } @@ -37,21 +36,4 @@ impl Id { pub fn to_nonzero_raw(self) -> NonZeroU64 { self.0 } - - /// Turns an `accesskit::NodeId` id into an `Id`. - /// - /// This method will only return `Some` for `accesskit::NodeId` values which were created from - /// `Id`'s. - /// - // TODO: Maybe we should not use AccessKit Ids at all in Widget implementation and do the - // mapping in the `App`. - pub fn try_from_accesskit(id: accesskit::NodeId) -> Option { - id.0.try_into().ok().map(Id) - } -} - -impl From for accesskit::NodeId { - fn from(id: Id) -> accesskit::NodeId { - accesskit::NodeId(id.to_nonzero_raw().into()) - } } diff --git a/src/lib.rs b/src/lib.rs index d5c29c1b2..f20da417e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,5 @@ pub use app_main::AppLauncher; pub(crate) use bloom::Bloom; pub use geometry::Axis; -pub use accesskit; pub use parley; pub use vello; diff --git a/src/widget/button.rs b/src/widget/button.rs index 40683ea84..b19c8bd9e 100644 --- a/src/widget/button.rs +++ b/src/widget/button.rs @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::ops::Deref; - use parley::Layout; use vello::{ kurbo::{Affine, Insets, Size}, @@ -26,8 +24,7 @@ use crate::{IdPath, Message}; use super::{ contexts::LifeCycleCx, piet_scene_helpers::{self, UnitPoint}, - AccessCx, BoxConstraints, ChangeFlags, Event, EventCx, LayoutCx, LifeCycle, PaintCx, UpdateCx, - Widget, + BoxConstraints, ChangeFlags, Event, EventCx, LayoutCx, LifeCycle, PaintCx, UpdateCx, Widget, }; pub struct Button { @@ -69,13 +66,6 @@ impl Widget for Button { cx.set_active(false); cx.request_paint(); } - Event::TargetedAccessibilityAction(request) => { - if request.action == accesskit::Action::Default - && cx.is_accesskit_target(request.target) - { - cx.add_message(Message::new(self.id_path.clone(), ())); - } - } _ => (), }; } @@ -112,13 +102,6 @@ impl Widget for Button { bc.constrain(size) } - fn accessibility(&mut self, cx: &mut AccessCx) { - let mut builder = accesskit::NodeBuilder::new(accesskit::Role::Button); - builder.set_name(self.label.deref()); - builder.set_default_action_verb(accesskit::DefaultActionVerb::Click); - cx.push_node(builder); - } - fn paint(&mut self, cx: &mut PaintCx, scene: &mut Scene) { let is_hot = cx.is_hot(); let is_active = cx.is_active(); diff --git a/src/widget/contexts.rs b/src/widget/contexts.rs index eb5277a79..a9568cb7d 100644 --- a/src/widget/contexts.rs +++ b/src/widget/contexts.rs @@ -17,10 +17,8 @@ //! Note: the organization of this code roughly follows the existing Druid //! widget system, particularly its contexts.rs. -use accesskit::TreeUpdate; -use glazier::WindowHandle; use parley::FontContext; -use vello::kurbo::{Point, Rect, Size}; +use vello::kurbo::{Point, Size}; use super::{PodFlags, WidgetState}; use crate::Message; @@ -30,7 +28,6 @@ use crate::Message; /// Static state that is shared between most contexts. pub struct CxState<'a> { #[allow(unused)] - window: &'a WindowHandle, font_cx: &'a mut FontContext, messages: &'a mut Vec, } @@ -83,16 +80,6 @@ pub struct LayoutCx<'a, 'b> { pub(crate) widget_state: &'a mut WidgetState, } -/// A context passed to [`accessibility`] methods of widgets. -/// -/// [`accessibility`]: crate::widget::Widget::accessibility -pub struct AccessCx<'a, 'b> { - pub(crate) cx_state: &'a mut CxState<'b>, - pub(crate) widget_state: &'a mut WidgetState, - pub(crate) update: &'a mut TreeUpdate, - pub(crate) node_classes: &'a mut accesskit::NodeClassSet, -} - /// A context passed to [`paint`] methods of widgets. /// /// [`paint`]: crate::widget::Widget::paint @@ -116,16 +103,8 @@ macro_rules! impl_context_method { } impl<'a> CxState<'a> { - pub fn new( - window: &'a WindowHandle, - font_cx: &'a mut FontContext, - messages: &'a mut Vec, - ) -> Self { - CxState { - window, - font_cx, - messages, - } + pub fn new(font_cx: &'a mut FontContext, messages: &'a mut Vec) -> Self { + CxState { font_cx, messages } } pub(crate) fn has_messages(&self) -> bool { @@ -159,11 +138,6 @@ impl<'a, 'b> EventCx<'a, 'b> { pub fn is_handled(&self) -> bool { self.is_handled } - - /// Check whether this widget's id matches the given id. - pub fn is_accesskit_target(&self, id: accesskit::NodeId) -> bool { - accesskit::NodeId::from(self.widget_state.id) == id - } } impl<'a, 'b> LifeCycleCx<'a, 'b> { @@ -193,48 +167,6 @@ impl<'a, 'b> LayoutCx<'a, 'b> { } } -// This function is unfortunate but works around kurbo versioning -fn to_accesskit_rect(r: Rect) -> accesskit::Rect { - println!("{:?}", r); - accesskit::Rect::new(r.x0, r.y0, r.x1, r.y1) -} - -impl<'a, 'b> AccessCx<'a, 'b> { - /// Add a node to the tree update being built. - /// - /// The id of the node pushed is obtained from the context. The - /// bounds are set based on the layout bounds. - pub fn push_node(&mut self, mut builder: accesskit::NodeBuilder) { - builder.set_bounds(to_accesskit_rect(Rect::from_origin_size( - self.widget_state.window_origin(), - self.widget_state.size, - ))); - let node = builder.build(self.node_classes); - self.push_node_raw(node); - } - - /// Add a node to the tree update being built. - /// - /// Similar to `push_node` but it is the responsibility of the caller - /// to set bounds before calling. - pub fn push_node_raw(&mut self, node: accesskit::Node) { - let id = self.widget_state.id.into(); - self.update.nodes.push((id, node)); - } - - /// Report whether accessibility was requested on this widget. - /// - /// This method is primarily intended for containers. The `accessibility` - /// method will be called on a widget when it or any of its descendants - /// have seen a request. However, in many cases a container need not push - /// a node for itself. - pub fn is_requested(&self) -> bool { - self.widget_state - .flags - .contains(PodFlags::REQUEST_ACCESSIBILITY) - } -} - impl<'a, 'b> PaintCx<'a, 'b> { pub(crate) fn new(cx_state: &'a mut CxState<'b>, widget_state: &'a mut WidgetState) -> Self { PaintCx { @@ -252,7 +184,6 @@ impl_context_method!( UpdateCx<'_, '_>, LifeCycleCx<'_, '_>, LayoutCx<'_, '_>, - AccessCx<'_, '_>, PaintCx<'_, '_>, { /// Returns whether this widget is hot. @@ -339,7 +270,6 @@ impl_context_method!( UpdateCx<'_, '_>, LifeCycleCx<'_, '_>, LayoutCx<'_, '_>, - AccessCx<'_, '_>, PaintCx<'_, '_>, { /// The layout size. diff --git a/src/widget/core.rs b/src/widget/core.rs index c4c727a19..68e308e11 100644 --- a/src/widget/core.rs +++ b/src/widget/core.rs @@ -28,8 +28,8 @@ use crate::Axis; use crate::{id::Id, Bloom}; use super::{ - contexts::LifeCycleCx, AccessCx, BoxConstraints, CxState, Event, EventCx, LayoutCx, LifeCycle, - PaintCx, UpdateCx, + contexts::LifeCycleCx, BoxConstraints, CxState, Event, EventCx, LayoutCx, LifeCycle, PaintCx, + UpdateCx, }; bitflags! { @@ -160,10 +160,6 @@ impl WidgetState { fn request(&mut self, flags: PodFlags) { self.flags |= flags } - - pub(crate) fn window_origin(&self) -> Point { - self.parent_window_origin + self.origin.to_vec2() - } } impl Pod { @@ -285,12 +281,6 @@ impl Pod { Pod::set_hot_state(&mut self.widget, &mut self.state, cx.cx_state, None); had_active || hot_changed } - Event::TargetedAccessibilityAction(action) => { - // println!("TODO: {:?}", action); - self.state - .sub_tree - .may_contain(&Id::try_from_accesskit(action.target).unwrap()) - } }; if recurse { // This clears the has_active state. Pod needs to clear this state since merge up can @@ -412,24 +402,6 @@ impl Pod { self.widget.compute_max_intrinsic(axis, &mut child_cx, bc) } - /// - pub fn accessibility(&mut self, cx: &mut AccessCx) { - if self.state.flags.intersects( - PodFlags::REQUEST_ACCESSIBILITY | PodFlags::DESCENDANT_REQUESTED_ACCESSIBILITY, - ) { - let mut child_cx = AccessCx { - cx_state: cx.cx_state, - widget_state: &mut self.state, - update: cx.update, - node_classes: cx.node_classes, - }; - self.widget.accessibility(&mut child_cx); - self.state.flags.remove( - PodFlags::REQUEST_ACCESSIBILITY | PodFlags::DESCENDANT_REQUESTED_ACCESSIBILITY, - ); - } - } - pub fn paint_raw(&mut self, cx: &mut PaintCx, scene: &mut Scene) { let mut inner_cx = PaintCx { cx_state: cx.cx_state, diff --git a/src/widget/linear_layout.rs b/src/widget/linear_layout.rs index 8183543c3..e3a890ba1 100644 --- a/src/widget/linear_layout.rs +++ b/src/widget/linear_layout.rs @@ -13,8 +13,7 @@ // limitations under the License. use crate::geometry::Axis; -use crate::widget::{AccessCx, BoxConstraints, Event}; -use accesskit::NodeId; +use crate::widget::{BoxConstraints, Event}; use vello::kurbo::Size; use vello::Scene; @@ -83,23 +82,6 @@ impl Widget for LinearLayout { self.axis.pack(major_used, max_minor) } - fn accessibility(&mut self, cx: &mut AccessCx) { - for child in &mut self.children { - child.accessibility(cx); - } - - if cx.is_requested() { - let mut builder = accesskit::NodeBuilder::new(accesskit::Role::GenericContainer); - builder.set_children( - self.children - .iter() - .map(|pod| pod.id().into()) - .collect::>(), - ); - cx.push_node(builder); - } - } - fn paint(&mut self, cx: &mut PaintCx, scene: &mut Scene) { for child in &mut self.children { // println!("paint child!"); diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 326c5d0c6..7da04cc9f 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -31,7 +31,7 @@ pub use self::core::{ChangeFlags, Pod}; pub(crate) use self::core::{PodFlags, WidgetState}; pub use box_constraints::BoxConstraints; pub use button::Button; -pub use contexts::{AccessCx, CxState, EventCx, LayoutCx, LifeCycleCx, PaintCx, UpdateCx}; +pub use contexts::{CxState, EventCx, LayoutCx, LifeCycleCx, PaintCx, UpdateCx}; pub use linear_layout::LinearLayout; pub use raw_event::{Event, LifeCycle, MouseEvent, PointerCrusher, ViewContext}; pub use switch::Switch; diff --git a/src/widget/raw_event.rs b/src/widget/raw_event.rs index d44047637..ec8e3754a 100644 --- a/src/widget/raw_event.rs +++ b/src/widget/raw_event.rs @@ -27,7 +27,6 @@ pub enum Event { MouseMove(MouseEvent), MouseWheel(MouseEvent), MouseLeft(), - TargetedAccessibilityAction(accesskit::ActionRequest), } #[derive(Debug, Clone)] diff --git a/src/widget/switch.rs b/src/widget/switch.rs index ca88843d2..21a080706 100644 --- a/src/widget/switch.rs +++ b/src/widget/switch.rs @@ -23,8 +23,7 @@ use crate::{IdPath, Message}; use super::{ contexts::LifeCycleCx, piet_scene_helpers::{fill_color, stroke}, - AccessCx, BoxConstraints, ChangeFlags, Event, EventCx, LayoutCx, LifeCycle, PaintCx, UpdateCx, - Widget, + BoxConstraints, ChangeFlags, Event, EventCx, LayoutCx, LifeCycle, PaintCx, UpdateCx, Widget, }; pub struct Switch { @@ -100,13 +99,6 @@ impl Widget for Switch { } cx.request_paint(); } - Event::TargetedAccessibilityAction(request) => { - if request.action == accesskit::Action::Default - && cx.is_accesskit_target(request.target) - { - cx.add_message(Message::new(self.id_path.clone(), ())); - } - } _ => (), }; } @@ -125,12 +117,6 @@ impl Widget for Switch { Size::new(SWITCH_WIDTH, SWITCH_HEIGHT) } - fn accessibility(&mut self, cx: &mut AccessCx) { - let mut builder = accesskit::NodeBuilder::new(accesskit::Role::Switch); - builder.set_default_action_verb(accesskit::DefaultActionVerb::Click); - cx.push_node(builder); - } - fn paint(&mut self, cx: &mut PaintCx, scene: &mut Scene) { // Change the position of of the knob based on its state // If the knob is currently being dragged with the mouse use the position that was set in MouseMove diff --git a/src/widget/taffy_layout.rs b/src/widget/taffy_layout.rs index 9549d276d..f4d54056c 100644 --- a/src/widget/taffy_layout.rs +++ b/src/widget/taffy_layout.rs @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::geometry::Axis; -use crate::widget::{AccessCx, BoxConstraints, Event}; -use accesskit::NodeId; +use crate::{ + geometry::Axis, + widget::{BoxConstraints, Event}, +}; use vello::{ kurbo::{Affine, Point, Size}, peniko::{Brush, Color, Fill}, @@ -408,23 +409,6 @@ impl Widget for TaffyLayout { output.size.get_abs(taffy_axis) as f64 } - fn accessibility(&mut self, cx: &mut AccessCx) { - for child in &mut self.children { - child.accessibility(cx); - } - - if cx.is_requested() { - let mut builder = accesskit::NodeBuilder::new(accesskit::Role::GenericContainer); - builder.set_children( - self.children - .iter() - .map(|pod| pod.id().into()) - .collect::>(), - ); - cx.push_node(builder); - } - } - fn paint(&mut self, cx: &mut PaintCx, scene: &mut Scene) { if let Some(color) = self.background_color { scene.fill( diff --git a/src/widget/text.rs b/src/widget/text.rs index 33aed3f71..9548da74d 100644 --- a/src/widget/text.rs +++ b/src/widget/text.rs @@ -119,10 +119,4 @@ impl Widget for TextWidget { crate::text::render_text(scene, Affine::IDENTITY, layout); } } - - fn accessibility(&mut self, cx: &mut super::AccessCx) { - let mut builder = accesskit::NodeBuilder::new(accesskit::Role::StaticText); - builder.set_value(self.text.clone()); - cx.push_node(builder); - } } diff --git a/src/widget/widget.rs b/src/widget/widget.rs index 4e36c7735..dab5032e9 100644 --- a/src/widget/widget.rs +++ b/src/widget/widget.rs @@ -19,7 +19,7 @@ use crate::geometry::Axis; use vello::{kurbo::Size, Scene}; use super::box_constraints::BoxConstraints; -use super::contexts::{AccessCx, EventCx, LayoutCx, LifeCycleCx, PaintCx, UpdateCx}; +use super::contexts::{EventCx, LayoutCx, LifeCycleCx, PaintCx, UpdateCx}; use super::raw_event::{Event, LifeCycle}; /// A basic widget trait. @@ -91,9 +91,6 @@ pub trait Widget { /// [`set_origin`]: struct.WidgetPod.html#method.set_origin fn layout(&mut self, cx: &mut LayoutCx, bc: &BoxConstraints) -> Size; - /// Update the accessibility tree. - fn accessibility(&mut self, cx: &mut AccessCx); - /// Paint the widget appearance. /// /// The [`PaintCtx`] derefs to something that implements the [`RenderContext`] @@ -230,10 +227,6 @@ impl Widget for Box { self.deref_mut().compute_max_intrinsic(axis, ctx, bc) } - fn accessibility(&mut self, cx: &mut AccessCx) { - self.deref_mut().accessibility(cx); - } - fn paint(&mut self, cx: &mut PaintCx, scene: &mut Scene) { self.deref_mut().paint(cx, scene); }