diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-07-15 11:03:12 +1200 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-07-15 11:03:12 +1200 |
commit | 4e3ee9c9d61ff1e05a7881c92d4414a2ae1da784 (patch) | |
tree | 307ba66b6123d7c3946d3a94214aa7ecca4d1ee5 | |
parent | 322ac023aa42662d4c592eb1789d62a9140f9ca4 (diff) | |
download | bedrock-pc-4e3ee9c9d61ff1e05a7881c92d4414a2ae1da784.zip |
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.
-rw-r--r-- | src/emulators/graphical_emulator.rs | 16 |
1 files 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<Gilrs>, 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())); } |