-
Notifications
You must be signed in to change notification settings - Fork 926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows: Fix transparency #675
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great! Besides what I've commented on, you also need a CHANGELOG entry.
src/platform/windows/window.rs
Outdated
fEnable: 1, | ||
hRgnBlur: ptr::null_mut(), | ||
hRgnBlur: CreateRectRgn(0, 0, -1, -1), // makes the window transparent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to manually free this region using DeleteObject
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good catch.
src/platform/windows/window.rs
Outdated
// the window is rendered properly. | ||
let opacity = 254; | ||
|
||
winuser::SetLayeredWindowAttributes(real_window.0, 0x0030c100, opacity, winuser::LWA_ALPHA); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meaning of the 0x0030c100
constant should be documented.
src/platform/windows/window.rs
Outdated
@@ -14,6 +14,7 @@ use winapi::um::{combaseapi, dwmapi, libloaderapi, winuser}; | |||
use winapi::um::objbase::COINIT_MULTITHREADED; | |||
use winapi::um::shobjidl_core::{CLSID_TaskbarList, ITaskbarList2}; | |||
use winapi::um::winnt::{LONG, LPCWSTR}; | |||
use winapi::um::wingdi::CreateRectRgn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since wingdi
is alphabetically before winnt
, this import should be before it.
@francesca64 Done! |
Thanks! |
CHANGELOG.md
if knowledge of this change could be valuable to usersFixed transparency in Windows 10 (#260). It also works with window decorations, by using
WS_EX_LAYERED
. Tested with the transparency example on my Windows 10 machine.