mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-01 04:34:11 +01:00
refactor(windows): use the behaviour enums of komorebi-config
core re-exports WindowContainerBehaviour, FloatingLayerBehaviour, Placement, CrossBoundaryBehaviour and WindowHandlingBehaviour, and border_manager re-exports ZOrder, from komorebi-config; the local definitions and their impls (including From<ZOrder> for isize, which the orphan rule requires to move with the type) are removed, so no call site changes. Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings: clean (tier 2). schema.json untouched.
This commit is contained in:
1 parent
79c9af95d1
commit
92adaf72fa
2 files changed
+6
-131
No files matched your search
@@ -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<ZOrder> 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::*;
|
||||
|
||||
@@ -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<config_generation::MatchingRule>),
|
||||
}
|
||||
|
||||
#[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::*;
|
||||
|
||||
Reference in new issue
Block a user