@@ -469,71 +469,74 @@ async fn run_instance<A, E, C>(
469469 events. push ( event) ;
470470 }
471471 }
472- _ => { }
473- }
472+ event:: Event :: AboutToWait => {
473+ if events. is_empty ( ) && messages. is_empty ( ) {
474+ continue ;
475+ }
474476
475- if events. is_empty ( ) && messages. is_empty ( ) {
476- continue ;
477- }
477+ debug. event_processing_started ( ) ;
478478
479- debug. event_processing_started ( ) ;
479+ let ( interface_state, statuses) = user_interface. update (
480+ & events,
481+ state. cursor ( ) ,
482+ & mut renderer,
483+ & mut clipboard,
484+ & mut messages,
485+ ) ;
480486
481- let ( interface_state, statuses) = user_interface. update (
482- & events,
483- state. cursor ( ) ,
484- & mut renderer,
485- & mut clipboard,
486- & mut messages,
487- ) ;
487+ debug. event_processing_finished ( ) ;
488488
489- debug. event_processing_finished ( ) ;
489+ for ( event, status) in
490+ events. drain ( ..) . zip ( statuses. into_iter ( ) )
491+ {
492+ runtime. broadcast ( event, status) ;
493+ }
490494
491- for ( event, status) in events. drain ( ..) . zip ( statuses. into_iter ( ) ) {
492- runtime. broadcast ( event, status) ;
493- }
495+ if !messages. is_empty ( )
496+ || matches ! (
497+ interface_state,
498+ user_interface:: State :: Outdated
499+ )
500+ {
501+ let mut cache =
502+ ManuallyDrop :: into_inner ( user_interface) . into_cache ( ) ;
494503
495- if !messages. is_empty ( )
496- || matches ! ( interface_state, user_interface:: State :: Outdated )
497- {
498- let mut cache =
499- ManuallyDrop :: into_inner ( user_interface) . into_cache ( ) ;
500-
501- // Update application
502- update (
503- & mut application,
504- & mut compositor,
505- & mut surface,
506- & mut cache,
507- & state,
508- & mut renderer,
509- & mut runtime,
510- & mut clipboard,
511- & mut should_exit,
512- & mut proxy,
513- & mut debug,
514- & mut messages,
515- & window,
516- ) ;
517-
518- // Update window
519- state. synchronize ( & application, & window) ;
520-
521- user_interface = ManuallyDrop :: new ( build_user_interface (
522- & application,
523- cache,
524- & mut renderer,
525- state. logical_size ( ) ,
526- & mut debug,
527- ) ) ;
528-
529- if should_exit {
530- break ;
531- }
532- }
504+ // Update application
505+ update (
506+ & mut application,
507+ & mut compositor,
508+ & mut surface,
509+ & mut cache,
510+ & mut state,
511+ & mut renderer,
512+ & mut runtime,
513+ & mut clipboard,
514+ & mut should_exit,
515+ & mut proxy,
516+ & mut debug,
517+ & mut messages,
518+ & window,
519+ ) ;
520+
521+ user_interface = ManuallyDrop :: new ( build_user_interface (
522+ & application,
523+ cache,
524+ & mut renderer,
525+ state. logical_size ( ) ,
526+ & mut debug,
527+ ) ) ;
528+
529+ if should_exit {
530+ break ;
531+ }
532+ }
533533
534- if !redraw_pending {
535- window. request_redraw ( ) ;
536- redraw_pending = true ;
534+ if !redraw_pending {
535+ window. request_redraw ( ) ;
536+ redraw_pending = true ;
537+ }
538+ }
539+ _ => { }
537540 }
538541 }
539542
@@ -595,7 +598,7 @@ pub fn update<A: Application, C, E: Executor>(
595598 compositor : & mut C ,
596599 surface : & mut C :: Surface ,
597600 cache : & mut user_interface:: Cache ,
598- state : & State < A > ,
601+ state : & mut State < A > ,
599602 renderer : & mut A :: Renderer ,
600603 runtime : & mut Runtime < E , Proxy < A :: Message > , A :: Message > ,
601604 clipboard : & mut Clipboard ,
@@ -632,6 +635,8 @@ pub fn update<A: Application, C, E: Executor>(
632635 ) ;
633636 }
634637
638+ state. synchronize ( application, window) ;
639+
635640 let subscription = application. subscription ( ) ;
636641 runtime. track ( subscription. into_recipes ( ) ) ;
637642}
0 commit comments