fix more no-default-features builds

This commit is contained in:
galister
2024-03-01 22:13:06 +01:00
parent d562d4b236
commit f42572d4cb
4 changed files with 69 additions and 17 deletions

View File

@@ -10,10 +10,7 @@ use ash::vk::SubmitInfo;
use smallvec::smallvec; use smallvec::smallvec;
#[cfg(feature = "openvr")] #[cfg(feature = "openvr")]
use vulkano::{ use vulkano::{device::physical::PhysicalDeviceType, instance::InstanceCreateFlags};
device::physical::PhysicalDeviceType, instance::InstanceCreateFlags,
instance::InstanceExtensions,
};
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
use {ash::vk, std::os::raw::c_void}; use {ash::vk, std::os::raw::c_void};
@@ -47,7 +44,7 @@ use vulkano::{
Image, ImageCreateInfo, ImageLayout, ImageTiling, ImageType, ImageUsage, SampleCount, Image, ImageCreateInfo, ImageLayout, ImageTiling, ImageType, ImageUsage, SampleCount,
SubresourceLayout, SubresourceLayout,
}, },
instance::{Instance, InstanceCreateInfo}, instance::{Instance, InstanceCreateInfo, InstanceExtensions},
memory::{ memory::{
allocator::{ allocator::{
AllocationCreateInfo, GenericMemoryAllocatorCreateInfo, MemoryAllocator, AllocationCreateInfo, GenericMemoryAllocatorCreateInfo, MemoryAllocator,

View File

@@ -19,7 +19,6 @@ use crate::{
overlay::RelativeTo, overlay::RelativeTo,
}, },
overlays::{ overlays::{
mirror,
toast::Toast, toast::Toast,
watch::{save_watch, WATCH_NAME}, watch::{save_watch, WATCH_NAME},
}, },
@@ -577,7 +576,6 @@ fn run_overlay(overlay: &OverlaySelector, action: &OverlayAction, app: &mut AppS
} }
} }
#[cfg(feature = "wayland")]
fn run_window(window: &Arc<str>, action: &WindowAction, app: &mut AppState) { fn run_window(window: &Arc<str>, action: &WindowAction, app: &mut AppState) {
use crate::overlays::custom; use crate::overlays::custom;
let selector = OverlaySelector::Name(window.clone()); let selector = OverlaySelector::Name(window.clone());
@@ -594,6 +592,7 @@ fn run_window(window: &Arc<str>, action: &WindowAction, app: &mut AppState) {
} }
}), }),
)); ));
#[cfg(feature = "wayland")]
app.tasks.enqueue(TaskType::CreateOverlay( app.tasks.enqueue(TaskType::CreateOverlay(
OverlaySelector::Name(window.clone()), OverlaySelector::Name(window.clone()),
Box::new({ Box::new({
@@ -602,10 +601,12 @@ fn run_window(window: &Arc<str>, action: &WindowAction, app: &mut AppState) {
Toast::new("Check your desktop for popup.".into(), "".into()) Toast::new("Check your desktop for popup.".into(), "".into())
.with_sound(true) .with_sound(true)
.submit(app); .submit(app);
mirror::new_mirror(name.clone(), false, &app.session) crate::overlays::mirror::new_mirror(name.clone(), false, &app.session)
} }
}), }),
)); ));
#[cfg(not(feature = "wayland"))]
log::warn!("Mirror not available without Wayland feature.");
} }
WindowAction::ShowUi => { WindowAction::ShowUi => {
app.tasks.enqueue(TaskType::Overlay( app.tasks.enqueue(TaskType::Overlay(

View File

@@ -72,16 +72,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
}); });
auto_run(running, args.openvr, args.openxr); auto_run(running, args);
Ok(()) Ok(())
} }
fn auto_run(running: Arc<AtomicBool>, openvr: bool, openxr: bool) { fn auto_run(running: Arc<AtomicBool>, args: Args) {
use backend::common::BackendError; use backend::common::BackendError;
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
if !openvr { if !args_get_openvr(&args) {
use crate::backend::openxr::openxr_run; use crate::backend::openxr::openxr_run;
match openxr_run(running.clone()) { match openxr_run(running.clone()) {
Ok(()) => return, Ok(()) => return,
@@ -94,7 +94,7 @@ fn auto_run(running: Arc<AtomicBool>, openvr: bool, openxr: bool) {
} }
#[cfg(feature = "openvr")] #[cfg(feature = "openvr")]
if !openxr { if !args_get_openxr(&args) {
use crate::backend::openvr::openvr_run; use crate::backend::openvr::openvr_run;
match openvr_run(running.clone()) { match openvr_run(running.clone()) {
Ok(()) => return, Ok(()) => return,
@@ -107,4 +107,30 @@ fn auto_run(running: Arc<AtomicBool>, openvr: bool, openxr: bool) {
} }
log::error!("No more backends to try"); log::error!("No more backends to try");
#[cfg(not(any(feature = "openvr", feature = "openxr")))]
compile_error!("No VR support! Enable either openvr or openxr features!");
#[cfg(not(any(feature = "wayland", feature = "x11")))]
compile_error!("No desktop support! Enable either wayland or x11 features!");
}
fn args_get_openvr(args: &Args) -> bool {
#[cfg(feature = "openvr")]
let ret = args.openvr;
#[cfg(not(feature = "openvr"))]
let ret = false;
ret
}
fn args_get_openxr(args: &Args) -> bool {
#[cfg(feature = "openxr")]
let ret = args.openxr;
#[cfg(not(feature = "openxr"))]
let ret = false;
ret
} }

View File

@@ -16,7 +16,6 @@ use wlx_capture::{
DrmFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, DrmFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
}, },
wayland::wayland_client::protocol::wl_output::Transform,
WlxCapture, WlxCapture,
}; };
@@ -27,7 +26,7 @@ use {
std::{collections::HashMap, error::Error, f32::consts::PI, ops::Deref, path::PathBuf}, std::{collections::HashMap, error::Error, f32::consts::PI, ops::Deref, path::PathBuf},
wlx_capture::{ wlx_capture::{
pipewire::{pipewire_select_screen, PipewireCapture}, pipewire::{pipewire_select_screen, PipewireCapture},
wayland::{WlxClient, WlxOutput}, wayland::{wayland_client::protocol::wl_output, WlxClient, WlxOutput},
wlr_dmabuf::WlrDmabufCapture, wlr_dmabuf::WlrDmabufCapture,
wlr_screencopy::WlrScreencopyCapture, wlr_screencopy::WlrScreencopyCapture,
}, },
@@ -566,14 +565,16 @@ where
interaction: Box::new(ScreenInteractionHandler::new( interaction: Box::new(ScreenInteractionHandler::new(
vec2(output.logical_pos.0 as f32, output.logical_pos.1 as f32), vec2(output.logical_pos.0 as f32, output.logical_pos.1 as f32),
vec2(output.logical_size.0 as f32, output.logical_size.1 as f32), vec2(output.logical_size.0 as f32, output.logical_size.1 as f32),
output.transform, output.transform.into(),
)), )),
}); });
let axis = Vec3::new(0., 0., 1.); let axis = Vec3::new(0., 0., 1.);
let transform = output.transform.into();
let angle = if session.config.upright_screen_fix { let angle = if session.config.upright_screen_fix {
match output.transform { match transform {
Transform::_90 | Transform::Flipped90 => PI / 2., Transform::_90 | Transform::Flipped90 => PI / 2.,
Transform::_180 | Transform::Flipped180 => PI, Transform::_180 | Transform::Flipped180 => PI,
Transform::_270 | Transform::Flipped270 => -PI / 2., Transform::_270 | Transform::Flipped270 => -PI / 2.,
@@ -584,7 +585,7 @@ where
}; };
let center = Vec2 { x: 0.5, y: 0.5 }; let center = Vec2 { x: 0.5, y: 0.5 };
let interaction_transform = match output.transform { let interaction_transform = match transform {
Transform::_90 | Transform::Flipped90 => Affine2::from_cols( Transform::_90 | Transform::Flipped90 => Affine2::from_cols(
Vec2::NEG_Y * (output.size.0 as f32 / output.size.1 as f32), Vec2::NEG_Y * (output.size.0 as f32 / output.size.1 as f32),
Vec2::NEG_X, Vec2::NEG_X,
@@ -797,6 +798,33 @@ where
Ok((overlays, extent)) Ok((overlays, extent))
} }
pub enum Transform {
Normal,
_90,
_180,
_270,
Flipped90,
Flipped180,
Flipped270,
}
#[cfg(feature = "wayland")]
impl From<wl_output::Transform> for Transform {
fn from(t: wl_output::Transform) -> Transform {
match t {
wl_output::Transform::Normal => Transform::Normal,
wl_output::Transform::_90 => Transform::_90,
wl_output::Transform::_180 => Transform::_180,
wl_output::Transform::_270 => Transform::_270,
wl_output::Transform::Flipped => Transform::Flipped180,
wl_output::Transform::Flipped90 => Transform::Flipped90,
wl_output::Transform::Flipped180 => Transform::Flipped180,
wl_output::Transform::Flipped270 => Transform::Flipped270,
_ => Transform::Normal,
}
}
}
fn extent_from_res(res: (i32, i32)) -> [u32; 3] { fn extent_from_res(res: (i32, i32)) -> [u32; 3] {
// screens above a certain resolution will have severe aliasing // screens above a certain resolution will have severe aliasing