mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-16 05:41:16 +01:00
fix(border): maintain config compat with windows opts
This commit adds a 7px border offset adjustment to the BORDER_OFFSET value wherever it is used to maintain config compatibility with komorebi for Windows. Windows has stupid 7px invisible borders around every app window which have to be taken into account when setting the values for these options, but this is not the case on macOS. However, if we don't replicate the factoring in of those invisible borders into our offset calculations, the same border config on Windows and macOS looks vastly different.
This commit is contained in:
1 parent
c23bf462cb
commit
8b4604d47e
6 files changed
+217
-206
No files matched your search
@@ -6,6 +6,7 @@ use crate::accessibility::notification_constants::kAXMainWindowChangedNotificati
|
||||
use crate::accessibility::notification_constants::kAXWindowMovedNotification;
|
||||
use crate::accessibility::notification_constants::kAXWindowResizedNotification;
|
||||
use crate::border_manager::BORDER_OFFSET;
|
||||
use crate::border_manager::BORDER_OFFSET_ADJUSTMENT;
|
||||
use crate::border_manager::BORDER_WIDTH;
|
||||
use crate::border_manager::ns_window::NsWindow;
|
||||
use crate::border_manager::window_kind_colour;
|
||||
@@ -56,7 +57,8 @@ unsafe extern "C-unwind" fn border_observer_callback(
|
||||
rect.size,
|
||||
);
|
||||
|
||||
let offset = BORDER_OFFSET.load(Ordering::Relaxed) as f64;
|
||||
let offset =
|
||||
BORDER_OFFSET.load(Ordering::Relaxed) as f64 + BORDER_OFFSET_ADJUSTMENT as f64;
|
||||
|
||||
ns_rect.origin.x -= offset;
|
||||
ns_rect.origin.y -= offset;
|
||||
|
||||
@@ -29,11 +29,19 @@ use std::sync::atomic::AtomicI32;
|
||||
use std::sync::atomic::AtomicU32;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
pub static BORDER_WIDTH: AtomicI32 = AtomicI32::new(6);
|
||||
pub static BORDER_OFFSET: AtomicI32 = AtomicI32::new(5);
|
||||
pub static BORDER_WIDTH: AtomicI32 = AtomicI32::new(10);
|
||||
pub static BORDER_OFFSET: AtomicI32 = AtomicI32::new(0);
|
||||
pub static BORDER_RADIUS: AtomicI32 = AtomicI32::new(10);
|
||||
pub static BORDER_ENABLED: AtomicBool = AtomicBool::new(true);
|
||||
|
||||
// Windows has a 7px invisible border around every app which the border_x
|
||||
// config options have to take into account. In order to keep the komorebi
|
||||
// configuration truly portable across Windows and macOS, we need to add
|
||||
// that same 7px adjustment to whatever BORDER_OFFSET is set to. I hate this,
|
||||
// but config compatibility has to come first, and komorebi for Windows already
|
||||
// has tens of thousands of users.
|
||||
pub static BORDER_OFFSET_ADJUSTMENT: i32 = 7;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref FOCUSED: AtomicU32 =
|
||||
AtomicU32::new(u32::from(Colour::Rgb(Rgb::new(66, 165, 245))));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::border_manager::BORDER_OFFSET;
|
||||
use crate::border_manager::BORDER_OFFSET_ADJUSTMENT;
|
||||
use crate::border_manager::BORDER_RADIUS;
|
||||
use crate::border_manager::BORDER_WIDTH;
|
||||
use color_eyre::eyre;
|
||||
@@ -38,7 +39,7 @@ unsafe impl Send for NsWindow {}
|
||||
|
||||
impl NsWindow {
|
||||
pub fn new(ns_rect: NSRect, target_window_id: u32) -> eyre::Result<NsWindow> {
|
||||
let offset = BORDER_OFFSET.load(Ordering::Relaxed) as f64;
|
||||
let offset = BORDER_OFFSET.load(Ordering::Relaxed) as f64 + BORDER_OFFSET_ADJUSTMENT as f64;
|
||||
|
||||
let mut ns_rect = ns_rect;
|
||||
|
||||
|
||||
@@ -965,6 +965,103 @@ in
|
||||
]
|
||||
);
|
||||
};
|
||||
auto_select_text = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
base_00 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base00";
|
||||
};
|
||||
base_01 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base01";
|
||||
};
|
||||
base_02 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base02";
|
||||
};
|
||||
base_03 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base03";
|
||||
};
|
||||
base_04 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base04";
|
||||
};
|
||||
base_05 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base05";
|
||||
};
|
||||
base_06 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base06";
|
||||
};
|
||||
base_07 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base07";
|
||||
};
|
||||
base_08 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base08";
|
||||
};
|
||||
base_09 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base09";
|
||||
};
|
||||
base_0a = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0A";
|
||||
};
|
||||
base_0b = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0B";
|
||||
};
|
||||
base_0c = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0C";
|
||||
};
|
||||
base_0d = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0D";
|
||||
};
|
||||
base_0e = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0E";
|
||||
};
|
||||
base_0f = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0F";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
@@ -1251,17 +1348,6 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
auto_select_text = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
auto_select_fill = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
@@ -1273,92 +1359,6 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
base_00 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base00";
|
||||
};
|
||||
base_01 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base01";
|
||||
};
|
||||
base_02 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base02";
|
||||
};
|
||||
base_03 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base03";
|
||||
};
|
||||
base_04 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base04";
|
||||
};
|
||||
base_05 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base05";
|
||||
};
|
||||
base_06 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base06";
|
||||
};
|
||||
base_07 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base07";
|
||||
};
|
||||
base_08 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base08";
|
||||
};
|
||||
base_09 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base09";
|
||||
};
|
||||
base_0a = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0A";
|
||||
};
|
||||
base_0b = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0B";
|
||||
};
|
||||
base_0c = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0C";
|
||||
};
|
||||
base_0d = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0D";
|
||||
};
|
||||
base_0e = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0E";
|
||||
};
|
||||
base_0f = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0F";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
+103
-103
@@ -427,7 +427,7 @@ in
|
||||
};
|
||||
border_offset = lib.mkOption {
|
||||
type = (lib.types.nullOr lib.types.int);
|
||||
default = 5;
|
||||
default = 0;
|
||||
description = "Offset of window borders";
|
||||
};
|
||||
border_radius = lib.mkOption {
|
||||
@@ -437,7 +437,7 @@ in
|
||||
};
|
||||
border_width = lib.mkOption {
|
||||
type = (lib.types.nullOr lib.types.int);
|
||||
default = 6;
|
||||
default = 10;
|
||||
description = "Width of window borders";
|
||||
};
|
||||
cross_boundary_behaviour = lib.mkOption {
|
||||
@@ -778,82 +778,7 @@ in
|
||||
]
|
||||
);
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
base_00 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base00";
|
||||
};
|
||||
base_01 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base01";
|
||||
};
|
||||
base_02 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base02";
|
||||
};
|
||||
base_03 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base03";
|
||||
};
|
||||
base_04 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base04";
|
||||
};
|
||||
base_05 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base05";
|
||||
};
|
||||
base_06 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base06";
|
||||
};
|
||||
base_07 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base07";
|
||||
};
|
||||
base_08 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base08";
|
||||
};
|
||||
base_09 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base09";
|
||||
};
|
||||
base_0a = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0A";
|
||||
};
|
||||
base_0b = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0B";
|
||||
};
|
||||
base_0c = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0C";
|
||||
};
|
||||
base_0d = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0D";
|
||||
};
|
||||
base_0e = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0E";
|
||||
};
|
||||
base_0f = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0F";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
stack_border = lib.mkOption {
|
||||
floating_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
@@ -864,29 +789,7 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_locked_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
single_border = lib.mkOption {
|
||||
bar_accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
@@ -1183,7 +1086,18 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
bar_accent = lib.mkOption {
|
||||
unfocused_locked_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
stack_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
@@ -1205,7 +1119,93 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
floating_border = lib.mkOption {
|
||||
single_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
base_00 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base00";
|
||||
};
|
||||
base_01 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base01";
|
||||
};
|
||||
base_02 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base02";
|
||||
};
|
||||
base_03 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base03";
|
||||
};
|
||||
base_04 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base04";
|
||||
};
|
||||
base_05 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base05";
|
||||
};
|
||||
base_06 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base06";
|
||||
};
|
||||
base_07 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base07";
|
||||
};
|
||||
base_08 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base08";
|
||||
};
|
||||
base_09 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base09";
|
||||
};
|
||||
base_0a = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0A";
|
||||
};
|
||||
base_0b = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0B";
|
||||
};
|
||||
base_0c = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0C";
|
||||
};
|
||||
base_0d = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0D";
|
||||
};
|
||||
base_0e = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0E";
|
||||
};
|
||||
base_0f = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0F";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@
|
||||
"null"
|
||||
],
|
||||
"format": "int32",
|
||||
"default": 5
|
||||
"default": 0
|
||||
},
|
||||
"border_radius": {
|
||||
"description": "Radius of window borders",
|
||||
@@ -70,7 +70,7 @@
|
||||
"null"
|
||||
],
|
||||
"format": "int32",
|
||||
"default": 6
|
||||
"default": 10
|
||||
},
|
||||
"cross_boundary_behaviour": {
|
||||
"description": "Determine what happens when an action is called on a window at a monitor boundary",
|
||||
|
||||
Reference in new issue
Block a user