-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Workaround top area not clickable on MacOS fullscreen #7281
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
base: main
Are you sure you want to change the base?
Conversation
Preview available at https://egui-pr-preview.github.io/pr/7281-lucasfix-macos-fullscreen |
// Fix the top window area not being clickable on macOS when in fullscreen on an external display | ||
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280 | ||
#[cfg(all(target_os = "macos", not(feature = "accesskit")))] | ||
let viewport_builder = viewport_builder.with_visible(true); |
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.
Looks like this will cause a white flash on Windows again:
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.
It shouldn't, unless my cfg statement is wrong 😬
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.
Oh yeah 🤦
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.
Let's check that this actually fixes the Rerun issue before we merge this
.with_visible(false); // Start hidden until we render the first frame to fix white flash on startup (https://github.com/emilk/egui/pull/3631) | ||
|
||
// Fix the top window area not being clickable on macOS when in fullscreen on an external display | ||
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280 | ||
#[cfg(all(target_os = "macos", not(feature = "accesskit")))] | ||
let winit_window_builder = winit_window_builder.with_visible(true); |
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 tend to prefer the cfg!
macro, because I find it leads to easier-to-read code:
// Fix the top window area not being clickable on macOS when in fullscreen on an external display | ||
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280 | ||
#[cfg(all(target_os = "macos", not(feature = "accesskit")))] | ||
let viewport_builder = viewport_builder.with_visible(true); |
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 can make a reusable function for this that better explain the if-and-why of it:
fn start_visible() {
if cfg!(feature = "accesskit") {
true // accesskit requires this: $LINK
} else if cfg!(windows) {
true // Fixes white flash on startup (https://github.com/emilk/egui/pull/3631)
} else if cfg!(target_os = "macos") {
// Fix the top window area not being clickable on macOS when in fullscreen on an external display
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280
false
} else {
true // no known preference one way or the other
}
}
Unfortunately this only works when the accesskit feature is disabled, since accesskit requires the window to be hidden on first frame.
To test:
cargo run -p egui_demo_app --no-default-features --features glow
should work andcargo run -p egui_demo_app
should not work