Skip to content

Commit

Permalink
Fix wrong detection of OS (#3238)
Browse files Browse the repository at this point in the history
We had a bunch of `cfg!(windows)` and `cfg!(macos)` which should
have been `cfg!(target_os = "windows")`.

I wonder what the effects of this PR will be fore Windows 😬
  • Loading branch information
emilk authored Aug 12, 2023
1 parent 9808702 commit 6633ecc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ fn run_and_return(
// Platform-dependent event handlers to workaround a winit bug
// See: https://github.com/rust-windowing/winit/issues/987
// See: https://github.com/rust-windowing/winit/issues/1619
#[cfg(windows)]
#[cfg(target_os = "windows")]
winit::event::Event::RedrawEventsCleared => {
next_repaint_time = extremely_far_future();
winit_app.run_ui_and_paint()
}
#[cfg(not(windows))]
#[cfg(not(target_os = "windows"))]
winit::event::Event::RedrawRequested(_) => {
next_repaint_time = extremely_far_future();
winit_app.run_ui_and_paint()
Expand Down Expand Up @@ -196,7 +196,7 @@ fn run_and_return(
EventResult::Wait => {}
EventResult::RepaintNow => {
log::trace!("Repaint caused by winit::Event: {:?}", event);
if cfg!(windows) {
if cfg!(target_os = "windows") {
// Fix flickering on Windows, see https://github.com/emilk/egui/pull/2280
next_repaint_time = extremely_far_future();
winit_app.run_ui_and_paint();
Expand Down Expand Up @@ -245,7 +245,7 @@ fn run_and_return(
//
// Note that this approach may cause issues on macOS (emilk/egui#2768); therefore,
// we only apply this approach on Windows to minimize the affect.
#[cfg(windows)]
#[cfg(target_os = "windows")]
{
event_loop.run_return(|_, _, control_flow| {
control_flow.set_exit();
Expand All @@ -270,11 +270,11 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
// Platform-dependent event handlers to workaround a winit bug
// See: https://github.com/rust-windowing/winit/issues/987
// See: https://github.com/rust-windowing/winit/issues/1619
winit::event::Event::RedrawEventsCleared if cfg!(windows) => {
winit::event::Event::RedrawEventsCleared if cfg!(target_os = "windows") => {
next_repaint_time = extremely_far_future();
winit_app.run_ui_and_paint()
}
winit::event::Event::RedrawRequested(_) if !cfg!(windows) => {
winit::event::Event::RedrawRequested(_) if !cfg!(target_os = "windows") => {
next_repaint_time = extremely_far_future();
winit_app.run_ui_and_paint()
}
Expand Down Expand Up @@ -302,7 +302,7 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
match event_result {
EventResult::Wait => {}
EventResult::RepaintNow => {
if cfg!(windows) {
if cfg!(target_os = "windows") {
// Fix flickering on Windows, see https://github.com/emilk/egui/pull/2280
next_repaint_time = extremely_far_future();
winit_app.run_ui_and_paint();
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_glium/examples/native_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ fn main() {
// Platform-dependent event handlers to workaround a winit bug
// See: https://github.com/rust-windowing/winit/issues/987
// See: https://github.com/rust-windowing/winit/issues/1619
glutin::event::Event::RedrawEventsCleared if cfg!(windows) => redraw(),
glutin::event::Event::RedrawRequested(_) if !cfg!(windows) => redraw(),
glutin::event::Event::RedrawEventsCleared if cfg!(target_os = "windows") => redraw(),
glutin::event::Event::RedrawRequested(_) if !cfg!(target_os = "windows") => redraw(),

glutin::event::Event::WindowEvent { event, .. } => {
use glutin::event::WindowEvent;
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_glium/examples/pure_glium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn main() {
// Platform-dependent event handlers to workaround a winit bug
// See: https://github.com/rust-windowing/winit/issues/987
// See: https://github.com/rust-windowing/winit/issues/1619
glutin::event::Event::RedrawEventsCleared if cfg!(windows) => redraw(),
glutin::event::Event::RedrawRequested(_) if !cfg!(windows) => redraw(),
glutin::event::Event::RedrawEventsCleared if cfg!(target_os = "windows") => redraw(),
glutin::event::Event::RedrawRequested(_) if !cfg!(target_os = "windows") => redraw(),

glutin::event::Event::WindowEvent { event, .. } => {
use glutin::event::WindowEvent;
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_glow/examples/pure_glow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ fn main() {
// Platform-dependent event handlers to workaround a winit bug
// See: https://github.com/rust-windowing/winit/issues/987
// See: https://github.com/rust-windowing/winit/issues/1619
winit::event::Event::RedrawEventsCleared if cfg!(windows) => redraw(),
winit::event::Event::RedrawRequested(_) if !cfg!(windows) => redraw(),
winit::event::Event::RedrawEventsCleared if cfg!(target_os = "windows") => redraw(),
winit::event::Event::RedrawRequested(_) if !cfg!(target_os = "windows") => redraw(),

winit::event::Event::WindowEvent { event, .. } => {
use winit::event::WindowEvent;
Expand Down

0 comments on commit 6633ecc

Please sign in to comment.