Description
use eframe::egui;
use std::time::{Duration, Instant};
struct TestApp {
start_time: Instant,
window_shown: bool,
}
impl TestApp {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
cc.egui_ctx
.send_viewport_cmd(egui::ViewportCommand::Visible(false));
Self {
start_time: Instant::now(),
window_shown: false,
}
}
}
impl eframe::App for TestApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
let ctx = ui.ctx().clone();
if !self.window_shown {
ctx.request_repaint();
ctx.send_viewport_cmd(egui::ViewportCommand::Visible(false));
if self.start_time.elapsed() >= Duration::from_secs(2) {
println!("[TestApp] 2 seconds elapsed! Sending ViewportCommand::Visible(true)");
ctx.send_viewport_cmd(egui::ViewportCommand::Visible(true));
self.window_shown = true;
}
}
ui.heading("Hidden Window Test App");
ui.label(format!(
"Elapsed time since launch: {:.2} seconds",
self.start_time.elapsed().as_secs_f64()
));
if self.window_shown {
ui.label("Status: Window is now VISIBLE!");
} else {
ui.label("Status: Window is currently HIDDEN...");
}
}
}
fn main() -> Result<(), eframe::Error> {
let mut viewport = egui::ViewportBuilder::default()
.with_title("Hidden Window Test")
.with_inner_size([400.0, 300.0])
.with_visible(false);
let options = eframe::NativeOptions {
viewport,
..Default::default()
};
eframe::run_native(
"Hidden Window Test",
options,
Box::new(|cc| Ok(Box::new(TestApp::new(cc)))),
)
}
Here is the simplest code to replicate this bug
btw this is crate I am using
egui = { version = "0.34.1", default-features = false, features = ["default_fonts"] }
eframe = { version = "0.34.1", default-features = false, features = ["wgpu_no_default_features", "persistence"] }
wgpu = { version = "29.0.1", default-features = false, features = ["vulkan"] }
Windows version
Winit version
v0.30.13
Description
Here is the simplest code to replicate this bug
btw this is crate I am using
Windows version
Winit version
v0.30.13