Add full-screen support

This commit is contained in:
Savanni D'Gerinel 2024-11-03 13:30:03 -05:00
parent db34e69cdf
commit 8e63e5210c
1 changed files with 16 additions and 3 deletions

View File

@ -367,20 +367,29 @@ fn main() {
}); });
app.connect_activate(move |app| { app.connect_activate(move |app| {
let window = gtk::ApplicationWindow::new(app);
let screen = CyberScreen::new(script.read().unwrap().clone()); let screen = CyberScreen::new(script.read().unwrap().clone());
let events = EventControllerKey::new(); let events = EventControllerKey::new();
events.connect_key_released({ events.connect_key_released({
let app = app.clone();
let window = window.clone();
let screen = screen.clone(); let screen = screen.clone();
move |_, key, _, _| { move |_, key, _, _| {
if key.name() == Some(GString::from("Right")) { let name = key
screen.next_page(); .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.add_controller(events);
window.set_child(Some(&screen)); window.set_child(Some(&screen));
@ -388,6 +397,10 @@ fn main() {
window.set_height_request(600); window.set_height_request(600);
window.present(); window.present();
window.connect_maximized_notify(|window| {
window.fullscreen();
});
let _ = glib::spawn_future_local({ let _ = glib::spawn_future_local({
let screen = screen.clone(); let screen = screen.clone();
async move { async move {