fix(wayland): use an actual timestamp for the frame callback
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -5475,6 +5475,7 @@ dependencies = [
|
||||
"parking_lot 0.12.4",
|
||||
"rand",
|
||||
"rustc-hash 2.1.1",
|
||||
"rustix 1.0.8",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"slotmap",
|
||||
|
||||
@@ -151,6 +151,7 @@ memfd = { version = "0.6.4", optional = true }
|
||||
vulkano = { git = "https://github.com/Schmarni-Dev/vulkano", branch = "0_35_dmabuf_fixes", optional = true }
|
||||
wgpu-hal = { version = "24", optional = true, features = ["vulkan"] }
|
||||
ash = { version = "0.38.0", optional = true, default-features = false }
|
||||
rustix = { version = "1.0.8", features = ["time"] }
|
||||
|
||||
[dependencies.stardust-xr]
|
||||
workspace = true
|
||||
|
||||
@@ -181,6 +181,7 @@ fn build_line_mesh(
|
||||
MeshMaterial3d(materials.add(BevyMaterial {
|
||||
base_color: Color::WHITE,
|
||||
perceptual_roughness: 1.0,
|
||||
// TODO: this should be Blend
|
||||
alpha_mode: AlphaMode::Opaque,
|
||||
..default()
|
||||
})),
|
||||
|
||||
@@ -32,6 +32,7 @@ use core::{buffer::Buffer, callback::Callback, surface::WL_SURFACE_REGISTRY};
|
||||
use display::Display;
|
||||
use mint::Vector2;
|
||||
use std::fs::File;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
fs::{self, OpenOptions},
|
||||
io::{self, ErrorKind},
|
||||
@@ -169,15 +170,13 @@ impl WaylandClient {
|
||||
}
|
||||
Err(e) => {
|
||||
// wayland clients really aren't nice when disconnecting properly, are they? :p
|
||||
if let server::Error::Decode(DecodeError::IoError(e)) = &e {
|
||||
if e.kind() == io::ErrorKind::ConnectionReset {
|
||||
if let server::Error::Decode(DecodeError::IoError(e)) = &e && e.kind() == io::ErrorKind::ConnectionReset {
|
||||
if let Some(pid) = client.get::<Display>(ObjectId::DISPLAY).and_then(|d| d.pid) {
|
||||
tracing::info!("Wayland: Client with pid: {pid} disconnected from server");
|
||||
} else {
|
||||
tracing::info!("Wayland: Unknown client disconnected from server");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
tracing::error!("Wayland: Error reading message: {:?}", e);
|
||||
break;
|
||||
@@ -205,8 +204,10 @@ impl WaylandClient {
|
||||
match message {
|
||||
Message::Disconnect => return Ok(true),
|
||||
Message::Frame(callback) => {
|
||||
let serial = client.next_event_serial();
|
||||
callback.done(client, callback.0, serial).await?;
|
||||
let now = rustix::time::clock_gettime(rustix::time::ClockId::Monotonic);
|
||||
let now = Duration::new(now.tv_sec as u64, now.tv_nsec as u32);
|
||||
let ms = (now.as_millis() % (u32::MAX as u128)) as u32;
|
||||
callback.done(client, callback.0, ms).await?;
|
||||
client
|
||||
.get::<Display>(ObjectId::DISPLAY)
|
||||
.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user