mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-10 23:22:43 +02:00
feat(wm): add new cmd to set active border offset
This commit introduces a new command, active-window-border-offset, which allows the user to offset the starting position of the active window border, thereby allowing for thicker or thinner active window borders, when used in conjunction with the active-window-border-width command. resolve #232
This commit is contained in:
@@ -107,6 +107,7 @@ pub enum SocketMessage {
|
|||||||
ActiveWindowBorder(bool),
|
ActiveWindowBorder(bool),
|
||||||
ActiveWindowBorderColour(WindowKind, u32, u32, u32),
|
ActiveWindowBorderColour(WindowKind, u32, u32, u32),
|
||||||
ActiveWindowBorderWidth(i32),
|
ActiveWindowBorderWidth(i32),
|
||||||
|
ActiveWindowBorderOffset(i32),
|
||||||
InvisibleBorders(Rect),
|
InvisibleBorders(Rect),
|
||||||
WorkAreaOffset(Rect),
|
WorkAreaOffset(Rect),
|
||||||
MonitorWorkAreaOffset(usize, Rect),
|
MonitorWorkAreaOffset(usize, Rect),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use crate::window::Window;
|
|||||||
use crate::windows_callbacks;
|
use crate::windows_callbacks;
|
||||||
use crate::WindowsApi;
|
use crate::WindowsApi;
|
||||||
use crate::BORDER_HWND;
|
use crate::BORDER_HWND;
|
||||||
|
use crate::BORDER_OFFSET;
|
||||||
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
||||||
use crate::BORDER_RECT;
|
use crate::BORDER_RECT;
|
||||||
use crate::TRANSPARENCY_COLOUR;
|
use crate::TRANSPARENCY_COLOUR;
|
||||||
@@ -128,6 +129,14 @@ impl Border {
|
|||||||
rect.bottom += invisible_borders.bottom;
|
rect.bottom += invisible_borders.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let border_offset = BORDER_OFFSET.lock();
|
||||||
|
if let Some(border_offset) = *border_offset {
|
||||||
|
rect.left -= border_offset.left;
|
||||||
|
rect.top -= border_offset.top;
|
||||||
|
rect.right += border_offset.right;
|
||||||
|
rect.bottom += border_offset.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
*BORDER_RECT.lock() = rect;
|
*BORDER_RECT.lock() = rect;
|
||||||
|
|
||||||
WindowsApi::position_border_window(self.hwnd(), &rect, activate)
|
WindowsApi::position_border_window(self.hwnd(), &rect, activate)
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ lazy_static! {
|
|||||||
|
|
||||||
static ref BORDER_RECT: Arc<Mutex<Rect>> =
|
static ref BORDER_RECT: Arc<Mutex<Rect>> =
|
||||||
Arc::new(Mutex::new(Rect::default()));
|
Arc::new(Mutex::new(Rect::default()));
|
||||||
|
|
||||||
|
static ref BORDER_OFFSET: Arc<Mutex<Option<Rect>>> =
|
||||||
|
Arc::new(Mutex::new(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false);
|
pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ use crate::BORDER_COLOUR_SINGLE;
|
|||||||
use crate::BORDER_COLOUR_STACK;
|
use crate::BORDER_COLOUR_STACK;
|
||||||
use crate::BORDER_ENABLED;
|
use crate::BORDER_ENABLED;
|
||||||
use crate::BORDER_HWND;
|
use crate::BORDER_HWND;
|
||||||
|
use crate::BORDER_OFFSET;
|
||||||
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
||||||
use crate::BORDER_WIDTH;
|
use crate::BORDER_WIDTH;
|
||||||
use crate::CUSTOM_FFM;
|
use crate::CUSTOM_FFM;
|
||||||
@@ -889,6 +890,20 @@ impl WindowManager {
|
|||||||
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
}
|
}
|
||||||
|
SocketMessage::ActiveWindowBorderOffset(offset) => {
|
||||||
|
let mut current_border_offset = BORDER_OFFSET.lock();
|
||||||
|
|
||||||
|
let new_border_offset = Rect {
|
||||||
|
left: offset,
|
||||||
|
top: offset,
|
||||||
|
right: offset * 2,
|
||||||
|
bottom: offset * 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
*current_border_offset = Option::from(new_border_offset);
|
||||||
|
|
||||||
|
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)?;
|
||||||
@@ -927,6 +942,9 @@ impl WindowManager {
|
|||||||
| SocketMessage::Promote
|
| SocketMessage::Promote
|
||||||
| SocketMessage::PromoteFocus
|
| SocketMessage::PromoteFocus
|
||||||
| SocketMessage::Retile
|
| SocketMessage::Retile
|
||||||
|
// Adding this one so that changes can be seen instantly after
|
||||||
|
// modifying the active window border offset
|
||||||
|
| SocketMessage::ActiveWindowBorderOffset(_)
|
||||||
// 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
|
||||||
|
|||||||
@@ -344,6 +344,10 @@ ActiveWindowBorderWidth(width) {
|
|||||||
RunWait, komorebic.exe active-window-border-width %width%, , Hide
|
RunWait, komorebic.exe active-window-border-width %width%, , Hide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActiveWindowBorderOffset(offset) {
|
||||||
|
RunWait, komorebic.exe active-window-border-offset %offset%, , 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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -450,6 +450,12 @@ struct ActiveWindowBorderWidth {
|
|||||||
width: i32,
|
width: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Parser, AhkFunction)]
|
||||||
|
struct ActiveWindowBorderOffset {
|
||||||
|
/// Desired offset of the active window border
|
||||||
|
offset: 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
|
||||||
@@ -755,6 +761,9 @@ enum SubCommand {
|
|||||||
/// Set the width for the active window border
|
/// Set the width for the active window border
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
ActiveWindowBorderWidth(ActiveWindowBorderWidth),
|
ActiveWindowBorderWidth(ActiveWindowBorderWidth),
|
||||||
|
/// Set the offset for the active window border
|
||||||
|
#[clap(arg_required_else_help = true)]
|
||||||
|
ActiveWindowBorderOffset(ActiveWindowBorderOffset),
|
||||||
/// 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),
|
||||||
@@ -1375,6 +1384,9 @@ fn main() -> Result<()> {
|
|||||||
SubCommand::ActiveWindowBorderWidth(arg) => {
|
SubCommand::ActiveWindowBorderWidth(arg) => {
|
||||||
send_message(&SocketMessage::ActiveWindowBorderWidth(arg.width).as_bytes()?)?;
|
send_message(&SocketMessage::ActiveWindowBorderWidth(arg.width).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
|
SubCommand::ActiveWindowBorderOffset(arg) => {
|
||||||
|
send_message(&SocketMessage::ActiveWindowBorderOffset(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