From 8e63e5210ce711aa5793350979aab83c00ac70cc Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 3 Nov 2024 13:30:03 -0500 Subject: [PATCH] Add full-screen support --- cyber-slides/src/main.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cyber-slides/src/main.rs b/cyber-slides/src/main.rs index e658030..c0c62b3 100644 --- a/cyber-slides/src/main.rs +++ b/cyber-slides/src/main.rs @@ -367,20 +367,29 @@ fn main() { }); app.connect_activate(move |app| { + let window = gtk::ApplicationWindow::new(app); let screen = CyberScreen::new(script.read().unwrap().clone()); let events = EventControllerKey::new(); events.connect_key_released({ + let app = app.clone(); + let window = window.clone(); let screen = screen.clone(); move |_, key, _, _| { - if key.name() == Some(GString::from("Right")) { - screen.next_page(); + let name = key + .name() + .map(|s| s.as_str().to_owned()) + .unwrap_or("".to_owned()); + match name.as_ref() { + "Right" => screen.next_page(), + "q" => app.quit(), + "Escape" => window.unfullscreen(), + _ => {} } } }); - let window = gtk::ApplicationWindow::new(app); window.add_controller(events); window.set_child(Some(&screen)); @@ -388,6 +397,10 @@ fn main() { window.set_height_request(600); window.present(); + window.connect_maximized_notify(|window| { + window.fullscreen(); + }); + let _ = glib::spawn_future_local({ let screen = screen.clone(); async move {