Skip to content

Windows: Fix transparency - #675

Merged
francesca64 merged 5 commits into
rust-windowing:masterfrom
subnomo:master
Oct 18, 2018
Merged

francesca64 merged 5 commits into
rust-windowing:masterfrom
subnomo:master

Conversation

@subnomo

@subnomo subnomo commented Oct 14, 2018 •

Copy link
Copy Markdown
Contributor
  • 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.

@francesca64 francesca64 added the DS - win32 Affects the Win32/Windows backend label Oct 14, 2018

@francesca64 francesca64 left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/platform/windows/window.rs Outdated
dwFlags: dwmapi::DWM_BB_ENABLE | dwmapi::DWM_BB_BLURREGION,
fEnable: 1,
hRgnBlur: ptr::null_mut(),
hRgnBlur: CreateRectRgn(0, 0, -1, -1), // makes the window transparent

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/platform/windows/window.rs Outdated
// the window is rendered properly.
let opacity = 254;

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

Copy link
Copy Markdown
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.

Comment thread src/platform/windows/window.rs Outdated
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
Copy Markdown
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.

Comment thread src/platform/windows/window.rs Resolved
@subnomo

subnomo commented Oct 15, 2018

Copy link
Copy Markdown
Contributor Author

@francesca64 Done!

@francesca64

Copy link
Copy Markdown
Member

Thanks!

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

Labels

DS - win32 Affects the Win32/Windows backend

Development

Successfully merging this pull request may close these issues.

2 participants