Re-enable fullscreen toggling
authorBernie Innocenti <codewiz@google.com>
Sun, 29 Mar 2020 12:57:27 +0000 (21:57 +0900)
committerBernie Innocenti <codewiz@google.com>
Sun, 29 Mar 2020 12:58:49 +0000 (21:58 +0900)
Tested only on Linux with X11. I wouldn't be too surprised if it was
broken on other plaforms.

main.rs
timer.rs

diff --git a/main.rs b/main.rs
index 8370992d633788911db26eecf2835ac4227fe474..2bdcae815801a7a1958ed770f282be4e593c4d00 100644 (file)
--- a/main.rs
+++ b/main.rs
@@ -253,12 +253,9 @@ fn main() {
     let mut soundplayer = sound::start();
 
     let event_loop = glutin::event_loop::EventLoop::new();
-    //let fullscreen = Some(glutin::window::Fullscreen::Borderless(event_loop.primary_monitor()));
     let window = glutin::window::WindowBuilder::new()
         //.with_dimensions(1280, 720)
-        //.with_fullscreen(fullscreen);
-        ;
-    //.with_title("MandelWow");
+        .with_title("MandelWow");
     let context = glutin::ContextBuilder::new()
         //.with_gl_profile(glutin::GlProfile::Core)
         //.with_gl(glutin::GlRequest::Specific(glutin::Api::WebGl, (2, 0)))
@@ -276,7 +273,7 @@ fn main() {
 
     let mut timer = Timer::new();
     let mut camera = support::camera::CameraState::new();
-    let _fullscreen = true;
+    let mut fullscreen = true;
 
     event_loop.run(move |event, _, control_flow| {
         let t = timer.t;
@@ -315,17 +312,15 @@ fn main() {
                                     VirtualKeyCode::PageDown => timer.t -= 0.2,
                                     VirtualKeyCode::F10 => screenshot(&display),
                                     VirtualKeyCode::F11 | VirtualKeyCode::Return => {
-                                        /*
                                         fullscreen ^= true;
-                                        if fullscreen {
-                                            // Not implemented on Linux
-                                            glutin::WindowBuilder::new()
-                                                .with_fullscreen(glutin::get_primary_monitor())
-                                                .with_depth_buffer(24) .rebuild_glium(&display).unwrap(); }
-                                        else {
-                                            glutin::WindowBuilder::new()
-                                                .rebuild_glium(&display).unwrap();
-                                        }*/
+                                        let fs = if fullscreen {
+                                            let monitor_handle = display.gl_window().window()
+                                                .available_monitors().next().unwrap();
+                                            Some(glium::glutin::window::Fullscreen::Borderless(monitor_handle))
+                                        } else {
+                                            None
+                                        };
+                                        display.gl_window().window().set_fullscreen(fs);
                                     }
                                     _ => (),
                                 }
index 8434a69976afeaecb2449d9636eb8700eb199ddb..afbfd1ab6183346636f6b6a0358fe09b82798d14 100644 (file)
--- a/timer.rs
+++ b/timer.rs
@@ -9,6 +9,7 @@ type Rocket = rust_rocket::Rocket;
 #[cfg(not(feature = "editor"))]
 type Rocket = ();
 
+#[cfg(feature = "editor")]
 const BPS: f32 = 10.0;
 
 #[derive(Debug)]