mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-04 12:11:36 +02:00
refactor(wm): ensure configurability via ipc
This commit ensures that new features such as stackbar, particularly where the configuration is located in the global state, can be configured via SocketMessages. A few structs had to be moved to komorebi-core to make this possible. I've also cleaned up a bunch of strum snake_case attrs which seemed to be unused. A new GlobalState SocketMessage has been introduced, and going forward we should make sure that this can send all global state to a requester, and move global state out of the State handler, which should only handle window manager state.
This commit is contained in:
@@ -1,15 +1,22 @@
|
|||||||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||||
#![allow(clippy::missing_errors_doc)]
|
#![allow(clippy::missing_errors_doc)]
|
||||||
|
|
||||||
|
pub use komorebi::colour::Colour;
|
||||||
|
pub use komorebi::colour::Rgb;
|
||||||
pub use komorebi::container::Container;
|
pub use komorebi::container::Container;
|
||||||
pub use komorebi::monitor::Monitor;
|
pub use komorebi::monitor::Monitor;
|
||||||
pub use komorebi::ring::Ring;
|
pub use komorebi::ring::Ring;
|
||||||
pub use komorebi::window::Window;
|
pub use komorebi::window::Window;
|
||||||
pub use komorebi::window_manager_event::WindowManagerEvent;
|
pub use komorebi::window_manager_event::WindowManagerEvent;
|
||||||
pub use komorebi::workspace::Workspace;
|
pub use komorebi::workspace::Workspace;
|
||||||
|
pub use komorebi::ActiveWindowBorderColours;
|
||||||
|
pub use komorebi::GlobalState;
|
||||||
pub use komorebi::Notification;
|
pub use komorebi::Notification;
|
||||||
pub use komorebi::NotificationEvent;
|
pub use komorebi::NotificationEvent;
|
||||||
|
pub use komorebi::StackbarConfig;
|
||||||
pub use komorebi::State;
|
pub use komorebi::State;
|
||||||
|
pub use komorebi::TabsConfig;
|
||||||
|
pub use komorebi_core::ActiveWindowBorderStyle;
|
||||||
pub use komorebi_core::Arrangement;
|
pub use komorebi_core::Arrangement;
|
||||||
pub use komorebi_core::Axis;
|
pub use komorebi_core::Axis;
|
||||||
pub use komorebi_core::CustomLayout;
|
pub use komorebi_core::CustomLayout;
|
||||||
@@ -20,6 +27,8 @@ pub use komorebi_core::Layout;
|
|||||||
pub use komorebi_core::OperationDirection;
|
pub use komorebi_core::OperationDirection;
|
||||||
pub use komorebi_core::Rect;
|
pub use komorebi_core::Rect;
|
||||||
pub use komorebi_core::SocketMessage;
|
pub use komorebi_core::SocketMessage;
|
||||||
|
pub use komorebi_core::StackbarMode;
|
||||||
|
pub use komorebi_core::WindowKind;
|
||||||
|
|
||||||
use komorebi::DATA_DIR;
|
use komorebi::DATA_DIR;
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,6 @@ impl Arrangement for CustomLayout {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum Axis {
|
pub enum Axis {
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Vertical,
|
Vertical,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use strum::EnumString;
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum CycleDirection {
|
pub enum CycleDirection {
|
||||||
Previous,
|
Previous,
|
||||||
Next,
|
Next,
|
||||||
|
|||||||
@@ -10,9 +10,18 @@ use crate::Rect;
|
|||||||
use crate::Sizing;
|
use crate::Sizing;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Debug,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Eq,
|
||||||
|
PartialEq,
|
||||||
|
Display,
|
||||||
|
EnumString,
|
||||||
|
ValueEnum,
|
||||||
|
JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum DefaultLayout {
|
pub enum DefaultLayout {
|
||||||
BSP,
|
BSP,
|
||||||
Columns,
|
Columns,
|
||||||
|
|||||||
+30
-11
@@ -131,9 +131,16 @@ pub enum SocketMessage {
|
|||||||
AltFocusHack(bool),
|
AltFocusHack(bool),
|
||||||
ActiveWindowBorder(bool),
|
ActiveWindowBorder(bool),
|
||||||
ActiveWindowBorderColour(WindowKind, u32, u32, u32),
|
ActiveWindowBorderColour(WindowKind, u32, u32, u32),
|
||||||
ActiveWindowBorderWidth(i32),
|
ActiveWindowBorderStyle(ActiveWindowBorderStyle),
|
||||||
ActiveWindowBorderOffset(i32),
|
BorderWidth(i32),
|
||||||
|
BorderOffset(i32),
|
||||||
InvisibleBorders(Rect),
|
InvisibleBorders(Rect),
|
||||||
|
StackbarMode(StackbarMode),
|
||||||
|
StackbarFocusedTextColour(u32, u32, u32),
|
||||||
|
StackbarUnfocusedTextColour(u32, u32, u32),
|
||||||
|
StackbarBackgroundColour(u32, u32, u32),
|
||||||
|
StackbarHeight(i32),
|
||||||
|
StackbarTabWidth(i32),
|
||||||
WorkAreaOffset(Rect),
|
WorkAreaOffset(Rect),
|
||||||
MonitorWorkAreaOffset(usize, Rect),
|
MonitorWorkAreaOffset(usize, Rect),
|
||||||
ResizeDelta(i32),
|
ResizeDelta(i32),
|
||||||
@@ -148,6 +155,7 @@ pub enum SocketMessage {
|
|||||||
IdentifyLayeredApplication(ApplicationIdentifier, String),
|
IdentifyLayeredApplication(ApplicationIdentifier, String),
|
||||||
IdentifyBorderOverflowApplication(ApplicationIdentifier, String),
|
IdentifyBorderOverflowApplication(ApplicationIdentifier, String),
|
||||||
State,
|
State,
|
||||||
|
GlobalState,
|
||||||
VisibleWindows,
|
VisibleWindows,
|
||||||
Query(StateQuery),
|
Query(StateQuery),
|
||||||
FocusFollowsMouse(FocusFollowsMouseImplementation, bool),
|
FocusFollowsMouse(FocusFollowsMouseImplementation, bool),
|
||||||
@@ -181,10 +189,29 @@ impl FromStr for SocketMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub enum StackbarMode {
|
||||||
|
Always,
|
||||||
|
Never,
|
||||||
|
OnStack,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, JsonSchema,
|
||||||
|
)]
|
||||||
|
pub enum ActiveWindowBorderStyle {
|
||||||
|
#[default]
|
||||||
|
/// Use the system border style
|
||||||
|
System,
|
||||||
|
/// Use the Windows 11-style rounded borders
|
||||||
|
Rounded,
|
||||||
|
/// Use the Windows 10-style square borders
|
||||||
|
Square,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum WindowKind {
|
pub enum WindowKind {
|
||||||
Single,
|
Single,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -194,7 +221,6 @@ pub enum WindowKind {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum StateQuery {
|
pub enum StateQuery {
|
||||||
FocusedMonitorIndex,
|
FocusedMonitorIndex,
|
||||||
FocusedWorkspaceIndex,
|
FocusedWorkspaceIndex,
|
||||||
@@ -215,7 +241,6 @@ pub enum StateQuery {
|
|||||||
ValueEnum,
|
ValueEnum,
|
||||||
JsonSchema,
|
JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum ApplicationIdentifier {
|
pub enum ApplicationIdentifier {
|
||||||
#[serde(alias = "exe")]
|
#[serde(alias = "exe")]
|
||||||
Exe,
|
Exe,
|
||||||
@@ -230,7 +255,6 @@ pub enum ApplicationIdentifier {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum FocusFollowsMouseImplementation {
|
pub enum FocusFollowsMouseImplementation {
|
||||||
/// A custom FFM implementation (slightly more CPU-intensive)
|
/// A custom FFM implementation (slightly more CPU-intensive)
|
||||||
Komorebi,
|
Komorebi,
|
||||||
@@ -241,7 +265,6 @@ pub enum FocusFollowsMouseImplementation {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum WindowContainerBehaviour {
|
pub enum WindowContainerBehaviour {
|
||||||
/// Create a new container for each new window
|
/// Create a new container for each new window
|
||||||
Create,
|
Create,
|
||||||
@@ -252,7 +275,6 @@ pub enum WindowContainerBehaviour {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum MoveBehaviour {
|
pub enum MoveBehaviour {
|
||||||
/// Swap the window container with the window container at the edge of the adjacent monitor
|
/// Swap the window container with the window container at the edge of the adjacent monitor
|
||||||
Swap,
|
Swap,
|
||||||
@@ -263,7 +285,6 @@ pub enum MoveBehaviour {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum HidingBehaviour {
|
pub enum HidingBehaviour {
|
||||||
/// Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps)
|
/// Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps)
|
||||||
Hide,
|
Hide,
|
||||||
@@ -276,7 +297,6 @@ pub enum HidingBehaviour {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum OperationBehaviour {
|
pub enum OperationBehaviour {
|
||||||
/// Process komorebic commands on temporarily unmanaged/floated windows
|
/// Process komorebic commands on temporarily unmanaged/floated windows
|
||||||
Op,
|
Op,
|
||||||
@@ -287,7 +307,6 @@ pub enum OperationBehaviour {
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum Sizing {
|
pub enum Sizing {
|
||||||
Increase,
|
Increase,
|
||||||
Decrease,
|
Decrease,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use crate::Axis;
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
)]
|
)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum OperationDirection {
|
pub enum OperationDirection {
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ use serde::Serialize;
|
|||||||
use crate::ring::Ring;
|
use crate::ring::Ring;
|
||||||
use crate::stackbar::Stackbar;
|
use crate::stackbar::Stackbar;
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
use crate::StackbarMode;
|
|
||||||
use crate::STACKBAR_MODE;
|
use crate::STACKBAR_MODE;
|
||||||
|
use komorebi_core::StackbarMode;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Getters, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Getters, JsonSchema)]
|
||||||
pub struct Container {
|
pub struct Container {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ use std::sync::atomic::AtomicU32;
|
|||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub use colour::*;
|
||||||
pub use hidden::*;
|
pub use hidden::*;
|
||||||
pub use process_command::*;
|
pub use process_command::*;
|
||||||
pub use process_event::*;
|
pub use process_event::*;
|
||||||
@@ -51,10 +52,12 @@ use color_eyre::Result;
|
|||||||
use komorebi_core::config_generation::IdWithIdentifier;
|
use komorebi_core::config_generation::IdWithIdentifier;
|
||||||
use komorebi_core::config_generation::MatchingRule;
|
use komorebi_core::config_generation::MatchingRule;
|
||||||
use komorebi_core::config_generation::MatchingStrategy;
|
use komorebi_core::config_generation::MatchingStrategy;
|
||||||
|
use komorebi_core::ActiveWindowBorderStyle;
|
||||||
use komorebi_core::ApplicationIdentifier;
|
use komorebi_core::ApplicationIdentifier;
|
||||||
use komorebi_core::HidingBehaviour;
|
use komorebi_core::HidingBehaviour;
|
||||||
use komorebi_core::Rect;
|
use komorebi_core::Rect;
|
||||||
use komorebi_core::SocketMessage;
|
use komorebi_core::SocketMessage;
|
||||||
|
use komorebi_core::StackbarMode;
|
||||||
use os_info::Version;
|
use os_info::Version;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ use crate::window::Window;
|
|||||||
use crate::window_manager;
|
use crate::window_manager;
|
||||||
use crate::window_manager::WindowManager;
|
use crate::window_manager::WindowManager;
|
||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
|
use crate::GlobalState;
|
||||||
use crate::Notification;
|
use crate::Notification;
|
||||||
use crate::NotificationEvent;
|
use crate::NotificationEvent;
|
||||||
|
use crate::ACTIVE_WINDOW_BORDER_STYLE;
|
||||||
use crate::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
use crate::BORDER_COLOUR_MONOCLE;
|
use crate::BORDER_COLOUR_MONOCLE;
|
||||||
use crate::BORDER_COLOUR_SINGLE;
|
use crate::BORDER_COLOUR_SINGLE;
|
||||||
@@ -71,6 +73,12 @@ use crate::MONITOR_INDEX_PREFERENCES;
|
|||||||
use crate::NO_TITLEBAR;
|
use crate::NO_TITLEBAR;
|
||||||
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
||||||
use crate::REMOVE_TITLEBARS;
|
use crate::REMOVE_TITLEBARS;
|
||||||
|
use crate::STACKBAR_FOCUSED_TEXT_COLOUR;
|
||||||
|
use crate::STACKBAR_MODE;
|
||||||
|
use crate::STACKBAR_TAB_BACKGROUND_COLOUR;
|
||||||
|
use crate::STACKBAR_TAB_HEIGHT;
|
||||||
|
use crate::STACKBAR_TAB_WIDTH;
|
||||||
|
use crate::STACKBAR_UNFOCUSED_TEXT_COLOUR;
|
||||||
use crate::SUBSCRIPTION_PIPES;
|
use crate::SUBSCRIPTION_PIPES;
|
||||||
use crate::SUBSCRIPTION_SOCKETS;
|
use crate::SUBSCRIPTION_SOCKETS;
|
||||||
use crate::TCP_CONNECTIONS;
|
use crate::TCP_CONNECTIONS;
|
||||||
@@ -766,6 +774,18 @@ impl WindowManager {
|
|||||||
|
|
||||||
tracing::info!("replying to state done");
|
tracing::info!("replying to state done");
|
||||||
}
|
}
|
||||||
|
SocketMessage::GlobalState => {
|
||||||
|
let state = match serde_json::to_string_pretty(&GlobalState::default()) {
|
||||||
|
Ok(state) => state,
|
||||||
|
Err(error) => error.to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
tracing::info!("replying to global state");
|
||||||
|
|
||||||
|
reply.write_all(state.as_bytes())?;
|
||||||
|
|
||||||
|
tracing::info!("replying to global state done");
|
||||||
|
}
|
||||||
SocketMessage::VisibleWindows => {
|
SocketMessage::VisibleWindows => {
|
||||||
let mut monitor_visible_windows = HashMap::new();
|
let mut monitor_visible_windows = HashMap::new();
|
||||||
|
|
||||||
@@ -1242,14 +1262,42 @@ impl WindowManager {
|
|||||||
|
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
}
|
}
|
||||||
SocketMessage::ActiveWindowBorderWidth(width) => {
|
SocketMessage::ActiveWindowBorderStyle(style) => {
|
||||||
|
let mut active_window_border_style = ACTIVE_WINDOW_BORDER_STYLE.lock();
|
||||||
|
*active_window_border_style = style;
|
||||||
|
|
||||||
|
WindowsApi::invalidate_border_rect()?;
|
||||||
|
}
|
||||||
|
SocketMessage::BorderWidth(width) => {
|
||||||
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
}
|
}
|
||||||
SocketMessage::ActiveWindowBorderOffset(offset) => {
|
SocketMessage::BorderOffset(offset) => {
|
||||||
BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
}
|
}
|
||||||
|
SocketMessage::StackbarMode(mode) => {
|
||||||
|
let mut stackbar_mode = STACKBAR_MODE.lock();
|
||||||
|
*stackbar_mode = mode;
|
||||||
|
}
|
||||||
|
SocketMessage::StackbarFocusedTextColour(r, g, b) => {
|
||||||
|
let rgb = Rgb::new(r, g, b);
|
||||||
|
STACKBAR_FOCUSED_TEXT_COLOUR.store(rgb.into(), Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
SocketMessage::StackbarUnfocusedTextColour(r, g, b) => {
|
||||||
|
let rgb = Rgb::new(r, g, b);
|
||||||
|
STACKBAR_UNFOCUSED_TEXT_COLOUR.store(rgb.into(), Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
SocketMessage::StackbarBackgroundColour(r, g, b) => {
|
||||||
|
let rgb = Rgb::new(r, g, b);
|
||||||
|
STACKBAR_TAB_BACKGROUND_COLOUR.store(rgb.into(), Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
SocketMessage::StackbarHeight(height) => {
|
||||||
|
STACKBAR_TAB_HEIGHT.store(height, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
SocketMessage::StackbarTabWidth(width) => {
|
||||||
|
STACKBAR_TAB_WIDTH.store(width, Ordering::SeqCst);
|
||||||
|
}
|
||||||
SocketMessage::ApplicationSpecificConfigurationSchema => {
|
SocketMessage::ApplicationSpecificConfigurationSchema => {
|
||||||
let asc = schema_for!(Vec<ApplicationConfiguration>);
|
let asc = schema_for!(Vec<ApplicationConfiguration>);
|
||||||
let schema = serde_json::to_string_pretty(&asc)?;
|
let schema = serde_json::to_string_pretty(&asc)?;
|
||||||
@@ -1358,7 +1406,7 @@ impl WindowManager {
|
|||||||
| SocketMessage::Retile
|
| SocketMessage::Retile
|
||||||
// Adding this one so that changes can be seen instantly after
|
// Adding this one so that changes can be seen instantly after
|
||||||
// modifying the active window border offset
|
// modifying the active window border offset
|
||||||
| SocketMessage::ActiveWindowBorderOffset(_)
|
| SocketMessage::BorderOffset(_)
|
||||||
// Adding this one because sometimes EVENT_SYSTEM_FOREGROUND isn't
|
// Adding this one because sometimes EVENT_SYSTEM_FOREGROUND isn't
|
||||||
// getting sent on FocusWindow, meaning the border won't be set
|
// getting sent on FocusWindow, meaning the border won't be set
|
||||||
// when processing events
|
// when processing events
|
||||||
@@ -1512,9 +1560,10 @@ pub fn read_commands_uds(wm: &Arc<Mutex<WindowManager>>, mut stream: UnixStream)
|
|||||||
|
|
||||||
if wm.is_paused {
|
if wm.is_paused {
|
||||||
return match message {
|
return match message {
|
||||||
SocketMessage::TogglePause | SocketMessage::State | SocketMessage::Stop => {
|
SocketMessage::TogglePause
|
||||||
Ok(wm.process_command(message, &mut stream)?)
|
| SocketMessage::State
|
||||||
}
|
| SocketMessage::GlobalState
|
||||||
|
| SocketMessage::Stop => Ok(wm.process_command(message, &mut stream)?),
|
||||||
_ => {
|
_ => {
|
||||||
tracing::trace!("ignoring while paused");
|
tracing::trace!("ignoring while paused");
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1561,9 +1610,10 @@ pub fn read_commands_tcp(
|
|||||||
|
|
||||||
if wm.is_paused {
|
if wm.is_paused {
|
||||||
return match message {
|
return match message {
|
||||||
SocketMessage::TogglePause | SocketMessage::State | SocketMessage::Stop => {
|
SocketMessage::TogglePause
|
||||||
Ok(wm.process_command(message, stream)?)
|
| SocketMessage::State
|
||||||
}
|
| SocketMessage::GlobalState
|
||||||
|
| SocketMessage::Stop => Ok(wm.process_command(message, stream)?),
|
||||||
_ => {
|
_ => {
|
||||||
tracing::trace!("ignoring while paused");
|
tracing::trace!("ignoring while paused");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ use crate::STACKBAR_TAB_WIDTH;
|
|||||||
use crate::STACKBAR_UNFOCUSED_TEXT_COLOUR;
|
use crate::STACKBAR_UNFOCUSED_TEXT_COLOUR;
|
||||||
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
||||||
use crate::WORKSPACE_RULES;
|
use crate::WORKSPACE_RULES;
|
||||||
|
use komorebi_core::StackbarMode;
|
||||||
|
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
@@ -47,6 +48,7 @@ use komorebi_core::config_generation::IdWithIdentifier;
|
|||||||
use komorebi_core::config_generation::MatchingRule;
|
use komorebi_core::config_generation::MatchingRule;
|
||||||
use komorebi_core::config_generation::MatchingStrategy;
|
use komorebi_core::config_generation::MatchingStrategy;
|
||||||
use komorebi_core::resolve_home_path;
|
use komorebi_core::resolve_home_path;
|
||||||
|
use komorebi_core::ActiveWindowBorderStyle;
|
||||||
use komorebi_core::ApplicationIdentifier;
|
use komorebi_core::ApplicationIdentifier;
|
||||||
use komorebi_core::DefaultLayout;
|
use komorebi_core::DefaultLayout;
|
||||||
use komorebi_core::FocusFollowsMouseImplementation;
|
use komorebi_core::FocusFollowsMouseImplementation;
|
||||||
@@ -82,17 +84,6 @@ pub struct ActiveWindowBorderColours {
|
|||||||
pub monocle: Colour,
|
pub monocle: Colour,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub enum ActiveWindowBorderStyle {
|
|
||||||
#[default]
|
|
||||||
/// Use the system border style
|
|
||||||
System,
|
|
||||||
/// Use the Windows 11-style rounded borders
|
|
||||||
Rounded,
|
|
||||||
/// Use the Windows 10-style square borders
|
|
||||||
Square,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct WorkspaceConfig {
|
pub struct WorkspaceConfig {
|
||||||
/// Name
|
/// Name
|
||||||
@@ -317,13 +308,6 @@ pub struct StaticConfig {
|
|||||||
pub stackbar: Option<StackbarConfig>,
|
pub stackbar: Option<StackbarConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub enum StackbarMode {
|
|
||||||
Always,
|
|
||||||
Never,
|
|
||||||
OnStack,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct TabsConfig {
|
pub struct TabsConfig {
|
||||||
width: Option<i32>,
|
width: Option<i32>,
|
||||||
@@ -334,9 +318,9 @@ pub struct TabsConfig {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct StackbarConfig {
|
pub struct StackbarConfig {
|
||||||
height: Option<i32>,
|
pub height: Option<i32>,
|
||||||
mode: Option<StackbarMode>,
|
pub mode: Option<StackbarMode>,
|
||||||
tabs: Option<TabsConfig>,
|
pub tabs: Option<TabsConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&WindowManager> for StaticConfig {
|
impl From<&WindowManager> for StaticConfig {
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ use uds_windows::UnixListener;
|
|||||||
|
|
||||||
use komorebi_core::config_generation::MatchingRule;
|
use komorebi_core::config_generation::MatchingRule;
|
||||||
use komorebi_core::custom_layout::CustomLayout;
|
use komorebi_core::custom_layout::CustomLayout;
|
||||||
|
use komorebi_core::ActiveWindowBorderStyle;
|
||||||
use komorebi_core::Arrangement;
|
use komorebi_core::Arrangement;
|
||||||
use komorebi_core::Axis;
|
use komorebi_core::Axis;
|
||||||
use komorebi_core::CycleDirection;
|
use komorebi_core::CycleDirection;
|
||||||
use komorebi_core::DefaultLayout;
|
use komorebi_core::DefaultLayout;
|
||||||
use komorebi_core::FocusFollowsMouseImplementation;
|
use komorebi_core::FocusFollowsMouseImplementation;
|
||||||
|
use komorebi_core::HidingBehaviour;
|
||||||
use komorebi_core::Layout;
|
use komorebi_core::Layout;
|
||||||
use komorebi_core::MoveBehaviour;
|
use komorebi_core::MoveBehaviour;
|
||||||
use komorebi_core::OperationBehaviour;
|
use komorebi_core::OperationBehaviour;
|
||||||
@@ -48,10 +50,23 @@ use crate::window_manager_event::WindowManagerEvent;
|
|||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
use crate::winevent_listener;
|
use crate::winevent_listener;
|
||||||
use crate::workspace::Workspace;
|
use crate::workspace::Workspace;
|
||||||
|
use crate::ActiveWindowBorderColours;
|
||||||
|
use crate::Colour;
|
||||||
|
use crate::Rgb;
|
||||||
|
use crate::WorkspaceRule;
|
||||||
|
use crate::ACTIVE_WINDOW_BORDER_STYLE;
|
||||||
|
use crate::BORDER_COLOUR_MONOCLE;
|
||||||
|
use crate::BORDER_COLOUR_SINGLE;
|
||||||
|
use crate::BORDER_COLOUR_STACK;
|
||||||
|
use crate::BORDER_ENABLED;
|
||||||
use crate::BORDER_HWND;
|
use crate::BORDER_HWND;
|
||||||
|
use crate::BORDER_OFFSET;
|
||||||
|
use crate::BORDER_WIDTH;
|
||||||
|
use crate::CUSTOM_FFM;
|
||||||
use crate::DATA_DIR;
|
use crate::DATA_DIR;
|
||||||
use crate::DISPLAY_INDEX_PREFERENCES;
|
use crate::DISPLAY_INDEX_PREFERENCES;
|
||||||
use crate::FLOAT_IDENTIFIERS;
|
use crate::FLOAT_IDENTIFIERS;
|
||||||
|
use crate::HIDING_BEHAVIOUR;
|
||||||
use crate::HOME_DIR;
|
use crate::HOME_DIR;
|
||||||
use crate::LAYERED_WHITELIST;
|
use crate::LAYERED_WHITELIST;
|
||||||
use crate::MANAGE_IDENTIFIERS;
|
use crate::MANAGE_IDENTIFIERS;
|
||||||
@@ -59,8 +74,15 @@ use crate::MONITOR_INDEX_PREFERENCES;
|
|||||||
use crate::NO_TITLEBAR;
|
use crate::NO_TITLEBAR;
|
||||||
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
||||||
use crate::REMOVE_TITLEBARS;
|
use crate::REMOVE_TITLEBARS;
|
||||||
|
use crate::STACKBAR_FOCUSED_TEXT_COLOUR;
|
||||||
|
use crate::STACKBAR_MODE;
|
||||||
|
use crate::STACKBAR_TAB_BACKGROUND_COLOUR;
|
||||||
|
use crate::STACKBAR_TAB_HEIGHT;
|
||||||
|
use crate::STACKBAR_TAB_WIDTH;
|
||||||
|
use crate::STACKBAR_UNFOCUSED_TEXT_COLOUR;
|
||||||
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
||||||
use crate::WORKSPACE_RULES;
|
use crate::WORKSPACE_RULES;
|
||||||
|
use komorebi_core::StackbarMode;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WindowManager {
|
pub struct WindowManager {
|
||||||
@@ -91,10 +113,27 @@ pub struct State {
|
|||||||
pub resize_delta: i32,
|
pub resize_delta: i32,
|
||||||
pub new_window_behaviour: WindowContainerBehaviour,
|
pub new_window_behaviour: WindowContainerBehaviour,
|
||||||
pub cross_monitor_move_behaviour: MoveBehaviour,
|
pub cross_monitor_move_behaviour: MoveBehaviour,
|
||||||
|
pub unmanaged_window_operation_behaviour: OperationBehaviour,
|
||||||
pub work_area_offset: Option<Rect>,
|
pub work_area_offset: Option<Rect>,
|
||||||
pub focus_follows_mouse: Option<FocusFollowsMouseImplementation>,
|
pub focus_follows_mouse: Option<FocusFollowsMouseImplementation>,
|
||||||
pub mouse_follows_focus: bool,
|
pub mouse_follows_focus: bool,
|
||||||
pub has_pending_raise_op: bool,
|
pub has_pending_raise_op: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub struct GlobalState {
|
||||||
|
pub active_window_border_enabled: bool,
|
||||||
|
pub active_window_border_colours: ActiveWindowBorderColours,
|
||||||
|
pub active_window_border_style: ActiveWindowBorderStyle,
|
||||||
|
pub border_offset: i32,
|
||||||
|
pub border_width: i32,
|
||||||
|
pub stackbar_mode: StackbarMode,
|
||||||
|
pub stackbar_focused_text_colour: Colour,
|
||||||
|
pub stackbar_unfocused_text_colour: Colour,
|
||||||
|
pub stackbar_tab_background_colour: Colour,
|
||||||
|
pub stackbar_tab_width: i32,
|
||||||
|
pub stackbar_height: i32,
|
||||||
pub remove_titlebars: bool,
|
pub remove_titlebars: bool,
|
||||||
pub float_identifiers: Vec<MatchingRule>,
|
pub float_identifiers: Vec<MatchingRule>,
|
||||||
pub manage_identifiers: Vec<MatchingRule>,
|
pub manage_identifiers: Vec<MatchingRule>,
|
||||||
@@ -103,6 +142,52 @@ pub struct State {
|
|||||||
pub name_change_on_launch_identifiers: Vec<MatchingRule>,
|
pub name_change_on_launch_identifiers: Vec<MatchingRule>,
|
||||||
pub monitor_index_preferences: HashMap<usize, Rect>,
|
pub monitor_index_preferences: HashMap<usize, Rect>,
|
||||||
pub display_index_preferences: HashMap<usize, String>,
|
pub display_index_preferences: HashMap<usize, String>,
|
||||||
|
pub workspace_rules: HashMap<String, WorkspaceRule>,
|
||||||
|
pub window_hiding_behaviour: HidingBehaviour,
|
||||||
|
pub configuration_dir: PathBuf,
|
||||||
|
pub data_dir: PathBuf,
|
||||||
|
pub custom_ffm: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for GlobalState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
active_window_border_enabled: BORDER_ENABLED.load(Ordering::SeqCst),
|
||||||
|
active_window_border_colours: ActiveWindowBorderColours {
|
||||||
|
single: Colour::Rgb(Rgb::from(BORDER_COLOUR_SINGLE.load(Ordering::SeqCst))),
|
||||||
|
stack: Colour::Rgb(Rgb::from(BORDER_COLOUR_STACK.load(Ordering::SeqCst))),
|
||||||
|
monocle: Colour::Rgb(Rgb::from(BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst))),
|
||||||
|
},
|
||||||
|
active_window_border_style: *ACTIVE_WINDOW_BORDER_STYLE.lock(),
|
||||||
|
border_offset: BORDER_OFFSET.load(Ordering::SeqCst),
|
||||||
|
border_width: BORDER_WIDTH.load(Ordering::SeqCst),
|
||||||
|
stackbar_mode: *STACKBAR_MODE.lock(),
|
||||||
|
stackbar_focused_text_colour: Colour::Rgb(Rgb::from(
|
||||||
|
STACKBAR_FOCUSED_TEXT_COLOUR.load(Ordering::SeqCst),
|
||||||
|
)),
|
||||||
|
stackbar_unfocused_text_colour: Colour::Rgb(Rgb::from(
|
||||||
|
STACKBAR_UNFOCUSED_TEXT_COLOUR.load(Ordering::SeqCst),
|
||||||
|
)),
|
||||||
|
stackbar_tab_background_colour: Colour::Rgb(Rgb::from(
|
||||||
|
STACKBAR_TAB_BACKGROUND_COLOUR.load(Ordering::SeqCst),
|
||||||
|
)),
|
||||||
|
stackbar_tab_width: STACKBAR_TAB_WIDTH.load(Ordering::SeqCst),
|
||||||
|
stackbar_height: STACKBAR_TAB_HEIGHT.load(Ordering::SeqCst),
|
||||||
|
remove_titlebars: REMOVE_TITLEBARS.load(Ordering::SeqCst),
|
||||||
|
float_identifiers: FLOAT_IDENTIFIERS.lock().clone(),
|
||||||
|
manage_identifiers: MANAGE_IDENTIFIERS.lock().clone(),
|
||||||
|
layered_whitelist: LAYERED_WHITELIST.lock().clone(),
|
||||||
|
tray_and_multi_window_identifiers: TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock().clone(),
|
||||||
|
name_change_on_launch_identifiers: OBJECT_NAME_CHANGE_ON_LAUNCH.lock().clone(),
|
||||||
|
monitor_index_preferences: MONITOR_INDEX_PREFERENCES.lock().clone(),
|
||||||
|
display_index_preferences: DISPLAY_INDEX_PREFERENCES.lock().clone(),
|
||||||
|
workspace_rules: WORKSPACE_RULES.lock().clone(),
|
||||||
|
window_hiding_behaviour: *HIDING_BEHAVIOUR.lock(),
|
||||||
|
configuration_dir: HOME_DIR.clone(),
|
||||||
|
data_dir: DATA_DIR.clone(),
|
||||||
|
custom_ffm: CUSTOM_FFM.load(Ordering::SeqCst),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<Self> for WindowManager {
|
impl AsRef<Self> for WindowManager {
|
||||||
@@ -123,14 +208,7 @@ impl From<&WindowManager> for State {
|
|||||||
focus_follows_mouse: wm.focus_follows_mouse,
|
focus_follows_mouse: wm.focus_follows_mouse,
|
||||||
mouse_follows_focus: wm.mouse_follows_focus,
|
mouse_follows_focus: wm.mouse_follows_focus,
|
||||||
has_pending_raise_op: wm.has_pending_raise_op,
|
has_pending_raise_op: wm.has_pending_raise_op,
|
||||||
remove_titlebars: REMOVE_TITLEBARS.load(Ordering::SeqCst),
|
unmanaged_window_operation_behaviour: wm.unmanaged_window_operation_behaviour,
|
||||||
float_identifiers: FLOAT_IDENTIFIERS.lock().clone(),
|
|
||||||
manage_identifiers: MANAGE_IDENTIFIERS.lock().clone(),
|
|
||||||
layered_whitelist: LAYERED_WHITELIST.lock().clone(),
|
|
||||||
tray_and_multi_window_identifiers: TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock().clone(),
|
|
||||||
name_change_on_launch_identifiers: OBJECT_NAME_CHANGE_ON_LAUNCH.lock().clone(),
|
|
||||||
monitor_index_preferences: MONITOR_INDEX_PREFERENCES.lock().clone(),
|
|
||||||
display_index_preferences: DISPLAY_INDEX_PREFERENCES.lock().clone(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ use crate::window_manager_event::WindowManagerEvent;
|
|||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
use crate::winevent::WinEvent;
|
use crate::winevent::WinEvent;
|
||||||
use crate::winevent_listener;
|
use crate::winevent_listener;
|
||||||
use crate::ActiveWindowBorderStyle;
|
|
||||||
use crate::ACTIVE_WINDOW_BORDER_STYLE;
|
use crate::ACTIVE_WINDOW_BORDER_STYLE;
|
||||||
use crate::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
use crate::BORDER_RECT;
|
use crate::BORDER_RECT;
|
||||||
@@ -50,6 +49,7 @@ use crate::DISPLAY_INDEX_PREFERENCES;
|
|||||||
use crate::MONITOR_INDEX_PREFERENCES;
|
use crate::MONITOR_INDEX_PREFERENCES;
|
||||||
use crate::TRANSPARENCY_COLOUR;
|
use crate::TRANSPARENCY_COLOUR;
|
||||||
use crate::WINDOWS_11;
|
use crate::WINDOWS_11;
|
||||||
|
use komorebi_core::ActiveWindowBorderStyle;
|
||||||
|
|
||||||
pub extern "system" fn valid_display_monitors(
|
pub extern "system" fn valid_display_monitors(
|
||||||
hmonitor: HMONITOR,
|
hmonitor: HMONITOR,
|
||||||
|
|||||||
@@ -815,6 +815,8 @@ enum SubCommand {
|
|||||||
Whkdrc,
|
Whkdrc,
|
||||||
/// Show a JSON representation of the current window manager state
|
/// Show a JSON representation of the current window manager state
|
||||||
State,
|
State,
|
||||||
|
/// Show a JSON representation of the current global state
|
||||||
|
GlobalState,
|
||||||
/// Show a JSON representation of visible windows
|
/// Show a JSON representation of visible windows
|
||||||
VisibleWindows,
|
VisibleWindows,
|
||||||
/// Query the current window manager state
|
/// Query the current window manager state
|
||||||
@@ -2025,6 +2027,9 @@ Stop-Process -Name:whkd -ErrorAction SilentlyContinue
|
|||||||
SubCommand::State => {
|
SubCommand::State => {
|
||||||
print_query(&SocketMessage::State.as_bytes()?);
|
print_query(&SocketMessage::State.as_bytes()?);
|
||||||
}
|
}
|
||||||
|
SubCommand::GlobalState => {
|
||||||
|
print_query(&SocketMessage::GlobalState.as_bytes()?);
|
||||||
|
}
|
||||||
SubCommand::VisibleWindows => {
|
SubCommand::VisibleWindows => {
|
||||||
print_query(&SocketMessage::VisibleWindows.as_bytes()?);
|
print_query(&SocketMessage::VisibleWindows.as_bytes()?);
|
||||||
}
|
}
|
||||||
@@ -2139,10 +2144,10 @@ Stop-Process -Name:whkd -ErrorAction SilentlyContinue
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
SubCommand::ActiveWindowBorderWidth(arg) => {
|
SubCommand::ActiveWindowBorderWidth(arg) => {
|
||||||
send_message(&SocketMessage::ActiveWindowBorderWidth(arg.width).as_bytes()?)?;
|
send_message(&SocketMessage::BorderWidth(arg.width).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
SubCommand::ActiveWindowBorderOffset(arg) => {
|
SubCommand::ActiveWindowBorderOffset(arg) => {
|
||||||
send_message(&SocketMessage::ActiveWindowBorderOffset(arg.offset).as_bytes()?)?;
|
send_message(&SocketMessage::BorderOffset(arg.offset).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
SubCommand::ResizeDelta(arg) => {
|
SubCommand::ResizeDelta(arg) => {
|
||||||
send_message(&SocketMessage::ResizeDelta(arg.pixels).as_bytes()?)?;
|
send_message(&SocketMessage::ResizeDelta(arg.pixels).as_bytes()?)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user