fix more no-default-features builds
This commit is contained in:
@@ -10,10 +10,7 @@ use ash::vk::SubmitInfo;
|
||||
use smallvec::smallvec;
|
||||
|
||||
#[cfg(feature = "openvr")]
|
||||
use vulkano::{
|
||||
device::physical::PhysicalDeviceType, instance::InstanceCreateFlags,
|
||||
instance::InstanceExtensions,
|
||||
};
|
||||
use vulkano::{device::physical::PhysicalDeviceType, instance::InstanceCreateFlags};
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
use {ash::vk, std::os::raw::c_void};
|
||||
@@ -47,7 +44,7 @@ use vulkano::{
|
||||
Image, ImageCreateInfo, ImageLayout, ImageTiling, ImageType, ImageUsage, SampleCount,
|
||||
SubresourceLayout,
|
||||
},
|
||||
instance::{Instance, InstanceCreateInfo},
|
||||
instance::{Instance, InstanceCreateInfo, InstanceExtensions},
|
||||
memory::{
|
||||
allocator::{
|
||||
AllocationCreateInfo, GenericMemoryAllocatorCreateInfo, MemoryAllocator,
|
||||
|
||||
@@ -19,7 +19,6 @@ use crate::{
|
||||
overlay::RelativeTo,
|
||||
},
|
||||
overlays::{
|
||||
mirror,
|
||||
toast::Toast,
|
||||
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) {
|
||||
use crate::overlays::custom;
|
||||
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(
|
||||
OverlaySelector::Name(window.clone()),
|
||||
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())
|
||||
.with_sound(true)
|
||||
.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 => {
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
|
||||
34
src/main.rs
34
src/main.rs
@@ -72,16 +72,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
});
|
||||
|
||||
auto_run(running, args.openvr, args.openxr);
|
||||
auto_run(running, args);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn auto_run(running: Arc<AtomicBool>, openvr: bool, openxr: bool) {
|
||||
fn auto_run(running: Arc<AtomicBool>, args: Args) {
|
||||
use backend::common::BackendError;
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
if !openvr {
|
||||
if !args_get_openvr(&args) {
|
||||
use crate::backend::openxr::openxr_run;
|
||||
match openxr_run(running.clone()) {
|
||||
Ok(()) => return,
|
||||
@@ -94,7 +94,7 @@ fn auto_run(running: Arc<AtomicBool>, openvr: bool, openxr: bool) {
|
||||
}
|
||||
|
||||
#[cfg(feature = "openvr")]
|
||||
if !openxr {
|
||||
if !args_get_openxr(&args) {
|
||||
use crate::backend::openvr::openvr_run;
|
||||
match openvr_run(running.clone()) {
|
||||
Ok(()) => return,
|
||||
@@ -107,4 +107,30 @@ fn auto_run(running: Arc<AtomicBool>, openvr: bool, openxr: bool) {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ use wlx_capture::{
|
||||
DrmFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
|
||||
DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
||||
},
|
||||
wayland::wayland_client::protocol::wl_output::Transform,
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
@@ -27,7 +26,7 @@ use {
|
||||
std::{collections::HashMap, error::Error, f32::consts::PI, ops::Deref, path::PathBuf},
|
||||
wlx_capture::{
|
||||
pipewire::{pipewire_select_screen, PipewireCapture},
|
||||
wayland::{WlxClient, WlxOutput},
|
||||
wayland::{wayland_client::protocol::wl_output, WlxClient, WlxOutput},
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
wlr_screencopy::WlrScreencopyCapture,
|
||||
},
|
||||
@@ -566,14 +565,16 @@ where
|
||||
interaction: Box::new(ScreenInteractionHandler::new(
|
||||
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),
|
||||
output.transform,
|
||||
output.transform.into(),
|
||||
)),
|
||||
});
|
||||
|
||||
let axis = Vec3::new(0., 0., 1.);
|
||||
|
||||
let transform = output.transform.into();
|
||||
|
||||
let angle = if session.config.upright_screen_fix {
|
||||
match output.transform {
|
||||
match transform {
|
||||
Transform::_90 | Transform::Flipped90 => PI / 2.,
|
||||
Transform::_180 | Transform::Flipped180 => PI,
|
||||
Transform::_270 | Transform::Flipped270 => -PI / 2.,
|
||||
@@ -584,7 +585,7 @@ where
|
||||
};
|
||||
|
||||
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(
|
||||
Vec2::NEG_Y * (output.size.0 as f32 / output.size.1 as f32),
|
||||
Vec2::NEG_X,
|
||||
@@ -797,6 +798,33 @@ where
|
||||
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] {
|
||||
// screens above a certain resolution will have severe aliasing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user