WayVR: WayVRDisplayList ui type, toggle display visibility and pause rendering of them
This commit is contained in:
@@ -43,7 +43,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
use crate::overlays::wayvr::action_wayvr;
|
||||
use crate::overlays::wayvr::wayvr_action;
|
||||
|
||||
pub mod helpers;
|
||||
pub mod input;
|
||||
@@ -266,12 +266,8 @@ pub fn openvr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
|
||||
}
|
||||
},
|
||||
#[cfg(feature = "wayvr")]
|
||||
TaskType::WayVR(task) => {
|
||||
if let Some(overlay) =
|
||||
action_wayvr(&task.catalog_name, &task.app_name, &mut state)
|
||||
{
|
||||
overlays.add(overlay);
|
||||
}
|
||||
TaskType::WayVR(action) => {
|
||||
wayvr_action(&mut state, &mut overlays, &action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
use crate::overlays::wayvr::action_wayvr;
|
||||
use crate::overlays::wayvr::wayvr_action;
|
||||
|
||||
mod helpers;
|
||||
mod input;
|
||||
@@ -491,12 +491,8 @@ pub fn openxr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
|
||||
_ => {}
|
||||
},
|
||||
#[cfg(feature = "wayvr")]
|
||||
TaskType::WayVR(task) => {
|
||||
if let Some(overlay) =
|
||||
action_wayvr(&task.catalog_name, &task.app_name, &mut app_state)
|
||||
{
|
||||
overlays.add(overlay);
|
||||
}
|
||||
TaskType::WayVR(action) => {
|
||||
wayvr_action(&mut app_state, &mut overlays, &action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-10
@@ -5,13 +5,13 @@ use std::{
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
use crate::overlays::wayvr::WayVRAction;
|
||||
|
||||
use super::{
|
||||
common::OverlaySelector,
|
||||
overlay::{OverlayBackend, OverlayState},
|
||||
@@ -52,12 +52,6 @@ pub enum SystemTask {
|
||||
ShowHide,
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
pub struct WayVRTask {
|
||||
pub catalog_name: Arc<str>,
|
||||
pub app_name: Arc<str>,
|
||||
}
|
||||
|
||||
pub type OverlayTask = dyn FnOnce(&mut AppState, &mut OverlayState) + Send;
|
||||
pub type CreateOverlayTask =
|
||||
dyn FnOnce(&mut AppState) -> Option<(OverlayState, Box<dyn OverlayBackend>)> + Send;
|
||||
@@ -69,7 +63,7 @@ pub enum TaskType {
|
||||
DropOverlay(OverlaySelector),
|
||||
System(SystemTask),
|
||||
#[cfg(feature = "wayvr")]
|
||||
WayVR(WayVRTask),
|
||||
WayVR(WayVRAction),
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Copy)]
|
||||
|
||||
@@ -15,7 +15,7 @@ use smithay::{
|
||||
wayland::shell::xdg::ToplevelSurface,
|
||||
};
|
||||
|
||||
use crate::gen_id;
|
||||
use crate::{backend::overlay::OverlayID, gen_id};
|
||||
|
||||
use super::{
|
||||
client::WayVRManager, comp::send_frames_surface_tree, egl_data, smithay_wrapper, window,
|
||||
@@ -47,6 +47,8 @@ pub struct Display {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub name: String,
|
||||
pub visible: bool,
|
||||
pub overlay_id: Option<OverlayID>,
|
||||
wm: Rc<RefCell<window::WindowManager>>,
|
||||
displayed_windows: Vec<DisplayWindow>,
|
||||
wayland_env: super::WaylandEnv,
|
||||
@@ -112,6 +114,8 @@ impl Display {
|
||||
gles_texture,
|
||||
wayland_env,
|
||||
processes: Vec::new(),
|
||||
visible: true,
|
||||
overlay_id: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -216,6 +220,11 @@ impl Display {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_visible(&mut self, visible: bool) {
|
||||
log::info!("Display \"{}\" visible: {}", self.name.as_str(), visible);
|
||||
self.visible = visible;
|
||||
}
|
||||
|
||||
pub fn send_mouse_move(&self, manager: &mut WayVRManager, x: u32, y: u32) {
|
||||
if let Some(window_handle) = self.get_hovered_window(x, y) {
|
||||
let wm = self.wm.borrow();
|
||||
|
||||
+14
-10
@@ -43,7 +43,7 @@ impl WaylandEnv {
|
||||
pub struct WayVR {
|
||||
time_start: u64,
|
||||
gles_renderer: GlesRenderer,
|
||||
displays: display::DisplayVec,
|
||||
pub displays: display::DisplayVec,
|
||||
manager: client::WayVRManager,
|
||||
wm: Rc<RefCell<window::WindowManager>>,
|
||||
egl_data: Rc<egl_data::EGLData>,
|
||||
@@ -102,13 +102,19 @@ impl WayVR {
|
||||
|
||||
pub fn tick_display(&mut self, display: display::DisplayHandle) -> anyhow::Result<()> {
|
||||
// millis since the start of wayvr
|
||||
let time_ms = get_millis() - self.time_start;
|
||||
|
||||
let display = self
|
||||
.displays
|
||||
.get(&display)
|
||||
.ok_or(anyhow::anyhow!("Invalid display handle"))?;
|
||||
|
||||
let time_ms = get_millis() - self.time_start;
|
||||
|
||||
if !display.visible {
|
||||
// Display is invisible, do not render
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
display.tick_render(&mut self.gles_renderer, time_ms)?;
|
||||
|
||||
Ok(())
|
||||
@@ -172,6 +178,12 @@ impl WayVR {
|
||||
self.manager.send_key(virtual_key, down);
|
||||
}
|
||||
|
||||
pub fn set_display_visible(&mut self, display: display::DisplayHandle, visible: bool) {
|
||||
if let Some(display) = self.displays.get_mut(&display) {
|
||||
display.set_visible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_dmabuf_data(&self, display: display::DisplayHandle) -> Option<egl_data::DMAbufData> {
|
||||
self.displays
|
||||
.get(&display)
|
||||
@@ -188,14 +200,6 @@ impl WayVR {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_display_by_handle(
|
||||
&self,
|
||||
display: display::DisplayHandle,
|
||||
) -> Option<&display::Display> {
|
||||
self.displays.get(&display)
|
||||
}
|
||||
|
||||
pub fn create_display(
|
||||
&mut self,
|
||||
width: u32,
|
||||
|
||||
Reference in New Issue
Block a user