-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Add transparent windows support on Windows #1250
base: main
Are you sure you want to change the base?
Conversation
Hello @ArcticFqx thanks so much for sending this pull request. Please ignore CI test failures (There is an issue with the Windows test suite). I'll merge this soon 🎉 |
@@ -881,7 +881,7 @@ class win32_edge_engine { | |||
}); | |||
RegisterClassEx(&wc); | |||
m_window = CreateWindow(L"Neutralinojs_webview", L"", WS_OVERLAPPEDWINDOW, 99999999, | |||
CW_USEDEFAULT, 640, 480, nullptr, nullptr, | |||
CW_USEDEFAULT, 8000, 8000, nullptr, nullptr, |
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.
Is it necessary to make the window so large?
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.
Yes. There is something about this in the description of the Pull Request.
There was an issue otherwise.
(Its not actually that big tho)
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 issue may stem from creating the window as WS_OVERLAPPEDWINDOW
see Win32 docs.
It may be worthwhile to call CreateWindowEx
instead like so:
m_window = CreateWindowEx(WS_EX_LAYERED, L"Neutralinojs_webview", L"", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, nullptr, nullptr,
GetModuleHandle(nullptr), nullptr);
and then enable transparency via SetLayeredWindowAttributes(m_window, 0, XXX, LWA_ALPHA);
where XXX
is the alpha value.
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.
Yeah, that does work for the entire window and it keeps the resizing behavior consistent, but this also affects the transparency of the webview content, which I think we don't want to happen as we want to control that with CSS instead.
It's a good start though, it's half of a better solution than my proposed PR. We have to be a little clever if we want to keep the window itself transparent, but not the webview.
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.
Hmm, would changing
SetEnvironmentVariable(L"WEBVIEW2_DEFAULT_BACKGROUND_COLOR", L"00FFFFFF");
to
SetEnvironmentVariable(L"WEBVIEW2_DEFAULT_BACKGROUND_COLOR", L"FFFFFFFF");
prevent the webview from becoming 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.
Yes, the format for that string is AARRGGBB.
Hey! @ArcticFqx, |
I used Windows 11 and it worked. |
can you share a screenshot? |
@Sadaf-A here: (I am on Windows 11 23H2 |
Hey, thanks for sharing the screenshot are you able to move the window and close it? |
Unfortunately no :( I would have wished that too. But apparently it has to be borderless. (I guess that`s still the case?) |
I am using Windows 11
As mentioned in the second bullet point, the window is in effect borderless, you need to create a custom titlebar. You can use this if you need to move the window https://neutralino.js.org/docs/api/window#windowsetdraggableregiondomid |
Is there some other requirement that I'm missing in this PR? I don't really have the other platforms to compare too. |
I think the only issue is that even after the borderless property is set to false the window is coming out to be borderless |
Description
This enables support for transparent windows on Windows.
Resolves #1201.
Changes proposed
WEBVIEW2_DEFAULT_BACKGROUND_COLOR
environment variable to make the WebView2 background transparent white.How to test it
Set
"transparent": true
inneutralino.config.json
.