Print some window events
authorTomas Wenström <tomas.wenstrom@gmail.com>
Thu, 14 Feb 2019 14:07:03 +0000 (15:07 +0100)
committerTomas Wenström <tomas.wenstrom@gmail.com>
Fri, 15 Feb 2019 20:50:32 +0000 (21:50 +0100)
src/main.rs

index 9efa97d..d474fd6 100644 (file)
@@ -22,6 +22,7 @@ use common::Point2D;
 use sprites::SpriteManager;
 use sdl2::video::WindowContext;
 use sdl2::render::TextureCreator;
+use sdl2::event::WindowEvent;
 
 #[macro_use] mod common;
 mod boll;
@@ -132,6 +133,13 @@ fn main() {
                         point!(0.0, 0.0),
                     )))
                 }
+                Event::Window { win_event: WindowEvent::Resized(x, y), .. } => { println!("window resized({}, {})", x, y) }
+                Event::Window { win_event: WindowEvent::Maximized, .. } => { println!("window maximized") }
+                Event::Window { win_event: WindowEvent::Restored, .. } => { println!("window restored") }
+                Event::Window { win_event: WindowEvent::Enter, .. } => { println!("window enter") }
+                Event::Window { win_event: WindowEvent::Leave, .. } => { println!("window leave") }
+                Event::Window { win_event: WindowEvent::FocusGained, .. } => { println!("window focus gained") }
+                Event::Window { win_event: WindowEvent::FocusLost, .. } => { println!("window focus lost") }
                 _ => {}
             }
         }