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 no longer get fully transparent background with winit v0.24.0 #1814

Closed
dotdash opened this issue Dec 31, 2020 · 1 comment · Fixed by #1815
Closed

Windows no longer get fully transparent background with winit v0.24.0 #1814

dotdash opened this issue Dec 31, 2020 · 1 comment · Fixed by #1815
Labels
B - bug Dang, that shouldn't have happened DS - windows

Comments

@dotdash
Copy link
Contributor

dotdash commented Dec 31, 2020

I have a small toy program that uses OpenGL (via glutin) in a non-decorated, transparent window to display some graphics. Starting with v0.24.0 the windows is no longer fully transparent. In the image below, the left side is with winit 0.23, and the right side with 0.24.

transparency_bug

I identified #1621 as the culprit, reverting this commit fixes the issue for me, but I don't know Windows well enough to know why that is.

@maroider
Copy link
Member

maroider commented Jan 3, 2021

I've reproduced this with the transparent example.

@msiglreith msiglreith added DS - windows B - bug Dang, that shouldn't have happened labels Jan 4, 2021
msiglreith pushed a commit that referenced this issue Feb 17, 2021
* Restore the ability to have fully transparent windows on Windows

Besides its original purpose, commit 6343059 "Fix Windows transparency
behavior to support fully-opaque regions (#1621)" also included some
changes considered cleanups, one of them was:

* Remove the `CreateRectRgn` call, since we want the entire window's region to
  have blur behind it, and `DwnEnableBlurBehindWindow` does that by default.

But the original code actually disabled the blur effect for the whole
window by creating an empty region for it, because that allows for the
window to be truely fully transparent. With the blur effect in place,
the areas meant to be transparent either blur the things behind it
(until Windows 8) or are darkened (since Windows 8). This also means
that on Windows 8 and newer, the resulting colors are darker than
intended in translucent areas when the blur effect is enabled.

This restores the behaviour from winit <0.24 and fixes #1814.

Arguably, one might want to expose the ability to control the blur
region, but that is outside the scope of this commit.

* Remove useless WS_EX_LAYERED from transparent windows on Windows

`WS_EX_LAYERED` is not supposed to be used in combination with
`CS_OWNDC`. In winit, as it is currently used, `WS_EX_LAYERED` actually
has no effect at all. The only relevant call is to
`SetLayeredWindowAttributes`, which is required to make the window
visible at all with `WS_EX_LAYERED` set, but is called with full
opacity, i.e. there's no transparency involved at all.

The actual transparency is already achieved by using
`DwmEnableBlurBehindWindow`, so `WS_EX_LAYERED` and the call to
`SetLayeredWindowAttributes` can both be removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - windows
Development

Successfully merging a pull request may close this issue.

3 participants