mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-05 10:23:25 +02:00
feat(wm): add border colour for monocle
This commit adds a new WindowKind to allow the user to set a unique colour to identify when a window container in monocle mode is active. resolve #404
This commit is contained in:
@@ -363,6 +363,9 @@ komorebic.exe active-window-border-colour [R G B] --window-kind single
|
|||||||
|
|
||||||
# optionally, if you want a different colour for stacks of windows
|
# optionally, if you want a different colour for stacks of windows
|
||||||
komorebic.exe active-window-border-colour [R G B] --window-kind stack
|
komorebic.exe active-window-border-colour [R G B] --window-kind stack
|
||||||
|
|
||||||
|
# optionally, if you want a different colour for windows in monocle mode
|
||||||
|
komorebic.exe active-window-border-colour [R G B] --window-kind monocle
|
||||||
```
|
```
|
||||||
|
|
||||||
It is important to note that the active window border will only apply to windows managed by `komorebi`.
|
It is important to note that the active window border will only apply to windows managed by `komorebi`.
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ impl FromStr for SocketMessage {
|
|||||||
pub enum WindowKind {
|
pub enum WindowKind {
|
||||||
Single,
|
Single,
|
||||||
Stack,
|
Stack,
|
||||||
|
Monocle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ komorebic invisible-borders 7 0 14 7
|
|||||||
# Uncomment the next lines if you want a visual border around the active window
|
# Uncomment the next lines if you want a visual border around the active window
|
||||||
# komorebic active-window-border-colour 66 165 245 --window-kind single
|
# komorebic active-window-border-colour 66 165 245 --window-kind single
|
||||||
# komorebic active-window-border-colour 256 165 66 --window-kind stack
|
# komorebic active-window-border-colour 256 165 66 --window-kind stack
|
||||||
|
# komorebic active-window-border-colour 255 51 153 --window-kind monocle
|
||||||
# komorebic active-window-border enable
|
# komorebic active-window-border enable
|
||||||
|
|
||||||
komorebic complete-configuration
|
komorebic complete-configuration
|
||||||
@@ -163,6 +163,7 @@ pub static BORDER_HWND: AtomicIsize = AtomicIsize::new(0);
|
|||||||
pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false);
|
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_MONOCLE: 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);
|
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
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ use crate::Notification;
|
|||||||
use crate::NotificationEvent;
|
use crate::NotificationEvent;
|
||||||
use crate::ALT_FOCUS_HACK;
|
use crate::ALT_FOCUS_HACK;
|
||||||
use crate::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
|
use crate::BORDER_COLOUR_MONOCLE;
|
||||||
use crate::BORDER_COLOUR_SINGLE;
|
use crate::BORDER_COLOUR_SINGLE;
|
||||||
use crate::BORDER_COLOUR_STACK;
|
use crate::BORDER_COLOUR_STACK;
|
||||||
use crate::BORDER_ENABLED;
|
use crate::BORDER_ENABLED;
|
||||||
@@ -1027,6 +1028,9 @@ impl WindowManager {
|
|||||||
WindowKind::Stack => {
|
WindowKind::Stack => {
|
||||||
BORDER_COLOUR_STACK.store(r | (g << 8) | (b << 16), Ordering::SeqCst);
|
BORDER_COLOUR_STACK.store(r | (g << 8) | (b << 16), Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
WindowKind::Monocle => {
|
||||||
|
BORDER_COLOUR_MONOCLE.store(r | (g << 8) | (b << 16), Ordering::SeqCst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
@@ -1075,9 +1079,30 @@ impl WindowManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
|
SocketMessage::ToggleMonocle => {
|
||||||
|
let current = BORDER_COLOUR_CURRENT.load(Ordering::SeqCst);
|
||||||
|
let monocle = BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst);
|
||||||
|
|
||||||
|
if monocle != 0 {
|
||||||
|
if current == monocle {
|
||||||
|
BORDER_COLOUR_CURRENT.store(
|
||||||
|
BORDER_COLOUR_SINGLE.load(Ordering::SeqCst),
|
||||||
|
Ordering::SeqCst,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
BORDER_COLOUR_CURRENT.store(
|
||||||
|
BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst),
|
||||||
|
Ordering::SeqCst,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
SocketMessage::StackWindow(_) => {
|
SocketMessage::StackWindow(_) => {
|
||||||
BORDER_COLOUR_CURRENT
|
let stack = BORDER_COLOUR_STACK.load(Ordering::SeqCst);
|
||||||
.store(BORDER_COLOUR_STACK.load(Ordering::SeqCst), Ordering::SeqCst);
|
if stack != 0 {
|
||||||
|
BORDER_COLOUR_CURRENT
|
||||||
|
.store(BORDER_COLOUR_STACK.load(Ordering::SeqCst), Ordering::SeqCst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SocketMessage::UnstackWindow => {
|
SocketMessage::UnstackWindow => {
|
||||||
BORDER_COLOUR_CURRENT.store(
|
BORDER_COLOUR_CURRENT.store(
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use crate::windows_api::WindowsApi;
|
|||||||
use crate::Notification;
|
use crate::Notification;
|
||||||
use crate::NotificationEvent;
|
use crate::NotificationEvent;
|
||||||
use crate::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
|
use crate::BORDER_COLOUR_MONOCLE;
|
||||||
use crate::BORDER_COLOUR_SINGLE;
|
use crate::BORDER_COLOUR_SINGLE;
|
||||||
use crate::BORDER_COLOUR_STACK;
|
use crate::BORDER_COLOUR_STACK;
|
||||||
use crate::BORDER_ENABLED;
|
use crate::BORDER_ENABLED;
|
||||||
@@ -510,6 +511,7 @@ impl WindowManager {
|
|||||||
| WindowManagerEvent::Minimize(_, window) => {
|
| WindowManagerEvent::Minimize(_, window) => {
|
||||||
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
|
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
|
||||||
let mut target_window = None;
|
let mut target_window = None;
|
||||||
|
let mut target_window_is_monocle = false;
|
||||||
if self
|
if self
|
||||||
.focused_workspace()?
|
.focused_workspace()?
|
||||||
.floating_windows()
|
.floating_windows()
|
||||||
@@ -523,6 +525,7 @@ impl WindowManager {
|
|||||||
if let Some(monocle_container) = self.focused_workspace()?.monocle_container() {
|
if let Some(monocle_container) = self.focused_workspace()?.monocle_container() {
|
||||||
if let Some(window) = monocle_container.focused_window() {
|
if let Some(window) = monocle_container.focused_window() {
|
||||||
target_window = Option::from(*window);
|
target_window = Option::from(*window);
|
||||||
|
target_window_is_monocle = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +542,12 @@ impl WindowManager {
|
|||||||
let container_size = self.focused_container()?.windows().len();
|
let container_size = self.focused_container()?.windows().len();
|
||||||
target_window = Option::from(*self.focused_window()?);
|
target_window = Option::from(*self.focused_window()?);
|
||||||
|
|
||||||
if container_size > 1 {
|
if target_window_is_monocle {
|
||||||
|
BORDER_COLOUR_CURRENT.store(
|
||||||
|
BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst),
|
||||||
|
Ordering::SeqCst,
|
||||||
|
);
|
||||||
|
} else if container_size > 1 {
|
||||||
BORDER_COLOUR_CURRENT.store(
|
BORDER_COLOUR_CURRENT.store(
|
||||||
BORDER_COLOUR_STACK.load(Ordering::SeqCst),
|
BORDER_COLOUR_STACK.load(Ordering::SeqCst),
|
||||||
Ordering::SeqCst,
|
Ordering::SeqCst,
|
||||||
|
|||||||
Reference in New Issue
Block a user