diff --git a/services/gam/src/contexts.rs b/services/gam/src/contexts.rs index b50647c3d..ccf9c176d 100644 --- a/services/gam/src/contexts.rs +++ b/services/gam/src/contexts.rs @@ -364,6 +364,7 @@ impl ContextManager { } else if // app covering an app (context.layout.behavior() == LayoutBehavior::App) && (leaving_focused_context.layout.behavior() == LayoutBehavior::App) { + log::debug!("resolved: app covering app"); context.layout.set_visibility_state(true, canvases); leaving_visibility = false; self.context_stack.pop(); @@ -371,16 +372,25 @@ impl ContextManager { } else if // alert covering an app (context.layout.behavior() == LayoutBehavior::Alert) && (leaving_focused_context.layout.behavior() == LayoutBehavior::App) { + log::debug!("resolved: alert covering app"); context.layout.set_visibility_state(true, canvases); leaving_visibility = true; self.context_stack.push(token); } else if // app covering an alert (context.layout.behavior() == LayoutBehavior::App) && (leaving_focused_context.layout.behavior() == LayoutBehavior::Alert) { + log::debug!("resolved: app covering alert"); context.layout.set_visibility_state(true, canvases); leaving_visibility = false; self.context_stack.pop(); } + } else { + log::warn!("resolved: staying in same context. This is not an expected case."); + // this path "shouldn't" happen because the discipline is that every pop-up must + // return control back to the main thread (you can't chain pop-ups). + // thus, kick out a warning if this happens, but also, try to do something reasonable. + self.redraw().expect("couldn't redraw the currently focused app"); + return Ok(()); } } else { // there was no current focus, just make the activation visible diff --git a/services/modals/src/main.rs b/services/modals/src/main.rs index 539a0423b..acebddbf6 100644 --- a/services/modals/src/main.rs +++ b/services/modals/src/main.rs @@ -156,6 +156,7 @@ fn wrapped_main() -> ! { let mut work_queue = Vec::<(xous::MessageSender, [u32; 4])>::new(); let mut dynamic_notification_listener: Option = None; + let mut dynamic_notification_active: bool = false; loop { let mut msg = xous::receive_message(modals_sid).unwrap(); @@ -660,6 +661,10 @@ fn wrapped_main() -> ! { renderer_modal.activate(); } RendererState::RunDynamicNotification(config) => { + if dynamic_notification_active { + log::error!("Dynamic notification already active! Double-calls lead to unpredictable results"); + } + dynamic_notification_active = true; let mut top_text = String::new(); if let Some(title) = config.title { #[cfg(feature = "tts")] @@ -687,6 +692,7 @@ fn wrapped_main() -> ! { Some(DEFAULT_STYLE), ); renderer_modal.activate(); + xous::yield_slice(); } RendererState::None => { log::error!( @@ -744,6 +750,7 @@ fn wrapped_main() -> ! { }, Some(Opcode::DoCloseDynamicNotification) => { renderer_modal.gam.relinquish_focus().unwrap(); + dynamic_notification_active = false; op = RendererState::None; if let Some(sender) = dynamic_notification_listener.take() { // unblock the listener with no key hit response