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
feat: support Mica/Acrylic on Windows #38163
Conversation
I can't believe you did this in like 30 LoC, this is so much simpler than I thought it would have been. |
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.
How does this feature work together with our custom titlebar implementation where we basically extend into the non-client area ?
#if BUILDFLAG(IS_WIN) | ||
// DWMWA_USE_HOSTBACKDROPBRUSH is only supported on Windows 11 22H2 and up. | ||
if (base::win::GetVersion() < base::win::Version::WIN11_22H2) | ||
return; |
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.
Should this surface an error to the user rather than silent termination ?
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.
We don't for comparable version-gated features like this - historically it's just been clearly noted in docs.
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.
I think silently failing is fine here
DwmSetWindowAttribute(GetAcceleratedWidget(), DWMWA_SYSTEMBACKDROP_TYPE, | ||
&backdrop_type, sizeof(backdrop_type)); | ||
if (FAILED(result)) | ||
LOG(WARNING) << "Failed to set background material to " << material; |
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.
User facing error instead of LOG ?
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.
I'm also open to that, but we don't have a clear convention there either really 🤔 for dark mode for example we don't surface a user facing error:
electron/shell/browser/win/dark_mode.cc
Line 57 in 5d12035
TrySetWindowTheme(hWnd, dark); |
Beyond that - we don't really get a good error message from the call sadly, so all we'd really be able to say is "it failed"
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.
Because we set this in the constructor we can't safely have a user facing error afaik anyway. I think the LOG is fine here. We shouldn't fail to construct a window just because the DWM call got lost
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.
API LGTM
ada14f1
to
d5c4d44
Compare
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.
API LGTM
Release Notes Persisted
|
I was unable to backport this PR to "24-x-y" cleanly; |
I was unable to backport this PR to "25-x-y" cleanly; |
@codebytere has manually backported this PR to "25-x-y", please check out #38357 |
@codebytere has manually backported this PR to "24-x-y", please check out #38361 |
@codebytere Is this the intended behavior? The effect only applies to the title bar? |
Interesting, with Glasstron this was a bug, not sure if that is suppose to happen. |
|
So sorry for all you that are suscribed but this is SO cool! I'm surprised how little lines it takes to do something like this |
Having the same issue. Is this expected? Is it possible to apply also Mica to the web content background? |
Have you tried with |
Yes, I’ve tried all 4 combinations on both Here’s my Electron Fiddle code to repro this: https://gist.github.com/blueset/b406e2d1bd9218a16b599e72a3ee82c7 |
@blueset @michalzaq12 I had the same issue, but it worked when I added |
Setting |
I confirm, same problem. |
just bump into the same issue. |
bump, also happening to me |
Description of Change
Supersedes #30298.
Closes #16391.
Closes #29937.
Adds support for background material effects on Windows with
win.setBackgroundMaterial(material)
.Checklist
npm test
passesRelease Notes
Notes: Add support for Mica and Acrylic background effects on Windows.