-
Notifications
You must be signed in to change notification settings - Fork 920
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
Transparent example not working #2502
Comments
Ok I think I have a fix, but I'm not sure if it will really do the job. I think you just have to insert this in
Note you won't want to use the |
thanks for the report. It should work fine when actually drawing something onto the window surface, which the examples don't do. |
However this would be an overhead for apps that don't need to draw the window surface, for example when using Webview2. Transparency used to work out of the box for undecorated windows before #1933 . I really don't know what caused the regression or if it can be fixed but it is the reason why I kept TAO (the winit fork for WRY) using subclasses. This could also be a blocker for us to migrate back to using winit directly. Edit: Seems it is indeed #2419 not #1933, I thought it was #1933 because at the time I was testing it along with #1891 which is similar to #2419 |
I might be not understand how transparency works on windows, but aren't you required to provide a buffer with alpha value in the end? Is it just blending with black background now if you draw into subview(not sure how that called on windows, but that's my understanding of what happens). You might just clear it with fully transparent color it or do something like. |
Webview2 works a bit differently. I don't remember the correct term for it but it is a sort of a child window which has its own window surface.
Also this was an overstatement from me, I think I wanted to say it will be a minor setback. |
In general if you don't feel the root window with something it could contain random data leading to graphical artifacts. Conveniently some GPU drivers do clear the buffer with zeros for you, so you have some sort of initialized thingy, but it's not always the case and on linux users can disable that for example leading you to blending with random data. I'm not an expert here, but you should always explicitly initialize the buffers you blend against. |
Window transparency is broken on Macos as well. |
I'm not sure what are you talking about, transparency works just fine on all the available backends, only example is broken, nothing more. Real code with e.g. OpenGL is not affected. |
The transparent example also does not work on macos. I dug a little bit, and I believe the bug is with the platform_impl/window.rs where the code is using the setOpaque method of NSWindow. As far as I can tell, this method is deprecated and no longer exists, and the NSWindow API created using objc2 crate is out of date. |
You mean that using with_transparent will not work but using openGL on the context directly will? |
idk, just run https://github.com/rust-windowing/glutin example from here, it's transparent. There's also alacritty which uses |
Nope, that would've thrown an error. It only does that if the receiver/window is NULL. |
@ericguedespinto Do you have a minimal reproducible example for the MacOS behavior? If yes, could you open a new issue for that? If not, could you try out #3048 ? |
are any workarounds available? Transparency also is not working for me as well. |
having the same issue here, reported to RioTerm as well: raphamorim/rio#361 |
Could you provide some more guidance? |
can confirm the glutin example works for me from their readme:
can correctly see my web browser through the transparent window
|
You might have to check your NVIDIA driver settings in case some presentation compatibility has been set. |
Is there any solution at present? |
This has been fixed? Just set the alpha channel of color Tested with v0.30.5 on Windows11: use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::window::{Window, WindowId};
#[path = "util/fill.rs"]
mod fill;
#[derive(Default)]
struct State {
window: Option<Window>,
}
impl ApplicationHandler for State {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let attributes = Window::default_attributes().with_transparent(true);
self.window = Some(event_loop.create_window(attributes).unwrap());
}
fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
_window_id: WindowId,
event: WindowEvent,
) {
let window = self.window.as_ref().unwrap();
match event {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::RedrawRequested => {
fill::fill_window(&window);
},
_ => (),
}
}
}
fn main() {
let event_loop = EventLoop::new().unwrap();
let mut state = State::default();
let _ = event_loop.run_app(&mut state);
} |
Cannot confirm, this transparency example does not work for me.
|
I'm pretty sure softbuffer doesn't handle alpha channel, but generally has nothing to do with e.g. winit. Try |
Can confirm that the glutin example works for me #2502 (comment) |
Then it works, since glutin explicitly draws transparent content. |
Weird... |
When I run
cargo run --example transparent
instead of a transparent window I just get a white window with no decorations.It seems the problem was introduced in this PR:
#2419
If I revert to a commit before that PR was merged, then I see no GUI window showing up at all which I believe is the intended result (I see the icon in the taskbar and it appears in the alt+tab window list).
When I run the transparent example on the latest commit I just get a white window (with the expected icon in the taskbar)
I am running Windows 10.
The text was updated successfully, but these errors were encountered: