diff --git a/komorebi/src/border_manager/mod.rs b/komorebi/src/border_manager/mod.rs index f4a7c528..ccbb0a98 100644 --- a/komorebi/src/border_manager/mod.rs +++ b/komorebi/src/border_manager/mod.rs @@ -11,6 +11,7 @@ use crate::windows_api; use crate::workspace::Workspace; use crate::workspace::WorkspaceLayer; pub use border::Border; +pub use komorebi_config::behaviour::ZOrder; use border::border_hwnds; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; @@ -20,8 +21,6 @@ use komorebi_themes::colour::Colour; use komorebi_themes::colour::Rgb; use lazy_static::lazy_static; use parking_lot::Mutex; -use serde::Deserialize; -use serde::Serialize; use std::collections::HashMap; use std::collections::HashSet; use std::collections::hash_map::Entry; @@ -32,7 +31,6 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicI32; use std::sync::atomic::AtomicU32; use std::sync::atomic::Ordering; -use strum::Display; use windows::Win32::Foundation::HWND; use windows::Win32::Graphics::Direct2D::ID2D1HwndRenderTarget; @@ -1102,42 +1100,6 @@ pub fn hide_border(tracking_hwnd: isize) { }); } -#[derive(Debug, Copy, Clone, Display, Serialize, Deserialize, PartialEq)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Z Order (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos) -pub enum ZOrder { - /// HWND_TOP - /// - /// Places the window at the top of the Z order. - Top, - /// HWND_NOTOPMOST - /// - /// Places the window above all non-topmost windows (that is, behind all topmost windows). - /// This flag has no effect if the window is already a non-topmost window. - NoTopMost, - /// HWND_BOTTOM - /// - /// Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, - /// the window loses its topmost status and is placed at the bottom of all other windows. - Bottom, - /// HWND_TOPMOST - /// - /// Places the window above all non-topmost windows. - /// The window maintains its topmost position even when it is deactivated. - TopMost, -} - -impl From for isize { - fn from(val: ZOrder) -> Self { - match val { - ZOrder::Top => 0, - ZOrder::NoTopMost => -2, - ZOrder::Bottom => 1, - ZOrder::TopMost => -1, - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index c02029ce..569bee03 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -41,6 +41,11 @@ pub use komorebi_layouts::validate_ratios; // Local modules and exports pub use animation::AnimationStyle; +pub use komorebi_config::behaviour::CrossBoundaryBehaviour; +pub use komorebi_config::behaviour::FloatingLayerBehaviour; +pub use komorebi_config::behaviour::Placement; +pub use komorebi_config::behaviour::WindowContainerBehaviour; +pub use komorebi_config::behaviour::WindowHandlingBehaviour; pub use komorebi_protocol::types::ApplicationIdentifier; pub use komorebi_protocol::types::BorderImplementation; pub use komorebi_protocol::types::BorderStyle; @@ -93,72 +98,6 @@ pub struct WindowManagementBehaviour { pub float_rule_placement: Placement, } -#[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Window container behaviour when a new window is opened -pub enum WindowContainerBehaviour { - /// Create a new container for each new window - #[default] - Create, - /// Append new windows to the focused window container - Append, -} - -#[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Floating layer behaviour when a new window is opened -pub enum FloatingLayerBehaviour { - /// Tile new windows (unless they match a float rule or float override is active) - #[default] - Tile, - /// Float new windows - Float, -} - -#[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Placement behaviour for floating windows -pub enum Placement { - /// Does not change the size or position of the window - #[default] - None, - /// Center the window without changing the size - Center, - /// Center the window and resize it according to the `AspectRatio` - CenterAndResize, -} - -impl FloatingLayerBehaviour { - pub fn should_float(&self) -> bool { - match self { - FloatingLayerBehaviour::Tile => false, - FloatingLayerBehaviour::Float => true, - } - } -} - -impl Placement { - pub fn should_center(&self) -> bool { - match self { - Placement::None => false, - Placement::Center | Placement::CenterAndResize => true, - } - } - - pub fn should_resize(&self) -> bool { - match self { - Placement::None | Placement::Center => false, - Placement::CenterAndResize => true, - } - } -} - #[derive( Clone, Copy, @@ -385,32 +324,6 @@ pub enum PlacementMatchingRules { Many(Vec), } -#[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Behaviour when an action would cross a monitor boundary -pub enum CrossBoundaryBehaviour { - /// Attempt to perform actions across a workspace boundary - Workspace, - /// Attempt to perform actions across a monitor boundary - #[default] - Monitor, -} - -#[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Window handling behaviour -pub enum WindowHandlingBehaviour { - #[default] - /// Synchronous - Sync, - /// Asynchronous - Async, -} - #[cfg(test)] mod tests { use super::*;