WIP fix handling resizing

This commit is contained in:
Stephen Seo 2021-12-14 19:54:13 +09:00
parent a132d30f59
commit ed7755d953
2 changed files with 13 additions and 13 deletions

View 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");
}
}

View 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 => {