Skip to content

Commit

Permalink
Changes for testing winit-blur
Browse files Browse the repository at this point in the history
Changes to make the new blur-behind functionality of winit work.
  • Loading branch information
haudan committed Jun 15, 2018
1 parent 78afc32 commit 7f06a07
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
39 changes: 39 additions & 0 deletions examples/blurry.rs
Original file line number Diff line number Diff line change
@@ -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
});
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ pub use winit::{
WindowId,
};

pub use winit::dpi;

use std::io;

mod api;
Expand Down
1 change: 1 addition & 0 deletions src/os/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 7f06a07

Please sign in to comment.