WayVR: Display auto-hide support (Fixes #98), keyboard settings in config
This commit is contained in:
@@ -15,11 +15,14 @@ use smithay::{
|
||||
wayland::shell::xdg::ToplevelSurface,
|
||||
};
|
||||
|
||||
use crate::{backend::overlay::OverlayID, gen_id};
|
||||
use crate::{
|
||||
backend::{overlay::OverlayID, wayvr::time::get_millis},
|
||||
gen_id,
|
||||
};
|
||||
|
||||
use super::{
|
||||
client::WayVRManager, comp::send_frames_surface_tree, egl_data, event_queue::SyncEventQueue,
|
||||
process, smithay_wrapper, time, window,
|
||||
process, smithay_wrapper, time, window, WayVRSignal,
|
||||
};
|
||||
|
||||
fn generate_auth_key() -> String {
|
||||
@@ -55,6 +58,7 @@ pub struct Display {
|
||||
pub displayed_windows: Vec<DisplayWindow>,
|
||||
wayland_env: super::WaylandEnv,
|
||||
last_pressed_time_ms: u64,
|
||||
pub no_windows_since: Option<u64>,
|
||||
|
||||
// Render data stuff
|
||||
gles_texture: GlesTexture, // TODO: drop texture
|
||||
@@ -123,6 +127,7 @@ impl Display {
|
||||
overlay_id: None,
|
||||
tasks: SyncEventQueue::new(),
|
||||
last_pressed_time_ms: 0,
|
||||
no_windows_since: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -158,7 +163,24 @@ impl Display {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tick(&mut self) {
|
||||
pub fn tick(
|
||||
&mut self,
|
||||
config: &super::Config,
|
||||
handle: &DisplayHandle,
|
||||
signals: &mut SyncEventQueue<WayVRSignal>,
|
||||
) {
|
||||
if self.visible {
|
||||
if !self.displayed_windows.is_empty() {
|
||||
self.no_windows_since = None;
|
||||
} else if let Some(auto_hide_delay) = config.auto_hide_delay {
|
||||
if let Some(s) = self.no_windows_since {
|
||||
if s + (auto_hide_delay as u64) < get_millis() {
|
||||
signals.send(WayVRSignal::DisplayHideRequest(*handle));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while let Some(task) = self.tasks.read() {
|
||||
match task {
|
||||
DisplayTask::ProcessCleanup(process_handle) => {
|
||||
@@ -169,6 +191,7 @@ impl Display {
|
||||
self.name,
|
||||
self.displayed_windows.len()
|
||||
);
|
||||
self.no_windows_since = Some(get_millis());
|
||||
|
||||
self.reposition_windows();
|
||||
}
|
||||
@@ -248,6 +271,7 @@ impl Display {
|
||||
self.visible = visible;
|
||||
if visible {
|
||||
self.wants_redraw = true;
|
||||
self.no_windows_since = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,16 @@ pub enum WayVRTask {
|
||||
ProcessTerminationRequest(process::ProcessHandle),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum WayVRSignal {
|
||||
DisplayHideRequest(display::DisplayHandle),
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
pub click_freeze_time_ms: u32,
|
||||
pub keyboard_repeat_delay_ms: u32,
|
||||
pub keyboard_repeat_rate: u32,
|
||||
pub auto_hide_delay: Option<u32>, // if None, auto-hide is disabled
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -83,6 +89,7 @@ pub struct WayVR {
|
||||
config: Config,
|
||||
|
||||
tasks: SyncEventQueue<WayVRTask>,
|
||||
pub signals: SyncEventQueue<WayVRSignal>,
|
||||
}
|
||||
|
||||
pub enum MouseIndex {
|
||||
@@ -140,6 +147,7 @@ impl WayVR {
|
||||
processes: ProcessVec::new(),
|
||||
egl_data: Rc::new(egl_data),
|
||||
wm: Rc::new(RefCell::new(window::WindowManager::new())),
|
||||
signals: SyncEventQueue::new(),
|
||||
tasks,
|
||||
config,
|
||||
})
|
||||
@@ -206,9 +214,9 @@ impl WayVR {
|
||||
}
|
||||
}
|
||||
|
||||
for display in self.displays.vec.iter_mut().flatten() {
|
||||
display.obj.tick();
|
||||
}
|
||||
self.displays.iter_mut(&mut |handle, display| {
|
||||
display.tick(&self.config, &handle, &mut self.signals);
|
||||
});
|
||||
|
||||
while let Some(task) = self.tasks.read() {
|
||||
match task {
|
||||
|
||||
Reference in New Issue
Block a user