From 7f06a079592c78ead89107964b20752d6c9abe37 Mon Sep 17 00:00:00 2001 From: Daniel Hauser Date: Fri, 15 Jun 2018 21:17:26 +0200 Subject: [PATCH] Changes for testing winit-blur Changes to make the new blur-behind functionality of winit work. --- Cargo.toml | 3 ++- examples/blurry.rs | 39 +++++++++++++++++++++++++++++++++++++++ src/lib.rs | 2 ++ src/os/macos.rs | 1 + src/platform/macos/mod.rs | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 examples/blurry.rs diff --git a/Cargo.toml b/Cargo.toml index 543fc71505..7f4df1cf4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,8 @@ icon_loading = ["winit/icon_loading"] lazy_static = "1" libc = "0.2" shared_library = "0.1.0" -winit = "0.15.0" +#winit = "0.15.0" +winit = {path = "../winit"} [build-dependencies] gl_generator = "0.9" diff --git a/examples/blurry.rs b/examples/blurry.rs new file mode 100644 index 0000000000..76f2cb100a --- /dev/null +++ b/examples/blurry.rs @@ -0,0 +1,39 @@ +extern crate glutin; + +mod support; + +use glutin::{GlContext, dpi::LogicalSize}; +use glutin::os::macos::{WindowExt, BlurMaterial}; + +fn main() { + let mut events_loop = glutin::EventsLoop::new(); + let window = glutin::WindowBuilder::new() + .with_title("A fantastic window!") + //.with_decorations(false) + .with_blur(true); + let context = glutin::ContextBuilder::new(); + let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap(); + gl_window.set_blur_material(BlurMaterial::Dark); + + let _ = unsafe { gl_window.make_current() }; + + println!("Pixel format of the window's GL context: {:?}", gl_window.get_pixel_format()); + + let gl = support::load(&gl_window); + + events_loop.run_forever(|event| { + println!("{:?}", event); + match event { + glutin::Event::WindowEvent { event, .. } => match event { + glutin::WindowEvent::CloseRequested => return glutin::ControlFlow::Break, + glutin::WindowEvent::Resized(LogicalSize { width: w, height: h }) => gl_window.resize(w as u32, h as u32), + _ => (), + }, + _ => (), + } + + gl.draw_frame([0.0, 0.0, 0.0, 0.0]); + let _ = gl_window.swap_buffers(); + glutin::ControlFlow::Continue + }); +} diff --git a/src/lib.rs b/src/lib.rs index 385405bf3f..b9f5dab93f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,6 +94,8 @@ pub use winit::{ WindowId, }; +pub use winit::dpi; + use std::io; mod api; diff --git a/src/os/macos.rs b/src/os/macos.rs index 65099866a6..f59150c21a 100644 --- a/src/os/macos.rs +++ b/src/os/macos.rs @@ -4,6 +4,7 @@ pub use winit::os::macos::ActivationPolicy; pub use winit::os::macos::MonitorIdExt; pub use winit::os::macos::WindowBuilderExt; pub use winit::os::macos::WindowExt; +pub use winit::os::macos::BlurMaterial; use {Context, HeadlessContext}; use os::GlContextExt; diff --git a/src/platform/macos/mod.rs b/src/platform/macos/mod.rs index 79ef26a047..dbdba9e136 100644 --- a/src/platform/macos/mod.rs +++ b/src/platform/macos/mod.rs @@ -44,7 +44,7 @@ impl Context { gl_attr: &GlAttributes<&Context>, ) -> Result<(winit::Window, Self), CreationError> { - let transparent = window_builder.window.transparent; + let transparent = window_builder.window.transparent || window_builder.window.blur; let window = window_builder.build(events_loop)?; if gl_attr.sharing.is_some() {