Skip to content
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

Merged
merged 5 commits into from
Oct 18, 2018
Merged

Conversation

subnomo
Copy link
Contributor

@subnomo subnomo commented Oct 14, 2018

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users

Fixed 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.

Copy link
Member

@francesca64 francesca64 left a 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.

fEnable: 1,
hRgnBlur: ptr::null_mut(),
hRgnBlur: CreateRectRgn(0, 0, -1, -1), // makes the window transparent
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch.

// the window is rendered properly.
let opacity = 254;

winuser::SetLayeredWindowAttributes(real_window.0, 0x0030c100, opacity, winuser::LWA_ALPHA);
Copy link
Member

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.

@@ -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;
Copy link
Member

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.

src/platform/windows/window.rs Show resolved Hide resolved
@subnomo
Copy link
Contributor Author

subnomo commented Oct 15, 2018

@francesca64 Done!

@francesca64
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants