pipewire pause/resume, update wlx-capture, pipewire dmabuf preps

This commit is contained in:
galister
2024-02-02 19:05:33 +01:00
parent d71bf65ee8
commit 93e4058f7f
7 changed files with 114 additions and 45 deletions

View File

@@ -66,9 +66,9 @@ impl OverlayData<OpenVrOverlayData> {
pub(super) fn after_input(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
if self.state.want_visible && !self.data.visible {
self.show(overlay, app);
self.show_internal(overlay, app);
} else if !self.state.want_visible && self.data.visible {
self.hide(overlay);
self.hide_internal(overlay, app);
}
}
@@ -82,7 +82,7 @@ impl OverlayData<OpenVrOverlayData> {
}
}
fn show(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
fn show_internal(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
let handle = match self.data.handle {
Some(handle) => handle,
None => self.initialize(overlay, app),
@@ -92,9 +92,10 @@ impl OverlayData<OpenVrOverlayData> {
panic!("Failed to show overlay: {}", e);
}
self.data.visible = true;
self.backend.resume(app);
}
fn hide(&mut self, overlay: &mut OverlayManager) {
fn hide_internal(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
let Some(handle) = self.data.handle else {
return;
};
@@ -103,6 +104,7 @@ impl OverlayData<OpenVrOverlayData> {
panic!("Failed to hide overlay: {}", e);
}
self.data.visible = false;
self.backend.pause(app);
}
pub(super) fn upload_color(&self, overlay: &mut OverlayManager) {

View File

@@ -204,6 +204,10 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
}
}
overlays
.iter_mut()
.for_each(|o| o.after_input(&mut app_state));
let (_, views) = xr_state
.session
.locate_views(

View File

@@ -6,12 +6,14 @@ use super::{swapchain::SwapchainRenderData, transform_to_posef, XrState};
use crate::{
backend::{openxr::swapchain::create_swapchain_render_data, overlay::OverlayData},
graphics::WlxCommandBuffer,
state::AppState,
};
use vulkano::image::view::ImageView;
#[derive(Default)]
pub struct OpenXrOverlayData {
last_view: Option<Arc<ImageView>>,
last_visible: bool,
pub(super) swapchain: Option<SwapchainRenderData>,
pub(super) init: bool,
}
@@ -67,4 +69,15 @@ impl OverlayData<OpenXrOverlayData> {
});
Some(quad)
}
pub(super) fn after_input(&mut self, app: &mut AppState) {
if self.data.last_visible != self.state.want_visible {
if self.state.want_visible {
self.backend.resume(app);
} else {
self.backend.pause(app);
}
}
self.data.last_visible = self.state.want_visible;
}
}

View File

@@ -169,6 +169,17 @@ where
pub fn view(&mut self) -> Option<Arc<ImageView>> {
self.backend.view()
}
pub fn set_visible(&mut self, app: &mut AppState, visible: bool) {
let old_visible = self.state.want_visible;
self.state.want_visible = visible;
if visible != old_visible {
if visible {
self.backend.resume(app);
} else {
self.backend.pause(app);
}
}
}
}
pub trait OverlayRenderer {