fn handle_thread_event(&mut self, event: GlutinThreadEvent, window_target: &EventLoopWindowTarget<GlutinThreadEvent>) {
        use GlutinThreadEvent::*;

        match event {
            CreateRenderWindow(actions, events, window_properties) => {
                // Get the initial set of properties for the window
                let title               = window_properties.title().get();
                let (size_x, size_y)    = window_properties.size().get();
                let fullscreen          = window_properties.fullscreen().get();
                let decorations         = window_properties.has_decorations().get();

                let fullscreen          = if fullscreen { Some(Fullscreen::Borderless(None)) } else { None };

                // Create a window
                let window_builder      = glutin::window::WindowBuilder::new()
                    .with_title(title)
                    .with_inner_size(glutin::dpi::LogicalSize::new(size_x as f64, size_y as _))
                    .with_fullscreen(fullscreen)
                    .with_decorations(decorations);
                let windowed_context    = glutin::ContextBuilder::new()
                    .with_gl(GlRequest::Specific(Api::OpenGl, (3, 3)))
                    .with_vsync(false)
                    .build_windowed(window_builder, &window_target)
                    .unwrap();

                // Store the window context in a new glutin window
                let window_id           = windowed_context.window().id();
                let size                = windowed_context.window().inner_size();
                let scale               = windowed_context.window().scale_factor();
                let window              = GlutinWindow::new(windowed_context);

                // Store the publisher for the events for this window
                let mut initial_events  = events.republish_weak();
                self.window_events.insert(window_id, events);

                // Run the window as a process on this thread
                self.run_process(async move { 
                    // Send the initial events for this window (set the size and the DPI)
                    initial_events.publish(DrawEvent::Resize(size.width as f64, size.height as f64)).await;
                    initial_events.publish(DrawEvent::Scale(scale)).await;
                    initial_events.publish(DrawEvent::Redraw).await;

                    let window_events = initial_events;

                    // Process the actions for the window
                    send_actions_to_window(window, actions, window_events, window_properties).await;

                    // Stop processing events for the window once there are no more actions
                    glutin_thread().send_event(GlutinThreadEvent::StopSendingToWindow(window_id));
                });
            }

            StopSendingToWindow(window_id) => {
                self.window_events.remove(&window_id);

                if self.window_events.len() == 0 && self.will_stop_when_no_windows {
                    self.will_exit = true;
                }
            }

            RunProcess(start_process) => {
                self.run_process(start_process());
            },

            WakeFuture(future_id) => {
                self.poll_future(future_id);
            },

            StopWhenAllWindowsClosed => {
                self.will_stop_when_no_windows = true;

                if self.window_events.len() == 0 {
                    self.will_exit = true;
                }
            }
        }
    }
///
/// Handles one of our user events from the GlutinThreadEvent enum
///
Handles one of our user events from the GlutinThreadEvent enum
Handles one of our user events from the GlutinThreadEvent enum
fn handle_thread_event(&mut self, event: GlutinThreadEvent, window_target: &EventLoopWindowTarget<GlutinThreadEvent>) {
        use GlutinThreadEvent::*;
        match event {
            CreateRenderWindow(actions, events, window_properties) => {
                // Get the initial set of properties for the window
                let title               = window_properties.title().get();
                let (size_x, size_y)    = window_properties.size().get();
                let fullscreen          = window_properties.fullscreen().get();
                let decorations         = window_properties.has_decorations().get();
                let fullscreen          = if fullscreen { Some(Fullscreen::Borderless(None)) } else { None };
                // Create a window
                let window_builder      = glutin::window::WindowBuilder::new()
                    .with_title(title)
                    .with_inner_size(glutin::dpi::LogicalSize::new(size_x as f64, size_y as _))
                    .with_fullscreen(fullscreen)
                    .with_decorations(decorations);
                let windowed_context    = glutin::ContextBuilder::new()
                    .with_gl(GlRequest::Specific(Api::OpenGl, (3, 3)))
                    .with_vsync(false)
                    .build_windowed(window_builder, &window_target)
                    .unwrap();
                // Store the window context in a new glutin window
                let window_id           = windowed_context.window().id();
                let size                = windowed_context.window().inner_size();
                let scale               = windowed_context.window().scale_factor();
                let window              = GlutinWindow::new(windowed_context);
                // Store the publisher for the events for this window
                let mut initial_events  = events.republish_weak();
                self.window_events.insert(window_id, events);
                // Run the window as a process on this thread
                self.run_process(async move { 
                    // Send the initial events for this window (set the size and the DPI)
                    initial_events.publish(DrawEvent::Resize(size.width as f64, size.height as f64)).await;
                    initial_events.publish(DrawEvent::Scale(scale)).await;
                    initial_events.publish(DrawEvent::Redraw).await;
                    let window_events = initial_events;
                    // Process the actions for the window
                    send_actions_to_window(window, actions, window_events, window_properties).await;
                    // Stop processing events for the window once there are no more actions
                    glutin_thread().send_event(GlutinThreadEvent::StopSendingToWindow(window_id));
                });
            }
            StopSendingToWindow(window_id) => {
                self.window_events.remove(&window_id);
                if self.window_events.len() == 0 && self.will_stop_when_no_windows {
                    self.will_exit = true;
                }
            }
            RunProcess(start_process) => {
                self.run_process(start_process());
            },
            WakeFuture(future_id) => {
                self.poll_future(future_id);
            },
            StopWhenAllWindowsClosed => {
                self.will_stop_when_no_windows = true;
                if self.window_events.len() == 0 {
                    self.will_exit = true;
                }
            }
        }
    }
fn handle_thread_event ( & mut self , event : GlutinThreadEvent , window_target : & EventLoopWindowTarget < GlutinThreadEvent > ) { use GlutinThreadEvent :: * ; match event { CreateRenderWindow ( actions , events , window_properties ) => { // Get the initial set of properties for the window let title = window_properties . title ( ) . get ( ) ; let ( size_x , size_y ) = window_properties . size ( ) . get ( ) ; let fullscreen = window_properties . fullscreen ( ) . get ( ) ; let decorations = window_properties . has_decorations ( ) . get ( ) ; let fullscreen = if fullscreen { Some ( Fullscreen :: Borderless ( None ) ) } else { None } ; // Create a window let window_builder = glutin :: window :: WindowBuilder :: new ( ) . with_title ( title ) . with_inner_size ( glutin :: dpi :: LogicalSize :: new ( size_x as f64 , size_y as _ ) ) . with_fullscreen ( fullscreen ) . with_decorations ( decorations ) ; let windowed_context = glutin :: ContextBuilder :: new ( ) . with_gl ( GlRequest :: Specific ( Api :: OpenGl , ( 3 , 3 ) ) ) . with_vsync ( false ) . build_windowed ( window_builder , & window_target ) . unwrap ( ) ; // Store the window context in a new glutin window let window_id = windowed_context . window ( ) . id ( ) ; let size = windowed_context . window ( ) . inner_size ( ) ; let scale = windowed_context . window ( ) . scale_factor ( ) ; let window = GlutinWindow :: new ( windowed_context ) ; // Store the publisher for the events for this window let mut initial_events = events . republish_weak ( ) ; self . window_events . insert ( window_id , events ) ; // Run the window as a process on this thread self . run_process ( async move { // Send the initial events for this window (set the size and the DPI) initial_events . publish ( DrawEvent :: Resize ( size . width as f64 , size . height as f64 ) ) . await ; initial_events . publish ( DrawEvent :: Scale ( scale ) ) . await ; initial_events . publish ( DrawEvent :: Redraw ) . await ; let window_events = initial_events ; // Process the actions for the window send_actions_to_window ( window , actions , window_events , window_properties ) . await ; // Stop processing events for the window once there are no more actions glutin_thread ( ) . send_event ( GlutinThreadEvent :: StopSendingToWindow ( window_id ) ) ; } ) ; } StopSendingToWindow ( window_id ) => { self . window_events . remove ( & window_id ) ; if self . window_events . len ( ) == 0 && self . will_stop_when_no_windows { self . will_exit = true ; } } RunProcess ( start_process ) => { self . run_process ( start_process ( ) ) ; } , WakeFuture ( future_id ) => { self . poll_future ( future_id ) ; } , StopWhenAllWindowsClosed => { self . will_stop_when_no_windows = true ; if self . window_events . len ( ) == 0 { self . will_exit = true ; } } } }
Handles one of our user events from the GlutinThreadEvent enum
Handles one of our user events from the GlutinThreadEvent enum
&mut self
event
GlutinThreadEvent
window_target
&EventLoopWindowTarget<GlutinThreadEvent>