]> git.seodisparate.com - mpd_info_screen/commitdiff
WIP fix handling resizing
authorStephen Seo <seo.disparate@gmail.com>
Tue, 14 Dec 2021 10:54:13 +0000 (19:54 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Tue, 14 Dec 2021 10:54:13 +0000 (19:54 +0900)
src/display.rs
src/main.rs

index b9f51f592fe01f3fe2df0ae5faf627cc588b172c..0271ec272c735c1ae73a3f5dc73174a966c7f916 100644 (file)
@@ -47,17 +47,4 @@ impl EventHandler for MPDDisplay {
 
         graphics::present(ctx)
     }
-
-    fn resize_event(&mut self, ctx: &mut Context, width: f32, height: f32) {
-        graphics::set_screen_coordinates(
-            ctx,
-            Rect {
-                x: 0.0,
-                y: 0.0,
-                w: width,
-                h: height,
-            },
-        )
-        .expect("Failed to handle resizing window");
-    }
 }
index dc9c307ef495b87a77b78d829140d8aa2a969f1e..9ceace9cbfae3fb8bed130f3a784bda3201334bc 100644 (file)
@@ -4,6 +4,7 @@ mod mpd_handler;
 use ggez::conf::{WindowMode, WindowSetup};
 use ggez::event::winit_event::KeyboardInput;
 use ggez::event::{self, ControlFlow, EventHandler};
+use ggez::graphics::{self, Rect};
 use ggez::ContextBuilder;
 use std::net::Ipv4Addr;
 use std::thread;
@@ -74,6 +75,18 @@ fn main() -> Result<(), String> {
                     }
                     _ => (),
                 },
+                event::winit_event::WindowEvent::Resized(phys_size) => {
+                    graphics::set_screen_coordinates(
+                        ctx,
+                        Rect {
+                            x: 0.0,
+                            y: 0.0,
+                            w: phys_size.width as f32,
+                            h: phys_size.height as f32,
+                        },
+                    )
+                    .expect("Failed to handle resizing window");
+                }
                 x => println!("Other window event fired: {:?}", x),
             },
             event::winit_event::Event::MainEventsCleared => {