mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-10 23:22:43 +02:00
feat(config): update border opts, add deprecations
This commit includes backwards-compatible renames of active_window_border_offset and active_window_border_width to border_offset and border_width respectively. Since the invisible window border adjustments were removed in #678, the invisible window borders set by the OS can now also be adjusted via border_offset and border_width, which is the primary reason for the rename. invisible_borders has been marked as deprecated and the previously deprecated alt_focus_hack option has been removed.
This commit is contained in:
@@ -86,11 +86,7 @@ impl Border {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(
|
pub fn set_position(self, window: Window, activate: bool) -> Result<()> {
|
||||||
self,
|
|
||||||
window: Window,
|
|
||||||
activate: bool,
|
|
||||||
) -> Result<()> {
|
|
||||||
if self.hwnd == 0 {
|
if self.hwnd == 0 {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -205,7 +205,6 @@ pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(10);
|
|||||||
pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false);
|
pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false);
|
||||||
pub static CUSTOM_FFM: AtomicBool = AtomicBool::new(false);
|
pub static CUSTOM_FFM: AtomicBool = AtomicBool::new(false);
|
||||||
pub static SESSION_ID: AtomicU32 = AtomicU32::new(0);
|
pub static SESSION_ID: AtomicU32 = AtomicU32::new(0);
|
||||||
pub static ALT_FOCUS_HACK: AtomicBool = AtomicBool::new(false);
|
|
||||||
pub static BORDER_ENABLED: AtomicBool = AtomicBool::new(false);
|
pub static BORDER_ENABLED: AtomicBool = AtomicBool::new(false);
|
||||||
pub static BORDER_HWND: AtomicIsize = AtomicIsize::new(0);
|
pub static BORDER_HWND: AtomicIsize = AtomicIsize::new(0);
|
||||||
pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false);
|
pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false);
|
||||||
|
|||||||
@@ -192,10 +192,7 @@ impl Monitor {
|
|||||||
self.workspaces().len()
|
self.workspaces().len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_focused_workspace(
|
pub fn update_focused_workspace(&mut self, offset: Option<Rect>) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
offset: Option<Rect>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let work_area = *self.work_area_size();
|
let work_area = *self.work_area_size();
|
||||||
let offset = if self.work_area_offset().is_some() {
|
let offset = if self.work_area_offset().is_some() {
|
||||||
self.work_area_offset()
|
self.work_area_offset()
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ use crate::window_manager::WindowManager;
|
|||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
use crate::Notification;
|
use crate::Notification;
|
||||||
use crate::NotificationEvent;
|
use crate::NotificationEvent;
|
||||||
use crate::ALT_FOCUS_HACK;
|
|
||||||
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;
|
||||||
@@ -1252,8 +1251,8 @@ impl WindowManager {
|
|||||||
BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
}
|
}
|
||||||
SocketMessage::AltFocusHack(enable) => {
|
SocketMessage::AltFocusHack(_) => {
|
||||||
ALT_FOCUS_HACK.store(enable, Ordering::SeqCst);
|
tracing::info!("this action is deprecated");
|
||||||
}
|
}
|
||||||
SocketMessage::ApplicationSpecificConfigurationSchema => {
|
SocketMessage::ApplicationSpecificConfigurationSchema => {
|
||||||
let asc = schema_for!(Vec<ApplicationConfiguration>);
|
let asc = schema_for!(Vec<ApplicationConfiguration>);
|
||||||
|
|||||||
@@ -376,8 +376,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
// If we have moved across the monitors, use that override, otherwise determine
|
// If we have moved across the monitors, use that override, otherwise determine
|
||||||
// if a move has taken place by ruling out a resize
|
// if a move has taken place by ruling out a resize
|
||||||
let is_move = moved_across_monitors
|
let is_move = moved_across_monitors || resize.right == 0 && resize.bottom == 0;
|
||||||
|| resize.right == 0 && resize.bottom == 0;
|
|
||||||
|
|
||||||
if is_move {
|
if is_move {
|
||||||
tracing::info!("moving with mouse");
|
tracing::info!("moving with mouse");
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ impl From<&Monitor> for MonitorConfig {
|
|||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
/// The `komorebi.json` static configuration file reference for `v0.1.20`
|
/// The `komorebi.json` static configuration file reference for `v0.1.20`
|
||||||
pub struct StaticConfig {
|
pub struct StaticConfig {
|
||||||
/// Dimensions of Windows' own invisible borders; don't set these yourself unless you are told to
|
/// DEPRECATED from v0.1.22: no longer required
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub invisible_borders: Option<Rect>,
|
pub invisible_borders: Option<Rect>,
|
||||||
/// Delta to resize windows by (default 50)
|
/// Delta to resize windows by (default 50)
|
||||||
@@ -238,12 +238,14 @@ 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)
|
/// Width of the window border (default: 8)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub active_window_border_width: Option<i32>,
|
#[serde(alias = "active_window_border_width")]
|
||||||
/// Offset of the active window border (default: None)
|
pub border_width: Option<i32>,
|
||||||
|
/// Offset of the window border (default: -1)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub active_window_border_offset: Option<i32>,
|
#[serde(alias = "active_window_border_offset")]
|
||||||
|
pub 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>,
|
||||||
@@ -259,10 +261,6 @@ pub struct StaticConfig {
|
|||||||
/// Monitor and workspace configurations
|
/// Monitor and workspace configurations
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub monitors: Option<Vec<MonitorConfig>>,
|
pub monitors: Option<Vec<MonitorConfig>>,
|
||||||
/// DEPRECATED from v0.1.20: no longer required
|
|
||||||
#[schemars(skip)]
|
|
||||||
#[serde(skip_serializing)]
|
|
||||||
pub alt_focus_hack: Option<bool>,
|
|
||||||
/// Which Windows signal to use when hiding windows (default: minimize)
|
/// Which Windows signal to use when hiding windows (default: minimize)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub window_hiding_behaviour: Option<HidingBehaviour>,
|
pub window_hiding_behaviour: Option<HidingBehaviour>,
|
||||||
@@ -377,8 +375,8 @@ 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,
|
||||||
active_window_border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)),
|
border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)),
|
||||||
active_window_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,
|
||||||
default_workspace_padding: Option::from(
|
default_workspace_padding: Option::from(
|
||||||
@@ -388,7 +386,6 @@ impl From<&WindowManager> for StaticConfig {
|
|||||||
DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst),
|
DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst),
|
||||||
),
|
),
|
||||||
monitors: Option::from(monitors),
|
monitors: Option::from(monitors),
|
||||||
alt_focus_hack: None,
|
|
||||||
window_hiding_behaviour: Option::from(*HIDING_BEHAVIOUR.lock()),
|
window_hiding_behaviour: Option::from(*HIDING_BEHAVIOUR.lock()),
|
||||||
global_work_area_offset: value.work_area_offset,
|
global_work_area_offset: value.work_area_offset,
|
||||||
float_rules: None,
|
float_rules: None,
|
||||||
@@ -429,7 +426,7 @@ impl StaticConfig {
|
|||||||
DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst);
|
DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.active_window_border_width.map_or_else(
|
self.border_width.map_or_else(
|
||||||
|| {
|
|| {
|
||||||
BORDER_WIDTH.store(8, Ordering::SeqCst);
|
BORDER_WIDTH.store(8, Ordering::SeqCst);
|
||||||
},
|
},
|
||||||
@@ -438,7 +435,7 @@ impl StaticConfig {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
BORDER_OFFSET.store(self.active_window_border_offset.unwrap_or(-1), Ordering::SeqCst);
|
BORDER_OFFSET.store(self.border_offset.unwrap_or(-1), Ordering::SeqCst);
|
||||||
|
|
||||||
if let Some(colours) = &self.active_window_border_colours {
|
if let Some(colours) = &self.active_window_border_colours {
|
||||||
BORDER_COLOUR_SINGLE.store(u32::from(colours.single), Ordering::SeqCst);
|
BORDER_COLOUR_SINGLE.store(u32::from(colours.single), Ordering::SeqCst);
|
||||||
@@ -895,6 +892,12 @@ impl StaticConfig {
|
|||||||
|
|
||||||
wm.focus_follows_mouse = value.focus_follows_mouse;
|
wm.focus_follows_mouse = value.focus_follows_mouse;
|
||||||
|
|
||||||
|
let monitor_count = wm.monitors().len();
|
||||||
|
|
||||||
|
for i in 0..monitor_count {
|
||||||
|
wm.update_focused_workspace_by_monitor_idx(i)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-19
@@ -4,7 +4,6 @@ use std::convert::TryFrom;
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
use std::fmt::Write as _;
|
use std::fmt::Write as _;
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
|
|
||||||
use color_eyre::eyre;
|
use color_eyre::eyre;
|
||||||
use color_eyre::eyre::anyhow;
|
use color_eyre::eyre::anyhow;
|
||||||
@@ -19,9 +18,6 @@ use serde::Deserialize;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde::Serializer;
|
use serde::Serializer;
|
||||||
use windows::Win32::Foundation::HWND;
|
use windows::Win32::Foundation::HWND;
|
||||||
use winput::press;
|
|
||||||
use winput::release;
|
|
||||||
use winput::Vk;
|
|
||||||
|
|
||||||
use komorebi_core::ApplicationIdentifier;
|
use komorebi_core::ApplicationIdentifier;
|
||||||
use komorebi_core::HidingBehaviour;
|
use komorebi_core::HidingBehaviour;
|
||||||
@@ -31,7 +27,6 @@ use crate::styles::ExtendedWindowStyle;
|
|||||||
use crate::styles::WindowStyle;
|
use crate::styles::WindowStyle;
|
||||||
use crate::window_manager_event::WindowManagerEvent;
|
use crate::window_manager_event::WindowManagerEvent;
|
||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
use crate::ALT_FOCUS_HACK;
|
|
||||||
use crate::FLOAT_IDENTIFIERS;
|
use crate::FLOAT_IDENTIFIERS;
|
||||||
use crate::HIDDEN_HWNDS;
|
use crate::HIDDEN_HWNDS;
|
||||||
use crate::HIDING_BEHAVIOUR;
|
use crate::HIDING_BEHAVIOUR;
|
||||||
@@ -143,11 +138,7 @@ impl Window {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(
|
pub fn set_position(&mut self, layout: &Rect, top: bool) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
layout: &Rect,
|
|
||||||
top: bool,
|
|
||||||
) -> Result<()> {
|
|
||||||
let rect = *layout;
|
let rect = *layout;
|
||||||
WindowsApi::position_window(self.hwnd(), &rect, top)
|
WindowsApi::position_window(self.hwnd(), &rect, top)
|
||||||
}
|
}
|
||||||
@@ -298,12 +289,7 @@ impl Window {
|
|||||||
let mut tried_resetting_foreground_access = false;
|
let mut tried_resetting_foreground_access = false;
|
||||||
let mut max_attempts = 10;
|
let mut max_attempts = 10;
|
||||||
|
|
||||||
let hotkey_uses_alt = WindowsApi::alt_is_pressed();
|
|
||||||
while !foregrounded && max_attempts > 0 {
|
while !foregrounded && max_attempts > 0 {
|
||||||
if ALT_FOCUS_HACK.load(Ordering::SeqCst) {
|
|
||||||
press(Vk::Alt);
|
|
||||||
}
|
|
||||||
|
|
||||||
match WindowsApi::set_foreground_window(self.hwnd()) {
|
match WindowsApi::set_foreground_window(self.hwnd()) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
foregrounded = true;
|
foregrounded = true;
|
||||||
@@ -324,10 +310,6 @@ impl Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ALT_FOCUS_HACK.load(Ordering::SeqCst) && !hotkey_uses_alt {
|
|
||||||
release(Vk::Alt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center cursor in Window
|
// Center cursor in Window
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ impl WindowsApi {
|
|||||||
| SetWindowPosition::FRAME_CHANGED;
|
| SetWindowPosition::FRAME_CHANGED;
|
||||||
|
|
||||||
let shadow_rect = Self::shadow_rect(hwnd)?;
|
let shadow_rect = Self::shadow_rect(hwnd)?;
|
||||||
let rect = Rect{
|
let rect = Rect {
|
||||||
left: layout.left + shadow_rect.left,
|
left: layout.left + shadow_rect.left,
|
||||||
top: layout.top + shadow_rect.top,
|
top: layout.top + shadow_rect.top,
|
||||||
right: layout.right + shadow_rect.right,
|
right: layout.right + shadow_rect.right,
|
||||||
|
|||||||
@@ -203,11 +203,7 @@ impl Workspace {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(&mut self, work_area: &Rect, offset: Option<Rect>) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
work_area: &Rect,
|
|
||||||
offset: Option<Rect>,
|
|
||||||
) -> Result<()> {
|
|
||||||
if !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) {
|
if !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1077,8 +1077,9 @@ enum SubCommand {
|
|||||||
WatchConfiguration(WatchConfiguration),
|
WatchConfiguration(WatchConfiguration),
|
||||||
/// Signal that the final configuration option has been sent
|
/// Signal that the final configuration option has been sent
|
||||||
CompleteConfiguration,
|
CompleteConfiguration,
|
||||||
/// Enable or disable a hack simulating ALT key presses to ensure focus changes succeed
|
/// DEPRECATED since v0.1.22
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
|
#[clap(hide = true)]
|
||||||
AltFocusHack(AltFocusHack),
|
AltFocusHack(AltFocusHack),
|
||||||
/// Set the window behaviour when switching workspaces / cycling stacks
|
/// Set the window behaviour when switching workspaces / cycling stacks
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
|
|||||||
Reference in New Issue
Block a user