diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index d6468af8..ee3e1e77 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -105,6 +105,7 @@ pub enum SocketMessage { CompleteConfiguration, ActiveWindowBorder(bool), ActiveWindowBorderColour(WindowKind, u32, u32, u32), + ActiveWindowBorderWidth(i32), InvisibleBorders(Rect), WorkAreaOffset(Rect), MonitorWorkAreaOffset(usize, Rect), diff --git a/komorebi/src/border.rs b/komorebi/src/border.rs index 5940fb78..a83d32b0 100644 --- a/komorebi/src/border.rs +++ b/komorebi/src/border.rs @@ -103,6 +103,10 @@ impl Border { if self.hwnd == 0 { Ok(()) } else { + if !WindowsApi::is_window(self.hwnd()) { + Self::create("komorebi-border-window")?; + } + let mut should_expand_border = false; let mut rect = WindowsApi::window_rect(window.hwnd())?; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 37f67be8..18f7d453 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -8,6 +8,7 @@ use std::net::TcpStream; use std::path::PathBuf; use std::process::Command; use std::sync::atomic::AtomicBool; +use std::sync::atomic::AtomicI32; use std::sync::atomic::AtomicIsize; use std::sync::atomic::AtomicU32; use std::sync::atomic::Ordering; @@ -170,6 +171,7 @@ pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false); pub static BORDER_COLOUR_SINGLE: AtomicU32 = AtomicU32::new(0); pub static BORDER_COLOUR_STACK: AtomicU32 = AtomicU32::new(0); pub static BORDER_COLOUR_CURRENT: AtomicU32 = AtomicU32::new(0); +pub static BORDER_WIDTH: AtomicI32 = AtomicI32::new(20); // 0 0 0 aka pure black, I doubt anyone will want this as a border colour pub const TRANSPARENCY_COLOUR: u32 = 0; diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 40247664..4f74afaa 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -48,6 +48,7 @@ use crate::BORDER_COLOUR_STACK; use crate::BORDER_ENABLED; use crate::BORDER_HWND; use crate::BORDER_OVERFLOW_IDENTIFIERS; +use crate::BORDER_WIDTH; use crate::CUSTOM_FFM; use crate::DATA_DIR; use crate::FLOAT_IDENTIFIERS; @@ -881,6 +882,10 @@ impl WindowManager { WindowsApi::invalidate_border_rect()?; } + SocketMessage::ActiveWindowBorderWidth(width) => { + BORDER_WIDTH.store(width, Ordering::SeqCst); + WindowsApi::invalidate_border_rect()?; + } SocketMessage::NotificationSchema => { let notification = schema_for!(Notification); let schema = serde_json::to_string_pretty(¬ification)?; diff --git a/komorebi/src/windows_callbacks.rs b/komorebi/src/windows_callbacks.rs index cd1d0515..82e20026 100644 --- a/komorebi/src/windows_callbacks.rs +++ b/komorebi/src/windows_callbacks.rs @@ -39,6 +39,7 @@ use crate::windows_api::WindowsApi; use crate::winevent_listener::WINEVENT_CALLBACK_CHANNEL; use crate::BORDER_COLOUR_CURRENT; use crate::BORDER_RECT; +use crate::BORDER_WIDTH; use crate::MONITOR_INDEX_PREFERENCES; use crate::TRANSPARENCY_COLOUR; @@ -164,7 +165,7 @@ pub extern "system" fn border_window( let hdc = BeginPaint(window, &mut ps); let hpen = CreatePen( PS_SOLID, - 20, + BORDER_WIDTH.load(Ordering::SeqCst), COLORREF(BORDER_COLOUR_CURRENT.load(Ordering::SeqCst)), ); let hbrush = WindowsApi::create_solid_brush(TRANSPARENCY_COLOUR); diff --git a/komorebic.lib.ahk b/komorebic.lib.ahk index 9f46ada0..46e068ab 100644 --- a/komorebic.lib.ahk +++ b/komorebic.lib.ahk @@ -336,6 +336,10 @@ ActiveWindowBorderColour(r, g, b, window_kind) { RunWait, komorebic.exe active-window-border-colour %r% %g% %b% --window-kind %window_kind%, , Hide } +ActiveWindowBorderWidth(width) { + RunWait, komorebic.exe active-window-border-width %width%, , Hide +} + FocusFollowsMouse(boolean_state, implementation) { RunWait, komorebic.exe focus-follows-mouse %boolean_state% --implementation %implementation%, , Hide } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index bad11ec7..c79591a7 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -444,6 +444,12 @@ struct ActiveWindowBorderColour { b: u32, } +#[derive(Parser, AhkFunction)] +struct ActiveWindowBorderWidth { + /// Desired width of the active window border + width: i32, +} + #[derive(Parser, AhkFunction)] struct Start { /// Allow the use of komorebi's custom focus-follows-mouse implementation @@ -744,6 +750,9 @@ enum SubCommand { /// Set the colour for the active window border #[clap(arg_required_else_help = true)] ActiveWindowBorderColour(ActiveWindowBorderColour), + /// Set the width for the active window border + #[clap(arg_required_else_help = true)] + ActiveWindowBorderWidth(ActiveWindowBorderWidth), /// Enable or disable focus follows mouse for the operating system #[clap(arg_required_else_help = true)] FocusFollowsMouse(FocusFollowsMouse), @@ -1358,6 +1367,9 @@ fn main() -> Result<()> { .as_bytes()?, )?; } + SubCommand::ActiveWindowBorderWidth(arg) => { + send_message(&SocketMessage::ActiveWindowBorderWidth(arg.width).as_bytes()?)?; + } SubCommand::ResizeDelta(arg) => { send_message(&SocketMessage::ResizeDelta(arg.pixels).as_bytes()?)?; }