From 6633ecce64ed3183ee121a6285116fa227dddea2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 12 Aug 2023 13:50:31 +0200 Subject: [PATCH] Fix wrong detection of OS (#3238) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 😬 --- crates/eframe/src/native/run.rs | 14 +++++++------- crates/egui_glium/examples/native_texture.rs | 4 ++-- crates/egui_glium/examples/pure_glium.rs | 4 ++-- crates/egui_glow/examples/pure_glow.rs | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 00bc23bac3c..bd084a50129 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -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() @@ -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(); @@ -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(); @@ -270,11 +270,11 @@ fn run_and_exit(event_loop: EventLoop, 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() } @@ -302,7 +302,7 @@ fn run_and_exit(event_loop: EventLoop, 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(); diff --git a/crates/egui_glium/examples/native_texture.rs b/crates/egui_glium/examples/native_texture.rs index 19e4eaec6af..b19b08f0cef 100644 --- a/crates/egui_glium/examples/native_texture.rs +++ b/crates/egui_glium/examples/native_texture.rs @@ -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; diff --git a/crates/egui_glium/examples/pure_glium.rs b/crates/egui_glium/examples/pure_glium.rs index dc7ad58f09e..801f7b1457b 100644 --- a/crates/egui_glium/examples/pure_glium.rs +++ b/crates/egui_glium/examples/pure_glium.rs @@ -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; diff --git a/crates/egui_glow/examples/pure_glow.rs b/crates/egui_glow/examples/pure_glow.rs index 10466048898..008c3dad32b 100644 --- a/crates/egui_glow/examples/pure_glow.rs +++ b/crates/egui_glow/examples/pure_glow.rs @@ -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;