1313// limitations under the License.
1414
1515use std:: collections:: HashSet ;
16- use std:: sync:: { Arc , Mutex } ;
1716use std:: time:: Duration ;
1817
19- use accesskit:: TreeUpdate ;
20- use glazier:: { IdleHandle , IdleToken , WindowHandle } ;
2118use parley:: FontContext ;
2219use tokio:: runtime:: Runtime ;
2320use vello:: {
@@ -27,8 +24,8 @@ use vello::{
2724use xilem_core:: { AsyncWake , MessageResult } ;
2825
2926use crate :: widget:: {
30- AccessCx , BoxConstraints , CxState , EventCx , LayoutCx , LifeCycle , LifeCycleCx , PaintCx , Pod ,
31- PodFlags , UpdateCx , ViewContext , WidgetState ,
27+ BoxConstraints , CxState , EventCx , LayoutCx , LifeCycle , LifeCycleCx , PaintCx , Pod , PodFlags ,
28+ UpdateCx , ViewContext , WidgetState ,
3229} ;
3330use crate :: {
3431 view:: { Cx , Id , View } ,
@@ -46,7 +43,6 @@ pub struct App<T, V: View<T>> {
4643 return_chan : tokio:: sync:: mpsc:: Sender < ( V , V :: State , HashSet < Id > ) > ,
4744 id : Option < Id > ,
4845 events : Vec < Message > ,
49- window_handle : WindowHandle ,
5046 root_state : WidgetState ,
5147 root_pod : Option < Pod > ,
5248 size : Size ,
@@ -55,11 +51,6 @@ pub struct App<T, V: View<T>> {
5551 cx : Cx ,
5652 font_cx : FontContext ,
5753 pub ( crate ) rt : Runtime ,
58- // This is allocated an id for AccessKit, but as we get multi-window,
59- // there should be a real window object with id.
60- window_id : crate :: id:: Id ,
61- pub ( crate ) accesskit_connected : bool ,
62- node_classes : accesskit:: NodeClassSet ,
6354}
6455
6556/// The standard delay for waiting for async futures.
@@ -79,14 +70,12 @@ struct AppTask<T, V: View<T>, F: FnMut(&mut T) -> V> {
7970 app_logic : F ,
8071 view : Option < V > ,
8172 state : Option < V :: State > ,
82- idle_handle : Option < IdleHandle > ,
8373 pending_async : HashSet < Id > ,
8474 ui_state : UiState ,
8575}
8676
8777/// A message sent from the main UI thread ([`App`]) to the [`AppTask`].
8878pub ( crate ) enum AppReq {
89- SetIdleHandle ( IdleHandle ) ,
9079 Events ( Vec < Message > ) ,
9180 Wake ( IdPath ) ,
9281 // Parameter indicates whether it should be delayed for async
@@ -115,9 +104,6 @@ enum UiState {
115104 WokeUI ,
116105}
117106
118- #[ derive( Clone , Default ) ]
119- pub struct WakeQueue ( Arc < Mutex < Vec < IdPath > > > ) ;
120-
121107impl < T : Send + ' static , V : View < T > + ' static > App < T , V >
122108where
123109 V :: State : ' static ,
@@ -159,7 +145,6 @@ where
159145 app_logic,
160146 view : None ,
161147 state : None ,
162- idle_handle : None ,
163148 pending_async : HashSet :: new ( ) ,
164149 ui_state : UiState :: Start ,
165150 } ;
@@ -172,64 +157,20 @@ where
172157 id : None ,
173158 root_pod : None ,
174159 events : Vec :: new ( ) ,
175- window_handle : Default :: default ( ) ,
176160 root_state : WidgetState :: new ( ) ,
177161 size : Default :: default ( ) ,
178162 new_size : Default :: default ( ) ,
179163 cursor_pos : None ,
180164 cx,
181165 font_cx : FontContext :: new ( ) ,
182166 rt,
183- window_id : crate :: id:: Id :: next ( ) ,
184- accesskit_connected : false ,
185- node_classes : accesskit:: NodeClassSet :: new ( ) ,
186- }
187- }
188-
189- pub fn connect ( & mut self , window_handle : WindowHandle ) {
190- self . window_handle = window_handle. clone ( ) ;
191- if let Some ( idle_handle) = window_handle. get_idle_handle ( ) {
192- let _ = self
193- . req_chan
194- . blocking_send ( AppReq :: SetIdleHandle ( idle_handle) ) ;
195167 }
196168 }
197169
198170 pub fn size ( & mut self , size : Size ) {
199171 self . new_size = size;
200172 }
201173
202- pub fn accessibility ( & mut self ) -> TreeUpdate {
203- let mut update = TreeUpdate {
204- nodes : vec ! [ ] ,
205- tree : None ,
206- focus : accesskit:: NodeId ( 0 ) ,
207- } ;
208- self . ensure_root ( ) ;
209- let root_pod = self . root_pod . as_mut ( ) . unwrap ( ) ;
210- let mut window_node_builder = accesskit:: NodeBuilder :: new ( accesskit:: Role :: Window ) ;
211- window_node_builder. set_name ( "xilem window" ) ;
212- window_node_builder. set_children ( vec ! [ root_pod. id( ) . into( ) ] ) ;
213- if let Ok ( scale) = self . window_handle . get_scale ( ) {
214- window_node_builder. set_transform ( Box :: new ( accesskit:: Affine :: scale_non_uniform (
215- scale. x ( ) ,
216- scale. y ( ) ,
217- ) ) ) ;
218- }
219- let window_node = window_node_builder. build ( & mut self . node_classes ) ;
220- update. nodes . push ( ( self . window_id . into ( ) , window_node) ) ;
221- update. tree = Some ( accesskit:: Tree :: new ( self . window_id . into ( ) ) ) ;
222- let mut cx_state = CxState :: new ( & self . window_handle , & mut self . font_cx , & mut self . events ) ;
223- let mut access_cx = AccessCx {
224- cx_state : & mut cx_state,
225- widget_state : & mut self . root_state ,
226- update : & mut update,
227- node_classes : & mut self . node_classes ,
228- } ;
229- root_pod. accessibility ( & mut access_cx) ;
230- update
231- }
232-
233174 /// Run a paint cycle for the application.
234175 ///
235176 /// This is not just painting, but involves processing events, doing layout
@@ -240,8 +181,7 @@ where
240181 // TODO: be more lazy re-rendering
241182 self . render ( ) ;
242183 let root_pod = self . root_pod . as_mut ( ) . unwrap ( ) ;
243- let mut cx_state =
244- CxState :: new ( & self . window_handle , & mut self . font_cx , & mut self . events ) ;
184+ let mut cx_state = CxState :: new ( & mut self . font_cx , & mut self . events ) ;
245185
246186 let mut lifecycle_cx = LifeCycleCx :: new ( & mut cx_state, & mut self . root_state ) ;
247187 root_pod. lifecycle ( & mut lifecycle_cx, & LifeCycle :: TreeUpdate ) ;
@@ -282,16 +222,10 @@ where
282222 continue ;
283223 }
284224
285- if self . accesskit_connected {
286- let update = self . accessibility ( ) ;
287- // TODO: it would be cleaner to not use a closure here.
288- self . window_handle . update_accesskit_if_active ( || update) ;
289- }
290225 // Borrow again to avoid multiple borrows.
291226 // TODO: maybe make accessibility a method on CxState?
292227 let root_pod = self . root_pod . as_mut ( ) . unwrap ( ) ;
293- let mut cx_state =
294- CxState :: new ( & self . window_handle , & mut self . font_cx , & mut self . events ) ;
228+ let mut cx_state = CxState :: new ( & mut self . font_cx , & mut self . events ) ;
295229 let mut paint_cx = PaintCx :: new ( & mut cx_state, & mut self . root_state ) ;
296230 root_pod. paint_impl ( & mut paint_cx) ;
297231 break ;
@@ -309,12 +243,11 @@ where
309243 Event :: MouseLeft ( ) => {
310244 self . cursor_pos = None ;
311245 }
312- _ => { }
313246 }
314247
315248 self . ensure_root ( ) ;
316249 let root_pod = self . root_pod . as_mut ( ) . unwrap ( ) ;
317- let mut cx_state = CxState :: new ( & self . window_handle , & mut self . font_cx , & mut self . events ) ;
250+ let mut cx_state = CxState :: new ( & mut self . font_cx , & mut self . events ) ;
318251 let mut event_cx = EventCx :: new ( & mut cx_state, & mut self . root_state ) ;
319252 root_pod. event ( & mut event_cx, & event) ;
320253 self . send_events ( ) ;
@@ -399,7 +332,6 @@ impl<T, V: View<T>, F: FnMut(&mut T) -> V> AppTask<T, V, F> {
399332 } ;
400333 match req {
401334 Ok ( Some ( req) ) => match req {
402- AppReq :: SetIdleHandle ( handle) => self . idle_handle = Some ( handle) ,
403335 AppReq :: Events ( events) => {
404336 for event in events {
405337 let id_path = & event. id_path [ 1 ..] ;
@@ -426,9 +358,6 @@ impl<T, V: View<T>, F: FnMut(&mut T) -> V> AppTask<T, V, F> {
426358 if needs_rebuild {
427359 // request re-render from UI thread
428360 if self . ui_state == UiState :: Start {
429- if let Some ( handle) = self . idle_handle . as_mut ( ) {
430- handle. schedule_idle ( IdleToken :: new ( 42 ) ) ;
431- }
432361 self . ui_state = UiState :: WokeUI ;
433362 }
434363 let id = id_path. last ( ) . unwrap ( ) ;
0 commit comments