mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-07 05:25:21 +02:00
fix(config): align border opts in st/dyn configs
This commit aligns the border option naming and arguments between the dynamic and static configuration approaches. The previously named border_width and border_offset options in the static config will be replaced by active_window_border_width and active_window_border_offset in v0.1.19. Similarly the option for the offset will now take a single signed integer, as it does when using the komorebic command. re #526
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"derive-ahk",
|
"derive-ahk",
|
||||||
"komorebi",
|
"komorebi",
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ pub fn current_virtual_desktop() -> Option<Vec<u8>> {
|
|||||||
// This is the path on Windows 11
|
// This is the path on Windows 11
|
||||||
if current.is_none() {
|
if current.is_none() {
|
||||||
current = hkcu
|
current = hkcu
|
||||||
.open_subkey(r#"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops"#)
|
.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(
|
.and_then(
|
||||||
|desktops| match desktops.get_raw_value("CurrentVirtualDesktop") {
|
|desktops| match desktops.get_raw_value("CurrentVirtualDesktop") {
|
||||||
@@ -357,7 +357,7 @@ pub struct Notification {
|
|||||||
pub fn notify_subscribers(notification: &str) -> Result<()> {
|
pub fn notify_subscribers(notification: &str) -> Result<()> {
|
||||||
let mut stale_subscriptions = vec![];
|
let mut stale_subscriptions = vec![];
|
||||||
let mut subscriptions = SUBSCRIPTION_PIPES.lock();
|
let mut subscriptions = SUBSCRIPTION_PIPES.lock();
|
||||||
for (subscriber, pipe) in subscriptions.iter_mut() {
|
for (subscriber, pipe) in &mut *subscriptions {
|
||||||
match writeln!(pipe, "{notification}") {
|
match writeln!(pipe, "{notification}") {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
tracing::debug!("pushed notification to subscriber: {}", subscriber);
|
tracing::debug!("pushed notification to subscriber: {}", subscriber);
|
||||||
|
|||||||
@@ -259,9 +259,8 @@ impl WindowManager {
|
|||||||
.focused_workspace()
|
.focused_workspace()
|
||||||
.ok_or_else(|| anyhow!("there is no workspace"))?
|
.ok_or_else(|| anyhow!("there is no workspace"))?
|
||||||
.containers()
|
.containers()
|
||||||
.iter()
|
|
||||||
{
|
{
|
||||||
for window in container.windows().iter() {
|
for window in container.windows() {
|
||||||
match identifier {
|
match identifier {
|
||||||
ApplicationIdentifier::Exe => {
|
ApplicationIdentifier::Exe => {
|
||||||
if window.exe()? == *id {
|
if window.exe()? == *id {
|
||||||
|
|||||||
@@ -250,12 +250,18 @@ pub struct StaticConfig {
|
|||||||
/// Path to applications.yaml from komorebi-application-specific-configurations (default: None)
|
/// Path to applications.yaml from komorebi-application-specific-configurations (default: None)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub app_specific_configuration_path: Option<PathBuf>,
|
pub app_specific_configuration_path: Option<PathBuf>,
|
||||||
/// Width of the active window border (default: 20)
|
/// DEPRECATED from v0.1.19: use active_window_border_width instead
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub border_width: Option<i32>,
|
pub border_width: Option<i32>,
|
||||||
/// Offset of the active window border (default: None)
|
/// DEPRECATED from v0.1.19: use active_window_border_offset instead
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub border_offset: Option<Rect>,
|
pub border_offset: Option<Rect>,
|
||||||
|
/// Width of the active window border (default: 20)
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub active_window_border_width: Option<i32>,
|
||||||
|
/// Offset of the active window border (default: None)
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub active_window_border_offset: Option<i32>,
|
||||||
/// Display an active window border (default: false)
|
/// Display an active window border (default: false)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub active_window_border: Option<bool>,
|
pub active_window_border: Option<bool>,
|
||||||
@@ -396,8 +402,12 @@ impl From<&WindowManager> for StaticConfig {
|
|||||||
focus_follows_mouse: value.focus_follows_mouse,
|
focus_follows_mouse: value.focus_follows_mouse,
|
||||||
mouse_follows_focus: Option::from(value.mouse_follows_focus),
|
mouse_follows_focus: Option::from(value.mouse_follows_focus),
|
||||||
app_specific_configuration_path: None,
|
app_specific_configuration_path: None,
|
||||||
border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)),
|
active_window_border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)),
|
||||||
border_offset: *BORDER_OFFSET.lock(),
|
active_window_border_offset: BORDER_OFFSET
|
||||||
|
.lock()
|
||||||
|
.map_or(None, |offset| Option::from(offset.left)),
|
||||||
|
border_width: None,
|
||||||
|
border_offset: None,
|
||||||
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,
|
||||||
default_workspace_padding: Option::from(
|
default_workspace_padding: Option::from(
|
||||||
@@ -446,14 +456,31 @@ impl StaticConfig {
|
|||||||
DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst);
|
DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(width) = self.border_width {
|
self.active_window_border_width.map_or_else(
|
||||||
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
|| {
|
||||||
}
|
BORDER_WIDTH.store(20, Ordering::SeqCst);
|
||||||
|
},
|
||||||
|
|width| {
|
||||||
|
BORDER_WIDTH.store(width, Ordering::SeqCst);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
self.active_window_border_offset.map_or_else(
|
||||||
|
|| {
|
||||||
|
let mut border_offset = BORDER_OFFSET.lock();
|
||||||
|
*border_offset = None;
|
||||||
|
},
|
||||||
|
|offset| {
|
||||||
|
let new_border_offset = Rect {
|
||||||
|
left: offset,
|
||||||
|
top: offset,
|
||||||
|
right: offset * 2,
|
||||||
|
bottom: offset * 2,
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(offset) = self.border_offset {
|
let mut border_offset = BORDER_OFFSET.lock();
|
||||||
let mut border_offset = BORDER_OFFSET.lock();
|
*border_offset = Some(new_border_offset);
|
||||||
*border_offset = Some(offset);
|
},
|
||||||
}
|
);
|
||||||
|
|
||||||
if let Some(colours) = &self.active_window_border_colours {
|
if let Some(colours) = &self.active_window_border_colours {
|
||||||
BORDER_COLOUR_SINGLE.store(
|
BORDER_COLOUR_SINGLE.store(
|
||||||
|
|||||||
@@ -234,8 +234,7 @@ impl WindowsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn enum_windows(callback: WNDENUMPROC, callback_data_address: isize) -> Result<()> {
|
pub fn enum_windows(callback: WNDENUMPROC, callback_data_address: isize) -> Result<()> {
|
||||||
unsafe { EnumWindows(callback, LPARAM(callback_data_address)) }
|
unsafe { EnumWindows(callback, LPARAM(callback_data_address)) }.process()
|
||||||
.process()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_workspace_information(monitors: &mut Ring<Monitor>) -> Result<()> {
|
pub fn load_workspace_information(monitors: &mut Ring<Monitor>) -> Result<()> {
|
||||||
@@ -274,8 +273,7 @@ impl WindowsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn allow_set_foreground_window(process_id: u32) -> Result<()> {
|
pub fn allow_set_foreground_window(process_id: u32) -> Result<()> {
|
||||||
unsafe { AllowSetForegroundWindow(process_id) }
|
unsafe { AllowSetForegroundWindow(process_id) }.process()
|
||||||
.process()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn monitor_from_window(hwnd: HWND) -> isize {
|
pub fn monitor_from_window(hwnd: HWND) -> isize {
|
||||||
@@ -365,8 +363,7 @@ impl WindowsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn post_message(hwnd: HWND, message: u32, wparam: WPARAM, lparam: LPARAM) -> Result<()> {
|
fn post_message(hwnd: HWND, message: u32, wparam: WPARAM, lparam: LPARAM) -> Result<()> {
|
||||||
unsafe { PostMessageW(hwnd, message, wparam, lparam) }
|
unsafe { PostMessageW(hwnd, message, wparam, lparam) }.process()
|
||||||
.process()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close_window(hwnd: HWND) -> Result<()> {
|
pub fn close_window(hwnd: HWND) -> Result<()> {
|
||||||
|
|||||||
@@ -1452,7 +1452,7 @@ fn main() -> Result<()> {
|
|||||||
"'--config=\"{}\"'",
|
"'--config=\"{}\"'",
|
||||||
path.as_os_str()
|
path.as_os_str()
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.trim_start_matches(r#"\\?\"#),
|
.trim_start_matches(r"\\?\"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user