mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-10 15:12:52 +02:00
feat(wm): make active border with configurable
This commit introduces a new command which lets the user set a custom width value for the active window border when it is enabled. Unfortunately a little more width is required when working with rounded windows on Windows 11 to fill the gap left by the rounding. The default width remains set at 20. re #232
This commit is contained in:
@@ -105,6 +105,7 @@ pub enum SocketMessage {
|
|||||||
CompleteConfiguration,
|
CompleteConfiguration,
|
||||||
ActiveWindowBorder(bool),
|
ActiveWindowBorder(bool),
|
||||||
ActiveWindowBorderColour(WindowKind, u32, u32, u32),
|
ActiveWindowBorderColour(WindowKind, u32, u32, u32),
|
||||||
|
ActiveWindowBorderWidth(i32),
|
||||||
InvisibleBorders(Rect),
|
InvisibleBorders(Rect),
|
||||||
WorkAreaOffset(Rect),
|
WorkAreaOffset(Rect),
|
||||||
MonitorWorkAreaOffset(usize, Rect),
|
MonitorWorkAreaOffset(usize, Rect),
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ impl Border {
|
|||||||
if self.hwnd == 0 {
|
if self.hwnd == 0 {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
if !WindowsApi::is_window(self.hwnd()) {
|
||||||
|
Self::create("komorebi-border-window")?;
|
||||||
|
}
|
||||||
|
|
||||||
let mut should_expand_border = false;
|
let mut should_expand_border = false;
|
||||||
|
|
||||||
let mut rect = WindowsApi::window_rect(window.hwnd())?;
|
let mut rect = WindowsApi::window_rect(window.hwnd())?;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use std::net::TcpStream;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
use std::sync::atomic::AtomicI32;
|
||||||
use std::sync::atomic::AtomicIsize;
|
use std::sync::atomic::AtomicIsize;
|
||||||
use std::sync::atomic::AtomicU32;
|
use std::sync::atomic::AtomicU32;
|
||||||
use std::sync::atomic::Ordering;
|
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_SINGLE: AtomicU32 = AtomicU32::new(0);
|
||||||
pub static BORDER_COLOUR_STACK: 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_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
|
// 0 0 0 aka pure black, I doubt anyone will want this as a border colour
|
||||||
pub const TRANSPARENCY_COLOUR: u32 = 0;
|
pub const TRANSPARENCY_COLOUR: u32 = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ use crate::BORDER_COLOUR_STACK;
|
|||||||
use crate::BORDER_ENABLED;
|
use crate::BORDER_ENABLED;
|
||||||
use crate::BORDER_HWND;
|
use crate::BORDER_HWND;
|
||||||
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
||||||
|
use crate::BORDER_WIDTH;
|
||||||
use crate::CUSTOM_FFM;
|
use crate::CUSTOM_FFM;
|
||||||
use crate::DATA_DIR;
|
use crate::DATA_DIR;
|
||||||
use crate::FLOAT_IDENTIFIERS;
|
use crate::FLOAT_IDENTIFIERS;
|
||||||
@@ -881,6 +882,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
}
|
}
|
||||||
|
SocketMessage::ActiveWindowBorderWidth(width) => {
|
||||||
|
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
||||||
|
WindowsApi::invalidate_border_rect()?;
|
||||||
|
}
|
||||||
SocketMessage::NotificationSchema => {
|
SocketMessage::NotificationSchema => {
|
||||||
let notification = schema_for!(Notification);
|
let notification = schema_for!(Notification);
|
||||||
let schema = serde_json::to_string_pretty(¬ification)?;
|
let schema = serde_json::to_string_pretty(¬ification)?;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ use crate::windows_api::WindowsApi;
|
|||||||
use crate::winevent_listener::WINEVENT_CALLBACK_CHANNEL;
|
use crate::winevent_listener::WINEVENT_CALLBACK_CHANNEL;
|
||||||
use crate::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
use crate::BORDER_RECT;
|
use crate::BORDER_RECT;
|
||||||
|
use crate::BORDER_WIDTH;
|
||||||
use crate::MONITOR_INDEX_PREFERENCES;
|
use crate::MONITOR_INDEX_PREFERENCES;
|
||||||
use crate::TRANSPARENCY_COLOUR;
|
use crate::TRANSPARENCY_COLOUR;
|
||||||
|
|
||||||
@@ -164,7 +165,7 @@ pub extern "system" fn border_window(
|
|||||||
let hdc = BeginPaint(window, &mut ps);
|
let hdc = BeginPaint(window, &mut ps);
|
||||||
let hpen = CreatePen(
|
let hpen = CreatePen(
|
||||||
PS_SOLID,
|
PS_SOLID,
|
||||||
20,
|
BORDER_WIDTH.load(Ordering::SeqCst),
|
||||||
COLORREF(BORDER_COLOUR_CURRENT.load(Ordering::SeqCst)),
|
COLORREF(BORDER_COLOUR_CURRENT.load(Ordering::SeqCst)),
|
||||||
);
|
);
|
||||||
let hbrush = WindowsApi::create_solid_brush(TRANSPARENCY_COLOUR);
|
let hbrush = WindowsApi::create_solid_brush(TRANSPARENCY_COLOUR);
|
||||||
|
|||||||
@@ -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
|
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) {
|
FocusFollowsMouse(boolean_state, implementation) {
|
||||||
RunWait, komorebic.exe focus-follows-mouse %boolean_state% --implementation %implementation%, , Hide
|
RunWait, komorebic.exe focus-follows-mouse %boolean_state% --implementation %implementation%, , Hide
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -444,6 +444,12 @@ struct ActiveWindowBorderColour {
|
|||||||
b: u32,
|
b: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Parser, AhkFunction)]
|
||||||
|
struct ActiveWindowBorderWidth {
|
||||||
|
/// Desired width of the active window border
|
||||||
|
width: i32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Parser, AhkFunction)]
|
#[derive(Parser, AhkFunction)]
|
||||||
struct Start {
|
struct Start {
|
||||||
/// Allow the use of komorebi's custom focus-follows-mouse implementation
|
/// 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
|
/// Set the colour for the active window border
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
ActiveWindowBorderColour(ActiveWindowBorderColour),
|
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
|
/// Enable or disable focus follows mouse for the operating system
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
FocusFollowsMouse(FocusFollowsMouse),
|
FocusFollowsMouse(FocusFollowsMouse),
|
||||||
@@ -1358,6 +1367,9 @@ fn main() -> Result<()> {
|
|||||||
.as_bytes()?,
|
.as_bytes()?,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
SubCommand::ActiveWindowBorderWidth(arg) => {
|
||||||
|
send_message(&SocketMessage::ActiveWindowBorderWidth(arg.width).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