update deps, back to env_logger, fix screen transform
This commit is contained in:
@@ -66,17 +66,17 @@ impl OverlayData<OpenXrOverlayData> {
|
||||
|
||||
let sub_image = data.acquire_present_release(command_buffer, my_view, self.state.alpha)?;
|
||||
|
||||
let transform = self.state.transform * frame_transform.transform;
|
||||
|
||||
let aspect_ratio = extent[1] as f32 / extent[0] as f32;
|
||||
let (scale_x, scale_y) = if aspect_ratio < 1.0 {
|
||||
let major = self.state.transform.matrix3.col(0).length();
|
||||
let major = transform.matrix3.col(0).length();
|
||||
(major, major * aspect_ratio)
|
||||
} else {
|
||||
let major = self.state.transform.matrix3.col(1).length();
|
||||
let major = transform.matrix3.col(1).length();
|
||||
(major / aspect_ratio, major)
|
||||
};
|
||||
|
||||
let transform = self.state.transform * frame_transform.transform;
|
||||
|
||||
if let Some(curvature) = self.state.curvature {
|
||||
let radius = scale_x / (2.0 * PI * curvature);
|
||||
let quat = helpers::transform_to_norm_quat(&transform);
|
||||
|
||||
45
src/main.rs
45
src/main.rs
@@ -21,7 +21,6 @@ use std::{
|
||||
};
|
||||
|
||||
use clap::Parser;
|
||||
use flexi_logger::{Duplicate, FileSpec, LogSpecification};
|
||||
use sysinfo::Pid;
|
||||
|
||||
/// The lightweight desktop overlay for OpenVR and OpenXR
|
||||
@@ -181,10 +180,10 @@ fn logging_init(args: &mut Args) -> anyhow::Result<()> {
|
||||
if let Some(log_to) = log_file.filter(|s| !s.is_empty()) {
|
||||
if let Err(e) = file_logging_init(&log_to) {
|
||||
log::error!("Failed to initialize file logging: {}", e);
|
||||
flexi_logger::Logger::try_with_env_or_str("info")?.start()?;
|
||||
env_logger::init();
|
||||
}
|
||||
} else {
|
||||
flexi_logger::Logger::try_with_env_or_str("info")?.start()?;
|
||||
env_logger::init();
|
||||
}
|
||||
|
||||
log_panics::init();
|
||||
@@ -192,25 +191,26 @@ fn logging_init(args: &mut Args) -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
fn file_logging_init(log_to: &str) -> anyhow::Result<()> {
|
||||
let file_spec = FileSpec::try_from(PathBuf::from(log_to))?;
|
||||
let log_spec = LogSpecification::env_or_parse("info")?;
|
||||
use std::io::Write;
|
||||
let target = Box::new(std::fs::File::create(log_to)?);
|
||||
|
||||
let duplicate = log_spec
|
||||
.module_filters()
|
||||
.iter()
|
||||
.find(|m| m.module_name.is_none())
|
||||
.map(|m| match m.level_filter {
|
||||
log::LevelFilter::Trace => Duplicate::Trace,
|
||||
log::LevelFilter::Debug => Duplicate::Debug,
|
||||
log::LevelFilter::Info => Duplicate::Info,
|
||||
log::LevelFilter::Warn => Duplicate::Warn,
|
||||
_ => Duplicate::Error,
|
||||
});
|
||||
env_logger::Builder::new()
|
||||
.target(env_logger::Target::Pipe(target))
|
||||
.filter(None, log::LevelFilter::Info)
|
||||
.parse_default_env()
|
||||
.format(|buf, record| {
|
||||
eprintln!("[{}] {}", record.level(), record.args());
|
||||
writeln!(
|
||||
buf,
|
||||
"[{} {} {}] {}",
|
||||
chrono::Local::now().format("%H:%M:%S%.3f"),
|
||||
record.level(),
|
||||
record.module_path().unwrap_or_default(),
|
||||
record.args()
|
||||
)
|
||||
})
|
||||
.init();
|
||||
|
||||
flexi_logger::Logger::with(log_spec)
|
||||
.log_to_file(file_spec)
|
||||
.duplicate_to_stderr(duplicate.unwrap_or(Duplicate::Error))
|
||||
.start()?;
|
||||
println!("Logging to: {}", log_to);
|
||||
Ok(())
|
||||
}
|
||||
@@ -226,7 +226,10 @@ fn ensure_single_instance(replace: bool) -> bool {
|
||||
if let Ok(pid_str) = std::fs::read_to_string(&path) {
|
||||
if let Ok(pid) = pid_str.trim().parse::<u32>() {
|
||||
let mut system = sysinfo::System::new();
|
||||
system.refresh_processes(sysinfo::ProcessesToUpdate::Some(&[Pid::from_u32(pid)]));
|
||||
system.refresh_processes(
|
||||
sysinfo::ProcessesToUpdate::Some(&[Pid::from_u32(pid)]),
|
||||
false,
|
||||
);
|
||||
if let Some(proc) = system.process(sysinfo::Pid::from_u32(pid)) {
|
||||
if replace {
|
||||
proc.kill_with(sysinfo::Signal::Term);
|
||||
|
||||
@@ -477,9 +477,11 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
continue;
|
||||
}
|
||||
self.extent.get_or_insert_with(|| {
|
||||
self.transform = affine_from_format(&frame.format);
|
||||
extent_from_format(frame.format, &app.session.config)
|
||||
});
|
||||
if let Some(new_transform) = affine_from_format(&frame.format) {
|
||||
self.transform = new_transform;
|
||||
}
|
||||
match app.graphics.dmabuf_texture(frame) {
|
||||
Ok(new) => {
|
||||
let pipeline = match self.pipeline {
|
||||
@@ -520,9 +522,11 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
continue;
|
||||
};
|
||||
self.extent.get_or_insert_with(|| {
|
||||
self.transform = affine_from_format(&frame.format);
|
||||
extent_from_format(frame.format, &app.session.config)
|
||||
});
|
||||
if let Some(new_transform) = affine_from_format(&frame.format) {
|
||||
self.transform = new_transform;
|
||||
}
|
||||
log::debug!("{}: New MemFd frame", self.name);
|
||||
let format = fourcc_to_vk(frame.format.fourcc)?;
|
||||
|
||||
@@ -1053,29 +1057,30 @@ fn extent_from_res(width: u32, height: u32, config: &GeneralConfig) -> [u32; 3]
|
||||
[w, h, 1]
|
||||
}
|
||||
|
||||
fn affine_from_format(format: &FrameFormat) -> Affine3A {
|
||||
fn affine_from_format(format: &FrameFormat) -> Option<Affine3A> {
|
||||
const FLIP_X: Vec3 = Vec3 {
|
||||
x: -1.0,
|
||||
y: 1.0,
|
||||
z: 1.0,
|
||||
};
|
||||
|
||||
match format.transform {
|
||||
wlx_frame::Transform::None => Affine3A::IDENTITY,
|
||||
wlx_frame::Transform::Rotated90 => Affine3A::from_rotation_z(PI / 2.0),
|
||||
Some(match format.transform {
|
||||
wlx_frame::Transform::Normal => Affine3A::IDENTITY,
|
||||
wlx_frame::Transform::Rotated90 => Affine3A::from_rotation_z(-PI / 2.0),
|
||||
wlx_frame::Transform::Rotated180 => Affine3A::from_rotation_z(PI),
|
||||
wlx_frame::Transform::Rotated270 => Affine3A::from_rotation_z(-PI / 2.0),
|
||||
wlx_frame::Transform::Rotated270 => Affine3A::from_rotation_z(PI / 2.0),
|
||||
wlx_frame::Transform::Flipped => Affine3A::from_scale(FLIP_X),
|
||||
wlx_frame::Transform::Flipped90 => {
|
||||
Affine3A::from_scale(FLIP_X) * Affine3A::from_rotation_z(PI / 2.0)
|
||||
Affine3A::from_scale(FLIP_X) * Affine3A::from_rotation_z(-PI / 2.0)
|
||||
}
|
||||
wlx_frame::Transform::Flipped180 => {
|
||||
Affine3A::from_scale(FLIP_X) * Affine3A::from_rotation_z(PI)
|
||||
}
|
||||
wlx_frame::Transform::Flipped270 => {
|
||||
Affine3A::from_scale(FLIP_X) * Affine3A::from_rotation_z(-PI / 2.0)
|
||||
Affine3A::from_scale(FLIP_X) * Affine3A::from_rotation_z(PI / 2.0)
|
||||
}
|
||||
}
|
||||
wlx_frame::Transform::Undefined => return None,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "pipewire", feature = "x11"))]
|
||||
|
||||
Reference in New Issue
Block a user