diff --git a/src/display.rs b/src/display.rs index 32568d7..bdacd2d 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,7 +1,7 @@ use crate::mpd_handler::MPDHandler; use crate::Opt; use ggez::event::{self, EventHandler}; -use ggez::graphics::{self, Color, DrawParam, Drawable, Text, TextFragment}; +use ggez::graphics::{self, Color, DrawParam, Drawable, Rect, Text, TextFragment}; use ggez::timer::{check_update_time, fps, yield_now}; use ggez::Context; use ggez::GameError; @@ -47,4 +47,17 @@ 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"); + } } diff --git a/src/main.rs b/src/main.rs index b2d2a2b..1312ee5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ mod display; mod mpd_handler; -use ggez::conf::WindowSetup; +use ggez::conf::{WindowMode, WindowSetup}; use ggez::event; use ggez::ContextBuilder; use std::net::Ipv4Addr; @@ -34,6 +34,10 @@ fn main() -> Result<(), String> { title: "mpd info screen".into(), ..Default::default() }) + .window_mode(WindowMode { + resizable: true, + ..Default::default() + }) .build() .expect("Failed to create ggez context");