-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
eframe: Native option mouse_passthrough makes window invisible #2537
Comments
This ... appears to be a
A call to the IMHO, this should be reported upstream to edit: I used to have a section claiming it "works for me" on Windows 11. But this is not true. I missed the point about making a change to the minimal repro to actually reproduce the problem. Yes, it's a reproducible problem. But the repro code doesn't reproduce the problem as-is. |
I'll report it to winit then, thank you. Also changed the code to avoid the confusion. |
Thanks for fixing the minimal repro! Could you also link back to this issue when you create the upstream one? |
Current observation is that using set_cursor_hittest(false) while window in set_visible(false) breaks it. |
Is there a workaround to this currently? I tried to set visible to true on the frame in my app but it still doesn't render anything. It would seem that I need to access the native window creation itself to do fix this manually (not sure). One way I imagine is to manually get a handle to the window (in windows) and pass the correct options. Edit: I developed a work around specific for windows. I use the windows api functions EnumWindows and SetLayeredWindowAttributes to make the window appear again. First I get the window handle through the EnumWindows, searching for the correct window name and then call Here is my EnumWindows callback code for someone who also wants to get around this (using windows crate but winapi is identical or even more trivial): extern "system" fn enum_win(hwnd: HWND, mut lparam: LPARAM) -> BOOL {
let mut class_name = [0u16; 256];
unsafe { GetWindowTextW(hwnd, &mut class_name) };
let class_name = String::from_utf16_lossy(&class_name[..6 as usize]);
println!("class_name: {}", class_name);
let parameter = unsafe {std::mem::transmute::<LPARAM, &mut LPARAM>(lparam)};
if class_name == "name" {
println!("Found window: {}, {}", hwnd.0, class_name);
(*parameter).0 = hwnd.0;
return BOOL(0)
}
return BOOL(1)
} Nonetheless, the bug remains to be fixed as it completely removes the mouse_passthrough functionality. |
For myself I worked around it in eframe. if self.native_options.mouse_passthrough {
gl_window.window().set_cursor_hittest(false).unwrap();
} from integration.post_present(window);
window.set_cursor_hittest(!self.native_options.mouse_passthrough).unwrap();
|
Is there any update on this issue or rather a cleaner way of approaching patching the package? |
if the mentioned "workaround" of @Skrity is the fix, why this isn't merged yet? |
I cant quite seem to re-create your workaround, do you have a fork of this change? |
Is this still a problem on latest |
For some reason, I didn't think to check against master, and instead tried checking only the crates version. That's on me! If there is any work that needs to be done relating to this, I'd love to help, such as an example overlay program maybe? I'm mostly new to this though. 😄 Edit: After using what is current on master branch, the only thing I found that was a little unpleasant was that egui/crates/eframe/src/epi.rs clear_color(&egui::Visuals) only using the hard coded value, is there a reason? Because the function even has a comment. |
Hey, is there any progress on this? I know it's only been an issue for around one and a half years and it is a breaking bug, but shouldn't this get some patch here maybe if upstream isn't doing anything about it? I suggest a temporary feature flag that fixes this locally and can be removed later. |
And besides your code being not a general workaround, it's also just bad. I'd just recommend implementing something similar to this post: https://stackoverflow.com/a/2620522 static INIT_WINDOW_VISIBILITY_FIX: Once = Once::new();
pub fn init_window_visibility_fix() {
INIT_WINDOW_VISIBILITY_FIX.call_once(|| {
if let Err(e) = fix_window_visibility() {
log::error!("Failed to fix window visibility: {:?}", e);
}
});
}
fn fix_window_visibility() -> windows::core::Result<()> {
unsafe { EnumWindows(Some(enum_window_proc), LPARAM(0)) }
}
extern "system" fn enum_window_proc(hwnd: HWND, _: LPARAM) -> BOOL {
let mut class_name_buffer = [0u16; MAX_PATH as usize];
unsafe {
let mut process_id: u32 = 0;
GetWindowThreadProcessId(hwnd, Some(&mut process_id));
if process_id == GetCurrentProcessId() {
if GetWindowTextW(hwnd, &mut class_name_buffer) == 0 {
return TRUE;
}
let _ = SetLayeredWindowAttributes(hwnd, COLORREF(0), 255, LWA_ALPHA);
}
}
TRUE
} I just hope someone pushes some fixes to winit at some point |
You could be that someone! |
bruh, simple work around is call on startup |
and window is visible and passthrough |
Describe the bug
When using mouse_passthrough native option the window is entirely transparent, it only shows in task bar and task view as a black box.
Also reproducible on master.
To Reproduce
Steps to reproduce the behavior:
main.rs
cargo.toml
Expected behavior
Window will be visible, but cannot be interacted with.
Screenshots
Nothing to screenshot normally, but here's
screenshot of task view
Desktop (please complete the following information):
Additional context
The original issue is here
There were also a report of this problem
The text was updated successfully, but these errors were encountered: