mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 01:58:51 +02:00
feat(config): add active window border style opt
This commit is contained in:
@@ -194,6 +194,9 @@ lazy_static! {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ref ACTIVE_WINDOW_BORDER_STYLE: Arc<Mutex<ActiveWindowBorderStyle>> =
|
||||||
|
Arc::new(Mutex::new(ActiveWindowBorderStyle::System));
|
||||||
|
|
||||||
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()));
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use crate::window_manager::WindowManager;
|
|||||||
use crate::window_manager_event::WindowManagerEvent;
|
use crate::window_manager_event::WindowManagerEvent;
|
||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
use crate::workspace::Workspace;
|
use crate::workspace::Workspace;
|
||||||
|
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;
|
||||||
@@ -82,6 +83,17 @@ 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
|
||||||
@@ -260,6 +272,9 @@ pub struct StaticConfig {
|
|||||||
/// Active window border colours for different container types
|
/// Active window border colours for different container types
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub active_window_border_colours: Option<ActiveWindowBorderColours>,
|
pub active_window_border_colours: Option<ActiveWindowBorderColours>,
|
||||||
|
/// Active window border style (default: System)
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub active_window_border_style: Option<ActiveWindowBorderStyle>,
|
||||||
/// Global default workspace padding (default: 10)
|
/// Global default workspace padding (default: 10)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub default_workspace_padding: Option<i32>,
|
pub default_workspace_padding: Option<i32>,
|
||||||
@@ -411,6 +426,7 @@ impl From<&WindowManager> for StaticConfig {
|
|||||||
border_offset: Option::from(BORDER_OFFSET.load(Ordering::SeqCst)),
|
border_offset: Option::from(BORDER_OFFSET.load(Ordering::SeqCst)),
|
||||||
active_window_border: Option::from(BORDER_ENABLED.load(Ordering::SeqCst)),
|
active_window_border: Option::from(BORDER_ENABLED.load(Ordering::SeqCst)),
|
||||||
active_window_border_colours: border_colours,
|
active_window_border_colours: border_colours,
|
||||||
|
active_window_border_style: Option::from(*ACTIVE_WINDOW_BORDER_STYLE.lock()),
|
||||||
default_workspace_padding: Option::from(
|
default_workspace_padding: Option::from(
|
||||||
DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst),
|
DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst),
|
||||||
),
|
),
|
||||||
@@ -477,6 +493,9 @@ impl StaticConfig {
|
|||||||
BORDER_COLOUR_MONOCLE.store(u32::from(colours.monocle), Ordering::SeqCst);
|
BORDER_COLOUR_MONOCLE.store(u32::from(colours.monocle), Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let active_window_border_style = self.active_window_border_style.unwrap_or_default();
|
||||||
|
*ACTIVE_WINDOW_BORDER_STYLE.lock() = active_window_border_style;
|
||||||
|
|
||||||
let mut float_identifiers = FLOAT_IDENTIFIERS.lock();
|
let mut float_identifiers = FLOAT_IDENTIFIERS.lock();
|
||||||
let mut regex_identifiers = REGEX_IDENTIFIERS.lock();
|
let mut regex_identifiers = REGEX_IDENTIFIERS.lock();
|
||||||
let mut manage_identifiers = MANAGE_IDENTIFIERS.lock();
|
let mut manage_identifiers = MANAGE_IDENTIFIERS.lock();
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ 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::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
use crate::BORDER_RECT;
|
use crate::BORDER_RECT;
|
||||||
use crate::BORDER_WIDTH;
|
use crate::BORDER_WIDTH;
|
||||||
@@ -232,10 +234,20 @@ pub extern "system" fn border_window(
|
|||||||
// the window was made with DWMWCP_ROUNDSMALL then this is the
|
// the window was made with DWMWCP_ROUNDSMALL then this is the
|
||||||
// wrong size. In the future we should read the DWM properties
|
// wrong size. In the future we should read the DWM properties
|
||||||
// of windows and attempt to match appropriately.
|
// of windows and attempt to match appropriately.
|
||||||
if *WINDOWS_11 {
|
match *ACTIVE_WINDOW_BORDER_STYLE.lock() {
|
||||||
RoundRect(hdc, 0, 0, border_rect.right, border_rect.bottom, 20, 20);
|
ActiveWindowBorderStyle::System => {
|
||||||
} else {
|
if *WINDOWS_11 {
|
||||||
Rectangle(hdc, 0, 0, border_rect.right, border_rect.bottom);
|
RoundRect(hdc, 0, 0, border_rect.right, border_rect.bottom, 20, 20);
|
||||||
|
} else {
|
||||||
|
Rectangle(hdc, 0, 0, border_rect.right, border_rect.bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ActiveWindowBorderStyle::Rounded => {
|
||||||
|
RoundRect(hdc, 0, 0, border_rect.right, border_rect.bottom, 20, 20);
|
||||||
|
}
|
||||||
|
ActiveWindowBorderStyle::Square => {
|
||||||
|
Rectangle(hdc, 0, 0, border_rect.right, border_rect.bottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EndPaint(window, &ps);
|
EndPaint(window, &ps);
|
||||||
ValidateRect(window, None);
|
ValidateRect(window, None);
|
||||||
|
|||||||
Reference in New Issue
Block a user