tree: add Transform
This commit is contained in:
parent
c99a2dfafa
commit
8b0bb61ee0
25 changed files with 153 additions and 136 deletions
|
|
@ -18,7 +18,7 @@ use {
|
|||
time::Time,
|
||||
tracy::FrameName,
|
||||
tree::OutputNode,
|
||||
utils::{errorfmt::ErrorFmt, oserror::OsError, transform_ext::TransformExt},
|
||||
utils::{errorfmt::ErrorFmt, oserror::OsError},
|
||||
video::{
|
||||
dmabuf::DmaBufId,
|
||||
drm::{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ use {
|
|||
ifs::wl_output::BlendSpace,
|
||||
scale::Scale,
|
||||
tools::tool_client::{Handle, ToolClient, with_tool_client},
|
||||
utils::{errorfmt::ErrorFmt, ordered_float::F64, transform_ext::TransformExt},
|
||||
tree::Transform,
|
||||
utils::{errorfmt::ErrorFmt, ordered_float::F64},
|
||||
wire::{JayRandrId, jay_compositor, jay_randr},
|
||||
},
|
||||
clap::{
|
||||
|
|
@ -15,7 +16,7 @@ use {
|
|||
builder::{PossibleValue, PossibleValuesParser},
|
||||
},
|
||||
isnt::std_1::vec::IsntVecExt,
|
||||
jay_config::video::{TearingMode, Transform, VrrMode},
|
||||
jay_config::video::{TearingMode, VrrMode},
|
||||
linearize::LinearizeExt,
|
||||
std::{
|
||||
cell::RefCell,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ use {
|
|||
tasks::{self, handle_const_40hz_latch, idle},
|
||||
tracy::enable_profiler,
|
||||
tree::{
|
||||
DisplayNode, NodeIds, OutputNode, TearingMode, VrrMode, WorkspaceNode,
|
||||
DisplayNode, NodeIds, OutputNode, TearingMode, Transform, VrrMode, WorkspaceNode,
|
||||
container_layout, container_render_positions, container_render_titles, float_layout,
|
||||
float_titles, output_render_data, placeholder_render_textures,
|
||||
},
|
||||
|
|
@ -82,7 +82,7 @@ use {
|
|||
},
|
||||
ahash::AHashSet,
|
||||
forker::ForkerProxy,
|
||||
jay_config::{_private::DEFAULT_SEAT_NAME, video::Transform, workspace::WorkspaceDisplayOrder},
|
||||
jay_config::{_private::DEFAULT_SEAT_NAME, workspace::WorkspaceDisplayOrder},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
env,
|
||||
|
|
|
|||
|
|
@ -1561,7 +1561,7 @@ impl ConfigProxyHandler {
|
|||
transform: Transform,
|
||||
) -> Result<(), CphError> {
|
||||
let connector = self.get_output_node(connector)?;
|
||||
connector.update_transform(transform);
|
||||
connector.update_transform(transform.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use {
|
|||
tree::OutputNode,
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt, rc_eq::rc_eq, transform_ext::TransformExt,
|
||||
hash_map_ext::HashMapExt, rc_eq::rc_eq,
|
||||
},
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, rc::Rc},
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ use {
|
|||
state::State,
|
||||
theme::Color,
|
||||
time::Time,
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, errorfmt::ErrorFmt, timer::TimerFd, transform_ext::TransformExt,
|
||||
},
|
||||
tree::Transform,
|
||||
utils::{asyncevent::AsyncEvent, errorfmt::ErrorFmt, timer::TimerFd},
|
||||
},
|
||||
isnt::std_1::primitive::IsntSliceExt,
|
||||
jay_config::video::Transform,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::VecDeque,
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ use {
|
|||
scale::Scale,
|
||||
state::State,
|
||||
theme::Color,
|
||||
tree::{Node, OutputNode},
|
||||
utils::{clonecell::UnsafeCellCloneSafe, transform_ext::TransformExt},
|
||||
tree::{Node, OutputNode, Transform},
|
||||
utils::clonecell::UnsafeCellCloneSafe,
|
||||
video::{Modifier, dmabuf::DmaBuf, drm::sync_obj::SyncObjCtx},
|
||||
},
|
||||
ahash::AHashMap,
|
||||
indexmap::{IndexMap, IndexSet},
|
||||
jay_config::video::{GfxApi as ConfigGfxApi, Transform},
|
||||
jay_config::video::GfxApi as ConfigGfxApi,
|
||||
linearize::Linearize,
|
||||
std::{
|
||||
any::Any,
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Region,
|
||||
tree::{Node, OutputNode},
|
||||
utils::{cell_ext::CellExt, errorfmt::ErrorFmt, transform_ext::TransformExt},
|
||||
tree::{self, Node, OutputNode},
|
||||
utils::{cell_ext::CellExt, errorfmt::ErrorFmt},
|
||||
wire::{ExtImageCopyCaptureFrameV1Id, ext_image_copy_capture_frame_v1::*},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -216,7 +216,7 @@ impl ExtImageCopyCaptureFrameV1 {
|
|||
&fb,
|
||||
aq,
|
||||
re,
|
||||
jay_config::video::Transform::None,
|
||||
tree::Transform::None,
|
||||
self.client.state.color_manager.srgb_gamma22(),
|
||||
on.global.pos.get(),
|
||||
render_hardware_cursors,
|
||||
|
|
@ -244,7 +244,7 @@ impl ExtImageCopyCaptureFrameV1 {
|
|||
true,
|
||||
true,
|
||||
false,
|
||||
jay_config::video::Transform::None,
|
||||
tree::Transform::None,
|
||||
None,
|
||||
self.client.state.color_manager.srgb_linear(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ use {
|
|||
},
|
||||
scale::Scale,
|
||||
state::OutputData,
|
||||
tree::OutputNode,
|
||||
tree::{OutputNode, Transform},
|
||||
utils::{copyhashmap::CopyHashMap, hash_map_ext::HashMapExt, rc_eq::RcEq},
|
||||
wire::JayHeadManagerSessionV1Id,
|
||||
},
|
||||
jay_config::video::{TearingMode, Transform, VrrMode},
|
||||
jay_config::video::{TearingMode, VrrMode},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
rc::Rc,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::head_management::HeadState,
|
||||
utils::transform_ext::TransformExt,
|
||||
wire::{
|
||||
jay_head_ext_compositor_space_info_v1::{
|
||||
Disabled, Enabled, Inside, JayHeadExtCompositorSpaceInfoV1RequestHandler, Outside,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::head_management::{HeadOp, HeadState},
|
||||
utils::transform_ext::TransformExt,
|
||||
tree::Transform,
|
||||
wire::{
|
||||
jay_head_ext_compositor_space_transformer_v1::{
|
||||
JayHeadExtCompositorSpaceTransformerV1RequestHandler, SetTransform,
|
||||
|
|
@ -10,7 +10,6 @@ use {
|
|||
jay_head_manager_ext_compositor_space_transformer_v1::JayHeadManagerExtCompositorSpaceTransformerV1RequestHandler,
|
||||
},
|
||||
},
|
||||
jay_config::video::Transform,
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ use {
|
|||
object::{Object, Version},
|
||||
scale::Scale,
|
||||
state::{ConnectorData, DrmDevData, OutputData, State},
|
||||
tree::{OutputNode, TearingMode, VrrMode},
|
||||
utils::{errorfmt::ErrorFmt, transform_ext::TransformExt},
|
||||
tree::{OutputNode, TearingMode, Transform, VrrMode},
|
||||
utils::errorfmt::ErrorFmt,
|
||||
wire::{JayRandrId, jay_randr::*},
|
||||
},
|
||||
jay_config::video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
|
||||
jay_config::video::{TearingMode as ConfigTearingMode, VrrMode as ConfigVrrMode},
|
||||
linearize::LinearizeExt,
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ use {
|
|||
object::{Object, Version},
|
||||
scale::Scale,
|
||||
state::State,
|
||||
tree::{LatchListener, OutputNode, ToplevelNode, WorkspaceNode, WorkspaceNodeId},
|
||||
tree::{
|
||||
LatchListener, OutputNode, ToplevelNode, Transform, WorkspaceNode, WorkspaceNodeId,
|
||||
},
|
||||
utils::{
|
||||
clonecell::{CloneCell, UnsafeCellCloneSafe},
|
||||
errorfmt::ErrorFmt,
|
||||
|
|
@ -24,7 +26,6 @@ use {
|
|||
wire::{JayScreencastId, jay_screencast::*},
|
||||
},
|
||||
ahash::AHashSet,
|
||||
jay_config::video::Transform,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::DerefMut,
|
||||
|
|
|
|||
|
|
@ -21,15 +21,14 @@ use {
|
|||
object::{Object, Version},
|
||||
rect::Rect,
|
||||
state::{ConnectorData, State},
|
||||
tree::{OutputNode, TearingMode, VrrMode, calculate_logical_size},
|
||||
tree::{OutputNode, TearingMode, Transform, VrrMode, calculate_logical_size},
|
||||
utils::{
|
||||
cell_ext::CellExt, clonecell::CloneCell, copyhashmap::CopyHashMap, ordered_float::F64,
|
||||
rc_eq::rc_eq, transform_ext::TransformExt,
|
||||
rc_eq::rc_eq,
|
||||
},
|
||||
wire::{WlOutputId, WpColorManagementOutputV1Id, ZxdgOutputV1Id, wl_output::*},
|
||||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::video::Transform,
|
||||
linearize::Linearize,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
|
|
|
|||
|
|
@ -79,13 +79,13 @@ use {
|
|||
tree::{
|
||||
BeforeLatchListener, BeforeLatchResult, ContainerNode, FindTreeResult, FoundNode,
|
||||
LatchListener, Node, NodeId, NodeLayerLink, NodeLocation, NodeVisitor, NodeVisitorBase,
|
||||
OutputNode, PlaceholderNode, PresentationListener, ToplevelNode, VblankListener,
|
||||
OutputNode, PlaceholderNode, PresentationListener, ToplevelNode, Transform,
|
||||
VblankListener,
|
||||
},
|
||||
utils::{
|
||||
cell_ext::CellExt, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
double_buffered::DoubleBuffered, errorfmt::ErrorFmt, event_listener::EventListener,
|
||||
linkedlist::LinkedList, numcell::NumCell, smallmap::SmallMap,
|
||||
transform_ext::TransformExt,
|
||||
},
|
||||
video::{
|
||||
dmabuf::DMA_BUF_SYNC_READ,
|
||||
|
|
@ -99,7 +99,6 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
isnt::std_1::{primitive::IsntSliceExt, vec::IsntVecExt},
|
||||
jay_config::video::Transform,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::hash_map::{Entry, OccupiedEntry},
|
||||
|
|
|
|||
|
|
@ -9,11 +9,9 @@ use {
|
|||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
scale::Scale,
|
||||
tree::VrrMode,
|
||||
utils::transform_ext::TransformExt,
|
||||
tree::{Transform, VrrMode},
|
||||
wire::{ZwlrOutputConfigurationHeadV1Id, zwlr_output_configuration_head_v1::*},
|
||||
},
|
||||
jay_config::video::Transform,
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ use {
|
|||
object::{Object, Version},
|
||||
scale,
|
||||
state::OutputData,
|
||||
tree::VrrMode,
|
||||
utils::transform_ext::TransformExt,
|
||||
tree::{self, VrrMode},
|
||||
wire::{ZwlrOutputHeadV1Id, zwlr_output_head_v1::*},
|
||||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::video,
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
|
@ -111,7 +109,7 @@ impl ZwlrOutputHeadV1 {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn send_transform(&self, transform: video::Transform) {
|
||||
pub fn send_transform(&self, transform: tree::Transform) {
|
||||
self.client.event(Transform {
|
||||
self_id: self.id,
|
||||
transform: transform.to_wl(),
|
||||
|
|
@ -173,7 +171,7 @@ impl ZwlrOutputHeadV1 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn hande_transform_change(&self, transform: video::Transform) {
|
||||
pub fn hande_transform_change(&self, transform: tree::Transform) {
|
||||
self.send_transform(transform);
|
||||
self.manager.schedule_done();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ use {
|
|||
rect::Rect,
|
||||
scale::Scale,
|
||||
theme::Color,
|
||||
utils::transform_ext::TransformExt,
|
||||
tree::Transform,
|
||||
},
|
||||
jay_config::video::Transform,
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ use {
|
|||
gfx_api::{AcquireSync, GfxError, ReleaseSync, needs_render_usage},
|
||||
scale::Scale,
|
||||
state::State,
|
||||
tree::Transform,
|
||||
video::drm::DrmError,
|
||||
},
|
||||
indexmap::IndexMap,
|
||||
jay_config::video::Transform,
|
||||
std::{ops::Deref, rc::Rc},
|
||||
thiserror::Error,
|
||||
uapi::OwnedFd,
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ use {
|
|||
tree::{
|
||||
ContainerNode, ContainerSplit, Direction, DisplayNode, FindTreeUsecase, FloatNode,
|
||||
FoundNode, LatchListener, Node, NodeIds, NodeVisitorBase, OutputNode, PlaceholderNode,
|
||||
TearingMode, TileState, ToplevelData, ToplevelNode, ToplevelNodeBase, VrrMode,
|
||||
WorkspaceNode, WsMoveConfig, generic_node_visitor, move_ws_to_output,
|
||||
TearingMode, TileState, ToplevelData, ToplevelNode, ToplevelNodeBase, Transform,
|
||||
VrrMode, WorkspaceNode, WsMoveConfig, generic_node_visitor, move_ws_to_output,
|
||||
},
|
||||
udmabuf::UdmabufHolder,
|
||||
utils::{
|
||||
|
|
@ -135,7 +135,7 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
bstr::ByteSlice,
|
||||
jay_config::{PciId, video::Transform, workspace::WorkspaceDisplayOrder},
|
||||
jay_config::{PciId, workspace::WorkspaceDisplayOrder},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
fmt::{Debug, Formatter},
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ use {
|
|||
},
|
||||
output_schedule::OutputSchedule,
|
||||
state::{ConnectorData, OutputData, State},
|
||||
tree::{OutputNode, WsMoveConfig, move_ws_to_output},
|
||||
tree::{OutputNode, Transform, WsMoveConfig, move_ws_to_output},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, clonecell::CloneCell, hash_map_ext::HashMapExt, rc_eq::RcEq,
|
||||
},
|
||||
},
|
||||
jay_config::video::Transform,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::VecDeque,
|
||||
|
|
|
|||
112
src/tree.rs
112
src/tree.rs
|
|
@ -4,6 +4,10 @@ use {
|
|||
client::{Client, ClientId},
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_output::{
|
||||
TF_90, TF_180, TF_270, TF_FLIPPED, TF_FLIPPED_90, TF_FLIPPED_180, TF_FLIPPED_270,
|
||||
TF_NORMAL,
|
||||
},
|
||||
wl_seat::{
|
||||
Dnd, NodeSeatState, WlSeatGlobal,
|
||||
tablet::{
|
||||
|
|
@ -23,7 +27,10 @@ use {
|
|||
renderer::Renderer,
|
||||
utils::{linkedlist::NodeRef, numcell::NumCell},
|
||||
},
|
||||
jay_config::{Direction as JayDirection, window::TileState as ConfigTileState},
|
||||
jay_config::{
|
||||
Direction as JayDirection, video::Transform as ConfigTransform,
|
||||
window::TileState as ConfigTileState,
|
||||
},
|
||||
linearize::{Linearize, LinearizeExt},
|
||||
std::{
|
||||
fmt::{Debug, Display},
|
||||
|
|
@ -46,6 +53,109 @@ mod toplevel;
|
|||
mod walker;
|
||||
mod workspace;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, Linearize)]
|
||||
pub enum Transform {
|
||||
#[default]
|
||||
None,
|
||||
Rotate90,
|
||||
Rotate180,
|
||||
Rotate270,
|
||||
Flip,
|
||||
FlipRotate90,
|
||||
FlipRotate180,
|
||||
FlipRotate270,
|
||||
}
|
||||
|
||||
impl From<ConfigTransform> for Transform {
|
||||
fn from(value: ConfigTransform) -> Self {
|
||||
match value {
|
||||
ConfigTransform::None => Transform::None,
|
||||
ConfigTransform::Rotate90 => Transform::Rotate90,
|
||||
ConfigTransform::Rotate180 => Transform::Rotate180,
|
||||
ConfigTransform::Rotate270 => Transform::Rotate270,
|
||||
ConfigTransform::Flip => Transform::Flip,
|
||||
ConfigTransform::FlipRotate90 => Transform::FlipRotate90,
|
||||
ConfigTransform::FlipRotate180 => Transform::FlipRotate180,
|
||||
ConfigTransform::FlipRotate270 => Transform::FlipRotate270,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<ConfigTransform> for Transform {
|
||||
fn into(self) -> ConfigTransform {
|
||||
match self {
|
||||
Transform::None => ConfigTransform::None,
|
||||
Transform::Rotate90 => ConfigTransform::Rotate90,
|
||||
Transform::Rotate180 => ConfigTransform::Rotate180,
|
||||
Transform::Rotate270 => ConfigTransform::Rotate270,
|
||||
Transform::Flip => ConfigTransform::Flip,
|
||||
Transform::FlipRotate90 => ConfigTransform::FlipRotate90,
|
||||
Transform::FlipRotate180 => ConfigTransform::FlipRotate180,
|
||||
Transform::FlipRotate270 => ConfigTransform::FlipRotate270,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Transform {
|
||||
pub fn maybe_swap<T>(self, (left, right): (T, T)) -> (T, T) {
|
||||
match self {
|
||||
Self::None | Self::Rotate180 | Self::Flip | Self::FlipRotate180 => (left, right),
|
||||
Self::Rotate90 | Self::Rotate270 | Self::FlipRotate90 | Self::FlipRotate270 => {
|
||||
(right, left)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_wl(self) -> i32 {
|
||||
match self {
|
||||
Self::None => TF_NORMAL,
|
||||
Self::Rotate90 => TF_90,
|
||||
Self::Rotate180 => TF_180,
|
||||
Self::Rotate270 => TF_270,
|
||||
Self::Flip => TF_FLIPPED,
|
||||
Self::FlipRotate90 => TF_FLIPPED_90,
|
||||
Self::FlipRotate180 => TF_FLIPPED_180,
|
||||
Self::FlipRotate270 => TF_FLIPPED_270,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_wl(wl: i32) -> Option<Self> {
|
||||
let tf = match wl {
|
||||
TF_NORMAL => Self::None,
|
||||
TF_90 => Self::Rotate90,
|
||||
TF_180 => Self::Rotate180,
|
||||
TF_270 => Self::Rotate270,
|
||||
TF_FLIPPED => Self::Flip,
|
||||
TF_FLIPPED_90 => Self::FlipRotate90,
|
||||
TF_FLIPPED_180 => Self::FlipRotate180,
|
||||
TF_FLIPPED_270 => Self::FlipRotate270,
|
||||
_ => return None,
|
||||
};
|
||||
Some(tf)
|
||||
}
|
||||
|
||||
pub fn apply_point(self, width: i32, height: i32, (x, y): (i32, i32)) -> (i32, i32) {
|
||||
match self {
|
||||
Self::None => (x, y),
|
||||
Self::Rotate90 => (y, height - x),
|
||||
Self::Rotate180 => (width - x, height - y),
|
||||
Self::Rotate270 => (width - y, x),
|
||||
Self::Flip => (width - x, y),
|
||||
Self::FlipRotate90 => (y, x),
|
||||
Self::FlipRotate180 => (x, height - y),
|
||||
Self::FlipRotate270 => (width - y, height - x),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inverse(self) -> Self {
|
||||
match self {
|
||||
Self::Rotate90 => Self::Rotate270,
|
||||
Self::Rotate270 => Self::Rotate90,
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Linearize)]
|
||||
pub enum TileState {
|
||||
Tiled,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ use {
|
|||
theme::BarPosition,
|
||||
tree::{
|
||||
Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLayerLink,
|
||||
NodeLocation, PinnedNode, StackedNode, TddType, TileDragDestination,
|
||||
NodeLocation, PinnedNode, StackedNode, TddType, TileDragDestination, Transform,
|
||||
WorkspaceDragDestination, WorkspaceNode, WorkspaceNodeId, walker::NodeVisitor,
|
||||
},
|
||||
utils::{
|
||||
|
|
@ -60,7 +60,6 @@ use {
|
|||
linkedlist::{LinkedList, NodeRef},
|
||||
on_drop_event::OnDropEvent,
|
||||
scroller::Scroller,
|
||||
transform_ext::TransformExt,
|
||||
},
|
||||
wire::{
|
||||
ExtImageCopyCaptureSessionV1Id, JayOutputId, JayScreencastId, ZwlrScreencopyFrameV1Id,
|
||||
|
|
@ -68,7 +67,7 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::{
|
||||
video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
|
||||
video::{TearingMode as ConfigTearingMode, VrrMode as ConfigVrrMode},
|
||||
workspace::WorkspaceDisplayOrder,
|
||||
},
|
||||
smallvec::SmallVec,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ pub mod syncqueue;
|
|||
pub mod threshold_counter;
|
||||
pub mod timer;
|
||||
pub mod toplevel_identifier;
|
||||
pub mod transform_ext;
|
||||
pub mod tri;
|
||||
pub mod unlink_on_drop;
|
||||
pub mod vec_ext;
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
use {
|
||||
crate::ifs::wl_output::{
|
||||
TF_90, TF_180, TF_270, TF_FLIPPED, TF_FLIPPED_90, TF_FLIPPED_180, TF_FLIPPED_270, TF_NORMAL,
|
||||
},
|
||||
jay_config::video::{
|
||||
Transform,
|
||||
Transform::{
|
||||
Flip, FlipRotate90, FlipRotate180, FlipRotate270, None, Rotate90, Rotate180, Rotate270,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
pub trait TransformExt: Sized {
|
||||
fn maybe_swap<T>(self, args: (T, T)) -> (T, T);
|
||||
|
||||
fn to_wl(self) -> i32;
|
||||
|
||||
fn from_wl(wl: i32) -> Option<Self>;
|
||||
|
||||
fn apply_point(self, width: i32, height: i32, point: (i32, i32)) -> (i32, i32);
|
||||
|
||||
fn inverse(self) -> Self;
|
||||
}
|
||||
|
||||
impl TransformExt for Transform {
|
||||
fn maybe_swap<T>(self, (left, right): (T, T)) -> (T, T) {
|
||||
match self {
|
||||
None | Rotate180 | Flip | FlipRotate180 => (left, right),
|
||||
Rotate90 | Rotate270 | FlipRotate90 | FlipRotate270 => (right, left),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_wl(self) -> i32 {
|
||||
match self {
|
||||
None => TF_NORMAL,
|
||||
Rotate90 => TF_90,
|
||||
Rotate180 => TF_180,
|
||||
Rotate270 => TF_270,
|
||||
Flip => TF_FLIPPED,
|
||||
FlipRotate90 => TF_FLIPPED_90,
|
||||
FlipRotate180 => TF_FLIPPED_180,
|
||||
FlipRotate270 => TF_FLIPPED_270,
|
||||
}
|
||||
}
|
||||
|
||||
fn from_wl(wl: i32) -> Option<Self> {
|
||||
let tf = match wl {
|
||||
TF_NORMAL => None,
|
||||
TF_90 => Rotate90,
|
||||
TF_180 => Rotate180,
|
||||
TF_270 => Rotate270,
|
||||
TF_FLIPPED => Flip,
|
||||
TF_FLIPPED_90 => FlipRotate90,
|
||||
TF_FLIPPED_180 => FlipRotate180,
|
||||
TF_FLIPPED_270 => FlipRotate270,
|
||||
_ => return Option::None,
|
||||
};
|
||||
Some(tf)
|
||||
}
|
||||
|
||||
fn apply_point(self, width: i32, height: i32, (x, y): (i32, i32)) -> (i32, i32) {
|
||||
match self {
|
||||
None => (x, y),
|
||||
Rotate90 => (y, height - x),
|
||||
Rotate180 => (width - x, height - y),
|
||||
Rotate270 => (width - y, x),
|
||||
Flip => (width - x, y),
|
||||
FlipRotate90 => (y, x),
|
||||
FlipRotate180 => (x, height - y),
|
||||
FlipRotate270 => (width - y, height - x),
|
||||
}
|
||||
}
|
||||
|
||||
fn inverse(self) -> Self {
|
||||
match self {
|
||||
Rotate90 => Rotate270,
|
||||
Rotate270 => Rotate90,
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue