Skip to content

Commit

Permalink
feat: winit v0.30.0 + glutin-winit v0.5.0 + accesskit v0.14.0 +…
Browse files Browse the repository at this point in the history
… `accesskit_winit` v0.20.0 (#598)

* feat: Bump accesskit, winit and glutin

* migrated to the new winit and glutin

* clean up

* clean up

* fix example

* clean up

* clean up

* fix window drop

* clean up

* update glutin and glutin-winit

* clippy

* fmt

* fix
  • Loading branch information
marc2332 authored Jun 10, 2024
1 parent 6be74f9 commit 4e4d5c3
Show file tree
Hide file tree
Showing 23 changed files with 1,033 additions and 1,044 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ dioxus-sdk = { version = "0.5", features = ["clipboard"]}
skia-safe = { version = "0.72.0", features = ["gl", "textlayout", "svg"] }

gl = "0.14.0"
glutin = "0.31.2"
glutin-winit = "0.4.2"
glutin = "0.32.0"
glutin-winit = "0.5.0"
raw-window-handle = "0.5.2"
winit = "0.29.9"
winit = "0.30.0"
tokio = { version = "1.33.0", features = ["sync", "rt-multi-thread", "time", "macros"] }
accesskit = { version = "0.12.2", features = ["serde"]}
accesskit_winit = "0.18.0"
accesskit = { version = "0.14.0", features = ["serde"]}
accesskit_winit = "0.20.0"
shipyard = { version = "0.6.2", features = ["proc", "std", "parallel"], default-features = false }
smallvec = "1.13.1"

Expand Down
16 changes: 7 additions & 9 deletions crates/common/src/event_messages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use accesskit::NodeId;
use accesskit_winit::ActionRequestEvent;
use dioxus_core::Template;
use torin::prelude::CursorPoint;
use uuid::Uuid;
Expand All @@ -24,12 +22,12 @@ pub enum EventMessage {
RemeasureTextGroup(TextGroupMeasurement),
/// Change the cursor icon
SetCursorIcon(CursorIcon),
/// Accessibility action request event
ActionRequestEvent(ActionRequestEvent),
/// Accessibility Window Event
Accessibility(accesskit_winit::WindowEvent),
/// Focus the given accessibility NodeID
FocusAccessibilityNode(NodeId),
FocusAccessibilityNode(accesskit::NodeId),
/// Queue a focus the given accessibility NodeID
QueueFocusAccessibilityNode(NodeId),
QueueFocusAccessibilityNode(accesskit::NodeId),
/// Focus the next accessibility Node
FocusNextAccessibilityNode,
/// Focus the previous accessibility Node
Expand All @@ -40,8 +38,8 @@ pub enum EventMessage {
WithWindow(Box<dyn FnOnce(&Window) + Send + Sync>),
}

impl From<ActionRequestEvent> for EventMessage {
fn from(value: ActionRequestEvent) -> Self {
Self::ActionRequestEvent(value)
impl From<accesskit_winit::Event> for EventMessage {
fn from(value: accesskit_winit::Event) -> Self {
Self::Accessibility(value.window_event)
}
}
11 changes: 3 additions & 8 deletions crates/core/src/accessibility/accessibility_manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::{accessibility::*, dom::DioxusNode};
use accesskit::{
Action, DefaultActionVerb, Node, NodeBuilder, NodeClassSet, Rect, Role, Tree, TreeUpdate,
};
use accesskit::{Action, DefaultActionVerb, Node, NodeBuilder, Rect, Role, Tree, TreeUpdate};

use freya_node_state::AccessibilityNodeState;
use std::sync::{Arc, Mutex};
Expand All @@ -15,8 +13,6 @@ pub const ACCESSIBILITY_ROOT_ID: AccessibilityId = AccessibilityId(0);
pub struct AccessibilityManager {
/// Accessibility Nodes
pub nodes: Vec<(AccessibilityId, Node)>,
/// Accessibility tree
pub node_classes: NodeClassSet,
/// Current focused Accessibility Node.
pub focused_id: AccessibilityId,
}
Expand All @@ -25,7 +21,6 @@ impl AccessibilityManager {
pub fn new(focused_id: AccessibilityId) -> Self {
Self {
focused_id,
node_classes: NodeClassSet::default(),
nodes: Vec::default(),
}
}
Expand Down Expand Up @@ -95,7 +90,7 @@ impl AccessibilityManager {
}

// Insert the node into the Tree
let node = builder.build(&mut self.node_classes);
let node = builder.build();
self.push_node(accessibility_id, node);
}

Expand Down Expand Up @@ -127,7 +122,7 @@ impl AccessibilityManager {
.collect::<Vec<AccessibilityId>>(),
);

builder.build(&mut self.node_classes)
builder.build()
}

/// Process the Nodes accessibility Tree
Expand Down
17 changes: 8 additions & 9 deletions crates/freya/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use freya_renderer::{LaunchConfig, WindowConfig};
pub fn launch(app: AppComponent) {
launch_cfg(
app,
LaunchConfig {
window: WindowConfig::<()> {
LaunchConfig::<()> {
window_config: WindowConfig {
width: 600.0,
height: 600.0,
decorations: true,
Expand Down Expand Up @@ -81,8 +81,8 @@ pub fn launch(app: AppComponent) {
pub fn launch_with_title(app: AppComponent, title: &'static str) {
launch_cfg(
app,
LaunchConfig {
window: WindowConfig::<()> {
LaunchConfig::<()> {
window_config: WindowConfig {
width: 400.0,
height: 300.0,
decorations: true,
Expand Down Expand Up @@ -125,8 +125,8 @@ pub fn launch_with_title(app: AppComponent, title: &'static str) {
pub fn launch_with_props(app: AppComponent, title: &'static str, (width, height): (f64, f64)) {
launch_cfg(
app,
LaunchConfig {
window: WindowConfig::<()> {
LaunchConfig::<()> {
window_config: WindowConfig {
width,
height,
decorations: true,
Expand Down Expand Up @@ -156,14 +156,13 @@ pub fn launch_with_props(app: AppComponent, title: &'static str, (width, height)
/// fn main() {
/// launch_cfg(
/// app,
/// LaunchConfig::<()>::builder()
/// LaunchConfig::<()>::new()
/// .with_width(500.0)
/// .with_height(400.0)
/// .with_decorations(true)
/// .with_transparency(false)
/// .with_title("Freya App")
/// .with_background("rgb(150, 100, 200")
/// .build()
/// );
/// }
///
Expand All @@ -179,7 +178,7 @@ pub fn launch_with_props(app: AppComponent, title: &'static str, (width, height)
/// )
/// }
/// ```
pub fn launch_cfg<T: 'static + Clone + Send>(app: AppComponent, config: LaunchConfig<T>) {
pub fn launch_cfg<T: 'static + Clone>(app: AppComponent, config: LaunchConfig<T>) {
use freya_core::prelude::{FreyaDOM, SafeDOM};

let fdom = FreyaDOM::default();
Expand Down
2 changes: 1 addition & 1 deletion crates/hooks/tests/use_editable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ pub async fn replace_text() {
editable.process_event(&EditableEvent::KeyDown(e.data));
};

let onclick = move |e: MouseEvent| {
let onclick = move |_: MouseEvent| {
editable.process_event(&EditableEvent::Click);
};

Expand Down
29 changes: 16 additions & 13 deletions crates/renderer/src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,18 @@ use winit::{
pub struct AccessKitManager {
accessibility_manager: SharedAccessibilityManager,
accessibility_adapter: Adapter,
title: String,
}

impl AccessKitManager {
pub fn new(window: &Window, proxy: EventLoopProxy<EventMessage>) -> Self {
let title = window.title();
let accessibility_manager = AccessibilityManager::new(ACCESSIBILITY_ROOT_ID).wrap();
let accessibility_adapter = {
let accessibility_manager = accessibility_manager.clone();
Adapter::new(
window,
move || {
let mut accessibility_manager = accessibility_manager.lock().unwrap();
accessibility_manager.process(ACCESSIBILITY_ROOT_ID, title.as_str())
},
proxy,
)
};
let accessibility_adapter = Adapter::with_event_loop_proxy(window, proxy);
Self {
accessibility_manager,
accessibility_adapter,
title,
}
}

Expand All @@ -47,7 +39,7 @@ impl AccessKitManager {

/// Focus a new accessibility node
pub fn focus_node(
&self,
&mut self,
id: AccessibilityId,
platform_sender: &NativePlatformSender,
window: &Window,
Expand Down Expand Up @@ -118,7 +110,7 @@ impl AccessKitManager {

/// Focus the next accessibility node
pub fn focus_next_node(
&self,
&mut self,
direction: AccessibilityFocusDirection,
platform_sender: &NativePlatformSender,
window: &Window,
Expand All @@ -140,4 +132,15 @@ impl AccessKitManager {
// Update the Adapter
self.accessibility_adapter.update_if_active(|| tree);
}

/// Process the initial tree
pub fn process_initial_tree(&mut self) {
let tree = self
.accessibility_manager
.lock()
.unwrap()
.process(ACCESSIBILITY_ROOT_ID, &self.title);

self.accessibility_adapter.update_if_active(|| tree);
}
}
Loading

0 comments on commit 4e4d5c3

Please sign in to comment.