sorry about monster commit
This commit is contained in:
@@ -1,26 +1,23 @@
|
||||
use std::{
|
||||
sync::{Arc, LazyLock, atomic::AtomicU64},
|
||||
sync::{atomic::AtomicU64, Arc, LazyLock},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use glam::{Affine2, Vec2, vec2};
|
||||
use glam::{vec2, Affine2, Vec2};
|
||||
use vulkano::image::view::ImageView;
|
||||
use wlx_capture::WlxCapture;
|
||||
use wlx_capture::{frame::Transform, WlxCapture};
|
||||
|
||||
use crate::{
|
||||
backend::{
|
||||
input::{Haptics, PointerHit, PointerMode},
|
||||
overlay::{FrameMeta, OverlayBackend, ShouldRender},
|
||||
},
|
||||
graphics::CommandBuffers,
|
||||
graphics::{CommandBuffers, ExtentExt},
|
||||
state::AppState,
|
||||
subsystem::hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
||||
};
|
||||
|
||||
use super::{
|
||||
Transform,
|
||||
capture::{ScreenPipeline, WlxCaptureIn, WlxCaptureOut, receive_callback},
|
||||
};
|
||||
use super::capture::{receive_callback, ScreenPipeline, WlxCaptureIn, WlxCaptureOut};
|
||||
|
||||
const CURSOR_SIZE: f32 = 16. / 1440.;
|
||||
|
||||
@@ -66,17 +63,17 @@ impl ScreenBackend {
|
||||
|
||||
pub(super) fn set_mouse_transform(&mut self, pos: Vec2, size: Vec2, transform: Transform) {
|
||||
self.mouse_transform = match transform {
|
||||
Transform::_90 | Transform::Flipped90 => Affine2::from_cols(
|
||||
Transform::Rotated90 | Transform::Flipped90 => Affine2::from_cols(
|
||||
vec2(0., size.y),
|
||||
vec2(-size.x, 0.),
|
||||
vec2(pos.x + size.x, pos.y),
|
||||
),
|
||||
Transform::_180 | Transform::Flipped180 => Affine2::from_cols(
|
||||
Transform::Rotated180 | Transform::Flipped180 => Affine2::from_cols(
|
||||
vec2(-size.x, 0.),
|
||||
vec2(0., -size.y),
|
||||
vec2(pos.x + size.x, pos.y + size.y),
|
||||
),
|
||||
Transform::_270 | Transform::Flipped270 => Affine2::from_cols(
|
||||
Transform::Rotated270 | Transform::Flipped270 => Affine2::from_cols(
|
||||
vec2(0., -size.y),
|
||||
vec2(size.x, 0.),
|
||||
vec2(pos.x, pos.y + size.y),
|
||||
@@ -85,16 +82,16 @@ impl ScreenBackend {
|
||||
};
|
||||
}
|
||||
|
||||
pub(super) fn get_interaction_transform(&mut self, res: Vec2, transform: Transform) {
|
||||
pub(super) fn set_interaction_transform(&mut self, res: Vec2, transform: Transform) {
|
||||
let center = Vec2 { x: 0.5, y: 0.5 };
|
||||
self.interaction_transform = Some(match transform {
|
||||
Transform::_90 | Transform::Flipped90 => {
|
||||
Transform::Rotated90 | Transform::Flipped90 => {
|
||||
Affine2::from_cols(Vec2::NEG_Y * (res.x / res.y), Vec2::NEG_X, center)
|
||||
}
|
||||
Transform::_180 | Transform::Flipped180 => {
|
||||
Transform::Rotated180 | Transform::Flipped180 => {
|
||||
Affine2::from_cols(Vec2::NEG_X, Vec2::NEG_Y * (-res.x / res.y), center)
|
||||
}
|
||||
Transform::_270 | Transform::Flipped270 => {
|
||||
Transform::Rotated270 | Transform::Flipped270 => {
|
||||
Affine2::from_cols(Vec2::Y * (res.x / res.y), Vec2::X, center)
|
||||
}
|
||||
_ if res.y > res.x => {
|
||||
@@ -164,9 +161,14 @@ impl OverlayBackend for ScreenBackend {
|
||||
if let Some(pipeline) = self.pipeline.as_mut() {
|
||||
if self.meta.is_some_and(|old| old.extent != meta.extent) {
|
||||
pipeline.set_extent(app, [meta.extent[0] as _, meta.extent[1] as _])?;
|
||||
self.set_interaction_transform(
|
||||
meta.extent.extent_vec2(),
|
||||
frame.get_transform(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.pipeline = Some(ScreenPipeline::new(&meta, app)?);
|
||||
self.set_interaction_transform(meta.extent.extent_vec2(), frame.get_transform());
|
||||
}
|
||||
|
||||
self.meta = Some(meta);
|
||||
|
||||
@@ -6,22 +6,21 @@ use vulkano::{
|
||||
command_buffer::CommandBufferUsage,
|
||||
device::Queue,
|
||||
format::Format,
|
||||
image::{Image, sampler::Filter, view::ImageView},
|
||||
image::{sampler::Filter, view::ImageView, Image},
|
||||
pipeline::graphics::{color_blend::AttachmentBlend, input_assembly::PrimitiveTopology},
|
||||
};
|
||||
use wgui::gfx::{WGfx, pass::WGfxPass, pipeline::WGfxPipeline};
|
||||
use wgui::gfx::{pass::WGfxPass, pipeline::WGfxPipeline, WGfx};
|
||||
use wlx_capture::{
|
||||
frame::{self as wlx_frame, DrmFormat, FrameFormat, MouseMeta, Transform, WlxFrame},
|
||||
WlxCapture,
|
||||
frame::{self as wlx_frame, DrmFormat, FrameFormat, MouseMeta, WlxFrame},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
backend::overlay::FrameMeta,
|
||||
config::GeneralConfig,
|
||||
graphics::{
|
||||
CommandBuffers, Vert2Uv,
|
||||
dmabuf::{WGfxDmabuf, fourcc_to_vk},
|
||||
upload_quad_vertices,
|
||||
dmabuf::{fourcc_to_vk, WGfxDmabuf},
|
||||
upload_quad_vertices, CommandBuffers, Vert2Uv,
|
||||
},
|
||||
state::AppState,
|
||||
};
|
||||
@@ -209,6 +208,10 @@ impl WlxCaptureOut {
|
||||
format: self.image.format(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) const fn get_transform(&self) -> Transform {
|
||||
self.format.transform
|
||||
}
|
||||
}
|
||||
|
||||
fn upload_image(
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use std::{f32::consts::PI, sync::Arc};
|
||||
|
||||
use backend::ScreenBackend;
|
||||
use glam::{Quat, Vec3, vec3a};
|
||||
use wayland_client::protocol::wl_output;
|
||||
use glam::{vec3a, Quat, Vec3};
|
||||
use wl::create_screens_wayland;
|
||||
use x11::{create_screens_x11pw, create_screens_xshm};
|
||||
use wlx_capture::frame::Transform;
|
||||
|
||||
use crate::{
|
||||
backend::overlay::{OverlayState, Positioning},
|
||||
@@ -21,41 +20,12 @@ pub mod wl;
|
||||
#[cfg(feature = "x11")]
|
||||
pub mod x11;
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Transform {
|
||||
Normal,
|
||||
_90,
|
||||
_180,
|
||||
_270,
|
||||
Flipped,
|
||||
Flipped90,
|
||||
Flipped180,
|
||||
Flipped270,
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
impl From<wl_output::Transform> for Transform {
|
||||
fn from(t: wl_output::Transform) -> Self {
|
||||
match t {
|
||||
wl_output::Transform::_90 => Self::_90,
|
||||
wl_output::Transform::_180 => Self::_180,
|
||||
wl_output::Transform::_270 => Self::_270,
|
||||
wl_output::Transform::Flipped => Self::Flipped,
|
||||
wl_output::Transform::Flipped90 => Self::Flipped90,
|
||||
wl_output::Transform::Flipped180 => Self::Flipped180,
|
||||
wl_output::Transform::Flipped270 => Self::Flipped270,
|
||||
_ => Self::Normal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_screen_state(name: Arc<str>, transform: Transform, session: &AppSession) -> OverlayState {
|
||||
let angle = if session.config.upright_screen_fix {
|
||||
match transform {
|
||||
Transform::_90 | Transform::Flipped90 => PI / 2.,
|
||||
Transform::_180 | Transform::Flipped180 => PI,
|
||||
Transform::_270 | Transform::Flipped270 => -PI / 2.,
|
||||
Transform::Rotated90 | Transform::Flipped90 => PI / 2.,
|
||||
Transform::Rotated180 | Transform::Flipped180 => PI,
|
||||
Transform::Rotated270 | Transform::Flipped270 => -PI / 2.,
|
||||
_ => 0.,
|
||||
}
|
||||
} else {
|
||||
@@ -103,12 +73,12 @@ pub fn create_screens(app: &mut AppState) -> anyhow::Result<(ScreenCreateData, O
|
||||
.ok();
|
||||
|
||||
#[cfg(feature = "pipewire")]
|
||||
match create_screens_x11pw(app) {
|
||||
match x11::create_screens_x11pw(app) {
|
||||
Ok(data) => return Ok((data, keymap)),
|
||||
Err(e) => log::info!("Will not use X11 PipeWire capture: {e:?}"),
|
||||
}
|
||||
|
||||
Ok((create_screens_xshm(app)?, keymap))
|
||||
Ok((x11::create_screens_xshm(app)?, keymap))
|
||||
}
|
||||
#[cfg(not(feature = "x11"))]
|
||||
anyhow::bail!("No backends left to try.")
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use glam::vec2;
|
||||
use wlx_capture::{
|
||||
WlxCapture,
|
||||
wayland::{WlxClient, WlxOutput},
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
wlr_screencopy::WlrScreencopyCapture,
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -13,10 +13,10 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
ScreenCreateData,
|
||||
backend::ScreenBackend,
|
||||
capture::{MainThreadWlxCapture, new_wlx_capture},
|
||||
capture::{new_wlx_capture, MainThreadWlxCapture},
|
||||
pw::{load_pw_token_config, save_pw_token_config},
|
||||
ScreenCreateData,
|
||||
};
|
||||
|
||||
impl ScreenBackend {
|
||||
@@ -126,7 +126,7 @@ pub fn create_screens_wayland(wl: &mut WlxClient, app: &mut AppState) -> ScreenC
|
||||
) {
|
||||
let logical_pos = vec2(output.logical_pos.0 as f32, output.logical_pos.1 as f32);
|
||||
let logical_size = vec2(output.logical_size.0 as f32, output.logical_size.1 as f32);
|
||||
let transform = output.transform.into();
|
||||
let transform = output.transform;
|
||||
|
||||
backend.set_mouse_transform(logical_pos, logical_size, transform);
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ use std::sync::Arc;
|
||||
|
||||
use glam::vec2;
|
||||
use wlx_capture::{
|
||||
WlxCapture,
|
||||
frame::Transform,
|
||||
xshm::{XshmCapture, XshmScreen},
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -12,9 +13,9 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
ScreenCreateData, Transform,
|
||||
backend::ScreenBackend,
|
||||
capture::{MainThreadWlxCapture, new_wlx_capture},
|
||||
capture::{new_wlx_capture, MainThreadWlxCapture},
|
||||
ScreenCreateData,
|
||||
};
|
||||
|
||||
#[cfg(feature = "pipewire")]
|
||||
|
||||
Reference in New Issue
Block a user