fix: x11 builds
This commit is contained in:
@@ -8,18 +8,17 @@ use std::{
|
|||||||
#[cfg(feature = "openxr")]
|
#[cfg(feature = "openxr")]
|
||||||
use openxr as xr;
|
use openxr as xr;
|
||||||
|
|
||||||
use glam::{vec2, Affine3A, Vec2, Vec3A, Vec3Swizzles};
|
use glam::{Affine3A, Vec2, Vec3A, Vec3Swizzles};
|
||||||
use idmap::IdMap;
|
use idmap::IdMap;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wlx_capture::wayland::{OutputChangeEvent, WlxClient};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{AStrMapExt, AStrSetExt},
|
config::{AStrMapExt, AStrSetExt},
|
||||||
overlays::{
|
overlays::{
|
||||||
keyboard::{create_keyboard, KEYBOARD_NAME},
|
keyboard::{create_keyboard, KEYBOARD_NAME},
|
||||||
screen::{create_screen_interaction, create_screen_renderer_wl, load_pw_token_config},
|
screen::WlxClientAlias,
|
||||||
watch::{create_watch, create_watch_canvas, WATCH_NAME},
|
watch::{create_watch, WATCH_NAME},
|
||||||
},
|
},
|
||||||
state::AppState,
|
state::AppState,
|
||||||
};
|
};
|
||||||
@@ -41,12 +40,22 @@ pub enum BackendError {
|
|||||||
Fatal(#[from] anyhow::Error),
|
Fatal(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
|
fn create_wl_client() -> Option<WlxClientAlias> {
|
||||||
|
wlx_capture::wayland::WlxClient::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "wayland"))]
|
||||||
|
fn create_wl_client() -> Option<WlxClientAlias> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
pub struct OverlayContainer<T>
|
pub struct OverlayContainer<T>
|
||||||
where
|
where
|
||||||
T: Default,
|
T: Default,
|
||||||
{
|
{
|
||||||
overlays: IdMap<usize, OverlayData<T>>,
|
overlays: IdMap<usize, OverlayData<T>>,
|
||||||
wl: Option<WlxClient>,
|
wl: Option<WlxClientAlias>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> OverlayContainer<T>
|
impl<T> OverlayContainer<T>
|
||||||
@@ -55,7 +64,7 @@ where
|
|||||||
{
|
{
|
||||||
pub fn new(app: &mut AppState) -> anyhow::Result<Self> {
|
pub fn new(app: &mut AppState) -> anyhow::Result<Self> {
|
||||||
let mut overlays = IdMap::new();
|
let mut overlays = IdMap::new();
|
||||||
let mut wl = WlxClient::new();
|
let mut wl = create_wl_client();
|
||||||
|
|
||||||
app.screens.clear();
|
app.screens.clear();
|
||||||
let data = if let Some(wl) = wl.as_mut() {
|
let data = if let Some(wl) = wl.as_mut() {
|
||||||
@@ -111,7 +120,19 @@ where
|
|||||||
Ok(Self { overlays, wl })
|
Ok(Self { overlays, wl })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "wayland"))]
|
||||||
|
pub fn update(&mut self, _app: &mut AppState) -> anyhow::Result<Vec<OverlayData<T>>> {
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
pub fn update(&mut self, app: &mut AppState) -> anyhow::Result<Vec<OverlayData<T>>> {
|
pub fn update(&mut self, app: &mut AppState) -> anyhow::Result<Vec<OverlayData<T>>> {
|
||||||
|
use crate::overlays::{
|
||||||
|
screen::{create_screen_interaction, create_screen_renderer_wl, load_pw_token_config},
|
||||||
|
watch::create_watch_canvas,
|
||||||
|
};
|
||||||
|
use glam::vec2;
|
||||||
|
use wlx_capture::wayland::OutputChangeEvent;
|
||||||
|
|
||||||
let mut removed_overlays = vec![];
|
let mut removed_overlays = vec![];
|
||||||
let Some(wl) = self.wl.as_mut() else {
|
let Some(wl) = self.wl.as_mut() else {
|
||||||
return Ok(removed_overlays);
|
return Ok(removed_overlays);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use core::slice;
|
use core::slice;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
|
f32::consts::PI,
|
||||||
ops::Add,
|
ops::Add,
|
||||||
ptr,
|
ptr,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@@ -21,9 +22,9 @@ use wlx_capture::{
|
|||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
use {
|
use {
|
||||||
|
crate::config::AStrMapExt,
|
||||||
crate::config_io,
|
crate::config_io,
|
||||||
glam::Vec3,
|
std::{error::Error, ops::Deref, path::PathBuf},
|
||||||
std::{error::Error, f32::consts::PI, ops::Deref, path::PathBuf},
|
|
||||||
wlx_capture::{
|
wlx_capture::{
|
||||||
pipewire::{pipewire_select_screen, PipewireCapture},
|
pipewire::{pipewire_select_screen, PipewireCapture},
|
||||||
wayland::{wayland_client::protocol::wl_output, WlxClient, WlxOutput},
|
wayland::{wayland_client::protocol::wl_output, WlxClient, WlxOutput},
|
||||||
@@ -35,19 +36,25 @@ use {
|
|||||||
#[cfg(feature = "x11")]
|
#[cfg(feature = "x11")]
|
||||||
use wlx_capture::xshm::{XshmCapture, XshmScreen};
|
use wlx_capture::xshm::{XshmCapture, XshmScreen};
|
||||||
|
|
||||||
use glam::{vec2, vec3a, Affine2, Quat, Vec2};
|
use glam::{vec2, vec3a, Affine2, Quat, Vec2, Vec3};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{
|
backend::{
|
||||||
input::{Haptics, InteractionHandler, PointerHit, PointerMode},
|
input::{Haptics, InteractionHandler, PointerHit, PointerMode},
|
||||||
overlay::{OverlayRenderer, OverlayState, SplitOverlayBackend},
|
overlay::{OverlayRenderer, OverlayState, SplitOverlayBackend},
|
||||||
},
|
},
|
||||||
config::{def_pw_tokens, AStrMapExt, PwTokenMap},
|
config::{def_pw_tokens, PwTokenMap},
|
||||||
graphics::{fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy},
|
graphics::{fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy},
|
||||||
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
||||||
state::{AppSession, AppState, ScreenMeta},
|
state::{AppSession, AppState, ScreenMeta},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
|
pub(crate) type WlxClientAlias = wlx_capture::wayland::WlxClient;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "wayland"))]
|
||||||
|
pub(crate) type WlxClientAlias = ();
|
||||||
|
|
||||||
const CURSOR_SIZE: f32 = 16. / 1440.;
|
const CURSOR_SIZE: f32 = 16. / 1440.;
|
||||||
|
|
||||||
static DRM_FORMATS: once_cell::sync::OnceCell<Vec<DrmFormat>> = once_cell::sync::OnceCell::new();
|
static DRM_FORMATS: once_cell::sync::OnceCell<Vec<DrmFormat>> = once_cell::sync::OnceCell::new();
|
||||||
@@ -90,9 +97,10 @@ impl InteractionHandler for ScreenInteractionHandler {
|
|||||||
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> Option<Haptics> {
|
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> Option<Haptics> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
log::trace!("Hover: {:?}", hit.uv);
|
log::trace!("Hover: {:?}", hit.uv);
|
||||||
if self.next_move < Instant::now() &&
|
if self.next_move < Instant::now()
|
||||||
(!app.session.config.focus_follows_mouse_mode
|
&& (!app.session.config.focus_follows_mouse_mode
|
||||||
|| app.input_state.pointers[hit.pointer].now.move_mouse) {
|
|| app.input_state.pointers[hit.pointer].now.move_mouse)
|
||||||
|
{
|
||||||
let pos = self.mouse_transform.transform_point2(hit.uv);
|
let pos = self.mouse_transform.transform_point2(hit.uv);
|
||||||
app.hid_provider.mouse_move(pos);
|
app.hid_provider.mouse_move(pos);
|
||||||
}
|
}
|
||||||
@@ -114,7 +122,6 @@ impl InteractionHandler for ScreenInteractionHandler {
|
|||||||
|
|
||||||
let pos = self.mouse_transform.transform_point2(hit.uv);
|
let pos = self.mouse_transform.transform_point2(hit.uv);
|
||||||
app.hid_provider.mouse_move(pos);
|
app.hid_provider.mouse_move(pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
fn on_scroll(&mut self, app: &mut AppState, hit: &PointerHit, delta: f32) {
|
fn on_scroll(&mut self, app: &mut AppState, hit: &PointerHit, delta: f32) {
|
||||||
if self.next_scroll > Instant::now() {
|
if self.next_scroll > Instant::now() {
|
||||||
@@ -653,15 +660,15 @@ pub(crate) struct ScreenCreateData {
|
|||||||
|
|
||||||
#[cfg(not(feature = "wayland"))]
|
#[cfg(not(feature = "wayland"))]
|
||||||
pub fn create_screens_wayland(
|
pub fn create_screens_wayland(
|
||||||
wl: &mut WlxClient,
|
_wl: &mut WlxClientAlias,
|
||||||
app: &AppState,
|
_app: &AppState,
|
||||||
) -> anyhow::Result<ScreenCreateData> {
|
) -> anyhow::Result<ScreenCreateData> {
|
||||||
anyhow::bail!("Wayland support not enabled")
|
anyhow::bail!("Wayland support not enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
pub fn create_screens_wayland(
|
pub fn create_screens_wayland(
|
||||||
wl: &mut WlxClient,
|
wl: &mut WlxClientAlias,
|
||||||
app: &mut AppState,
|
app: &mut AppState,
|
||||||
) -> anyhow::Result<ScreenCreateData> {
|
) -> anyhow::Result<ScreenCreateData> {
|
||||||
use crate::config::AStrMap;
|
use crate::config::AStrMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user