wayvr overlay removal

This commit is contained in:
galister
2025-12-26 13:19:57 +09:00
parent 771ade368c
commit dc6d03605f
4 changed files with 21 additions and 3 deletions

View File

@@ -353,10 +353,11 @@ impl WayVR {
continue; continue;
}; };
if let Some(oid) = self.state.window_to_overlay.get(&window_handle) { if let Some(oid) = self.state.window_to_overlay.remove(&window_handle) {
app.tasks.enqueue(TaskType::Overlay(OverlayTask::Drop( app.tasks.enqueue(TaskType::Overlay(OverlayTask::Drop(
OverlaySelector::Id(*oid), OverlaySelector::Id(oid),
))); )));
self.state.overlay_to_window.remove(oid);
} }
self.state.wm.remove_window(window_handle); self.state.wm.remove_window(window_handle);
@@ -389,6 +390,11 @@ impl WayVR {
.tasks .tasks
.send(WayVRTask::ProcessTerminationRequest(process_handle)); .send(WayVRTask::ProcessTerminationRequest(process_handle));
} }
pub fn overlay_added(&mut self, oid: OverlayID, window: window::WindowHandle) {
self.state.overlay_to_window.insert(oid, window);
self.state.window_to_overlay.insert(window, oid);
}
} }
impl WayVRState { impl WayVRState {

View File

@@ -226,8 +226,12 @@ impl OverlayBackend for WayVRBackend {
fn notify( fn notify(
&mut self, &mut self,
_app: &mut state::AppState, _app: &mut state::AppState,
_event_data: OverlayEventData, event_data: OverlayEventData,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
if let OverlayEventData::IdAssigned(oid) = event_data {
let wayvr = &mut self.wayvr.borrow_mut().data;
wayvr.overlay_added(oid, self.window.clone());
}
Ok(()) Ok(())
} }

View File

@@ -115,6 +115,8 @@ pub struct OverlayMeta {
#[allow(clippy::enum_variant_names)] #[allow(clippy::enum_variant_names)]
pub enum OverlayEventData { pub enum OverlayEventData {
/// Notifies a newly added overlay of its ID, even before the overlay is shown.
IdAssigned(OverlayID),
ActiveSetChanged(Option<usize>), ActiveSetChanged(Option<usize>),
NumSetsChanged(usize), NumSetsChanged(usize),
EditModeChanged(bool), EditModeChanged(bool),

View File

@@ -636,6 +636,12 @@ impl<T> OverlayWindowManager<T> {
} }
} }
self.overlays[oid]
.config
.backend
.notify(app, OverlayEventData::IdAssigned(oid))
.unwrap(); // IdAssigned not expected to fail
if !shown && show_on_spawn { if !shown && show_on_spawn {
log::debug!("activating {name} due to show_on_spawn"); log::debug!("activating {name} due to show_on_spawn");
self.overlays[oid].config.activate(app); self.overlays[oid].config.activate(app);