fix: polish stuff a bit

This commit is contained in:
Nova
2024-06-27 16:51:33 -04:00
parent d17841ec7a
commit f08f3e4e4b
11 changed files with 104 additions and 98 deletions

View File

@@ -234,7 +234,7 @@ fn stereokit_loop(
intentional_flatscreen,
&sk,
hmd,
World::has_bounds().then(move || play_space),
World::has_bounds().then_some(play_space),
);
if World::has_bounds() && World::get_bounds_size().x != 0.0 && World::get_bounds_size().y != 0.0
{

View File

@@ -101,8 +101,10 @@ impl Drop for Lines {
pub fn draw_all(token: &MainThreadToken) {
for lines in LINES_REGISTRY.get_valid_contents() {
if lines.space.node().unwrap().enabled() {
lines.draw(token);
if let Some(node) = lines.space.node() {
if node.enabled() {
lines.draw(token);
}
}
}
}

View File

@@ -163,8 +163,10 @@ impl Drop for Text {
pub fn draw_all(token: &MainThreadToken) {
for text in TEXT_REGISTRY.get_valid_contents() {
if text.space.node().unwrap().enabled() {
text.draw(token);
if let Some(node) = text.space.node() {
if node.enabled() {
text.draw(token);
}
}
}
}

View File

@@ -160,7 +160,7 @@ impl FieldRefAspect for Field {
) -> Result<f32> {
let reference_space = space.get_aspect::<Spatial>()?;
let field = node.get_aspect::<Field>()?;
Ok(field.distance(&reference_space, point.into()).into())
Ok(field.distance(&reference_space, point.into()))
}
async fn normal(

View File

@@ -45,22 +45,13 @@ impl Default for MouseEvent {
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Default)]
pub struct KeyboardEvent {
pub keyboard: (),
pub xkbv1: (),
pub keymap_id: u64,
pub keys: Vec<i32>,
}
impl Default for KeyboardEvent {
fn default() -> Self {
Self {
keyboard: (),
xkbv1: (),
keymap_id: 0,
keys: Default::default(),
}
}
}
#[allow(unused)]
pub struct MousePointer {

View File

@@ -89,8 +89,8 @@ impl ServerObjects {
mouse_pointer.update();
}
if let Some((left_hand, right_hand)) = self.hands.as_mut() {
left_hand.update(&sk, token);
right_hand.update(&sk, token);
left_hand.update(sk, token);
right_hand.update(sk, token);
}
if let Some((left_controller, right_controller)) = self.controllers.as_mut() {
left_controller.update(token);

View File

@@ -55,7 +55,7 @@ pub fn restore_session(session_dir: &Path) -> Vec<Child> {
.filter_map(Result::ok)
.filter_map(|c| ClientStateParsed::from_file(&c.path()))
.filter_map(ClientStateParsed::launch_command)
.filter_map(|startup_command| run_client(startup_command))
.filter_map(run_client)
.collect()
}

View File

@@ -150,7 +150,7 @@ impl SeatWrapper {
};
pointer.motion(
&mut state,
Some((surface, (0, 0).into())),
Some((surface, (0.0, 0.0).into())),
&MotionEvent {
location: (position.x as f64, position.y as f64).into(),
serial: SERIAL_COUNTER.next_serial(),
@@ -261,7 +261,7 @@ impl SeatWrapper {
};
touch.down(
&mut state.lock(),
Some((surface, (0, 0).into())),
Some((surface, (0.0, 0.0).into())),
&DownEvent {
slot: Some(id).into(),
location: (position.x as f64, position.y as f64).into(),
@@ -283,7 +283,7 @@ impl SeatWrapper {
};
touch.motion(
&mut state.lock(),
Some((surface, (0, 0).into())),
Some((surface, (0.0, 0.0).into())),
&touch::MotionEvent {
slot: Some(id).into(),
location: (position.x as f64, position.y as f64).into(),

View File

@@ -24,7 +24,7 @@ use smithay::{
reexports::wayland_server::{self, protocol::wl_surface::WlSurface, Resource},
wayland::compositor::{self, SurfaceData},
};
use std::{cell::RefCell, ffi::c_void, sync::Arc, time::Duration};
use std::{ffi::c_void, sync::Arc, time::Duration};
use stereokit_rust::{
material::{Material, Transparency},
shader::Shader,
@@ -121,7 +121,7 @@ impl CoreSurface {
let mapped = compositor::with_states(&wl_surface, |data| {
data.data_map
.get::<RendererSurfaceStateUserData>()
.map(|surface_states| surface_states.borrow().buffer().is_some())
.map(|surface_states| surface_states.lock().unwrap().buffer().is_some())
.unwrap_or(false)
});
@@ -135,7 +135,9 @@ impl CoreSurface {
let Some(renderer_surface_state) = data
.data_map
.get::<RendererSurfaceStateUserData>()
.map(RefCell::borrow)
.map(std::sync::Mutex::lock)
.map(Result::ok)
.flatten()
else {
return;
};

View File

@@ -427,7 +427,11 @@ impl Backend for XdgBackend {
.clone()
});
let toplevel_cached_state = compositor::with_states(toplevel.wl_surface(), |states| {
*states.cached_state.current::<SurfaceCachedState>()
states
.cached_state
.get::<SurfaceCachedState>()
.current()
.clone()
});
let toplevel_core_surface = CoreSurface::from_wl_surface(toplevel.wl_surface()).unwrap();