From 4e3ee9c9d61ff1e05a7881c92d4414a2ae1da784 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 15 Jul 2025 11:03:12 +1200 Subject: Fix window not being made visible when input device is accessed This is for when the emulator is started in dynamic mode. Reading from the input device wasn't making the window visible, because the break signal was only being fired when writing to the input device. --- src/emulators/graphical_emulator.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/emulators/graphical_emulator.rs b/src/emulators/graphical_emulator.rs index a4b07e5..7e75b61 100644 --- a/src/emulators/graphical_emulator.rs +++ b/src/emulators/graphical_emulator.rs @@ -9,6 +9,7 @@ pub struct GraphicalEmulator { pub gilrs: Option, pub fullscreen: bool, + pub visible: bool, pub scale: u32, pub render_mark: Instant, // last time screen was rendered pub frame_mark: Instant, // refreshes when clean @@ -37,6 +38,7 @@ impl GraphicalEmulator { render_mark: Instant::now(), frame_mark: Instant::now(), config, + visible: false, } } @@ -44,7 +46,8 @@ impl GraphicalEmulator { self.br.core.mem.load_program(bytecode); } - pub fn run(self, mut phosphor: Phosphor, visible: bool) { + pub fn run(mut self, mut phosphor: Phosphor, visible: bool) { + self.visible = visible; let window = WindowBuilder { dimensions: Some(self.dimensions()), size_bounds: Some(self.size_bounds()), @@ -59,7 +62,6 @@ impl GraphicalEmulator { program: Box::new(self), visible, }; - phosphor.add_window(window); phosphor.run().unwrap(); } @@ -233,9 +235,6 @@ impl WindowProgram for GraphicalEmulator { if let Some(signal) = self.br.evaluate(BATCH_SIZE, self.debug.enabled) { match signal { Signal::Break => { - if self.br.dev.input.accessed || self.br.dev.screen.accessed { - requests.write(Request::SetVisible(true)); - } } Signal::Fork | Signal::Reset => { self.br.reset(); @@ -260,6 +259,13 @@ impl WindowProgram for GraphicalEmulator { } } + if !self.visible { + if self.br.dev.input.accessed || self.br.dev.screen.accessed { + requests.write(Request::SetVisible(true)); + self.visible = true; + } + } + if std::mem::take(&mut self.br.dev.screen.dirty_dimensions) { requests.write(Request::SetSizeBounds(self.size_bounds())); } -- cgit v1.2.3-70-g09d2