diff options
author | pinumbernumber <1337rz@gmail.com> | 2015-06-14 22:20:32 +0100 |
---|---|---|
committer | pinumbernumber <1337rz@gmail.com> | 2015-06-14 22:20:32 +0100 |
commit | da4bcad6e32dd2b1df696dd786d6af342f247d0d (patch) | |
tree | 91d0ee4ace200e6961d213abcc46d6d41cd15ac3 | |
parent | a0e29d9410181368eee1e0b6db1bbbf11abf45f8 (diff) | |
download | glutin-da4bcad6e32dd2b1df696dd786d6af342f247d0d.tar.gz glutin-da4bcad6e32dd2b1df696dd786d6af342f247d0d.zip |
Implement transparency for X11
-rw-r--r-- | src/api/x11/window.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs index 8b74e77..9a6f6a8 100644 --- a/src/api/x11/window.rs +++ b/src/api/x11/window.rs @@ -339,7 +339,23 @@ impl Window { if fb.is_null() { return Err(OsError(format!("glx::ChooseFBConfig failed"))); } - let preferred_fb = *fb; // TODO: choose more wisely + + let preferred_fb = if builder.transparent { + let mut best_fbi_for_transparent = 0isize; + + for i in 0isize..num_fb as isize { + let vi = display.glx.as_ref().unwrap().GetVisualFromFBConfig(display.display as *mut _, *fb.offset(i)); + if (*vi).depth == 32 { + best_fbi_for_transparent = i; + break; + } + } + + *fb.offset(best_fbi_for_transparent) + } else { + *fb // TODO: choose more wisely + }; + (display.xlib.XFree)(fb as *mut _); preferred_fb }; @@ -425,11 +441,19 @@ impl Window { ffi::KeyReleaseMask | ffi::ButtonPressMask | ffi::ButtonReleaseMask | ffi::KeymapStateMask; swa.border_pixel = 0; + if builder.transparent { + swa.background_pixel = 0; + } swa.override_redirect = 0; swa }; let mut window_attributes = ffi::CWBorderPixel | ffi::CWColormap | ffi::CWEventMask; + + if builder.transparent { + window_attributes |= ffi::CWBackPixel; + } + if builder.monitor.is_some() { window_attributes |= ffi::CWOverrideRedirect; unsafe { |