@@ -13,7 +13,9 @@ use super::epi_integration::{self, EpiIntegration};
1313use crate :: epi;
1414
1515#[ derive( Debug ) ]
16- pub struct RequestRepaintEvent ;
16+ pub enum UserEvent {
17+ RequestRepaint ,
18+ }
1719
1820// ----------------------------------------------------------------------------
1921
@@ -45,14 +47,14 @@ trait WinitApp {
4547 fn paint ( & mut self ) -> EventResult ;
4648 fn on_event (
4749 & mut self ,
48- event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ,
49- event : & winit:: event:: Event < ' _ , RequestRepaintEvent > ,
50+ event_loop : & EventLoopWindowTarget < UserEvent > ,
51+ event : & winit:: event:: Event < ' _ , UserEvent > ,
5052 ) -> EventResult ;
5153}
5254
5355fn create_event_loop_builder (
5456 native_options : & mut epi:: NativeOptions ,
55- ) -> EventLoopBuilder < RequestRepaintEvent > {
57+ ) -> EventLoopBuilder < UserEvent > {
5658 let mut event_loop_builder = winit:: event_loop:: EventLoopBuilder :: with_user_event ( ) ;
5759
5860 if let Some ( hook) = std:: mem:: take ( & mut native_options. event_loop_builder ) {
@@ -68,10 +70,10 @@ fn create_event_loop_builder(
6870/// multiple times. This is just a limitation of winit.
6971fn with_event_loop (
7072 mut native_options : epi:: NativeOptions ,
71- f : impl FnOnce ( & mut EventLoop < RequestRepaintEvent > , NativeOptions ) ,
73+ f : impl FnOnce ( & mut EventLoop < UserEvent > , NativeOptions ) ,
7274) {
7375 use std:: cell:: RefCell ;
74- thread_local ! ( static EVENT_LOOP : RefCell <Option <EventLoop <RequestRepaintEvent >>> = RefCell :: new( None ) ) ;
76+ thread_local ! ( static EVENT_LOOP : RefCell <Option <EventLoop <UserEvent >>> = RefCell :: new( None ) ) ;
7577
7678 EVENT_LOOP . with ( |event_loop| {
7779 // Since we want to reference NativeOptions when creating the EventLoop we can't
@@ -84,7 +86,7 @@ fn with_event_loop(
8486 } ) ;
8587}
8688
87- fn run_and_return ( event_loop : & mut EventLoop < RequestRepaintEvent > , mut winit_app : impl WinitApp ) {
89+ fn run_and_return ( event_loop : & mut EventLoop < UserEvent > , mut winit_app : impl WinitApp ) {
8890 use winit:: platform:: run_return:: EventLoopExtRunReturn as _;
8991
9092 tracing:: debug!( "event_loop.run_return" ) ;
@@ -110,7 +112,7 @@ fn run_and_return(event_loop: &mut EventLoop<RequestRepaintEvent>, mut winit_app
110112 winit_app. paint ( )
111113 }
112114
113- winit:: event:: Event :: UserEvent ( RequestRepaintEvent )
115+ winit:: event:: Event :: UserEvent ( UserEvent :: RequestRepaint )
114116 | winit:: event:: Event :: NewEvents ( winit:: event:: StartCause :: ResumeTimeReached {
115117 ..
116118 } ) => EventResult :: RepaintNext ,
@@ -176,10 +178,7 @@ fn run_and_return(event_loop: &mut EventLoop<RequestRepaintEvent>, mut winit_app
176178 } ) ;
177179}
178180
179- fn run_and_exit (
180- event_loop : EventLoop < RequestRepaintEvent > ,
181- mut winit_app : impl WinitApp + ' static ,
182- ) -> ! {
181+ fn run_and_exit ( event_loop : EventLoop < UserEvent > , mut winit_app : impl WinitApp + ' static ) -> ! {
183182 tracing:: debug!( "event_loop.run" ) ;
184183
185184 let mut next_repaint_time = Instant :: now ( ) ;
@@ -200,7 +199,7 @@ fn run_and_exit(
200199 winit_app. paint ( )
201200 }
202201
203- winit:: event:: Event :: UserEvent ( RequestRepaintEvent )
202+ winit:: event:: Event :: UserEvent ( UserEvent :: RequestRepaint )
204203 | winit:: event:: Event :: NewEvents ( winit:: event:: StartCause :: ResumeTimeReached {
205204 ..
206205 } ) => EventResult :: RepaintNext ,
@@ -299,7 +298,7 @@ mod glow_integration {
299298 }
300299
301300 struct GlowWinitApp {
302- repaint_proxy : Arc < egui:: mutex:: Mutex < EventLoopProxy < RequestRepaintEvent > > > ,
301+ repaint_proxy : Arc < egui:: mutex:: Mutex < EventLoopProxy < UserEvent > > > ,
303302 app_name : String ,
304303 native_options : epi:: NativeOptions ,
305304 running : Option < GlowWinitRunning > ,
@@ -313,7 +312,7 @@ mod glow_integration {
313312
314313 impl GlowWinitApp {
315314 fn new (
316- event_loop : & EventLoop < RequestRepaintEvent > ,
315+ event_loop : & EventLoop < UserEvent > ,
317316 app_name : & str ,
318317 native_options : epi:: NativeOptions ,
319318 app_creator : epi:: AppCreator ,
@@ -330,7 +329,7 @@ mod glow_integration {
330329
331330 #[ allow( unsafe_code) ]
332331 fn create_glutin_windowed_context (
333- event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ,
332+ event_loop : & EventLoopWindowTarget < UserEvent > ,
334333 storage : Option < & dyn epi:: Storage > ,
335334 title : & String ,
336335 native_options : & NativeOptions ,
@@ -372,7 +371,7 @@ mod glow_integration {
372371 ( gl_window, gl)
373372 }
374373
375- fn init_run_state ( & mut self , event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ) {
374+ fn init_run_state ( & mut self , event_loop : & EventLoopWindowTarget < UserEvent > ) {
376375 let storage = epi_integration:: create_storage ( & self . app_name ) ;
377376
378377 let ( gl_window, gl) = Self :: create_glutin_windowed_context (
@@ -409,7 +408,10 @@ mod glow_integration {
409408 {
410409 let event_loop_proxy = self . repaint_proxy . clone ( ) ;
411410 integration. egui_ctx . set_request_repaint_callback ( move || {
412- event_loop_proxy. lock ( ) . send_event ( RequestRepaintEvent ) . ok ( ) ;
411+ event_loop_proxy
412+ . lock ( )
413+ . send_event ( UserEvent :: RequestRepaint )
414+ . ok ( ) ;
413415 } ) ;
414416 }
415417
@@ -552,8 +554,8 @@ mod glow_integration {
552554
553555 fn on_event (
554556 & mut self ,
555- event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ,
556- event : & winit:: event:: Event < ' _ , RequestRepaintEvent > ,
557+ event_loop : & EventLoopWindowTarget < UserEvent > ,
558+ event : & winit:: event:: Event < ' _ , UserEvent > ,
557559 ) -> EventResult {
558560 match event {
559561 winit:: event:: Event :: Resumed => {
@@ -697,7 +699,7 @@ mod wgpu_integration {
697699 }
698700
699701 struct WgpuWinitApp {
700- repaint_proxy : Arc < std:: sync:: Mutex < EventLoopProxy < RequestRepaintEvent > > > ,
702+ repaint_proxy : Arc < std:: sync:: Mutex < EventLoopProxy < UserEvent > > > ,
701703 app_name : String ,
702704 native_options : epi:: NativeOptions ,
703705 app_creator : Option < epi:: AppCreator > ,
@@ -711,7 +713,7 @@ mod wgpu_integration {
711713
712714 impl WgpuWinitApp {
713715 fn new (
714- event_loop : & EventLoop < RequestRepaintEvent > ,
716+ event_loop : & EventLoop < UserEvent > ,
715717 app_name : & str ,
716718 native_options : epi:: NativeOptions ,
717719 app_creator : epi:: AppCreator ,
@@ -728,7 +730,7 @@ mod wgpu_integration {
728730 }
729731
730732 fn create_window (
731- event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ,
733+ event_loop : & EventLoopWindowTarget < UserEvent > ,
732734 storage : Option < & dyn epi:: Storage > ,
733735 title : & String ,
734736 native_options : & NativeOptions ,
@@ -764,7 +766,7 @@ mod wgpu_integration {
764766
765767 fn init_run_state (
766768 & mut self ,
767- event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ,
769+ event_loop : & EventLoopWindowTarget < UserEvent > ,
768770 storage : Option < Box < dyn epi:: Storage > > ,
769771 window : winit:: window:: Window ,
770772 ) {
@@ -803,7 +805,7 @@ mod wgpu_integration {
803805 event_loop_proxy
804806 . lock ( )
805807 . unwrap ( )
806- . send_event ( RequestRepaintEvent )
808+ . send_event ( UserEvent :: RequestRepaint )
807809 . ok ( ) ;
808810 } ) ;
809811 }
@@ -934,8 +936,8 @@ mod wgpu_integration {
934936
935937 fn on_event (
936938 & mut self ,
937- event_loop : & EventLoopWindowTarget < RequestRepaintEvent > ,
938- event : & winit:: event:: Event < ' _ , RequestRepaintEvent > ,
939+ event_loop : & EventLoopWindowTarget < UserEvent > ,
940+ event : & winit:: event:: Event < ' _ , UserEvent > ,
939941 ) -> EventResult {
940942 match event {
941943 winit:: event:: Event :: Resumed => {
0 commit comments