-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Allow setting the browser's background color during attributes #197
Comments
I think we're following whatever is the standard on the |
if we allow setting the So I think we can do one of the following:
As to which format, winit has a unix specific struct called |
I see an |
@wusyong implemented a |
In macOS to set webview transparent we could use something like; let Color: id = msg_send![class!(NSColor), clearColor];
let () = msg_send![webview, setOpaque:NO];
let () = msg_send![webview, setBackgroundColor:Color]; We could write some helper for NSColor to use hex color by example so I don't see any issue for macOS. |
It's possible to set the background color on HTML already like this: |
I think it still |
Maybe it won't if we set transparent to the window and webview. |
This is kinda scary, having the window transparent all the time, can have some side effects. However we can set the webview to always be transparent and provide users with a method to change the window background. |
This doesn't work because there's 3 color stages
see my video on tauri-apps/tauri#1564 (comment) to see all 3. I think we can get 2 and 3 working fine enough, I'm not sure of a cross platform way of doing 1. The red flash will still happen with |
OS window can be styled too:
|
Could I take on this issue? |
Hmm this one is old. My stand is still we can make window and webview transparent and that's enough. People can always decide color on their html page |
I see. That's true. |
This is a nice to have feature and the code we use for transparent, can be slightly modified to also offer a way to set the color of the webview background so I don't see why wouldn't we offer this API also. |
I think this could also help with the white flashes when resizing, so that resizing the WebView doesn't look as laggy as it is. |
I just found the thread looking for answers to see if there is a setting to be changed for background color for webview or window.
It would be awesome if this could be implemented, and released later on. |
@Sid911 please open another issue for this or ask in our discord. |
I don't know if this is even possible to do, but I found Chromium's solution here:
Actual patch: https://codereview.chromium.org/296003010/patch/1/10001 Gist of the patch: create a second window using the CopyFromParent flag and using that for the draw context. When it comes to resizing, you sync on GL, then perform the resize, and then sync on X. It was brought up that this may not fix Wayland, but I was unable to reproduce the flicker they were describing on wayland (though I was using pixmap through xorg, so the issue may not have presented itself as a result). Whether this is even possible to do - whether in wry or tao - I have no idea. But worth documenting regardless. See https://discord.com/channels/616186924390023171/997615505223450624 for prior discussion on this. |
Is your feature request related to a problem? Please describe.
Allow the user to set a background color for the webview window to render while loading content. This is typically the step between the os window initializing the webview, and the webview initializing the application.
tauri-apps/tauri#1564 (my comment)
Describe the solution you'd like
Having a
background_color
field onwry::Attributes
(I think that is the proper place for it).I don't know which format we should accept the color in...
Describe alternatives you've considered
none yet
Would you assign yourself to implement this feature?
Additional context
The linux part seems easy enough once a format for accepting the color is decided on. Some pseudo-code to replace:
wry/src/webview/linux/mod.rs
Lines 138 to 146 in 765fe5a
with
assuming
bg_color
is some sort of struct with red, blue, green fields off64
.I assume webview2 and macOS has a way of setting the background color but I'm not familiar with them yet
The text was updated successfully, but these errors were encountered: