mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-27 20:01:14 +01:00
This commit is an implementation of a static JSON configuration loader. An example komorebi.json configuration file has been added. The application-specific configurations can be loaded directly from a file, and workspace configuration can be defined declaratively in the JSON. Individual rules etc. can also be added directly in the static configuration as one-offs. A JSONSchema can be generated using komorebic's static-config-schema command. This should be added to something like SchemaStore later. Loading from static configuration is significantly faster on startup, as the lock does not have to be reacquired for every command that is sent over the socket. When loading configuration from a static JSON file, a hotwatch instance will automatically be created to listen to file changes and apply any updates to both the global and window manager configuration state. A new --whkd flag has been added to the komorebic start command to optionally start whkd in a background process. A new komorebic command 'generate-static-config' has been added to help existing users migrate to a static JSON config file. Currently, custom layout file path information can not be automatically populated in the output of this command and must be added manually by the user if required. A new komorebic command 'fetch-asc' has been added to help users update to the latest version of the application-specific configurations in-place. resolve #427
47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use windows::Win32::Foundation::RECT;
|
|
|
|
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
|
|
pub struct Rect {
|
|
/// The left point in a Win32 Rect
|
|
pub left: i32,
|
|
/// The top point in a Win32 Rect
|
|
pub top: i32,
|
|
/// The right point in a Win32 Rect
|
|
pub right: i32,
|
|
/// The bottom point in a Win32 Rect
|
|
pub bottom: i32,
|
|
}
|
|
|
|
impl From<RECT> for Rect {
|
|
fn from(rect: RECT) -> Self {
|
|
Self {
|
|
left: rect.left,
|
|
top: rect.top,
|
|
right: rect.right - rect.left,
|
|
bottom: rect.bottom - rect.top,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Rect {
|
|
pub fn add_padding(&mut self, padding: Option<i32>) {
|
|
if let Some(padding) = padding {
|
|
self.left += padding;
|
|
self.top += padding;
|
|
self.right -= padding * 2;
|
|
self.bottom -= padding * 2;
|
|
}
|
|
}
|
|
|
|
#[must_use]
|
|
pub const fn contains_point(&self, point: (i32, i32)) -> bool {
|
|
point.0 >= self.left
|
|
&& point.0 <= self.left + self.right
|
|
&& point.1 >= self.top
|
|
&& point.1 <= self.top + self.bottom
|
|
}
|
|
}
|