mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-02 05:04:19 +01:00
merge: wip-cand6
Merge of wip-cand5, wip-u-bugfix, wip-u-wm, wip-u-settings3, wip-u-repotools, wip-u-nix3 and wip-u-e2e2unit. Resolutions: - docs/dev/macos-handcheck.md: every section is kept, in order. The bugfix agent's section F (bar clicks) and the settings agent's section (also headed F) both appended after E; the settings one is renamed G, text unchanged. - komorebi-for-mac/komorebi/src/animation/mod.rs and static_config.rs: the formatting-only revision of wip-u-nix3 (76ab52da, import order) conflicts with the semantic edits of wip-u-settings3 (S4/S5). The files are taken from wip-u-settings3 as they are; the following style(macos) revision formats them again with the check's rustfmt invocation. Verified: see the following revisions and the report.
This commit is contained in:
commit
97c21b9360
119 files changed
+4220
-1195
No files matched your search
@@ -28,4 +28,10 @@ schemars = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
default = ["schemars"]
|
||||
schemars = ["dep:schemars", "komorebi-config/schemars", "komorebi-layouts/schemars", "komorebi-themes/schemars", "komorebi-protocol/schemars"]
|
||||
schemars = [
|
||||
"dep:schemars",
|
||||
"komorebi-config/schemars",
|
||||
"komorebi-layouts/schemars",
|
||||
"komorebi-themes/schemars",
|
||||
"komorebi-protocol/schemars",
|
||||
]
|
||||
@@ -31,6 +31,9 @@ pub trait BarPlatform: Send + Sync {
|
||||
/// The GitHub API URL that says which release of this platform's komorebi is the latest.
|
||||
fn latest_release_api_url(&self) -> &'static str;
|
||||
|
||||
/// The page of this platform's release `version` that the update widget opens when clicked.
|
||||
fn release_page_url(&self, version: &str) -> String;
|
||||
|
||||
/// The icon of the program a command string would start (Windows: the executable's icon;
|
||||
/// macOS: none).
|
||||
fn command_icon(&self, command: &str) -> Option<ImageIcon>;
|
||||
|
||||
@@ -83,7 +83,7 @@ impl Update {
|
||||
{
|
||||
let client = reqwest::blocking::Client::new();
|
||||
if let Ok(response) = client
|
||||
.get("https://api.github.com/repos/LGUG2Z/komorebi/releases/latest")
|
||||
.get(platform().latest_release_api_url())
|
||||
.header("User-Agent", "komorebi-bar-version-checker")
|
||||
.send()
|
||||
{
|
||||
@@ -143,10 +143,9 @@ impl BarWidget for Update {
|
||||
if SelectableFrame::new(false)
|
||||
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
||||
.clicked()
|
||||
&& let Err(error) = platform().open_system_tool(SystemTool::Url(format!(
|
||||
"https://github.com/LGUG2Z/komorebi/releases/v{}",
|
||||
self.latest_version
|
||||
)))
|
||||
&& let Err(error) = platform().open_system_tool(SystemTool::Url(
|
||||
platform().release_page_url(&self.latest_version),
|
||||
))
|
||||
{
|
||||
eprintln!("{error}")
|
||||
}
|
||||
|
||||
@@ -1378,13 +1378,13 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
0 | 1 => self.enforce_no_resize(),
|
||||
_ => {
|
||||
// Zero is actually on the right
|
||||
if let Some(left) = resize_dimensions[1].as_mut() {
|
||||
left.top = 0;
|
||||
left.bottom = 0;
|
||||
left.right = 0;
|
||||
if let Some(right) = resize_dimensions[0].as_mut() {
|
||||
right.top = 0;
|
||||
right.bottom = 0;
|
||||
right.right = 0;
|
||||
}
|
||||
|
||||
// Handle stack on the right
|
||||
// Handle stack on the left
|
||||
let stack_size = resize_dimensions[1..].len();
|
||||
for (i, rect) in resize_dimensions[1..].iter_mut().enumerate() {
|
||||
if let Some(rect) = rect {
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
//! What the Windows `layouts`, `flipping`, `layout_flip`, `padding`, `closing`, `tiling` and
|
||||
//! `stacks` scenarios (shared with KDE, and the only place macOS-or-Windows tiling used to be
|
||||
//! checked) assert about where `Workspace::update_shared` puts the windows, run on the stub
|
||||
//! platform: the tiles the shared code hands to the platform (`latest_layout`, which the scenarios
|
||||
//! compare the OS frames with) for every layout, count, padding and flip.
|
||||
//!
|
||||
//! These protect all three daemons (Windows, KDE, macOS: each calls `update_shared`). Platform
|
||||
//! choice: the stub platform adds no border and adjusts nothing, so a daemon's own `adjust_layout`
|
||||
//! (the Windows border of 7 px, macOS or KDE frame corrections) is NOT covered and stays e2e
|
||||
//! (`windows_padding`).
|
||||
//!
|
||||
//! The Windows fixture `kfw-tiled.json` of the e2e library is the same state shape these
|
||||
//! workspaces serialize to (see `state_roundtrip.rs`).
|
||||
|
||||
mod common;
|
||||
|
||||
use common::*;
|
||||
use komorebi_core::Workspace;
|
||||
use komorebi_layouts::Axis;
|
||||
use komorebi_layouts::DefaultLayout;
|
||||
use komorebi_layouts::Layout;
|
||||
use komorebi_layouts::Rect;
|
||||
|
||||
const LAYOUTS: [DefaultLayout; 8] = [
|
||||
DefaultLayout::BSP,
|
||||
DefaultLayout::Columns,
|
||||
DefaultLayout::Rows,
|
||||
DefaultLayout::VerticalStack,
|
||||
DefaultLayout::HorizontalStack,
|
||||
DefaultLayout::UltrawideVerticalStack,
|
||||
DefaultLayout::Grid,
|
||||
DefaultLayout::RightMainVerticalStack,
|
||||
];
|
||||
|
||||
const AREA: Rect = Rect {
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 1920,
|
||||
bottom: 1080,
|
||||
};
|
||||
|
||||
fn workspace(
|
||||
layout: DefaultLayout,
|
||||
ids: &[u32],
|
||||
container_padding: Option<i32>,
|
||||
workspace_padding: Option<i32>,
|
||||
flip: Option<Axis>,
|
||||
) -> Workspace<StubPlatform> {
|
||||
let mut workspace = workspace_of(ids);
|
||||
workspace.layout = Layout::Default(layout);
|
||||
workspace.layout_flip = flip;
|
||||
workspace.globals.work_area = AREA;
|
||||
workspace.globals.container_padding = container_padding;
|
||||
workspace.globals.workspace_padding = workspace_padding;
|
||||
workspace
|
||||
}
|
||||
|
||||
fn tiles(
|
||||
layout: DefaultLayout,
|
||||
count: u32,
|
||||
container_padding: Option<i32>,
|
||||
workspace_padding: Option<i32>,
|
||||
flip: Option<Axis>,
|
||||
) -> Vec<Rect> {
|
||||
fresh();
|
||||
let ids: Vec<u32> = (1..=count).collect();
|
||||
let mut workspace = workspace(layout, &ids, container_padding, workspace_padding, flip);
|
||||
workspace.update_shared().unwrap();
|
||||
workspace.latest_layout.clone()
|
||||
}
|
||||
|
||||
fn inside(r: &Rect, a: &Rect) -> bool {
|
||||
r.left >= a.left
|
||||
&& r.top >= a.top
|
||||
&& r.left + r.right <= a.left + a.right
|
||||
&& r.top + r.bottom <= a.top + a.bottom
|
||||
}
|
||||
|
||||
fn overlap(a: &Rect, b: &Rect) -> bool {
|
||||
a.left < b.left + b.right
|
||||
&& b.left < a.left + a.right
|
||||
&& a.top < b.top + b.bottom
|
||||
&& b.top < a.top + a.bottom
|
||||
}
|
||||
|
||||
fn area(r: &Rect) -> i64 {
|
||||
i64::from(r.right) * i64::from(r.bottom)
|
||||
}
|
||||
|
||||
// mirrors: layouts / <layout>, <n> windows: every window is where the layout says
|
||||
// mirrors: layouts / ... inside the work area
|
||||
// mirrors: layouts / ... and not on each other
|
||||
// mirrors: tiling / every window is where the layout says; <a> and <b> do not overlap
|
||||
#[test]
|
||||
fn every_layout_tiles_every_container_inside_the_work_area_and_off_the_others() {
|
||||
for layout in LAYOUTS {
|
||||
for count in 1..=8 {
|
||||
for (cp, wp) in [(None, None), (Some(10), Some(20)), (Some(0), Some(0))] {
|
||||
let t = tiles(layout, count, cp, wp, None);
|
||||
assert_eq!(t.len(), count as usize, "{layout} {count}");
|
||||
for (i, r) in t.iter().enumerate() {
|
||||
assert!(
|
||||
inside(r, &AREA),
|
||||
"{layout} {count} {cp:?}/{wp:?}: {i} {r:?}"
|
||||
);
|
||||
assert!(
|
||||
r.right > 0 && r.bottom > 0,
|
||||
"{layout} {count}: {i} is empty"
|
||||
);
|
||||
for (j, o) in t.iter().enumerate().skip(i + 1) {
|
||||
assert!(!overlap(r, o), "{layout} {count}: {i} {r:?} over {j} {o:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: padding / a workspace padding 40 px more moves the windows 40 px in from the edge
|
||||
// mirrors: padding / a container padding 30 px more leaves the windows less room
|
||||
// mirrors: padding / with the padding as it was, the windows are as far from the edge as they were
|
||||
#[test]
|
||||
fn the_workspace_padding_moves_the_tiles_in_and_the_container_padding_shrinks_them() {
|
||||
for layout in LAYOUTS {
|
||||
let base = tiles(layout, 3, None, None, None);
|
||||
let more = tiles(layout, 3, None, Some(40), None);
|
||||
let edge = |t: &[Rect]| t.iter().map(|r| r.left).min().unwrap();
|
||||
assert_eq!(
|
||||
edge(&more),
|
||||
edge(&base) + 40,
|
||||
"{layout}: workspace padding 40"
|
||||
);
|
||||
assert!(inside(more.first().unwrap(), &AREA));
|
||||
|
||||
let padded = tiles(layout, 3, Some(30), None, None);
|
||||
for (a, b) in base.iter().zip(&padded) {
|
||||
assert!(
|
||||
area(b) < area(a),
|
||||
"{layout}: container padding 30 did not shrink {a:?}"
|
||||
);
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
base,
|
||||
tiles(layout, 3, None, None, None),
|
||||
"{layout}: back as it was"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: flipping / after 'flip-layout horizontal' every window is where the mirror of its place is
|
||||
// mirrors: flipping / flipped again, every window is where it was
|
||||
// mirrors: layout_flip / <label>: the daemon starts with the layout mirrored
|
||||
// mirrors: layout_flip / 'flip-layout vertical' adds to it: flipped along both axes
|
||||
#[test]
|
||||
fn a_flip_mirrors_the_tiles_of_the_workspace_as_a_set() {
|
||||
let mirror = |r: &Rect, axis: Axis| {
|
||||
let mut m = *r;
|
||||
if matches!(axis, Axis::Horizontal | Axis::HorizontalAndVertical) {
|
||||
m.left = AREA.left + AREA.right - (r.left + r.right);
|
||||
}
|
||||
if matches!(axis, Axis::Vertical | Axis::HorizontalAndVertical) {
|
||||
m.top = AREA.top + AREA.bottom - (r.top + r.bottom);
|
||||
}
|
||||
m
|
||||
};
|
||||
let key = |r: &Rect| (r.left, r.top, r.right, r.bottom);
|
||||
for layout in LAYOUTS {
|
||||
for count in 1..=6 {
|
||||
let plain = tiles(layout, count, Some(10), Some(20), None);
|
||||
for axis in [
|
||||
Axis::Horizontal,
|
||||
Axis::Vertical,
|
||||
Axis::HorizontalAndVertical,
|
||||
] {
|
||||
let mut flipped = tiles(layout, count, Some(10), Some(20), Some(axis));
|
||||
let mut want: Vec<Rect> = plain.iter().map(|r| mirror(r, axis)).collect();
|
||||
// the workspace padding is symmetric, so the mirror of the padded tiles is the
|
||||
// padded mirror
|
||||
flipped.sort_by_key(key);
|
||||
want.sort_by_key(key);
|
||||
assert_eq!(flipped, want, "{layout} {count} {axis}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: closing / the windows that are left take more room between them
|
||||
// mirrors: minimizing / with <target> minimized the others take more room between them
|
||||
// mirrors: floating / ... the others take more room between them
|
||||
#[test]
|
||||
fn removing_a_container_gives_the_others_more_room() {
|
||||
for layout in LAYOUTS.into_iter().filter(|l| *l != DefaultLayout::Grid) {
|
||||
fresh();
|
||||
let mut w = workspace(layout, &[1, 2, 3, 4], Some(10), Some(20), None);
|
||||
w.update_shared().unwrap();
|
||||
let before: i64 = w.latest_layout.iter().map(area).max().unwrap();
|
||||
// the focused (last) container leaves, as a closed, minimized or floated window does
|
||||
w.remove_focused_container();
|
||||
w.update_shared().unwrap();
|
||||
assert_eq!(w.latest_layout.len(), 3, "{layout}");
|
||||
let after: i64 = w.latest_layout.iter().map(area).max().unwrap();
|
||||
assert!(after >= before, "{layout}: {before} -> {after}");
|
||||
for (i, r) in w.latest_layout.iter().enumerate() {
|
||||
assert!(inside(r, &AREA), "{layout}: {i} {r:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: stacks / two containers, one of them a stack of two (three windows, two tiles)
|
||||
// mirrors: stacks / and they tile, not on each other
|
||||
#[test]
|
||||
fn a_stack_is_one_tile() {
|
||||
for layout in LAYOUTS {
|
||||
fresh();
|
||||
let mut w = workspace(layout, &[1, 2, 3], Some(10), Some(20), None);
|
||||
// stack window 3 onto container 1 as `stack left` does
|
||||
w.focus_container(2);
|
||||
let _ = w.move_window_to_container(0);
|
||||
w.update_shared().unwrap();
|
||||
assert_eq!(w.containers().len(), 2, "{layout}");
|
||||
assert_eq!(w.latest_layout.len(), 2, "{layout}");
|
||||
assert!(
|
||||
!overlap(&w.latest_layout[0], &w.latest_layout[1]),
|
||||
"{layout}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: tiling_off / after 'toggle-tiling' ... no window moved
|
||||
// mirrors: tiling_off / ... a layout change does not move them either
|
||||
#[test]
|
||||
fn a_workspace_with_tiling_off_places_nothing_whatever_the_layout() {
|
||||
for layout in LAYOUTS {
|
||||
fresh();
|
||||
let mut w = workspace(layout, &[1, 2, 3], Some(10), Some(20), None);
|
||||
w.tile = false;
|
||||
w.update_shared().unwrap();
|
||||
assert!(
|
||||
!log().iter().any(|l| l.starts_with("place_container")),
|
||||
"{layout}: a window was placed"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,34 +128,21 @@ fn the_ultrawide_stack_has_its_main_column_in_the_middle() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_right_main_vertical_stack_constrains_index_one_and_leaves_index_zero_free() {
|
||||
// characterization of what the code does: it follows the comment "Zero is actually on the
|
||||
// right" but indexes the second container, so the first (the main one) is never constrained
|
||||
// and the second may not be resized at all; the ignored test below says what the comment asks
|
||||
fn the_right_main_vertical_stack_constrains_its_main_container_at_index_zero() {
|
||||
// the main container is index 0 and is drawn on the right (komorebi-layouts arrangement.rs:
|
||||
// primary_left = area.right - primary_width): it may only be resized to the left. The stack
|
||||
// is on the left: nothing in it goes left, the first not up, the last not down.
|
||||
check(
|
||||
DefaultLayout::RightMainVerticalStack,
|
||||
&[
|
||||
&[""],
|
||||
&["ltrb", ""],
|
||||
&["ltrb", "", "tr"],
|
||||
&["ltrb", "", "trb", "tr"],
|
||||
&["l", "rb"],
|
||||
&["l", "rb", "tr"],
|
||||
&["l", "rb", "trb", "tr"],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "bug: enforce_resize_for_right_vertical_stack indexes resize_dimensions[1] where its \
|
||||
comment says zero is on the right; inherited unchanged from the Windows tree"]
|
||||
fn the_right_main_vertical_stack_constrains_its_main_container_at_index_zero() {
|
||||
fresh();
|
||||
let mut workspace = workspace_with(DefaultLayout::RightMainVerticalStack, 3);
|
||||
|
||||
workspace.enforce_resize_constraints();
|
||||
|
||||
// the main container is on the right: it cannot go up, down or right
|
||||
assert_eq!(sides(&workspace)[0], "l");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layouts_without_a_resize_rule_take_every_adjustment_away() {
|
||||
for layout in [DefaultLayout::Grid, DefaultLayout::Scrolling] {
|
||||
|
||||
@@ -23,4 +23,8 @@ schemars = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["schemars"]
|
||||
schemars = ["dep:schemars", "komorebi-layouts/schemars", "komorebi-themes/schemars"]
|
||||
schemars = [
|
||||
"dep:schemars",
|
||||
"komorebi-layouts/schemars",
|
||||
"komorebi-themes/schemars",
|
||||
]
|
||||
@@ -125,3 +125,89 @@ fn a_load_never_touches_the_groups_it_does_not_name() {
|
||||
assert_eq!(after.shared.animation, before.shared.animation);
|
||||
assert_eq!(after.shared.transparency, before.shared.transparency);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transparency_is_kept_by_a_load_without_the_key_unless_the_daemon_resets_it() {
|
||||
// Windows passes the keys as they are: absent keeps the value
|
||||
let windows = handle();
|
||||
load(
|
||||
&windows,
|
||||
SharedDelta {
|
||||
transparency: Some(true),
|
||||
transparency_alpha: Some(90),
|
||||
..SharedDelta::default()
|
||||
},
|
||||
);
|
||||
load(&windows, SharedDelta::default());
|
||||
let kept = windows.snapshot().shared.transparency;
|
||||
assert!(kept.enabled);
|
||||
assert_eq!(kept.alpha, 90);
|
||||
|
||||
// KDE passes `unwrap_or(false)` and `unwrap_or(200)`: absent resets to the defaults
|
||||
let kde = handle();
|
||||
load(
|
||||
&kde,
|
||||
SharedDelta {
|
||||
transparency: Some(true),
|
||||
transparency_alpha: Some(90),
|
||||
..SharedDelta::default()
|
||||
},
|
||||
);
|
||||
let (transparency, alpha): (Option<bool>, Option<u8>) = (None, None);
|
||||
load(
|
||||
&kde,
|
||||
SharedDelta {
|
||||
transparency: Some(transparency.unwrap_or(false)),
|
||||
transparency_alpha: Some(alpha.unwrap_or(200)),
|
||||
..SharedDelta::default()
|
||||
},
|
||||
);
|
||||
let reset = kde.snapshot().shared.transparency;
|
||||
assert!(!reset.enabled);
|
||||
assert_eq!(reset.alpha, 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_animation_block_follows_the_load_rules() {
|
||||
use komorebi_config::animation::PerAnimationPrefixConfig;
|
||||
use komorebi_protocol::animation::AnimationStyle;
|
||||
use komorebi_protocol::animation::prefix::AnimationPrefix;
|
||||
use komorebi_settings::shared::AnimationDelta;
|
||||
|
||||
let handle = handle();
|
||||
let block = |enabled, fps| SharedDelta {
|
||||
animation: Some(AnimationDelta {
|
||||
enabled,
|
||||
style: None,
|
||||
duration: Some(PerAnimationPrefixConfig::Global(120)),
|
||||
fps,
|
||||
}),
|
||||
..SharedDelta::default()
|
||||
};
|
||||
|
||||
// a per-kind map replaces the map, the global flag is left alone; fps given
|
||||
load(
|
||||
&handle,
|
||||
block(
|
||||
PerAnimationPrefixConfig::Prefix(HashMap::from([(AnimationPrefix::Movement, true)])),
|
||||
Some(30),
|
||||
),
|
||||
);
|
||||
let first = handle.snapshot().shared.animation.clone();
|
||||
assert!(!first.enabled);
|
||||
assert_eq!(first.enabled_per_animation.len(), 1);
|
||||
assert_eq!(first.duration, 120);
|
||||
assert_eq!(first.fps, 30);
|
||||
assert_eq!(first.style, AnimationStyle::Linear);
|
||||
|
||||
// a load with no animation block keeps all of it
|
||||
load(&handle, SharedDelta::default());
|
||||
assert_eq!(handle.snapshot().shared.animation, first);
|
||||
|
||||
// a global flag clears the map, and a block without fps resets fps
|
||||
load(&handle, block(PerAnimationPrefixConfig::Global(true), None));
|
||||
let second = handle.snapshot().shared.animation.clone();
|
||||
assert!(second.enabled);
|
||||
assert!(second.enabled_per_animation.is_empty());
|
||||
assert_eq!(second.fps, 60);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
//! The commands the `commands` end-to-end scenario sweeps (`SWEEP` and `PRINTED` in
|
||||
//! `e2e/lib/komorebi_vm/core/scenarios/commands.py`) are commands of the platforms' `komorebic`.
|
||||
//!
|
||||
//! The scenario only learns that a command is not one when it runs it in a guest (`error:
|
||||
//! unrecognized subcommand`, skipped with its name). Here the command lines are parsed with the
|
||||
//! platform's clap command, so a command that a platform lost, or a typo in the scenario, fails a
|
||||
//! native test and not a 7 minute guest run.
|
||||
//!
|
||||
//! mirrors: commands / <command> (the part "the command is understood: exit status 0", for the
|
||||
//! command line only; what the daemon does with it is the daemon's tests, see
|
||||
//! `komorebi-for-kde/komorebi/tests/command_sweep.rs`)
|
||||
|
||||
use komorebic_core::cli::Meta;
|
||||
use komorebic_core::cli::command;
|
||||
use komorebic_core::platform::macos::MacosCommands;
|
||||
use komorebic_core::platform::windows::WindowsCommands;
|
||||
use std::path::Path;
|
||||
|
||||
const META: Meta = Meta {
|
||||
name: "komorebic",
|
||||
about: "",
|
||||
author: "",
|
||||
version: "",
|
||||
};
|
||||
|
||||
/// The strings of the tuple named `name` in the scenario, or `None` without the e2e library (a
|
||||
/// source tree that is only the crates, as the nix build of one daemon has).
|
||||
fn tuple(name: &str) -> Option<Vec<String>> {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../e2e/lib/komorebi_vm/core/scenarios/commands.py");
|
||||
let source = std::fs::read_to_string(path).ok()?;
|
||||
let start = source.find(&format!("{name}: tuple[str, ...] = ("))?;
|
||||
let body = &source[start..];
|
||||
let end = body.find("\n)")?;
|
||||
Some(
|
||||
body[..end]
|
||||
.lines()
|
||||
.filter_map(|line| {
|
||||
let line = line.trim();
|
||||
line.strip_prefix('"')?
|
||||
.strip_suffix("\",")
|
||||
.map(str::to_string)
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
fn parses(cli: &clap::Command, line: &str) -> Result<(), String> {
|
||||
let mut args = vec!["komorebic".to_string()];
|
||||
args.extend(
|
||||
line.replace("{config}", "/tmp/komorebi.json")
|
||||
.split_whitespace()
|
||||
.map(str::to_string),
|
||||
);
|
||||
cli.clone()
|
||||
.try_get_matches_from(args)
|
||||
.map(|_| ())
|
||||
.map_err(|e| e.to_string().lines().next().unwrap_or_default().to_string())
|
||||
}
|
||||
|
||||
fn lines() -> Option<Vec<String>> {
|
||||
let mut lines = tuple("SWEEP")?;
|
||||
lines.extend(tuple("PRINTED")?);
|
||||
Some(lines)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_sweep_was_read() {
|
||||
if let Some(lines) = lines() {
|
||||
assert!(lines.len() > 200, "{} lines", lines.len());
|
||||
assert!(lines.iter().any(|l| l == "focus left"));
|
||||
assert!(lines.iter().any(|l| l == "state"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_command_of_the_sweep_is_a_command_of_the_windows_komorebic() {
|
||||
let Some(lines) = lines() else { return };
|
||||
let cli = command::<WindowsCommands>(&META);
|
||||
let missing: Vec<_> = lines
|
||||
.iter()
|
||||
.filter_map(|l| parses(&cli, l).err().map(|e| format!("{l}: {e}")))
|
||||
.collect();
|
||||
assert!(missing.is_empty(), "{missing:#?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_sweep_commands_the_macos_komorebic_lacks_are_the_known_eight() {
|
||||
let Some(lines) = lines() else { return };
|
||||
let cli = command::<MacosCommands>(&META);
|
||||
let mut missing: Vec<_> = lines
|
||||
.iter()
|
||||
.filter_map(|l| parses(&cli, l).err().map(|_| l.clone()))
|
||||
.collect();
|
||||
missing.sort();
|
||||
missing.dedup();
|
||||
// what the macOS command line lacks of the sweep, as of this writing: the scenario skips
|
||||
// these there (focus follows mouse by the Windows implementation, transparency, maximize)
|
||||
assert_eq!(
|
||||
missing,
|
||||
[
|
||||
"focus-follows-mouse disable",
|
||||
"focus-follows-mouse enable",
|
||||
"toggle-focus-follows-mouse --implementation windows",
|
||||
"toggle-maximize",
|
||||
"toggle-transparency",
|
||||
"transparency disable",
|
||||
"transparency enable",
|
||||
"transparency-alpha 150",
|
||||
]
|
||||
);
|
||||
// a command that every platform must have (the sweep's first lines) is one of macOS too
|
||||
for line in [
|
||||
"focus left",
|
||||
"move right",
|
||||
"retile",
|
||||
"toggle-float",
|
||||
"state",
|
||||
] {
|
||||
assert!(!missing.iter().any(|m| m == line), "{line}");
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,15 @@ Usage: komorebic.exe adjust-container-padding <SIZING> <ADJUSTMENT>
|
||||
|
||||
Arguments:
|
||||
<SIZING>
|
||||
[possible values: increase, decrease]
|
||||
Possible values:
|
||||
- increase: Increase
|
||||
- decrease: Decrease
|
||||
|
||||
<ADJUSTMENT>
|
||||
Pixels to adjust by as an integer
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,13 +7,15 @@ Usage: komorebic.exe adjust-workspace-padding <SIZING> <ADJUSTMENT>
|
||||
|
||||
Arguments:
|
||||
<SIZING>
|
||||
[possible values: increase, decrease]
|
||||
Possible values:
|
||||
- increase: Increase
|
||||
- decrease: Decrease
|
||||
|
||||
<ADJUSTMENT>
|
||||
Pixels to adjust by as an integer
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -12,10 +12,13 @@ Arguments:
|
||||
Options:
|
||||
-a, --animation-type <ANIMATION_TYPE>
|
||||
Animation type to apply the duration to. If not specified, sets global duration
|
||||
|
||||
[possible values: movement, transparency, workspace]
|
||||
|
||||
Possible values:
|
||||
- movement
|
||||
- transparency
|
||||
- workspace: A workspace sliding in and out of a monitor when it is switched to
|
||||
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -8,17 +8,51 @@ Usage: komorebic.exe animation-style [OPTIONS]
|
||||
Options:
|
||||
-s, --style <STYLE>
|
||||
Desired ease function for animation
|
||||
|
||||
Possible values:
|
||||
- linear: Linear
|
||||
- ease-in-sine: Ease in sine
|
||||
- ease-out-sine: Ease out sine
|
||||
- ease-in-out-sine: Ease in out sine
|
||||
- ease-in-quad: Ease in quad
|
||||
- ease-out-quad: Ease out quad
|
||||
- ease-in-out-quad: Ease in out quad
|
||||
- ease-in-cubic: Ease in cubic
|
||||
- ease-out-cubic: Ease out cubic
|
||||
- ease-in-out-cubic: Ease in out cubic
|
||||
- ease-in-quart: Ease in quart
|
||||
- ease-out-quart: Ease out quart
|
||||
- ease-in-out-quart: Ease in out quart
|
||||
- ease-in-quint: Ease in quint
|
||||
- ease-out-quint: Ease out quint
|
||||
- ease-in-out-quint: Ease in out quint
|
||||
- ease-in-expo: Ease in expo
|
||||
- ease-out-expo: Ease out expo
|
||||
- ease-in-out-expo: Ease in out expo
|
||||
- ease-in-circ: Ease in circ
|
||||
- ease-out-circ: Ease out circ
|
||||
- ease-in-out-circ: Ease in out circ
|
||||
- ease-in-back: Ease in back
|
||||
- ease-out-back: Ease out back
|
||||
- ease-in-out-back: Ease in out back
|
||||
- ease-in-elastic: Ease in elastic
|
||||
- ease-out-elastic: Ease out elastic
|
||||
- ease-in-out-elastic: Ease in out elastic
|
||||
- ease-in-bounce: Ease in bounce
|
||||
- ease-out-bounce: Ease out bounce
|
||||
- ease-in-out-bounce: Ease in out bounce
|
||||
|
||||
[default: linear]
|
||||
[possible values: linear, ease-in-sine, ease-out-sine, ease-in-out-sine, ease-in-quad, ease-out-quad, ease-in-out-quad, ease-in-cubic, ease-in-out-cubic, ease-in-quart, ease-out-quart, ease-in-out-quart, ease-in-quint, ease-out-quint, ease-in-out-quint, ease-in-expo,
|
||||
ease-out-expo, ease-in-out-expo, ease-in-circ, ease-out-circ, ease-in-out-circ, ease-in-back, ease-out-back, ease-in-out-back, ease-in-elastic, ease-out-elastic, ease-in-out-elastic, ease-in-bounce, ease-out-bounce, ease-in-out-bounce]
|
||||
|
||||
-a, --animation-type <ANIMATION_TYPE>
|
||||
Animation type to apply the style to. If not specified, sets global style
|
||||
|
||||
[possible values: movement, transparency, workspace]
|
||||
|
||||
Possible values:
|
||||
- movement
|
||||
- transparency
|
||||
- workspace: A workspace sliding in and out of a monitor when it is switched to
|
||||
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -12,10 +12,13 @@ Arguments:
|
||||
Options:
|
||||
-a, --animation-type <ANIMATION_TYPE>
|
||||
Animation type to apply the state to. If not specified, sets global state
|
||||
|
||||
[possible values: movement, transparency, workspace]
|
||||
|
||||
Possible values:
|
||||
- movement
|
||||
- transparency
|
||||
- workspace: A workspace sliding in and out of a monitor when it is switched to
|
||||
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -17,10 +17,17 @@ Arguments:
|
||||
|
||||
Options:
|
||||
-w, --window-kind <WINDOW_KIND>
|
||||
Possible values:
|
||||
- single: Single window
|
||||
- stack: Stack container
|
||||
- monocle: Monocle container
|
||||
- unfocused: Unfocused window
|
||||
- unfocused-locked: Unfocused locked container
|
||||
- floating: Floating window
|
||||
|
||||
[default: single]
|
||||
[possible values: single, stack, monocle, unfocused, unfocused-locked, floating]
|
||||
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -1,10 +1,10 @@
|
||||
```
|
||||
Scroll the Scrolling layout so that the focused column is in the middle of the screen, once
|
||||
|
||||
Usage: center-focus
|
||||
Usage: komorebic.exe center-focus
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
```
|
||||
@@ -7,10 +7,19 @@ Usage: komorebic.exe change-layout <DEFAULT_LAYOUT>
|
||||
|
||||
Arguments:
|
||||
<DEFAULT_LAYOUT>
|
||||
[possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling]
|
||||
Possible values:
|
||||
- bsp: BSP Layout
|
||||
- columns: Columns Layout
|
||||
- rows: Rows Layout
|
||||
- vertical-stack: Vertical Stack Layout
|
||||
- horizontal-stack: Horizontal Stack Layout
|
||||
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
|
||||
- grid: Grid Layout
|
||||
- right-main-vertical-stack: Right Main Vertical Stack Layout
|
||||
- scrolling: Scrolling Layout
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
```
|
||||
Take the neighbouring window on one side into the focused column of the Scrolling layout
|
||||
|
||||
Usage: consume <OPERATION_DIRECTION>
|
||||
Usage: komorebic.exe consume <OPERATION_DIRECTION>
|
||||
|
||||
Arguments:
|
||||
<OPERATION_DIRECTION>
|
||||
@@ -11,4 +11,4 @@ Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
```
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
```
|
||||
Make the focused column of the Scrolling layout fill the room that the columns in view leave on the screen, which does nothing in any other layout
|
||||
|
||||
Usage: expand
|
||||
Usage: komorebic.exe expand
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
|
||||
+3
-4
@@ -1,11 +1,10 @@
|
||||
```
|
||||
Take the focused window out of its column in the Scrolling layout and put it in a column of its own
|
||||
on the right
|
||||
Take the focused window out of its column in the Scrolling layout and put it in a column of its own on the right
|
||||
|
||||
Usage: expel
|
||||
Usage: komorebic.exe expel
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
```
|
||||
@@ -7,10 +7,13 @@ Usage: komorebic.exe flip-layout <AXIS>
|
||||
|
||||
Arguments:
|
||||
<AXIS>
|
||||
[possible values: horizontal, vertical, horizontal-and-vertical]
|
||||
Possible values:
|
||||
- horizontal: Horizontal axis
|
||||
- vertical: Vertical axis
|
||||
- horizontal-and-vertical: Both horizontal and vertical axes
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,13 +7,17 @@ Usage: komorebic.exe identify-layered-application <IDENTIFIER> <ID>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,13 +7,17 @@ Usage: komorebic.exe identify-object-name-change-application <IDENTIFIER> <ID>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,13 +7,17 @@ Usage: komorebic.exe identify-tray-application <IDENTIFIER> <ID>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,13 +7,17 @@ Usage: komorebic.exe ignore-rule <IDENTIFIER> <ID>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,7 +7,11 @@ Usage: komorebic.exe initial-named-workspace-rule <IDENTIFIER> <ID> <WORKSPACE>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
@@ -17,6 +21,6 @@ Arguments:
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,7 +7,11 @@ Usage: komorebic.exe initial-workspace-rule <IDENTIFIER> <ID> <MONITOR> <WORKSPA
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
@@ -20,6 +24,6 @@ Arguments:
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
```
|
||||
Set the layout column and row ratios for the focused workspace
|
||||
|
||||
Usage: komorebic.exe layout-ratios [OPTIONS]
|
||||
|
||||
Options:
|
||||
-c, --columns <COLUMNS>...
|
||||
Column width ratios (space-separated values between 0.1 and 0.9)
|
||||
|
||||
-r, --rows <ROWS>...
|
||||
Row height ratios (space-separated values between 0.1 and 0.9)
|
||||
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -7,13 +7,17 @@ Usage: komorebic.exe manage-rule <IDENTIFIER> <ID>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
```
|
||||
Set the behaviour when focusing in a direction while a monocle container is active
|
||||
|
||||
Usage: komorebic.exe monocle-focus-behaviour <BEHAVIOUR>
|
||||
|
||||
Arguments:
|
||||
<BEHAVIOUR>
|
||||
Desired monocle focus behaviour
|
||||
|
||||
Possible values:
|
||||
- cycle: Cycle the monocle container to the next/previous container in the workspace
|
||||
- no-op: Do nothing, allowing focus to fall through to cross-monitor logic
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -13,10 +13,19 @@ Arguments:
|
||||
The number of window containers on-screen required to trigger this layout rule
|
||||
|
||||
<LAYOUT>
|
||||
[possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling]
|
||||
Possible values:
|
||||
- bsp: BSP Layout
|
||||
- columns: Columns Layout
|
||||
- rows: Rows Layout
|
||||
- vertical-stack: Vertical Stack Layout
|
||||
- horizontal-stack: Horizontal Stack Layout
|
||||
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
|
||||
- grid: Grid Layout
|
||||
- right-main-vertical-stack: Right Main Vertical Stack Layout
|
||||
- scrolling: Scrolling Layout
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -10,10 +10,19 @@ Arguments:
|
||||
Target workspace name
|
||||
|
||||
<VALUE>
|
||||
[possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling]
|
||||
Possible values:
|
||||
- bsp: BSP Layout
|
||||
- columns: Columns Layout
|
||||
- rows: Rows Layout
|
||||
- vertical-stack: Vertical Stack Layout
|
||||
- horizontal-stack: Horizontal Stack Layout
|
||||
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
|
||||
- grid: Grid Layout
|
||||
- right-main-vertical-stack: Right Main Vertical Stack Layout
|
||||
- scrolling: Scrolling Layout
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,7 +7,11 @@ Usage: komorebic.exe named-workspace-rule <IDENTIFIER> <ID> <WORKSPACE>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
@@ -17,6 +21,6 @@ Arguments:
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
```
|
||||
Move the view of the Scrolling layout a column to the left or the right, or with the fingers on a touchpad, which does nothing in any other layout
|
||||
|
||||
Usage: pan [OPTIONS] [DIRECTION]
|
||||
Usage: komorebic.exe pan [OPTIONS] [DIRECTION]
|
||||
|
||||
Arguments:
|
||||
[DIRECTION]
|
||||
|
||||
@@ -7,13 +7,17 @@ Usage: komorebic.exe remove-title-bar <IDENTIFIER> <ID>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,13 +7,18 @@ Usage: komorebic.exe resize-axis <AXIS> <SIZING>
|
||||
|
||||
Arguments:
|
||||
<AXIS>
|
||||
[possible values: horizontal, vertical, horizontal-and-vertical]
|
||||
Possible values:
|
||||
- horizontal: Horizontal axis
|
||||
- vertical: Vertical axis
|
||||
- horizontal-and-vertical: Both horizontal and vertical axes
|
||||
|
||||
<SIZING>
|
||||
[possible values: increase, decrease]
|
||||
Possible values:
|
||||
- increase: Increase
|
||||
- decrease: Decrease
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -10,10 +10,12 @@ Arguments:
|
||||
[possible values: left, right, up, down]
|
||||
|
||||
<SIZING>
|
||||
[possible values: increase, decrease]
|
||||
Possible values:
|
||||
- increase: Increase
|
||||
- decrease: Decrease
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -1,11 +1,10 @@
|
||||
```
|
||||
Make the focused column of the Scrolling layout as wide as the screen, or put it back to the width
|
||||
that it had
|
||||
Make the focused column of the Scrolling layout as wide as the screen, or put it back to the width that it had
|
||||
|
||||
Usage: scrolling-layout-full-width
|
||||
Usage: komorebic.exe scrolling-layout-full-width
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
```
|
||||
@@ -8,11 +8,14 @@ Usage: komorebic.exe stackbar-mode <MODE>
|
||||
Arguments:
|
||||
<MODE>
|
||||
Desired stackbar mode
|
||||
|
||||
[possible values: always, never, on-stack]
|
||||
|
||||
Possible values:
|
||||
- always: Always show
|
||||
- never: Never show
|
||||
- on-stack: Show on stack
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
+1
-1
@@ -10,7 +10,7 @@ Options:
|
||||
Path to a static configuration JSON file
|
||||
|
||||
-a, --await-configuration
|
||||
Wait for 'komorebic complete-configuration' to be sent before processing events
|
||||
Wait for `komorebic complete-configuration` to be sent before processing events
|
||||
|
||||
-t, --tcp-port <TCP_PORT>
|
||||
Start a TCP server on the given port to allow the direct sending of SocketMessages
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
```
|
||||
Stack the windows of the focused column of the Scrolling layout, or spread the focused stack out
|
||||
into a column with a window in each slot
|
||||
Stack the windows of the focused column of the Scrolling layout, or spread the focused stack out into a column with a window in each slot
|
||||
|
||||
Usage: toggle-column-stack
|
||||
Usage: komorebic.exe toggle-column-stack
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
```
|
||||
Toggle the behaviour when focusing in a direction while a monocle container is active
|
||||
|
||||
Usage: komorebic.exe toggle-monocle-focus-behaviour
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -8,8 +8,8 @@ Usage: komorebic.exe unmanaged-window-operation-behaviour <OPERATION_BEHAVIOUR>
|
||||
Arguments:
|
||||
<OPERATION_BEHAVIOUR>
|
||||
Possible values:
|
||||
- op: Process komorebic commands on temporarily unmanaged/floated windows
|
||||
- no-op: Ignore komorebic commands on temporarily unmanaged/floated windows
|
||||
- op: Process commands on temporarily unmanaged/floated windows
|
||||
- no-op: Ignore commands on temporarily unmanaged/floated windows
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
|
||||
@@ -8,8 +8,8 @@ Usage: komorebic.exe window-hiding-behaviour <HIDING_BEHAVIOUR>
|
||||
Arguments:
|
||||
<HIDING_BEHAVIOUR>
|
||||
Possible values:
|
||||
- hide: END OF LIFE FEATURE: Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps)
|
||||
- minimize: Use the SW_MINIMIZE flag to hide windows when switching workspaces (has issues with frequent workspace switching)
|
||||
- hide: END OF LIFE FEATURE: Use the `SW_HIDE` flag to hide windows when switching workspaces (has issues with Electron apps)
|
||||
- minimize: Use the `SW_MINIMIZE` flag to hide windows when switching workspaces (has issues with frequent workspace switching)
|
||||
- cloak: Use the undocumented SetCloak Win32 function to hide windows when switching workspaces
|
||||
|
||||
Options:
|
||||
|
||||
@@ -16,10 +16,19 @@ Arguments:
|
||||
The number of window containers on-screen required to trigger this layout rule
|
||||
|
||||
<LAYOUT>
|
||||
[possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling]
|
||||
Possible values:
|
||||
- bsp: BSP Layout
|
||||
- columns: Columns Layout
|
||||
- rows: Rows Layout
|
||||
- vertical-stack: Vertical Stack Layout
|
||||
- horizontal-stack: Horizontal Stack Layout
|
||||
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
|
||||
- grid: Grid Layout
|
||||
- right-main-vertical-stack: Right Main Vertical Stack Layout
|
||||
- scrolling: Scrolling Layout
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -13,10 +13,19 @@ Arguments:
|
||||
Workspace index on the specified monitor (zero-indexed)
|
||||
|
||||
<VALUE>
|
||||
[possible values: bsp, columns, rows, vertical-stack, horizontal-stack, ultrawide-vertical-stack, grid, right-main-vertical-stack, scrolling]
|
||||
Possible values:
|
||||
- bsp: BSP Layout
|
||||
- columns: Columns Layout
|
||||
- rows: Rows Layout
|
||||
- vertical-stack: Vertical Stack Layout
|
||||
- horizontal-stack: Horizontal Stack Layout
|
||||
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
|
||||
- grid: Grid Layout
|
||||
- right-main-vertical-stack: Right Main Vertical Stack Layout
|
||||
- scrolling: Scrolling Layout
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -7,7 +7,11 @@ Usage: komorebic.exe workspace-rule <IDENTIFIER> <ID> <MONITOR> <WORKSPACE>
|
||||
|
||||
Arguments:
|
||||
<IDENTIFIER>
|
||||
[possible values: exe, class, title, path]
|
||||
Possible values:
|
||||
- exe: Executable name
|
||||
- class: Class
|
||||
- title: Window title
|
||||
- path: Executable path
|
||||
|
||||
<ID>
|
||||
Identifier as a string
|
||||
@@ -20,6 +24,6 @@ Arguments:
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -29,6 +29,21 @@ shims `komorebic-linux`, `komorebic-macos`, `komorebi-client-linux`, `komorebi-c
|
||||
- Heavy builds and e2e should not run at the same time as a timing-sensitive e2e: the Windows `commands`
|
||||
scenario is the most sensitive (section 6).
|
||||
|
||||
## Developer tools
|
||||
|
||||
`tools/` (README: [tools/README.md](../../tools/README.md)) holds the helper scripts, runnable from any jj
|
||||
workspace of the repository; none of them writes to the source tree.
|
||||
|
||||
| Command | Use |
|
||||
|---|---|
|
||||
| `tools/fast-check [--list] [--range \| --since REV]` | only the checks the touched paths need; warm in seconds (Windows clippy 8-9 s, KDE 1-3 s, macOS 2-3 s) |
|
||||
| `tools/e2e-needed [--since REV]` | does this diff change the Windows e2e binaries (`NO` carries a previous passing e2e over) |
|
||||
| `tools/kde-closure-check` | the KDE source filter list matches the KDE cargo closure |
|
||||
| `tools/mac-check.sh` | macOS type-check on Linux (fake C compiler `tools/cc-fake.sh`) |
|
||||
| `tools/trim-target`, `tools/gate-lock`, `tools/lite-env` | disk trimming, a heavy-gate lock, debug-info-off builds |
|
||||
|
||||
The persistent target directories are under `$FAST_CHECK_SCRATCH` (default `~/.cache/komorebi-fast-check`).
|
||||
|
||||
## 1. Windows (cross build from Linux via nix)
|
||||
|
||||
Binaries (the flake cross-compiles to `x86_64-pc-windows-msvc` with an xwin SDK):
|
||||
@@ -48,7 +63,7 @@ nix build -L --no-link .#checks.x86_64-linux.komorebi-workspace-fmt .#checks.x86
|
||||
nix build -L --no-link .#checks.x86_64-linux.e2e-tests # the Python of the e2e (pytest), no guest needed
|
||||
```
|
||||
|
||||
Quick loop without nix (what `fast-check` runs; clippy of the Windows tree from the nix dev shell):
|
||||
Quick loop without nix builds (what `tools/fast-check` runs; clippy of the Windows tree from the nix dev shell):
|
||||
|
||||
```sh
|
||||
nix develop --command cargo clippy --workspace --locked --all-targets -- -D warnings
|
||||
@@ -77,7 +92,7 @@ A single test file: `cargo test -p komorebi-linux --test NAME` (the files are in
|
||||
The `-p komorebi --lib` that older notes use is the thin binary package now: the unit tests are in
|
||||
`komorebi-linux`.
|
||||
|
||||
Run `tools/kde-closure-check` after any dependency change in the KDE tree or the crates it uses: the KDE
|
||||
Run `tools/kde-closure-check` (see [tools/README.md](../../tools/README.md)) after any dependency change in the KDE tree or the crates it uses: the KDE
|
||||
flake takes only the crates listed in `komorebi-for-kde/nix/root-crates.json`.
|
||||
|
||||
KDE nix checks (no VM): from the root flake they are prefixed `kfde-`, and the VM checks are left out:
|
||||
@@ -147,10 +162,11 @@ and `komorebi-bar-macos` still build alone). Before any change that touches macO
|
||||
the Mac first: nothing else can run them. After that walk [macos-handcheck.md](macos-handcheck.md).
|
||||
|
||||
On Linux, macOS can only be type-checked, through a fake C compiler and the target
|
||||
`aarch64-apple-darwin` (`tools/fast-check` does it; it cannot link or run):
|
||||
`aarch64-apple-darwin`: `tools/mac-check.sh` does it unconditionally, `tools/fast-check` when macOS files changed
|
||||
(fake compiler: `tools/cc-fake.sh`); it cannot link or run:
|
||||
|
||||
```sh
|
||||
COMMIT_HASH=dev cargo check --target aarch64-apple-darwin --workspace --all-targets # with CC_aarch64_apple_darwin set to a fake cc
|
||||
tools/mac-check.sh # = COMMIT_HASH=dev cargo check --target aarch64-apple-darwin ... --all-targets, CC set to tools/cc-fake.sh
|
||||
```
|
||||
|
||||
Nix, on a Mac: the checks of `komorebi-for-mac/flake.nix` (`komorebi-workspace-{clippy,fmt,toml-fmt,deny,nextest}`,
|
||||
|
||||
@@ -1317,3 +1317,57 @@ would move less than half of the file.
|
||||
wrongly called this an improvement). `WorkspacePlatform::begin_pass` is called once per pass after the
|
||||
layout is computed and its answer reaches the hooks as `Placement::pass`; Windows takes the snapshot
|
||||
there and `place_container` reads it, as the original did.
|
||||
|
||||
## 20. KDE and macOS: the converge of `window_manager.rs` and the router, and why `WindowManager<P>` still waits
|
||||
|
||||
Measured at the tip of `wip-u-wm` (cand5 plus the revisions below; no Windows file changed).
|
||||
|
||||
**Done (refactors, no behaviour change):** both daemons ask `window::foreground_window_id()` and
|
||||
`window::monitor_id_at_cursor()` instead of calling the backend or `MacosApi` inline (the macOS
|
||||
`window.rs` gets the two one-line wrappers); twelve macOS `process_command` arms (eleven methods) that were the
|
||||
same code inline as KDE's named methods now call methods with those names and bodies
|
||||
(`cycle_focus_workspace`, `cycle_focus_empty_workspace`, `close_workspace`,
|
||||
`move_container_to_last_workspace` for both the move and the send arm, `eager_focus`,
|
||||
`set_border_colour`, `set_layout_ratios`, `answer_query`, `add_named_workspace_rule`,
|
||||
`add_initial_named_workspace_rule`, `toggle_workspace_window_container_behaviour`).
|
||||
|
||||
**Where it stands:**
|
||||
|
||||
| | KDE against macOS |
|
||||
|---|---|
|
||||
| router arms present in both | 155 |
|
||||
| of them byte-identical | 137 |
|
||||
| of them different | 18: `Close`, `Minimize` (macOS window API), `DebugWindow`, `ManageRule`, `IgnoreRule`, `SessionFloatRule` (macOS identifies an application by role where KDE uses the class), `ReplaceConfiguration` (the run loop; no warning on macOS), `AddSubscriberPipe`, `ToggleWorkspaceLayer` (88 lines inline on macOS), `ResizeWindowAxis` (59 inline), the stack and unstack arms and `CycleStack*`, `FocusStackWindow` (KDE switches animations off around them), `ResizeWindowEdge` (1 line) |
|
||||
| `window_manager.rs` function lines identical with macOS | 1156 of KDE's 2595 (45%); 105 functions on macOS, 97 on KDE |
|
||||
|
||||
The 45% is below the 60% bar, and what separates the rest is not text:
|
||||
- **the hiding spot and the container API.** macOS calls `container.hide_on(spot, omit, screen)`,
|
||||
`load_focused_window_at(spot)?` and `restore_focused_window()?`, its own `ContainerExt`, where KDE and
|
||||
the shared crate have `Container::hide(omit, spot)`, `load_focused_window(spot)` and `restore()`; nine
|
||||
window manager functions (`add_window_to_container`, `cycle_container_window_*`, `focus_container_window`,
|
||||
`stack_all`, `monocle_on/off`, `cycle_monocle`, `transfer_window`) differ in exactly these calls;
|
||||
- **the error policy:** KDE writes `let _ = container.load_focused_window(())` (its window operations
|
||||
cannot fail), macOS writes `...?` (AX calls can); the shared form is `?`, which is equivalent on KDE
|
||||
because its operations always answer `Ok`;
|
||||
- **platform entry points:** `init`, `stop`, `new`, `focus_workspace`, `manage_focused_window`,
|
||||
`unmanage_focused_window`, `restore_all_windows`, `enforce_workspace_rules`, `resize_window` (52
|
||||
lines), `move_container_to_monitor`, `focus_floating_window_in_direction` (29);
|
||||
- **one-sided functions:** macOS 16 (the live-resize family, `entering_borders`, `workspace_transition`,
|
||||
`drag_origin`), KDE 4 (`adopt_maximize_change`, `adopt_workspace_change`, `sync_workspace_desktops`,
|
||||
`reap_invalid_windows`).
|
||||
|
||||
**Blockers for a `WindowManager<P>` over KDE and macOS (Windows keeps its own):**
|
||||
1. macOS's `ContainerExt` (`hide_on`, `load_focused_window_at`, `restore_focused_window`) against the
|
||||
shared `Container` with a `HideSpot`: kfm converges the container first (its semantics: AX errors,
|
||||
`cfg!(test)` guards) so that the nine functions become identical;
|
||||
2. the `?` against `let _` policy, then a mechanical KDE edit;
|
||||
3. the eleven platform entry points above as `WindowManagerPlatform` hooks (`init`, `stop`, `new`,
|
||||
`focus_workspace`, `restore_all_windows`, ...), which is as many hooks as functions moved, so the
|
||||
shared text would be about half of the file with a dozen hooks: not worth it yet;
|
||||
4. the 18 differing router arms, of which the stack family (animation guard) and the application
|
||||
identity (role against class) are hooks and the rest are macOS's own bodies.
|
||||
|
||||
Recommended next step: kfm unifies the container API (blocker 1) and the `?` policy (2) on both
|
||||
daemons; after that the nine functions are identical and the shared share passes 60% without new
|
||||
hooks, and `WindowManager<P>` can be created over KDE and macOS with the entry points of blocker 3 left
|
||||
in each daemon's extension trait.
|
||||
@@ -0,0 +1,142 @@
|
||||
# From e2e to unit: what the shared crates made testable natively
|
||||
|
||||
Base: `wip-cand5` plus the revisions that add the tests named here. Written 2026-10-31.
|
||||
|
||||
Before the shared crates, the Windows daemon could only be tested through a Windows guest (its crate
|
||||
does not compile on Linux) and the macOS daemon through nothing. Now Windows, KDE and macOS call the
|
||||
same `komorebi-core` (`Container`, `Workspace`, `Monitor`, `update_shared` and the platform hooks),
|
||||
`komorebi-layouts`, `komorebi-scrolling`, `komorebi-settings`, `komorebi-protocol`,
|
||||
`komorebi-config`, `komorebi-transport` and `komorebic-core`, so a native test of that code, on the
|
||||
stub platform (`crates/komorebi-core/tests/common`) or `FakeBackend`, protects all three. This
|
||||
document lists every e2e scenario, says whether that is now done, and ranks what is left.
|
||||
|
||||
## What stays out of reach
|
||||
|
||||
The daemons' own `process_command` / `process_event` are per platform (Windows: Win32 types; macOS:
|
||||
Mac types), only the KDE one runs on `FakeBackend`. So a native test of "send this command, then the
|
||||
state is that" exists for KDE only; for Windows and macOS it holds as far as the command's work is
|
||||
done by shared `Workspace`/`Monitor` methods. Rule matching (`should_act_individual`) exists three
|
||||
times (Windows `komorebi/src/window.rs:1178`, KDE `window.rs:661`, macOS `window.rs:1864`), not in
|
||||
`komorebi-config`. Every row below says which of these a test reaches.
|
||||
|
||||
## Classes
|
||||
|
||||
- A: already covered natively. B: coverable natively with the shared API, not yet. C: needs a real OS
|
||||
(compositor, Win32, timing, pointer, rendering, several processes).
|
||||
- "Now" marks what this work added (revisions on `wip-u-e2e2unit`).
|
||||
- Value: share of the gate it could stand in for. Effort S/M/L.
|
||||
- Check counts: dynamic numbers where the gate printed them (layouts 111, commands 265), else the
|
||||
number of check call sites in the scenario file (static, lower than the runs).
|
||||
|
||||
## Windows-origin scenarios (first: only e2e-testable on Windows, now native)
|
||||
|
||||
| Scenario (checks) | Behaviour | Class | Native test (cited, or proposed) | Eff. | Value |
|
||||
|---|---|---|---|---|---|
|
||||
| layouts (111) | 8 layouts x counts: each window where the layout says, inside the work area, not over another | A now (arithmetic); C (OS frame equals tile) | `crates/komorebi-core/tests/e2e_layouts.rs` `every_layout_tiles_every_container_inside_the_work_area_and_off_the_others` (shared `update_shared`), `komorebi-layouts/tests/layouts_everywhere.rs` (calculate, 3 areas, 1-12 windows) | S | high: 3 min, can shrink to 1 layout smoke |
|
||||
| flipping (3) | flip-layout mirrors every place, flip back restores | A now | `e2e_layouts.rs` `a_flip_mirrors_the_tiles_of_the_workspace_as_a_set`; `layouts_everywhere.rs` flips | S | med |
|
||||
| layout_flip (10) | `layout_flip` config mirrors from the start; flip-layout toggles; per workspace | A now for the maths; B for config key to `Workspace.layout_flip` | same tests; proposed: `komorebi-settings` or core test that loads a workspace config with `layout_flip` and checks the field | S | med |
|
||||
| padding (7) | workspace/container padding moves and shrinks tiles, setting back restores | A now | `e2e_layouts.rs` `the_workspace_padding_moves_the_tiles_in...`; existing `update_shared.rs` `the_padding_of_the_workspace_wins_over_the_monitors_even_when_it_is_zero` | S | med |
|
||||
| tiling (6), closing (5), minimizing (4), floating (7) | windows share the area; a leaving container (closed/minimized/floated) gives the others room | A now (room) + A (floating/removal): `workspace_layers.rs` floating_* , `workspace_containers.rs` removing_*; C: the OS event | `e2e_layouts.rs` `removing_a_container_gives_the_others_more_room` | S | med |
|
||||
| stacks (23) | stack/cycle-stack/unstack: one tile per stack, window in view has focus, others away | A: core `workspace_containers.rs` `stacking_*`, `unstacking_*`, `container_behaviour.rs` hide/restore; now `e2e_layouts.rs` `a_stack_is_one_tile`. B: `cycle-stack` has no shared method (daemon-side) | S | med (23 checks, 3 min) |
|
||||
| tiling_off (6) | toggle-tiling leaves windows, tiling again tiles | A now | `e2e_layouts.rs` `a_workspace_with_tiling_off_places_nothing...`; `update_shared.rs` `a_workspace_that_is_not_tiling_prunes_and_places_nothing` | S | low |
|
||||
| monocle (12) | monocle fills area, others away, toggle back; focus behaviours | A: `workspace_layers.rs` `toggling_monocle_*`, `reintegrating_*`, `cycling_monocle_*`; `update_shared.rs` `a_monocle_container_gets_the_work_area_less_every_padding`. Focus behaviour is daemon-side (B, needs seam) | - | - | med |
|
||||
| maximizing (29) | toggle-maximize, unmaximize on float, monocle wins | A: `workspace_layers.rs` `floating_the_maximized_window_*`, `update_shared.rs` `the_monocle_container_wins_over_a_maximized_window`; user-maximize event C | - | - | med |
|
||||
| promoting (4), moving (4), focus (7) | promote first tile, swap/cycle-move, focus order | A: `workspace_containers.rs` `promoting_*`, `swapping_containers_*`, `cycling_wraps_*`, `directions_follow_the_layout_and_the_flip`; focus OS agreement C | - | - | low |
|
||||
| workspaces (8), workspace_moves (8) | send/move/focus workspace, last-workspace | A: `monitor_workspaces.rs` (focus, last focused, ensure, remove); the OS hide/show is C | - | - | med |
|
||||
| commands (265, 7.6 min) | every komorebic command leaves the daemon alive, answers state, manages every window | A now for command line (`crates/komorebic-core/tests/e2e_sweep.rs`: every SWEEP/PRINTED line is a Windows command; macOS lacks exactly 8) and for the KDE model (`komorebi-for-kde/komorebi/tests/command_sweep.rs`, about 185 messages, 0.2 s); B: same sweep for the Windows and macOS daemons (needs seam, below); C: stall-family (daemon busy 8 s), socket answering | S done / L for Win+mac | highest: biggest, flakiest scenario |
|
||||
| unknown_monitor (12) | a window sent to a monitor that does not exist stays managed | B: shared `Monitor`/`Workspace::add_container` errors are covered (`monitor_workspaces.rs` `adding_a_container_to_a_workspace_that_is_not_there_is_an_error`); the daemon handler is per platform: needs seam | M | med (known flaky marker) |
|
||||
| rules (12), rules_class (5), rules_exe (5), manage_rules (4), title_rule (5), startup_rules (5) | which window a rule catches (kind, strategy, composite, last wins, manage over ignore); the workspace it goes to | A now for matching, KDE copy only: `komorebi-for-kde/komorebi/tests/rule_matching.rs` (13 tests). Windows and macOS copies of `should_act_individual` untested natively (windows crate does not build on Linux; macOS needs the Mini). Workspace of a rule: A in core: `workspace_containers.rs` `initial_placement_rules_choose_where_a_new_window_goes`. When-evaluated (open vs rename), hide/show: C | M to move the function into `komorebi-config` and test once for three daemons (recommended seam) | high |
|
||||
| state_fidelity (5) | state names title/exe/class/path as opened | A: `state_roundtrip.rs` (kfw/kfde fixtures, `the_fixtures_are_the_ones_the_e2e_library_has`, `a_windows_tiled_state_is_written_as_it_was_read`); what the OS reports C | - | - | low |
|
||||
| queries (3) | `komorebic query X` answers from the state, resize save/load round trip | B: state answers per query are `StateQuery` handling in the daemon; resize round trip needs `process_command` (KDE: `resize.rs` `sizes_saved_to_a_file_are_loaded_back_from_it` A) | M | low |
|
||||
| config_reload (8) | file change reloads names, layout, rules | A for the merge/reset semantics: `crates/komorebi-settings/tests/reload.rs` (`a_reload_merges_what_the_file_gives_and_resets_what_it_resets`), `src/handle.rs`; C: the file watch and the reload message dropped while the lock is held (the NEW failing check in gate5 is that mechanism) | - | - | med |
|
||||
| placement (1 x 5 cases) | initial_window_placement_rules first/last/Nth | A: `workspace_containers.rs` `a_one_based_placement_index_is_zero_based_and_out_of_range_falls_back_after_the_focused`, `initial_placement_rules_choose_where_a_new_window_goes`. The known Windows failure (number 2) is a daemon event-path matter | - | - | low |
|
||||
| scrolling (46) | strip, edges, columns, two monitors | A: `komorebi-scrolling/tests` (rules 80, tiles 40, heights 20, pan 16) and `update_shared.rs` `a_scrolling_workspace_*`; the resting window at an edge on the OS is C | - | - | med |
|
||||
| resize_commands (7), resize (26) | resize-axis widens and gives back; edge drag | A: `resize_constraints.rs`, `update_shared.rs` `the_resize_constraints_are_enforced_before_the_layout_is_calculated`; B (S): `DefaultLayout::resize` increase then decrease is the identity (no test in `komorebi-layouts`); the pointer drag and client rounding C | S | med |
|
||||
| pausing (4) | paused daemon ignores new windows | A: `komorebi-transport/src/pause.rs` (the message filter); the event filter is per daemon (B needs seam) | - | - | low |
|
||||
| hotplug (11), monitors (13) | unplug/plug a display, windows move, send-to-monitor | A for the model in `monitor_workspaces.rs`; the reconcile is per platform (Windows `monitor_reconciliator`, macOS own): B needs seam; the display itself C | L | med |
|
||||
| lifecycle (7), lifecycle_hidden (13), locking (7), handover (6), fullscreen (6), display_change (4), focus_follows_mouse (7) | stop/start restores windows, screen lock, minimize/unmanage/manage, fullscreen, mode change, pointer focus | A for hide/restore: `container_behaviour.rs` `restoring_*`, `workspace_layers.rs` `hiding_a_workspace_*`; the process, session, OS events and pointer are C | - | - | - |
|
||||
| Windows extras: bar (21), windows_padding, cloaking, config_file, tracking, second_display, display_change | bar process and window, 7 px border, cloaking, file watch, system focus setting, QXL display | bar schema: A (`crates/komorebi-bar-core/tests/schema_oracle.rs`); rest C | - | - | - |
|
||||
|
||||
## macOS-origin behaviour (never e2e-tested): what the shared tests now give
|
||||
|
||||
macOS has no e2e. The shared-crate tests that exist protect its code path as far as the hooks do:
|
||||
`state_roundtrip.rs` `a_macos_shaped_state_is_written_as_it_was_read_with_the_corner_last`,
|
||||
`a_macos_state_cannot_be_read_without_its_corner`, the `StubWindow` that is `Clone` but not `Copy`,
|
||||
and now `e2e_layouts.rs` (the tiles every macOS tiling goes through). Proposed B tests, platform
|
||||
dependent and meant for the Mini: the hide-spot corner per monitor (`hide_spot` hook is
|
||||
`StubState { spot }`) with `hide`/`restore` on a stack, and `komorebic-core` macOS command set
|
||||
(`e2e_sweep.rs` pins which sweep commands macOS lacks).
|
||||
|
||||
## KDE VM suites (33 suites with a test.py)
|
||||
|
||||
All of them need a headless or Plasma KWin: C. The model parts of them are already native through
|
||||
the KDE tests (`komorebi-for-kde/komorebi/tests`, about 880): `core-e2e` and `hotplug`, `placement`,
|
||||
`workspace-rules`, `scrolling`, `stacks`, `user-maximize`, `commands`, `core-lock`,
|
||||
`focus-follows-mouse`, `wallpaper` have a native model twin; `kwin*`, `check`, `module`, `keys-*`,
|
||||
`look`, `features`, `rdp`, `render-smoke`, `latency`, `client-geometry`, `drag-resize`,
|
||||
`live-resize`, `lock-sleep`, `run-kde`, `restart-survival`, `kwin-restart` are the compositor, the
|
||||
session, keys, pixels or timing (C). The `commands` suite's sweep now has a native twin
|
||||
(`command_sweep.rs`), so the suite can run a shorter sweep.
|
||||
|
||||
## Counts
|
||||
|
||||
Scenario rows: Windows/shared 43 scenarios + 7 Windows extras = 50. Classified by what is left to do
|
||||
after this work: A (fully native for the shared logic, e2e only needed as a smoke) 22; A now (added by
|
||||
this work) 9 of those (layouts, flipping, layout_flip, padding, tiling, closing, minimizing, floating,
|
||||
tiling_off, stacks in part); B open 7 (commands for Windows/macOS daemons, unknown_monitor, queries,
|
||||
hotplug reconcile, pausing event path, rules for Windows/macOS copies, resize identity); C only 21
|
||||
(lifecycle*, locking, display*, bar, extras, pointer, fullscreen, wallpaper rendering and the KDE
|
||||
suites). KDE VM: 0 A fully, 33 C (about 10 with a native model twin).
|
||||
|
||||
## Time saved
|
||||
|
||||
The Windows gate is about 2.3 min per scenario for 35 scenarios (about 80 min), the KDE suites 15
|
||||
x 1-13 min. Honest estimate:
|
||||
|
||||
- Today (what this work added): the arithmetic of layouts, flipping, layout_flip, padding, tiling
|
||||
and the room checks is native. A guest still has to show the daemon hands the tiles to the OS, so
|
||||
these scenarios shrink to one smoke each, or are merged into `tiling`: layouts (111 checks, about
|
||||
3 min) to one layout and 3 windows saves about 2 min; flipping, layout_flip, padding,
|
||||
tiling_off, minimizing, closing, floating merged in `tiling` save about 7 x 2 = 14 min. About 16
|
||||
min of 80 (20%) on Windows, plus commands: the 7.6 min scenario keeps 20 commands as a smoke and
|
||||
loses about 5 min once the Windows daemon is reachable by the sweep.
|
||||
- If the B items existed (daemon model reachable natively for Windows and macOS, rule matching in
|
||||
one shared function, config key tests): another 12 scenarios (rules, rules_class, rules_exe,
|
||||
manage_rules, title_rule, startup_rules, state_fidelity, queries, config_reload, placement,
|
||||
workspaces, workspace_moves) become one smoke each: about 25 min. Total about 45 min of the 80 min
|
||||
gate (55%), and almost all the flaky checks (stall-family markers sit in commands, config_reload,
|
||||
resize, maximizing, floating, which are the ones with timing).
|
||||
- KDE VM: the model twins let `commands`, `placement`, `workspace-rules`, `hotplug`, `scrolling`
|
||||
run with fewer cases; this is about 20-30 VM minutes of the 15 suites, not measured.
|
||||
|
||||
Not saved: boot and golden image (3 s from a state), the C scenarios.
|
||||
|
||||
## Seams that are missing (report only, nothing added)
|
||||
|
||||
1. The daemon's `process_command` and `process_event` are per platform. A model-level
|
||||
`CommandHandler<P>` in `komorebi-core` (taking `SocketMessage`, mutating `Monitor`/`Workspace`,
|
||||
calling hooks) would let one sweep (`command_sweep.rs`) protect Windows and macOS: `commands`,
|
||||
`unknown_monitor`, `queries`, `pausing`, `handover`, `moving`, `focus`, `monocle` focus behaviour.
|
||||
2. `should_act` / `should_act_individual` three times: move into `komorebi-config` (it already has
|
||||
`MatchingRule`, `MatchingStrategy`): one test file would replace the rule matching logic of rules,
|
||||
rules_class, rules_exe, manage_rules, title_rule, startup_rules for all daemons.
|
||||
3. Monitor reconciliation (Windows `monitor_reconciliator`, macOS own, KDE `reconcile.rs`) is not in
|
||||
`komorebi-core`: a pure `reconcile(old: &[MonitorSnapshot], new: &[MonitorSnapshot]) -> Plan`
|
||||
would make `hotplug` and `unknown_monitor` native.
|
||||
4. `cycle-stack`, `cycle-stack-index`, `focus-stack-window` are daemon methods, not `Container`
|
||||
methods; moving them into `komorebi-core::Container` would make the stacks scenario native
|
||||
beyond the existing stack/unstack tests.
|
||||
5. Event filtering while paused (`allowed_while_paused` is shared, the event path is not).
|
||||
|
||||
## Tests added, with the e2e check each mirrors
|
||||
|
||||
| Test file | Tests | Mirrors |
|
||||
|---|---|---|
|
||||
| `komorebi-layouts/tests/layouts_everywhere.rs` | 8 | layouts, flipping, layout_flip, padding, tiling, closing |
|
||||
| `crates/komorebi-core/tests/e2e_layouts.rs` | 6 | layouts, flipping, layout_flip, padding, closing, minimizing, floating, stacks, tiling, tiling_off |
|
||||
| `komorebi-for-kde/komorebi/tests/rule_matching.rs` | 13 | rules, rules_class, rules_exe, manage_rules, title_rule |
|
||||
| `komorebi-for-kde/komorebi/tests/command_sweep.rs` | 1 (185 messages) | commands |
|
||||
| `crates/komorebic-core/tests/e2e_sweep.rs` | 3 | commands |
|
||||
|
||||
Each test says what stays e2e: the OS frame equals the tile, borders, event timing, the daemon's own
|
||||
hooks.
|
||||
@@ -0,0 +1,31 @@
|
||||
# Known issues that need a decision
|
||||
|
||||
Findings of the consolidation reviews and tests that are NOT fixed because whether they are bugs, or how to fix them, is a decision for the owner. Each has the evidence, why it may or may not be a bug, the platforms, and a proposed fix. Paths are relative to the repository root at the time of writing and may have moved.
|
||||
|
||||
## 1. KDE FocusWorkspaceNumber, FocusWorkspaceNumbers and FocusLastWorkspace skip the pointer-monitor preamble
|
||||
|
||||
- **Evidence**: komorebi-for-kde/komorebi/src/process_command.rs lines 1245-1277: the arms for the three messages call `focus_workspace` on the focused monitor directly. The Windows daemon (komorebi/src/process_command.rs:972-987 for `FocusWorkspaceNumber`, and lines about 2185 and 2215 for the helpers behind `FocusLastWorkspace` and `FocusWorkspaceNumbers`) first checks `monitor_idx_from_current_pos()`: when the pointer is on another monitor whose focused workspace is empty, that monitor becomes the focused one. KDE has the same preamble only in `cycle_focus_workspace` (line 897-909).
|
||||
- **Why it may be a bug**: on a secondary monitor with an empty workspace and the pointer on it, `focus-workspace 2` switches the workspace of the monitor that was focused before, not the one the user is pointing at, unlike on Windows and unlike KDE's own `cycle-focus-workspace`. **Why not**: KWin may not report an empty monitor as pointed at the same way; the KDE tests do not cover it, so it may have been left out on purpose.
|
||||
- **Platforms**: KDE only (the Windows and macOS daemons are not known to be affected; not checked on macOS).
|
||||
- **Proposed fix**: add the preamble to the three arms, with a KDE unit test that the monitor under the pointer becomes the focused one; needs the owner to say which behaviour is intended.
|
||||
|
||||
## 2. Monitor::focus_workspace overwrites an existing workspace name
|
||||
|
||||
- **Evidence**: crates/komorebi-core/src/monitor.rs:159-165, `Monitor::focus_workspace`: on every focus it sets the workspace name to the platform's known name for that index, replacing a name the user or a rule gave the workspace. Pinned as-is by crates/komorebi-core/tests/monitor_workspaces.rs.
|
||||
- **Why it may be a bug**: a workspace renamed at runtime (`workspace-name`) loses its name the next time it is focused. **Why not**: the original Windows and KDE code did exactly this (the name table is the source of truth there); it only matters where names can differ from the table.
|
||||
- **Platforms**: all three (shared code, inherited unchanged from the Windows tree).
|
||||
- **Proposed fix**: only fill the name when the workspace has none; a behaviour change on all three daemons, so it needs the Windows e2e (`workspace`/`commands` scenarios) before landing.
|
||||
|
||||
## 3. Workspace::remove_container focuses the container before the focused one, not before the removed one
|
||||
|
||||
- **Evidence**: crates/komorebi-core/src/workspace.rs:1011-1016, `remove_container`, calls `focus_previous_container` (lines 796-799), which focuses `focused_container_idx() - 1` (saturating) after the removal, whatever index was removed. Pinned by crates/komorebi-core/tests/workspace_containers.rs (around line 240).
|
||||
- **Why it may be a bug**: closing a container that is not the focused one (a background window closes) moves the focus to a container next to the focused one rather than keeping the focused container focused. **Why not**: with the usual flow the removed container is the focused one, where both rules agree, and the original Windows code behaves identically.
|
||||
- **Platforms**: all three (shared code).
|
||||
- **Proposed fix**: when the removed index is below the focused one, decrement the focus by one; when it is above, leave it; when it is the focused one, focus the previous container. A behaviour change on all three, needing the Windows e2e (close scenarios) first.
|
||||
|
||||
## 4. Subscriber pushes have no write timeout on macOS
|
||||
|
||||
- **Evidence**: the macOS daemon's subscriber push (no write timeout in the subscriber send; see the macOS review notes in docs/dev/macos-handcheck.md): a stopped bar that does not read its socket wedges the daemon once the socket buffer is full.
|
||||
- **Why it may be a bug**: a daemon must not hang on a client. **Why not fixed**: the Windows review showed that a write timeout can truncate a notification mid-message, so the naive fix is worse.
|
||||
- **Platforms**: macOS (and the same shape on KDE, not verified).
|
||||
- **Proposed fix**: write the notification from a per-subscriber thread or channel with a drop-the-subscriber policy; needs a design decision.
|
||||
@@ -148,3 +148,19 @@ F. In `window.rs` `AdhocWindow::hide` / `Window::hide` duplicate the restore-pos
|
||||
## E. What is not checked at all
|
||||
|
||||
Everything above. In particular: no macOS test (399+ unit tests incl. those in window.rs for drag state) has run against any of these revisions; the unified binaries do not exist yet; no real Accessibility call was made; `komorebi-recorder` captures need a Mac.
|
||||
|
||||
## F. Bar clicks (system tools)
|
||||
|
||||
Run on the Mac with the unified bar; the unit tests for the argv are `cargo test -p komorebi-bar system_tool` and `release_page`.
|
||||
|
||||
- **M1. Battery widget click**: opens System Settings on the Battery pane (`open x-apple.systempreferences:com.apple.Battery-Settings.extension`, macOS 13 or later). If it opens System Settings elsewhere, or nothing, the pane id is wrong for that macOS version: write down the version and what opened. Before the fix the click did nothing visible (it tried `cmd.exe`).
|
||||
- **M2. CPU and memory widget click**: opens Activity Monitor (unchanged); the network widget click opens the Network pane; a storage widget click opens the folder in Finder.
|
||||
- **M3. Update widget**: with an installed version older than the latest komorebi-for-mac release the widget shows the new version; click opens `https://github.com/LGUG2Z/komorebi-for-mac/releases/tag/v<version>` in the default browser (not the Windows repository). After 12 hours (or with `data_refresh_interval` set to a small value) the widget still compares against komorebi-for-mac releases, never Windows ones (the refresh used to poll the Windows repository).
|
||||
|
||||
## G. Settings: S3 and S5 (wip-u-settings3 and earlier), appended by the settings agent
|
||||
|
||||
Type-check and clippy only; nothing here ran on a Mac. The settings now live in `settings()` (one snapshot per use); the process-wide statics for these groups are gone.
|
||||
|
||||
1. **S3 groups (paddings, floating aspect ratio, `layout_defaults`, `display_index_preferences`).** Config with `default_workspace_padding` 20 and `default_container_padding` 15: tiles 20 px from the work area, 15 apart. Reload with the key dropped: padding stays (merge); set it to 5 and reload: 5. `layout_defaults`: set, reload, workspaces use it; remove and reload: they fall back (the key resets). Aspect ratio: `toggle-float` with centring uses the configured ratio; remove the key and reload: 4:3 (Standard). `display_index_preference 0 <serial>`: monitor order follows it. Reload during a drag or workspace switch: no one-frame flash of half-new padding.
|
||||
2. **S5 animation (BEHAVIOUR: one snapshot for enabled, duration, style and fps).** Animation on (`komorebic animation true`), switch workspace: transition plays. While a transition runs, `komorebic animation-duration 1000`, then `animation-style`, then `animation false`: the running transition is not torn (no mix of old duration with new style), the next one follows the new values. Per-kind: `animation true --movement`, `animation false` (global): per-kind values are cleared by a global value, so movement is off again. Reload a file with `"animation": {"enabled": {"movement": true}}`: only movement animates and the global flag is untouched; reload a file with `"animation": {"enabled": true}` (no fps): fps back to 60; reload a file with no animation block: all animation settings keep their values. `komorebic animation-fps 30` then watch frame cadence. Stack a window (`stack`): no animation during the stack (the `suspend()` counter, unchanged), and animation is back after it, including after a stack command that fails.
|
||||
3. The border and transparency groups (S6, S4) are not moved on macOS: transparency does not exist there.
|
||||
@@ -332,3 +332,28 @@ all three daemons: statics removed, `apply_globals` applies them with one `Handl
|
||||
`display_index_preferences()`), each a clone from one snapshot. The only BEHAVIOUR is the single
|
||||
publish. Note the KDE integration test harness (`tests/config.rs`) now resets the paddings through
|
||||
`settings()`; it is the oracle that loads configurations over a fake desktop.
|
||||
|
||||
## 10. S4 and S5 as landed on `wip-u-settings3`, and what writing them showed
|
||||
|
||||
S4 (transparency enabled and alpha; KDE and Windows, macOS has none) and S5 (animation) moved the groups
|
||||
with their writers and readers, KDE first, then macOS (S5 only), then Windows. Per-revision gates are in
|
||||
the commit bodies. Differences between the daemons that the migration keeps, and that a later unification
|
||||
must decide on purpose:
|
||||
|
||||
* **Transparency on load:** KDE resets both keys when absent (`unwrap_or(false)`, `unwrap_or(200)`);
|
||||
Windows keeps the value. Both go through `SharedDelta::apply`; KDE builds its delta with `Some(unwrap_or(..))`.
|
||||
(The earlier table in section 2.1 said "kept" for both: corrected here.)
|
||||
* **When is a kind of animation on?** KDE and macOS: the per-kind value wins over the global one
|
||||
(`Animation::motion_for`). Windows: the global flag OR a per-kind true (a per-kind false does not turn off a
|
||||
global true), for window moves and the transparency animation; its workspace-transition helpers keep the
|
||||
per-kind-wins rule. The Windows accessors (`animation_enabled_for`, `animation_for`) encode its rule.
|
||||
* **Save-and-restore of the global animation flag:** KDE's stacking commands now hold
|
||||
`settings::animation_off()` (`Handle::scoped` on the global flag only, as the old swap did: per-kind values
|
||||
are not suspended), which also restores on an early error return. macOS keeps its `suspend()` counter
|
||||
(suspends every kind). Windows has no such write in the daemon; its shutdown path is the permanent
|
||||
`animation_off_for_good()`. Windows `WINDOW_HANDLING_BEHAVIOUR` moved to `WindowsSettings` and its one
|
||||
save-and-restore (the border paint test) uses `scoped`.
|
||||
* The old Windows window-move code held the per-kind enabled map's lock for the rest of the function while
|
||||
animating; it now takes one snapshot and holds nothing.
|
||||
|
||||
S6 (borders) is next and is not started.
|
||||
Generated
+4
-4
@@ -401,17 +401,17 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1767581716,
|
||||
"narHash": "sha256-FUbiUzdrGkLou37OGfb4vCLPnqdSIvtmJBxjh2iljiE=",
|
||||
"lastModified": 1793174968,
|
||||
"narHash": "sha256-u5nUf4cewaT36iIzG1s/VECktqUMiZaGF5BsgervsvQ=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "1d3f83babdd21e16bf5cfe0f1efcb4f49ee1bc2c",
|
||||
"rev": "19ecdd08213836b36c4296a3a4f4af5a3d5308db",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "1d3f83babdd21e16bf5cfe0f1efcb4f49ee1bc2c",
|
||||
"rev": "19ecdd08213836b36c4296a3a4f4af5a3d5308db",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
kfm-flake-parts.url = "github:hercules-ci/flake-parts/a34fae9c08a15ad73f295041fec82323541400a9";
|
||||
kfm-flake-parts.inputs.nixpkgs-lib.follows = "kfm-nixpkgs-lib";
|
||||
kfm-crane.url = "github:ipetkov/crane/7d59256814085fd9666a2ae3e774dc5ee216b630";
|
||||
kfm-rust-overlay.url = "github:oxalica/rust-overlay/1d3f83babdd21e16bf5cfe0f1efcb4f49ee1bc2c";
|
||||
kfm-rust-overlay.url = "github:oxalica/rust-overlay/19ecdd08213836b36c4296a3a4f4af5a3d5308db";
|
||||
kfm-rust-overlay.inputs.nixpkgs.follows = "kfm-nixpkgs";
|
||||
kfm-treefmt-nix.url = "github:numtide/treefmt-nix/d56486eb9493ad9c4777c65932618e9c2d0468fc";
|
||||
kfm-treefmt-nix.inputs.nixpkgs.follows = "kfm-nixpkgs";
|
||||
|
||||
@@ -127,7 +127,8 @@ pub fn main() -> eyre::Result<()> {
|
||||
);
|
||||
|
||||
if opts.quickstart {
|
||||
let komorebi_bar_json = include_str!("../../../komorebi-for-mac/docs/komorebi.bar.example.json").to_string();
|
||||
let komorebi_bar_json =
|
||||
include_str!("../../../komorebi-for-mac/docs/komorebi.bar.example.json").to_string();
|
||||
std::fs::write(home_dir.join("komorebi.bar.json"), komorebi_bar_json)?;
|
||||
println!(
|
||||
"Example komorebi.bar.json file written to {}",
|
||||
@@ -148,7 +149,8 @@ pub fn main() -> eyre::Result<()> {
|
||||
let mut config = match config_path {
|
||||
None => {
|
||||
let komorebi_bar_json =
|
||||
include_str!("../../../komorebi-for-mac/docs/komorebi.bar.example.json").to_string();
|
||||
include_str!("../../../komorebi-for-mac/docs/komorebi.bar.example.json")
|
||||
.to_string();
|
||||
|
||||
std::fs::write(&default_config_path, komorebi_bar_json)?;
|
||||
tracing::info!(
|
||||
|
||||
@@ -10,33 +10,18 @@ pub struct MacBar;
|
||||
|
||||
impl BarPlatform for MacBar {
|
||||
fn open_system_tool(&self, tool: SystemTool) -> io::Result<()> {
|
||||
match tool {
|
||||
SystemTool::TaskManager => Command::new("open")
|
||||
.args(["-a", "Activity Monitor"])
|
||||
.spawn(),
|
||||
// cmd.exe does not exist on macOS: this is what the battery widget does today
|
||||
SystemTool::PowerSettings => Command::new("cmd.exe")
|
||||
.args(["/C", "start", "ms-settings:batterysaver"])
|
||||
.spawn(),
|
||||
SystemTool::NetworkSettings => Command::new("open")
|
||||
.args(["x-apple.systempreferences:com.apple.Network-Settings.extension"])
|
||||
.spawn(),
|
||||
// explorer.exe does not exist on macOS: this is what the update widget does today
|
||||
SystemTool::Url(url) => Command::new("explorer.exe").args([url]).spawn(),
|
||||
SystemTool::StorageLocation(label) => {
|
||||
let parts: Vec<&str> = label.split(' ').collect();
|
||||
let path = parts[..parts.len() - 1].join(" ");
|
||||
|
||||
Command::new("open").args([path]).spawn()
|
||||
}
|
||||
}
|
||||
.map(|_| ())
|
||||
let (program, args) = system_tool_command(&tool);
|
||||
Command::new(program).args(args).spawn().map(|_| ())
|
||||
}
|
||||
|
||||
fn latest_release_api_url(&self) -> &'static str {
|
||||
"https://api.github.com/repos/LGUG2Z/komorebi-for-mac/releases/latest"
|
||||
}
|
||||
|
||||
fn release_page_url(&self, version: &str) -> String {
|
||||
format!("https://github.com/LGUG2Z/komorebi-for-mac/releases/tag/v{version}")
|
||||
}
|
||||
|
||||
fn calendar_icon(&self) -> &'static str {
|
||||
CALENDAR
|
||||
}
|
||||
@@ -58,3 +43,84 @@ impl BarPlatform for MacBar {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// The program and arguments that open `tool` on macOS: everything goes through `open`.
|
||||
fn system_tool_command(tool: &SystemTool) -> (&'static str, Vec<String>) {
|
||||
let args: Vec<String> = match tool {
|
||||
SystemTool::TaskManager => vec!["-a".into(), "Activity Monitor".into()],
|
||||
// System Settings of macOS 13 and later (the same scheme as the network pane)
|
||||
SystemTool::PowerSettings => {
|
||||
vec!["x-apple.systempreferences:com.apple.Battery-Settings.extension".into()]
|
||||
}
|
||||
SystemTool::NetworkSettings => {
|
||||
vec!["x-apple.systempreferences:com.apple.Network-Settings.extension".into()]
|
||||
}
|
||||
SystemTool::Url(url) => vec![url.clone()],
|
||||
SystemTool::StorageLocation(label) => {
|
||||
// the label is "<path> <usage>": the path is everything but the last word
|
||||
let parts: Vec<&str> = label.split(' ').collect();
|
||||
vec![parts[..parts.len() - 1].join(" ")]
|
||||
}
|
||||
};
|
||||
|
||||
("open", args)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn argv(tool: SystemTool) -> Vec<String> {
|
||||
let (program, args) = system_tool_command(&tool);
|
||||
assert_eq!(
|
||||
program, "open",
|
||||
"nothing on macOS is started by another program"
|
||||
);
|
||||
args
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_task_manager_is_activity_monitor() {
|
||||
assert_eq!(argv(SystemTool::TaskManager), ["-a", "Activity Monitor"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_battery_opens_the_battery_pane_of_system_settings() {
|
||||
assert_eq!(
|
||||
argv(SystemTool::PowerSettings),
|
||||
["x-apple.systempreferences:com.apple.Battery-Settings.extension"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_network_opens_the_network_pane_of_system_settings() {
|
||||
assert_eq!(
|
||||
argv(SystemTool::NetworkSettings),
|
||||
["x-apple.systempreferences:com.apple.Network-Settings.extension"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_url_is_opened_in_the_default_browser() {
|
||||
assert_eq!(
|
||||
argv(SystemTool::Url("https://example.com/a b".into())),
|
||||
["https://example.com/a b"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_storage_label_opens_its_path_without_the_free_space() {
|
||||
assert_eq!(
|
||||
argv(SystemTool::StorageLocation("/Volumes/My Disk 43%".into())),
|
||||
["/Volumes/My Disk"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_release_page_is_the_one_of_the_mac_repository() {
|
||||
assert_eq!(
|
||||
MacBar.release_page_url("0.1.2"),
|
||||
"https://github.com/LGUG2Z/komorebi-for-mac/releases/tag/v0.1.2"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,6 @@ use crate::macos::config::WorkspacesDisplayFormat;
|
||||
use crate::macos::render::RenderConfig;
|
||||
use crate::macos::selected_frame::SelectableFrame;
|
||||
use crate::macos::ui::CustomUi;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiConfigurationSwitcherConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiFocusedContainerConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiLayoutConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiLockedContainerConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiWorkspaceLayerConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiWorkspacesConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiLayout;
|
||||
use crate::macos::widgets::komorebi_layout::KomorebiLayoutExt;
|
||||
use crate::macos::widgets::widget::BarWidget;
|
||||
use eframe::egui::Align;
|
||||
@@ -39,6 +31,14 @@ use eframe::egui::vec2;
|
||||
use icns::IconFamily;
|
||||
use icns::IconType;
|
||||
use image::RgbaImage;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiConfigurationSwitcherConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiFocusedContainerConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiLayout;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiLayoutConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiLockedContainerConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiWorkspaceLayerConfig;
|
||||
pub use komorebi_bar_core::widgets::komorebi_config::KomorebiWorkspacesConfig;
|
||||
use komorebi_client::Container;
|
||||
use komorebi_client::PathExt;
|
||||
use komorebi_client::Rect;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
pub use komorebi_bar_core::widgets::applications;
|
||||
pub use komorebi_bar_core::widgets::battery;
|
||||
pub use komorebi_bar_core::widgets::cpu;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use crate::macos::bar::Alignment;
|
||||
pub use komorebi_bar_core::widgets::network_config::NetworkConfig;
|
||||
pub use komorebi_bar_core::widgets::network_config::NetworkSelectConfig;
|
||||
use crate::macos::config::LabelPrefix;
|
||||
use crate::macos::render::RenderConfig;
|
||||
use crate::macos::selected_frame::SelectableFrame;
|
||||
@@ -12,6 +10,8 @@ use eframe::egui::Label;
|
||||
use eframe::egui::TextFormat;
|
||||
use eframe::egui::Ui;
|
||||
use eframe::egui::text::LayoutJob;
|
||||
pub use komorebi_bar_core::widgets::network_config::NetworkConfig;
|
||||
pub use komorebi_bar_core::widgets::network_config::NetworkSelectConfig;
|
||||
use num_derive::FromPrimitive;
|
||||
use parking_lot::Mutex;
|
||||
use std::fmt;
|
||||
|
||||
@@ -11,9 +11,9 @@ use crate::macos::widgets::update::Update;
|
||||
use eframe::egui::Context;
|
||||
use eframe::egui::Ui;
|
||||
|
||||
use komorebi_bar_core::render::RenderConfig;
|
||||
pub use komorebi_bar_core::widgets::widget::BarWidget;
|
||||
pub use komorebi_bar_core::widgets::widget::WidgetConfig;
|
||||
use komorebi_bar_core::render::RenderConfig;
|
||||
|
||||
/// Stands in for a widget that macOS cannot run; `WidgetConfig::enabled` is false for those, so
|
||||
/// this is never built from a configuration that the bar loads.
|
||||
|
||||
@@ -35,6 +35,10 @@ impl BarPlatform for WindowsBar {
|
||||
"https://api.github.com/repos/LGUG2Z/komorebi/releases/latest"
|
||||
}
|
||||
|
||||
fn release_page_url(&self, version: &str) -> String {
|
||||
format!("https://github.com/LGUG2Z/komorebi/releases/v{version}")
|
||||
}
|
||||
|
||||
fn calendar_icon(&self) -> &'static str {
|
||||
CALENDAR_DOTS
|
||||
}
|
||||
|
||||
@@ -28,4 +28,8 @@ parking_lot = "0.13"
|
||||
|
||||
[features]
|
||||
default = ["schemars"]
|
||||
schemars = ["komorebi/default", "komorebi-linux/default", "komorebi-macos/default"]
|
||||
schemars = [
|
||||
"komorebi/default",
|
||||
"komorebi-linux/default",
|
||||
"komorebi-macos/default",
|
||||
]
|
||||
@@ -25,8 +25,16 @@ komorebi-macos = { package = "komorebi-macos", path = "../komorebi-for-mac/komor
|
||||
|
||||
[features]
|
||||
default = ["schemars"]
|
||||
deadlock_detection = ["komorebi-windows/deadlock_detection", "komorebi-linux/deadlock_detection", "komorebi-macos/deadlock_detection"]
|
||||
schemars = ["komorebi-windows/schemars", "komorebi-linux/schemars", "komorebi-macos/schemars"]
|
||||
deadlock_detection = [
|
||||
"komorebi-windows/deadlock_detection",
|
||||
"komorebi-linux/deadlock_detection",
|
||||
"komorebi-macos/deadlock_detection",
|
||||
]
|
||||
schemars = [
|
||||
"komorebi-windows/schemars",
|
||||
"komorebi-linux/schemars",
|
||||
"komorebi-macos/schemars",
|
||||
]
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dev-dependencies]
|
||||
serde_json = { workspace = true }
|
||||
@@ -10,14 +10,8 @@
|
||||
|
||||
use crate::core::animation::AnimationStyle;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
pub use prefix::AnimationPrefix;
|
||||
pub use komorebi_config::animation::PerAnimationPrefixConfig;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
|
||||
pub mod prefix;
|
||||
|
||||
@@ -27,52 +21,27 @@ pub const DEFAULT_ANIMATION_STYLE: AnimationStyle = AnimationStyle::Linear;
|
||||
pub const DEFAULT_ANIMATION_DURATION: u64 = 250;
|
||||
pub const DEFAULT_ANIMATION_FPS: u64 = 60;
|
||||
|
||||
pub static ANIMATION_STYLE_GLOBAL: LazyLock<Arc<Mutex<AnimationStyle>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(DEFAULT_ANIMATION_STYLE)));
|
||||
|
||||
pub static ANIMATION_ENABLED_GLOBAL: LazyLock<Arc<AtomicBool>> =
|
||||
LazyLock::new(|| Arc::new(AtomicBool::new(DEFAULT_ANIMATION_ENABLED)));
|
||||
|
||||
pub static ANIMATION_DURATION_GLOBAL: LazyLock<Arc<AtomicU64>> =
|
||||
LazyLock::new(|| Arc::new(AtomicU64::new(DEFAULT_ANIMATION_DURATION)));
|
||||
|
||||
pub static ANIMATION_STYLE_PER_ANIMATION: LazyLock<
|
||||
Arc<Mutex<HashMap<AnimationPrefix, AnimationStyle>>>,
|
||||
> = LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
|
||||
|
||||
pub static ANIMATION_ENABLED_PER_ANIMATION: LazyLock<Arc<Mutex<HashMap<AnimationPrefix, bool>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
|
||||
|
||||
pub static ANIMATION_DURATION_PER_ANIMATION: LazyLock<Arc<Mutex<HashMap<AnimationPrefix, u64>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
|
||||
|
||||
pub static ANIMATION_FPS: AtomicU64 = AtomicU64::new(DEFAULT_ANIMATION_FPS);
|
||||
|
||||
/// Returns how long window movement is animated for, in milliseconds, or `None` when it is not
|
||||
/// animated.
|
||||
///
|
||||
/// The `movement` settings win over the global ones, for whether it is animated and for how long.
|
||||
pub fn movement_animation() -> Option<u64> {
|
||||
let enabled = ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&AnimationPrefix::Movement)
|
||||
.copied()
|
||||
.unwrap_or_else(|| ANIMATION_ENABLED_GLOBAL.load(std::sync::atomic::Ordering::SeqCst));
|
||||
|
||||
enabled.then(|| {
|
||||
ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&AnimationPrefix::Movement)
|
||||
.copied()
|
||||
.unwrap_or_else(|| ANIMATION_DURATION_GLOBAL.load(std::sync::atomic::Ordering::SeqCst))
|
||||
})
|
||||
crate::settings::settings()
|
||||
.snapshot()
|
||||
.shared
|
||||
.animation
|
||||
.motion_for(AnimationPrefix::Movement)
|
||||
.map(|motion| motion.duration_ms)
|
||||
}
|
||||
|
||||
/// Returns the easing of window movement: the `movement` style, else the global one.
|
||||
pub fn movement_style() -> AnimationStyle {
|
||||
ANIMATION_STYLE_PER_ANIMATION
|
||||
.lock()
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
animation
|
||||
.style_per_animation
|
||||
.get(&AnimationPrefix::Movement)
|
||||
.copied()
|
||||
.unwrap_or_else(|| *ANIMATION_STYLE_GLOBAL.lock())
|
||||
.unwrap_or(animation.style)
|
||||
}
|
||||
@@ -219,6 +219,7 @@
|
||||
//! Once a message has been handled, every subscriber is sent a notification of it
|
||||
//! ([`notify_subscribers`]).
|
||||
|
||||
use crate::settings::animation_off;
|
||||
use crate::DATA_DIR;
|
||||
use crate::FLOATING_APPLICATIONS;
|
||||
use crate::IGNORE_IDENTIFIERS;
|
||||
@@ -229,13 +230,6 @@ use crate::SESSION_FLOATING_APPLICATIONS;
|
||||
use crate::SUBSCRIPTION_SOCKET_OPTIONS;
|
||||
use crate::SUBSCRIPTION_SOCKETS;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::backend::backend;
|
||||
use crate::border_manager;
|
||||
use crate::core::ApplicationIdentifier;
|
||||
@@ -1174,36 +1168,30 @@ impl WindowManager {
|
||||
self.move_container_in_cycle_direction(direction)?;
|
||||
}
|
||||
SocketMessage::StackWindow(direction) => {
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.add_window_to_container(direction)?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::UnstackWindow => {
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.remove_window_from_container()?;
|
||||
border_manager::destroy_all_borders()?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::StackAll => {
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.stack_all()?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::UnstackAll => {
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.unstack_all(true)?;
|
||||
border_manager::destroy_all_borders()?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::CycleStack(direction) => {
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.cycle_container_window_in_direction(direction)?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::CycleStackIndex(direction) => {
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.cycle_container_window_index_in_direction(direction)?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::FocusStackWindow(idx) => {
|
||||
// In case you are using this command on a bar on a monitor
|
||||
@@ -1213,9 +1201,8 @@ impl WindowManager {
|
||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
|
||||
let _animation_off = animation_off();
|
||||
self.focus_container_window(idx)?;
|
||||
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
|
||||
}
|
||||
SocketMessage::CycleFocusMonitor(direction) => {
|
||||
let monitor_idx = direction.next_idx(
|
||||
@@ -2048,14 +2035,15 @@ impl WindowManager {
|
||||
theme_manager::send_notification(*theme.clone());
|
||||
}
|
||||
SocketMessage::Transparency(enable) => {
|
||||
transparency_manager::TRANSPARENCY_ENABLED.store(enable, Ordering::SeqCst);
|
||||
crate::settings::settings().update(|settings| settings.shared.transparency.enabled = enable);
|
||||
}
|
||||
SocketMessage::ToggleTransparency => {
|
||||
let current = transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst);
|
||||
transparency_manager::TRANSPARENCY_ENABLED.store(!current, Ordering::SeqCst);
|
||||
crate::settings::settings().update(|settings| {
|
||||
settings.shared.transparency.enabled = !settings.shared.transparency.enabled;
|
||||
});
|
||||
}
|
||||
SocketMessage::TransparencyAlpha(alpha) => {
|
||||
transparency_manager::TRANSPARENCY_ALPHA.store(alpha, Ordering::SeqCst);
|
||||
crate::settings::settings().update(|settings| settings.shared.transparency.alpha = alpha);
|
||||
}
|
||||
SocketMessage::BorderColour(kind, r, g, b) => self.set_border_colour(kind, r, g, b),
|
||||
SocketMessage::BorderWidth(width) => {
|
||||
@@ -2066,41 +2054,51 @@ impl WindowManager {
|
||||
border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
||||
border_manager::destroy_all_borders()?;
|
||||
}
|
||||
SocketMessage::Animation(enable, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(enable, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationDuration(duration, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_DURATION_GLOBAL.store(duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
ANIMATION_FPS.store(fps, Ordering::SeqCst);
|
||||
SocketMessage::Animation(enable, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.enabled_per_animation.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
animation.enabled = enable;
|
||||
animation.enabled_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationDuration(duration, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.duration_per_animation.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
animation.duration = duration;
|
||||
animation.duration_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
crate::settings::settings().update(|settings| settings.shared.animation.fps = fps);
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.style_per_animation.insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
animation.style = style;
|
||||
animation.style_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::ReloadHotkeys => crate::kwin::hotkeys::reload()?,
|
||||
SocketMessage::HotkeysState => {
|
||||
let state = serde_json::to_string_pretty(&crate::kwin::hotkeys::state())?;
|
||||
|
||||
@@ -67,6 +67,33 @@ pub fn display_index_preferences() -> HashMap<usize, String> {
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// `transparency`: whether windows that are not focused are made see-through.
|
||||
pub fn transparency_enabled() -> bool {
|
||||
settings().snapshot().shared.transparency.enabled
|
||||
}
|
||||
|
||||
/// `transparency_alpha`: the opacity, 0 to 255, of a see-through window.
|
||||
pub fn transparency_alpha() -> u8 {
|
||||
settings().snapshot().shared.transparency.alpha
|
||||
}
|
||||
|
||||
/// Turns the global animation off until the guard is dropped, then puts back what it was unless
|
||||
/// something changed it meanwhile (a reload or a command wins). Per-animation values are not touched.
|
||||
/// This replaces the `swap(false)` and `store(restore)` pair of the commands that rearrange a stack.
|
||||
pub fn animation_off() -> komorebi_settings::Scoped<'static, KdeSettings, bool> {
|
||||
settings().scoped(|settings| &mut settings.shared.animation.enabled, false)
|
||||
}
|
||||
|
||||
/// `animation.fps`.
|
||||
pub fn animation_fps() -> u64 {
|
||||
settings().snapshot().shared.animation.fps
|
||||
}
|
||||
|
||||
/// The global `animation.enabled`.
|
||||
pub fn animation_enabled() -> bool {
|
||||
settings().snapshot().shared.animation.enabled
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -101,10 +101,8 @@ pub struct GlobalState {
|
||||
impl Default for GlobalState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
transparency_enabled: crate::transparency_manager::TRANSPARENCY_ENABLED
|
||||
.load(std::sync::atomic::Ordering::SeqCst),
|
||||
transparency_alpha: crate::transparency_manager::TRANSPARENCY_ALPHA
|
||||
.load(std::sync::atomic::Ordering::SeqCst),
|
||||
transparency_enabled: crate::settings::transparency_enabled(),
|
||||
transparency_alpha: crate::settings::transparency_alpha(),
|
||||
transparency_blacklist: TRANSPARENCY_BLACKLIST.lock().clone(),
|
||||
ignore_identifiers: IGNORE_IDENTIFIERS.lock().clone(),
|
||||
manage_identifiers: MANAGE_IDENTIFIERS.lock().clone(),
|
||||
|
||||
@@ -33,15 +33,6 @@ use crate::MANAGE_IDENTIFIERS;
|
||||
use crate::REGEX_IDENTIFIERS;
|
||||
use crate::TRANSPARENCY_BLACKLIST;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::animation::DEFAULT_ANIMATION_FPS;
|
||||
use crate::animation::PerAnimationPrefixConfig;
|
||||
use crate::backend::backend;
|
||||
use crate::border_manager;
|
||||
use crate::core::CrossBoundaryBehaviour;
|
||||
@@ -64,7 +55,6 @@ use crate::monitor::MonitorExt;
|
||||
use crate::monitor_reconciliator;
|
||||
use crate::ring::Ring;
|
||||
use crate::theme_manager;
|
||||
use crate::transparency_manager;
|
||||
use crate::window_manager::WindowManager;
|
||||
use crate::window_manager_event::WindowManagerEvent;
|
||||
use crate::workspace::Workspace;
|
||||
@@ -73,6 +63,7 @@ use color_eyre::eyre;
|
||||
use crossbeam_channel::Receiver;
|
||||
use hotwatch::EventKind;
|
||||
use hotwatch::Hotwatch;
|
||||
use komorebi_settings::shared::AnimationDelta;
|
||||
use komorebi_settings::shared::SharedDelta;
|
||||
use komorebi_themes::colour::Colour;
|
||||
use parking_lot::Mutex;
|
||||
@@ -351,10 +342,10 @@ impl From<&WindowManager> for StaticConfig {
|
||||
border: Option::from(border_manager::BORDER_ENABLED.load(Ordering::SeqCst)),
|
||||
border_colours,
|
||||
transparency: Option::from(
|
||||
transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst),
|
||||
crate::settings::transparency_enabled(),
|
||||
),
|
||||
transparency_alpha: Option::from(
|
||||
transparency_manager::TRANSPARENCY_ALPHA.load(Ordering::SeqCst),
|
||||
crate::settings::transparency_alpha(),
|
||||
),
|
||||
transparency_ignore_rules: None,
|
||||
// border_style: Option::from(STYLE.load()),
|
||||
@@ -447,44 +438,21 @@ impl ApplyGlobals for StaticConfig {
|
||||
// window::MINIMUM_WIDTH.store(width, Ordering::SeqCst);
|
||||
// }
|
||||
|
||||
// the animation block, as one update: a global value clears its per-animation map, a map
|
||||
// replaces the map, and a block without `fps` has the default (`SharedDelta::apply`)
|
||||
if let Some(animations) = &self.animation {
|
||||
match &animations.enabled {
|
||||
PerAnimationPrefixConfig::Prefix(enabled) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clone_from(enabled);
|
||||
crate::settings::settings().update(|settings| {
|
||||
SharedDelta {
|
||||
animation: Some(AnimationDelta {
|
||||
enabled: animations.enabled.clone(),
|
||||
style: animations.style.clone(),
|
||||
duration: animations.duration.clone(),
|
||||
fps: animations.fps,
|
||||
}),
|
||||
..SharedDelta::default()
|
||||
}
|
||||
PerAnimationPrefixConfig::Global(enabled) => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(*enabled, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
}
|
||||
|
||||
match &animations.style {
|
||||
Some(PerAnimationPrefixConfig::Prefix(style)) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clone_from(style);
|
||||
}
|
||||
Some(PerAnimationPrefixConfig::Global(style)) => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = *style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
match &animations.duration {
|
||||
Some(PerAnimationPrefixConfig::Prefix(duration)) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clone_from(duration);
|
||||
}
|
||||
Some(PerAnimationPrefixConfig::Global(duration)) => {
|
||||
ANIMATION_DURATION_GLOBAL.store(*duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
ANIMATION_FPS.store(
|
||||
animations.fps.unwrap_or(DEFAULT_ANIMATION_FPS),
|
||||
Ordering::SeqCst,
|
||||
);
|
||||
.apply(&mut settings.shared);
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(border_width) = self.border_width {
|
||||
@@ -555,10 +523,15 @@ impl ApplyGlobals for StaticConfig {
|
||||
// border_manager::send_notification(None);
|
||||
// }
|
||||
//
|
||||
transparency_manager::TRANSPARENCY_ENABLED
|
||||
.store(self.transparency.unwrap_or(false), Ordering::SeqCst);
|
||||
transparency_manager::TRANSPARENCY_ALPHA
|
||||
.store(self.transparency_alpha.unwrap_or(200), Ordering::SeqCst);
|
||||
// KDE resets both when the key is absent (unlike Windows, which keeps the value)
|
||||
crate::settings::settings().update(|settings| {
|
||||
SharedDelta {
|
||||
transparency: Some(self.transparency.unwrap_or(false)),
|
||||
transparency_alpha: Some(self.transparency_alpha.unwrap_or(200)),
|
||||
..SharedDelta::default()
|
||||
}
|
||||
.apply(&mut settings.shared);
|
||||
});
|
||||
|
||||
// the order every other place takes them in (floating, transparency, ignore, manage, regex):
|
||||
// a thread that takes two in another order can wait for one that holds what it needs
|
||||
|
||||
@@ -19,12 +19,7 @@ use crate::window::should_act;
|
||||
use crate::window_manager::WindowManager;
|
||||
use komorebi_backend::WindowId;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::AtomicU8;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
pub static TRANSPARENCY_ENABLED: AtomicBool = AtomicBool::new(false);
|
||||
pub static TRANSPARENCY_ALPHA: AtomicU8 = AtomicU8::new(200);
|
||||
|
||||
/// The opacity of a window that is not see-through at all.
|
||||
const OPAQUE: u8 = 255;
|
||||
@@ -107,8 +102,10 @@ pub fn transparent_windows(wm: &WindowManager) -> Vec<u32> {
|
||||
/// are made opaque, and the others are given [`TRANSPARENCY_ALPHA`]. With transparency off, every
|
||||
/// window is opaque. A failure is logged.
|
||||
pub fn apply(wm: &mut WindowManager) {
|
||||
let alpha = TRANSPARENCY_ALPHA.load(Ordering::SeqCst);
|
||||
let wanted: HashSet<u32> = if TRANSPARENCY_ENABLED.load(Ordering::SeqCst) {
|
||||
// one snapshot, so the flag and the alpha are from the same configuration
|
||||
let settings = crate::settings::settings().snapshot();
|
||||
let alpha = settings.shared.transparency.alpha;
|
||||
let wanted: HashSet<u32> = if settings.shared.transparency.enabled {
|
||||
transparent_windows(wm).into_iter().collect()
|
||||
} else {
|
||||
HashSet::new()
|
||||
|
||||
@@ -92,6 +92,12 @@ pub fn foreground_window_id() -> Option<PlatformWindowId> {
|
||||
backend().foreground_window().and_then(WindowId::to_u32)
|
||||
}
|
||||
|
||||
/// The id of the monitor the pointer is on, if the compositor says where it is
|
||||
pub fn monitor_id_at_cursor() -> Option<u32> {
|
||||
let (x, y) = backend().cursor_pos()?;
|
||||
backend().monitor_from_point(x, y)?.to_u32()
|
||||
}
|
||||
|
||||
/// Where the pointer is, if the compositor says
|
||||
pub fn cursor_position() -> Option<(i32, i32)> {
|
||||
backend().cursor_pos()
|
||||
|
||||
@@ -48,9 +48,6 @@
|
||||
//!
|
||||
//! [`listen_for_commands`]: crate::process_command::listen_for_commands
|
||||
|
||||
use crate::monitor::MonitorExt;
|
||||
use crate::scrolling::WorkspaceScrolling;
|
||||
use crate::workspace::WorkspaceExt;
|
||||
use crate::DATA_DIR;
|
||||
use crate::HIDDEN_WINDOWS;
|
||||
use crate::LibraryError;
|
||||
@@ -80,21 +77,25 @@ use crate::core::config_generation::MatchingRule;
|
||||
use crate::desktop;
|
||||
use crate::lockable_sequence::Lockable;
|
||||
use crate::monitor::Monitor;
|
||||
use crate::monitor::MonitorExt;
|
||||
use crate::ring::Ring;
|
||||
use crate::scrolling::WorkspaceScrolling;
|
||||
use crate::static_config::StaticConfig;
|
||||
use crate::static_config::StaticConfigExt;
|
||||
use crate::window::Window;
|
||||
use crate::window::foreground_window_id;
|
||||
use crate::window::monitor_id_at_cursor;
|
||||
use crate::window::should_act_individual;
|
||||
use crate::window_manager_event::WindowManagerEvent;
|
||||
use crate::window_manager_event_listener;
|
||||
use crate::workspace::Workspace;
|
||||
use crate::workspace::WorkspaceExt;
|
||||
use crate::workspace::WorkspaceLayer;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
use color_eyre::eyre::bail;
|
||||
use crossbeam_channel::Receiver;
|
||||
use hotwatch::Hotwatch;
|
||||
use komorebi_backend::WindowId;
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
@@ -324,10 +325,7 @@ impl WindowManager {
|
||||
let len = focused_workspace.floating_windows().len();
|
||||
|
||||
if len > 1 {
|
||||
let focused_window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let focused_rect = Window::from(focused_window_id).rect()?;
|
||||
|
||||
match direction {
|
||||
@@ -800,10 +798,7 @@ impl WindowManager {
|
||||
let focused_workspace = self.focused_workspace()?;
|
||||
let delta = self.resize_delta;
|
||||
|
||||
let focused_window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
for window in focused_workspace.floating_windows().iter() {
|
||||
if window.id == focused_window_id {
|
||||
let mut rect = window.rect()?;
|
||||
@@ -1706,10 +1701,7 @@ impl WindowManager {
|
||||
/// - The workspace cannot be tiled again.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn toggle_float(&mut self, force_float: bool) -> eyre::Result<()> {
|
||||
let window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("no foreground window")?;
|
||||
let window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
if workspace.monocle_container.is_some() {
|
||||
@@ -1816,10 +1808,8 @@ impl WindowManager {
|
||||
match workspace.layer {
|
||||
WorkspaceLayer::Floating => {
|
||||
let workspace = self.focused_workspace()?;
|
||||
let focused_window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id =
|
||||
foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
|
||||
let border_offset = 0;
|
||||
let border_width = 0;
|
||||
@@ -2366,8 +2356,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
pub fn monitor_idx_from_current_pos(&mut self) -> Option<usize> {
|
||||
let (x, y) = backend().cursor_pos()?;
|
||||
let monitor_id = backend().monitor_from_point(x, y)?.to_u32()?;
|
||||
let monitor_id = monitor_id_at_cursor()?;
|
||||
|
||||
for (i, monitor) in self.monitors().iter().enumerate() {
|
||||
if monitor.id == monitor_id {
|
||||
@@ -2476,10 +2465,7 @@ impl WindowManager {
|
||||
eyre::bail!("cannot move native maximized window to another monitor or workspace");
|
||||
}
|
||||
|
||||
let foreground_window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("no foreground window")?;
|
||||
let foreground_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let floating_window_index = workspace
|
||||
.floating_windows()
|
||||
.iter()
|
||||
@@ -2772,10 +2758,7 @@ impl WindowManager {
|
||||
let len = focused_workspace.floating_windows().len();
|
||||
|
||||
if len > 1 {
|
||||
let focused_window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
for (idx, window) in focused_workspace.floating_windows().iter().enumerate() {
|
||||
if window.id == focused_window_id {
|
||||
match direction {
|
||||
@@ -3276,10 +3259,8 @@ impl WindowManager {
|
||||
OperationBehaviour::NoOp
|
||||
) {
|
||||
let workspace = self.focused_workspace()?;
|
||||
let focused_hwnd = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
let focused_hwnd =
|
||||
foreground_window_id().ok_or_eyre("there is no foreground window")?;
|
||||
if !workspace.contains_managed_window(focused_hwnd) {
|
||||
bail!("ignoring commands while active window is not managed by komorebi");
|
||||
}
|
||||
@@ -3810,10 +3791,7 @@ impl WindowManager {
|
||||
/// The compositor reports no focused window.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn manage_focused_window(&mut self) -> eyre::Result<()> {
|
||||
let window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
let window_id = foreground_window_id().ok_or_eyre("there is no foreground window")?;
|
||||
|
||||
UNMANAGED_WINDOW_IDS.lock().retain(|id| *id != window_id);
|
||||
|
||||
@@ -3833,10 +3811,7 @@ impl WindowManager {
|
||||
/// The compositor reports no focused window.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn unmanage_focused_window(&mut self) -> eyre::Result<()> {
|
||||
let window_id = backend()
|
||||
.foreground_window()
|
||||
.and_then(WindowId::to_u32)
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
let window_id = foreground_window_id().ok_or_eyre("there is no foreground window")?;
|
||||
|
||||
window_manager_event_listener::send_notification(WindowManagerEvent::Unmanage(
|
||||
Window::from(window_id),
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
//! This file has one test because it changes the process-wide animation settings, which every
|
||||
//! other test that asks for the look would see.
|
||||
|
||||
use komorebi::animation::ANIMATION_FPS;
|
||||
use komorebi::animation::AnimationPrefix;
|
||||
use komorebi::backend::AnimationLook;
|
||||
use komorebi::backend::fake::Command;
|
||||
@@ -14,7 +13,6 @@ use komorebi::core::SocketMessage;
|
||||
use komorebi::core::animation::AnimationStyle;
|
||||
use komorebi::window_manager::WindowManager;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
#[test]
|
||||
fn the_animation_messages_set_the_animation_and_the_compositor_is_asked_for_it() {
|
||||
@@ -86,6 +84,6 @@ fn the_animation_messages_set_the_animation_and_the_compositor_is_asked_for_it()
|
||||
// the frame rate is kept, and asks nothing of the compositor
|
||||
let asked = fake.commands().len();
|
||||
send(&mut wm, SocketMessage::AnimationFps(30));
|
||||
assert_eq!(ANIMATION_FPS.load(Ordering::SeqCst), 30);
|
||||
assert_eq!(komorebi::settings::animation_fps(), 30);
|
||||
assert_eq!(fake.commands().len(), asked);
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
//! other test that asks for the look would see.
|
||||
|
||||
use color_eyre::eyre;
|
||||
use komorebi::animation::ANIMATION_FPS;
|
||||
use komorebi::animation::movement_animation;
|
||||
use komorebi::animation::movement_style;
|
||||
use komorebi::backend::fake::FakeBackend;
|
||||
@@ -19,7 +18,6 @@ use parking_lot::Mutex;
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
fn write_config(name: &str, json: &str) -> PathBuf {
|
||||
let path = PathBuf::from(format!("/tmp/kmb-anim-{name}-{}.json", std::process::id()));
|
||||
@@ -52,7 +50,7 @@ fn the_animation_key_of_the_file_is_the_animation_settings() {
|
||||
// one value for every kind of animation
|
||||
assert_eq!(movement_animation(), Some(120));
|
||||
assert_eq!(movement_style(), AnimationStyle::EaseOutExpo);
|
||||
assert_eq!(ANIMATION_FPS.load(Ordering::SeqCst), 30);
|
||||
assert_eq!(komorebi::settings::animation_fps(), 30);
|
||||
|
||||
// a value for the kinds a file names wins over the global ones, which a global value takes away
|
||||
let by_kind = write_config(
|
||||
@@ -66,7 +64,7 @@ fn the_animation_key_of_the_file_is_the_animation_settings() {
|
||||
assert_eq!(movement_animation(), None, "movement is off");
|
||||
assert_eq!(movement_style(), AnimationStyle::EaseInOutSine);
|
||||
assert_eq!(
|
||||
ANIMATION_FPS.load(Ordering::SeqCst),
|
||||
komorebi::settings::animation_fps(),
|
||||
60,
|
||||
"a file that leaves fps out has the default"
|
||||
);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
//! This file has one test because it changes the process-wide animation settings, which every
|
||||
//! other test that asks for the look would see.
|
||||
|
||||
use komorebi::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use komorebi::backend::AnimationLook;
|
||||
use komorebi::backend::fake::Command;
|
||||
use komorebi::backend::fake::FakeBackend;
|
||||
@@ -19,7 +18,6 @@ use komorebi::window_manager_event::KWinNotification;
|
||||
use komorebi::window_manager_event::SystemNotification;
|
||||
use komorebi::window_manager_event::WindowManagerEvent;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
#[test]
|
||||
fn the_animation_is_on_again_after_a_command_that_changes_a_stack() {
|
||||
@@ -94,7 +92,7 @@ fn the_animation_is_on_again_after_a_command_that_changes_a_stack() {
|
||||
fake.clear_commands();
|
||||
send(&mut wm, message.clone());
|
||||
assert!(
|
||||
ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst),
|
||||
komorebi::settings::animation_enabled(),
|
||||
"the animation is on again after {message:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
@@ -0,0 +1,577 @@
|
||||
//! A sweep of the commands that change the model, through [`WindowManager::process_command`] over
|
||||
//! a fake desktop with two monitors and three windows, the way the `commands` end-to-end scenario
|
||||
//! sweeps `komorebic` (`SWEEP` in `core/scenarios/commands.py`): after every command the daemon
|
||||
//! must be alive, answer a state query with JSON, and still manage every window it was given.
|
||||
//!
|
||||
//! mirrors: commands / <command> leaves the daemon healthy (the model commands of the sweep, as
|
||||
//! the `SocketMessage` each `komorebic` command is; the order is the scenario's, the ones that
|
||||
//! need a window the fake cannot have (the pointer, the real compositor, files) left out)
|
||||
//!
|
||||
//! Not covered here, and so still end-to-end: that `komorebic` parses each command and writes
|
||||
//! that message (see the CLI tests of `komorebic-core`), that the socket answers while a command
|
||||
//! runs, a command that stalls the daemon, and anything the real OS does with the windows.
|
||||
|
||||
use komorebi::backend::fake::FakeBackend;
|
||||
use komorebi::backend::with_backend;
|
||||
use komorebi::core::Axis;
|
||||
use komorebi::core::CycleDirection::Next;
|
||||
use komorebi::core::CycleDirection::Previous;
|
||||
use komorebi::core::DefaultLayout;
|
||||
use komorebi::core::MoveBehaviour;
|
||||
use komorebi::core::OperationBehaviour;
|
||||
use komorebi::core::OperationDirection::Down;
|
||||
use komorebi::core::OperationDirection::Left;
|
||||
use komorebi::core::OperationDirection::Right;
|
||||
use komorebi::core::OperationDirection::Up;
|
||||
use komorebi::core::Rect;
|
||||
use komorebi::core::Sizing::Decrease;
|
||||
use komorebi::core::Sizing::Increase;
|
||||
use komorebi::core::SocketMessage as M;
|
||||
use komorebi::window::Window;
|
||||
use komorebi::window_manager::WindowManager;
|
||||
use komorebi::window_manager_event::KWinNotification;
|
||||
use komorebi::window_manager_event::SystemNotification;
|
||||
use komorebi::window_manager_event::WindowManagerEvent;
|
||||
use std::sync::Arc;
|
||||
|
||||
const IDS: [u32; 3] = [31_001, 31_002, 31_003];
|
||||
|
||||
fn rect(left: i32) -> Rect {
|
||||
Rect {
|
||||
left,
|
||||
top: 0,
|
||||
right: 1920,
|
||||
bottom: 1080,
|
||||
}
|
||||
}
|
||||
|
||||
fn desktop() -> (Arc<FakeBackend>, WindowManager) {
|
||||
let fake = Arc::new(FakeBackend::new());
|
||||
fake.add_monitor(50, "DP-1", rect(0), rect(0));
|
||||
fake.add_monitor(51, "DP-2", rect(1920), rect(1920));
|
||||
let (_sender, receiver) = crossbeam_channel::bounded(1);
|
||||
let socket = std::path::PathBuf::from(format!("/tmp/kcs-{}.sock", std::process::id()));
|
||||
let mut wm = with_backend(fake.clone(), || {
|
||||
let mut wm = WindowManager::new(receiver, Some(socket)).unwrap();
|
||||
wm.init().unwrap();
|
||||
wm
|
||||
});
|
||||
for id in IDS {
|
||||
fake.open_window(
|
||||
id,
|
||||
&format!("exe{id}"),
|
||||
&format!("class.{id}"),
|
||||
&format!("window {id}"),
|
||||
);
|
||||
with_backend(fake.clone(), || {
|
||||
wm.process_event(WindowManagerEvent::Show(
|
||||
SystemNotification::KWin(KWinNotification::WindowAdded),
|
||||
Window::from(id),
|
||||
))
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
(fake, wm)
|
||||
}
|
||||
|
||||
fn managed(wm: &WindowManager, id: u32) -> bool {
|
||||
wm.monitors().iter().any(|monitor| {
|
||||
monitor
|
||||
.workspaces()
|
||||
.iter()
|
||||
.any(|workspace| workspace.contains_window(id))
|
||||
})
|
||||
}
|
||||
|
||||
/// The messages of the sweep that the fake desktop can run, in the scenario's order.
|
||||
fn sweep() -> Vec<(&'static str, M)> {
|
||||
vec![
|
||||
("focus left", M::FocusWindow(Left)),
|
||||
("focus right", M::FocusWindow(Right)),
|
||||
("focus up", M::FocusWindow(Up)),
|
||||
("focus down", M::FocusWindow(Down)),
|
||||
("move left", M::MoveWindow(Left)),
|
||||
("move right", M::MoveWindow(Right)),
|
||||
("move up", M::MoveWindow(Up)),
|
||||
("move down", M::MoveWindow(Down)),
|
||||
("cycle-focus next", M::CycleFocusWindow(Next)),
|
||||
("cycle-focus previous", M::CycleFocusWindow(Previous)),
|
||||
("cycle-move next", M::CycleMoveWindow(Next)),
|
||||
("cycle-move previous", M::CycleMoveWindow(Previous)),
|
||||
("stack left", M::StackWindow(Left)),
|
||||
("cycle-stack next", M::CycleStack(Next)),
|
||||
("cycle-stack previous", M::CycleStack(Previous)),
|
||||
("cycle-stack-index next", M::CycleStackIndex(Next)),
|
||||
("focus-stack-window 0", M::FocusStackWindow(0)),
|
||||
("unstack", M::UnstackWindow),
|
||||
("stack-all", M::StackAll),
|
||||
("unstack-all", M::UnstackAll),
|
||||
(
|
||||
"resize-edge left increase",
|
||||
M::ResizeWindowEdge(Left, Increase),
|
||||
),
|
||||
(
|
||||
"resize-edge right decrease",
|
||||
M::ResizeWindowEdge(Right, Decrease),
|
||||
),
|
||||
("resize-edge up increase", M::ResizeWindowEdge(Up, Increase)),
|
||||
(
|
||||
"resize-edge down decrease",
|
||||
M::ResizeWindowEdge(Down, Decrease),
|
||||
),
|
||||
(
|
||||
"resize-axis horizontal increase",
|
||||
M::ResizeWindowAxis(Axis::Horizontal, Increase),
|
||||
),
|
||||
(
|
||||
"resize-axis vertical decrease",
|
||||
M::ResizeWindowAxis(Axis::Vertical, Decrease),
|
||||
),
|
||||
("resize-delta 50", M::ResizeDelta(50)),
|
||||
("resize-delta 100", M::ResizeDelta(100)),
|
||||
("promote", M::Promote),
|
||||
("promote-swap", M::PromoteSwap),
|
||||
("promote-focus", M::PromoteFocus),
|
||||
("promote-window left", M::PromoteWindow(Left)),
|
||||
("retile", M::Retile),
|
||||
("flip-layout horizontal", M::FlipLayout(Axis::Horizontal)),
|
||||
("flip-layout vertical", M::FlipLayout(Axis::Vertical)),
|
||||
(
|
||||
"flip-layout horizontal-and-vertical",
|
||||
M::FlipLayout(Axis::HorizontalAndVertical),
|
||||
),
|
||||
(
|
||||
"flip-layout horizontal-and-vertical",
|
||||
M::FlipLayout(Axis::HorizontalAndVertical),
|
||||
),
|
||||
("cycle-layout next", M::CycleLayout(Next)),
|
||||
("cycle-layout previous", M::CycleLayout(Previous)),
|
||||
(
|
||||
"layout-ratios --columns 0.6 0.4",
|
||||
M::LayoutRatios(Some(vec![0.6, 0.4]), None),
|
||||
),
|
||||
(
|
||||
"change-layout columns",
|
||||
M::ChangeLayout(DefaultLayout::Columns),
|
||||
),
|
||||
("change-layout bsp", M::ChangeLayout(DefaultLayout::BSP)),
|
||||
("preselect-direction left", M::PreselectDirection(Left)),
|
||||
("cancel-preselect", M::CancelPreselect),
|
||||
("toggle-monocle", M::ToggleMonocle),
|
||||
("toggle-monocle", M::ToggleMonocle),
|
||||
("toggle-maximize", M::ToggleMaximize),
|
||||
("toggle-maximize", M::ToggleMaximize),
|
||||
("toggle-float", M::ToggleFloat),
|
||||
("toggle-float", M::ToggleFloat),
|
||||
("toggle-lock", M::ToggleLock),
|
||||
("toggle-lock", M::ToggleLock),
|
||||
("toggle-tiling", M::ToggleTiling),
|
||||
("toggle-tiling", M::ToggleTiling),
|
||||
("toggle-pause", M::TogglePause),
|
||||
("toggle-pause", M::TogglePause),
|
||||
("toggle-workspace-layer", M::ToggleWorkspaceLayer),
|
||||
("toggle-workspace-layer", M::ToggleWorkspaceLayer),
|
||||
(
|
||||
"toggle-window-container-behaviour",
|
||||
M::ToggleWindowContainerBehaviour,
|
||||
),
|
||||
(
|
||||
"toggle-window-container-behaviour",
|
||||
M::ToggleWindowContainerBehaviour,
|
||||
),
|
||||
("toggle-float-override", M::ToggleFloatOverride),
|
||||
("toggle-float-override", M::ToggleFloatOverride),
|
||||
(
|
||||
"toggle-workspace-window-container-behaviour",
|
||||
M::ToggleWorkspaceWindowContainerBehaviour,
|
||||
),
|
||||
(
|
||||
"toggle-workspace-window-container-behaviour",
|
||||
M::ToggleWorkspaceWindowContainerBehaviour,
|
||||
),
|
||||
(
|
||||
"toggle-workspace-float-override",
|
||||
M::ToggleWorkspaceFloatOverride,
|
||||
),
|
||||
(
|
||||
"toggle-workspace-float-override",
|
||||
M::ToggleWorkspaceFloatOverride,
|
||||
),
|
||||
(
|
||||
"ensure-named-workspaces 0 one two three",
|
||||
M::EnsureNamedWorkspaces(0, vec!["one".into(), "two".into(), "three".into()]),
|
||||
),
|
||||
(
|
||||
"workspace-name 0 0 one",
|
||||
M::WorkspaceName(0, 0, "one".into()),
|
||||
),
|
||||
("ensure-workspaces 0 3", M::EnsureWorkspaces(0, 3)),
|
||||
(
|
||||
"workspace-tiling 0 0 disable",
|
||||
M::WorkspaceTiling(0, 0, false),
|
||||
),
|
||||
(
|
||||
"workspace-tiling 0 0 enable",
|
||||
M::WorkspaceTiling(0, 0, true),
|
||||
),
|
||||
(
|
||||
"named-workspace-tiling one disable",
|
||||
M::NamedWorkspaceTiling("one".into(), false),
|
||||
),
|
||||
(
|
||||
"named-workspace-tiling one enable",
|
||||
M::NamedWorkspaceTiling("one".into(), true),
|
||||
),
|
||||
("focus-workspace 1", M::FocusWorkspaceNumber(1)),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
("focus-last-workspace", M::FocusLastWorkspace),
|
||||
("focus-last-workspace", M::FocusLastWorkspace),
|
||||
("focus-workspaces 1", M::FocusWorkspaceNumbers(1)),
|
||||
("focus-workspaces 0", M::FocusWorkspaceNumbers(0)),
|
||||
("cycle-workspace next", M::CycleFocusWorkspace(Next)),
|
||||
("cycle-workspace previous", M::CycleFocusWorkspace(Previous)),
|
||||
(
|
||||
"cycle-empty-workspace next",
|
||||
M::CycleFocusEmptyWorkspace(Next),
|
||||
),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
(
|
||||
"focus-named-workspace two",
|
||||
M::FocusNamedWorkspace("two".into()),
|
||||
),
|
||||
(
|
||||
"focus-named-workspace one",
|
||||
M::FocusNamedWorkspace("one".into()),
|
||||
),
|
||||
("send-to-workspace 1", M::SendContainerToWorkspaceNumber(1)),
|
||||
("focus-workspace 1", M::FocusWorkspaceNumber(1)),
|
||||
("move-to-workspace 0", M::MoveContainerToWorkspaceNumber(0)),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
(
|
||||
"cycle-send-to-workspace next",
|
||||
M::CycleSendContainerToWorkspace(Next),
|
||||
),
|
||||
("focus-workspace 1", M::FocusWorkspaceNumber(1)),
|
||||
(
|
||||
"cycle-move-to-workspace previous",
|
||||
M::CycleMoveContainerToWorkspace(Previous),
|
||||
),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
("send-to-last-workspace", M::SendContainerToLastWorkspace),
|
||||
("move-to-last-workspace", M::MoveContainerToLastWorkspace),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
("new-workspace", M::NewWorkspace),
|
||||
("close-workspace", M::CloseWorkspace),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
(
|
||||
"workspace-layout 0 0 columns",
|
||||
M::WorkspaceLayout(0, 0, DefaultLayout::Columns),
|
||||
),
|
||||
(
|
||||
"workspace-layout 0 0 bsp",
|
||||
M::WorkspaceLayout(0, 0, DefaultLayout::BSP),
|
||||
),
|
||||
(
|
||||
"named-workspace-layout one columns",
|
||||
M::NamedWorkspaceLayout("one".into(), DefaultLayout::Columns),
|
||||
),
|
||||
(
|
||||
"named-workspace-layout one bsp",
|
||||
M::NamedWorkspaceLayout("one".into(), DefaultLayout::BSP),
|
||||
),
|
||||
(
|
||||
"workspace-layout-rule 0 0 2 rows",
|
||||
M::WorkspaceLayoutRule(0, 0, 2, DefaultLayout::Rows),
|
||||
),
|
||||
(
|
||||
"workspace-layout-rule 0 0 3 columns",
|
||||
M::WorkspaceLayoutRule(0, 0, 3, DefaultLayout::Columns),
|
||||
),
|
||||
(
|
||||
"clear-workspace-layout-rules 0 0",
|
||||
M::ClearWorkspaceLayoutRules(0, 0),
|
||||
),
|
||||
(
|
||||
"named-workspace-layout-rule one 3 columns",
|
||||
M::NamedWorkspaceLayoutRule("one".into(), 3, DefaultLayout::Columns),
|
||||
),
|
||||
(
|
||||
"clear-named-workspace-layout-rules one",
|
||||
M::ClearNamedWorkspaceLayoutRules("one".into()),
|
||||
),
|
||||
(
|
||||
"workspace-layout 0 0 bsp",
|
||||
M::WorkspaceLayout(0, 0, DefaultLayout::BSP),
|
||||
),
|
||||
("focus-monitor 1", M::FocusMonitorNumber(1)),
|
||||
("focus-monitor 0", M::FocusMonitorNumber(0)),
|
||||
("cycle-monitor next", M::CycleFocusMonitor(Next)),
|
||||
("cycle-monitor previous", M::CycleFocusMonitor(Previous)),
|
||||
(
|
||||
"focus-monitor-workspace 1 1",
|
||||
M::FocusMonitorWorkspaceNumber(1, 1),
|
||||
),
|
||||
(
|
||||
"focus-monitor-workspace 0 0",
|
||||
M::FocusMonitorWorkspaceNumber(0, 0),
|
||||
),
|
||||
("focus-monitor 0", M::FocusMonitorNumber(0)),
|
||||
(
|
||||
"send-to-named-workspace two",
|
||||
M::SendContainerToNamedWorkspace("two".into()),
|
||||
),
|
||||
(
|
||||
"focus-named-workspace two",
|
||||
M::FocusNamedWorkspace("two".into()),
|
||||
),
|
||||
(
|
||||
"move-to-named-workspace one",
|
||||
M::MoveContainerToNamedWorkspace("one".into()),
|
||||
),
|
||||
(
|
||||
"focus-named-workspace one",
|
||||
M::FocusNamedWorkspace("one".into()),
|
||||
),
|
||||
("send-to-monitor 1", M::SendContainerToMonitorNumber(1)),
|
||||
("focus-monitor 1", M::FocusMonitorNumber(1)),
|
||||
("move-to-monitor 0", M::MoveContainerToMonitorNumber(0)),
|
||||
("focus-monitor 0", M::FocusMonitorNumber(0)),
|
||||
(
|
||||
"cycle-send-to-monitor next",
|
||||
M::CycleSendContainerToMonitor(Next),
|
||||
),
|
||||
("focus-monitor 1", M::FocusMonitorNumber(1)),
|
||||
(
|
||||
"cycle-move-to-monitor next",
|
||||
M::CycleMoveContainerToMonitor(Next),
|
||||
),
|
||||
("focus-monitor 0", M::FocusMonitorNumber(0)),
|
||||
(
|
||||
"send-to-monitor-workspace 1 1",
|
||||
M::SendContainerToMonitorWorkspaceNumber(1, 1),
|
||||
),
|
||||
(
|
||||
"focus-monitor-workspace 1 1",
|
||||
M::FocusMonitorWorkspaceNumber(1, 1),
|
||||
),
|
||||
(
|
||||
"move-to-monitor-workspace 0 0",
|
||||
M::MoveContainerToMonitorWorkspaceNumber(0, 0),
|
||||
),
|
||||
("focus-monitor 0", M::FocusMonitorNumber(0)),
|
||||
("focus-workspace 0", M::FocusWorkspaceNumber(0)),
|
||||
(
|
||||
"move-workspace-to-monitor 1",
|
||||
M::MoveWorkspaceToMonitorNumber(1),
|
||||
),
|
||||
(
|
||||
"cycle-move-workspace-to-monitor next",
|
||||
M::CycleMoveWorkspaceToMonitor(Next),
|
||||
),
|
||||
(
|
||||
"swap-workspaces-with-monitor 1",
|
||||
M::SwapWorkspacesToMonitorNumber(1),
|
||||
),
|
||||
(
|
||||
"swap-workspaces-with-monitor 1",
|
||||
M::SwapWorkspacesToMonitorNumber(1),
|
||||
),
|
||||
(
|
||||
"global-work-area-offset 10 10 20 20",
|
||||
M::WorkAreaOffset(Rect {
|
||||
left: 10,
|
||||
top: 10,
|
||||
right: 20,
|
||||
bottom: 20,
|
||||
}),
|
||||
),
|
||||
(
|
||||
"global-work-area-offset 0 0 0 0",
|
||||
M::WorkAreaOffset(Rect::default()),
|
||||
),
|
||||
(
|
||||
"monitor-work-area-offset 0 10 10 20 20",
|
||||
M::MonitorWorkAreaOffset(
|
||||
0,
|
||||
Rect {
|
||||
left: 10,
|
||||
top: 10,
|
||||
right: 20,
|
||||
bottom: 20,
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
"monitor-work-area-offset 0 0 0 0 0",
|
||||
M::MonitorWorkAreaOffset(0, Rect::default()),
|
||||
),
|
||||
(
|
||||
"workspace-work-area-offset 0 0 10 10 20 20",
|
||||
M::WorkspaceWorkAreaOffset(
|
||||
0,
|
||||
0,
|
||||
Rect {
|
||||
left: 10,
|
||||
top: 10,
|
||||
right: 20,
|
||||
bottom: 20,
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
"workspace-work-area-offset 0 0 0 0 0 0",
|
||||
M::WorkspaceWorkAreaOffset(0, 0, Rect::default()),
|
||||
),
|
||||
(
|
||||
"toggle-window-based-work-area-offset",
|
||||
M::ToggleWindowBasedWorkAreaOffset,
|
||||
),
|
||||
(
|
||||
"toggle-window-based-work-area-offset",
|
||||
M::ToggleWindowBasedWorkAreaOffset,
|
||||
),
|
||||
(
|
||||
"focused-workspace-container-padding 20",
|
||||
M::FocusedWorkspaceContainerPadding(20),
|
||||
),
|
||||
(
|
||||
"focused-workspace-container-padding 10",
|
||||
M::FocusedWorkspaceContainerPadding(10),
|
||||
),
|
||||
(
|
||||
"focused-workspace-padding 20",
|
||||
M::FocusedWorkspacePadding(20),
|
||||
),
|
||||
(
|
||||
"focused-workspace-padding 10",
|
||||
M::FocusedWorkspacePadding(10),
|
||||
),
|
||||
(
|
||||
"adjust-container-padding increase 5",
|
||||
M::AdjustContainerPadding(Increase, 5),
|
||||
),
|
||||
(
|
||||
"adjust-container-padding decrease 5",
|
||||
M::AdjustContainerPadding(Decrease, 5),
|
||||
),
|
||||
(
|
||||
"adjust-workspace-padding increase 5",
|
||||
M::AdjustWorkspacePadding(Increase, 5),
|
||||
),
|
||||
(
|
||||
"adjust-workspace-padding decrease 5",
|
||||
M::AdjustWorkspacePadding(Decrease, 5),
|
||||
),
|
||||
("container-padding 0 0 12", M::ContainerPadding(0, 0, 12)),
|
||||
("container-padding 0 0 10", M::ContainerPadding(0, 0, 10)),
|
||||
("workspace-padding 0 0 12", M::WorkspacePadding(0, 0, 12)),
|
||||
("workspace-padding 0 0 10", M::WorkspacePadding(0, 0, 10)),
|
||||
(
|
||||
"named-workspace-container-padding one 12",
|
||||
M::NamedWorkspaceContainerPadding("one".into(), 12),
|
||||
),
|
||||
(
|
||||
"named-workspace-container-padding one 10",
|
||||
M::NamedWorkspaceContainerPadding("one".into(), 10),
|
||||
),
|
||||
(
|
||||
"named-workspace-padding one 12",
|
||||
M::NamedWorkspacePadding("one".into(), 12),
|
||||
),
|
||||
(
|
||||
"named-workspace-padding one 10",
|
||||
M::NamedWorkspacePadding("one".into(), 10),
|
||||
),
|
||||
(
|
||||
"cross-monitor-move-behaviour insert",
|
||||
M::CrossMonitorMoveBehaviour(MoveBehaviour::Insert),
|
||||
),
|
||||
(
|
||||
"cross-monitor-move-behaviour swap",
|
||||
M::CrossMonitorMoveBehaviour(MoveBehaviour::Swap),
|
||||
),
|
||||
(
|
||||
"toggle-cross-monitor-move-behaviour",
|
||||
M::ToggleCrossMonitorMoveBehaviour,
|
||||
),
|
||||
(
|
||||
"toggle-cross-monitor-move-behaviour",
|
||||
M::ToggleCrossMonitorMoveBehaviour,
|
||||
),
|
||||
(
|
||||
"toggle-monocle-focus-behaviour",
|
||||
M::ToggleMonocleFocusBehaviour,
|
||||
),
|
||||
(
|
||||
"toggle-monocle-focus-behaviour",
|
||||
M::ToggleMonocleFocusBehaviour,
|
||||
),
|
||||
(
|
||||
"unmanaged-window-operation-behaviour op",
|
||||
M::UnmanagedWindowOperationBehaviour(OperationBehaviour::Op),
|
||||
),
|
||||
(
|
||||
"unmanaged-window-operation-behaviour no-op",
|
||||
M::UnmanagedWindowOperationBehaviour(OperationBehaviour::NoOp),
|
||||
),
|
||||
(
|
||||
"unmanaged-window-operation-behaviour op",
|
||||
M::UnmanagedWindowOperationBehaviour(OperationBehaviour::Op),
|
||||
),
|
||||
("session-float-rule", M::SessionFloatRule),
|
||||
("clear-session-float-rules", M::ClearSessionFloatRules),
|
||||
("toggle-float", M::ToggleFloat),
|
||||
("enforce-workspace-rules", M::EnforceWorkspaceRules),
|
||||
("clear-all-workspace-rules", M::ClearAllWorkspaceRules),
|
||||
("manage", M::ManageFocusedWindow),
|
||||
("retile", M::Retile),
|
||||
(
|
||||
"scrolling: change-layout scrolling",
|
||||
M::ChangeLayout(DefaultLayout::Scrolling),
|
||||
),
|
||||
("scrolling: consume left", M::Consume(Left)),
|
||||
("scrolling: expel", M::Expel),
|
||||
("scrolling: toggle-column-stack", M::ToggleColumnStack),
|
||||
(
|
||||
"scrolling: scrolling-layout-full-width",
|
||||
M::ScrollingLayoutFullWidth,
|
||||
),
|
||||
("scrolling: center-focus", M::CenterFocus),
|
||||
("scrolling: expand", M::Expand),
|
||||
("change-layout bsp", M::ChangeLayout(DefaultLayout::BSP)),
|
||||
]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_command_of_the_sweep_breaks_the_daemon() {
|
||||
let (fake, mut wm) = desktop();
|
||||
|
||||
let mut errors = Vec::new();
|
||||
for (step, (name, message)) in sweep().into_iter().enumerate() {
|
||||
let mut reply = Vec::new();
|
||||
let result = with_backend(fake.clone(), || wm.process_command(message, &mut reply));
|
||||
if let Err(error) = result {
|
||||
errors.push(format!("{step} {name}: {error}"));
|
||||
}
|
||||
|
||||
for id in IDS {
|
||||
assert!(
|
||||
managed(&wm, id),
|
||||
"after {step} `{name}` the window {id} is not managed"
|
||||
);
|
||||
}
|
||||
|
||||
let mut state = Vec::new();
|
||||
with_backend(fake.clone(), || wm.process_command(M::State, &mut state)).unwrap();
|
||||
serde_json::from_slice::<serde_json::Value>(&state)
|
||||
.unwrap_or_else(|error| panic!("after {step} `{name}` the state is not JSON: {error}"));
|
||||
}
|
||||
|
||||
// a command may refuse (a direction with no window in it), which is not a broken daemon; any
|
||||
// other error is one the end-to-end scenario would call a command that was not understood
|
||||
let others: Vec<_> = errors
|
||||
.iter()
|
||||
.filter(|e| !e.ends_with("there is no container or monitor in this direction"))
|
||||
.collect();
|
||||
assert!(others.is_empty(), "commands that failed: {others:#?}");
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
//! How a rule matches a window: the kinds (title, class, exe, path), every matching strategy,
|
||||
//! composite rules, the last rule that matches winning, and a manage rule rescuing a window an
|
||||
//! ignore rule covers. These are the pure functions every rule-driven behaviour of the daemon
|
||||
//! goes through, so what the `rules`, `rules_class`, `rules_exe`, `manage_rules`, `title_rule`
|
||||
//! and `startup_rules` end-to-end scenarios assert about WHICH window a rule catches is asserted
|
||||
//! here with no window manager.
|
||||
//!
|
||||
//! Not covered here, and so still end-to-end: that the daemon applies the rule at the right moment
|
||||
//! (when the window opens, not when it is renamed later), that the window then lands on the right
|
||||
//! workspace and is hidden or shown, and what the OS reports as a window's title, class and
|
||||
//! executable.
|
||||
|
||||
use komorebi::backend::fake::FakeBackend;
|
||||
use komorebi::backend::with_backend;
|
||||
use komorebi::core::ApplicationIdentifier;
|
||||
use komorebi::core::SocketMessage;
|
||||
use komorebi::core::config_generation::IdWithIdentifier;
|
||||
use komorebi::core::config_generation::MatchingRule;
|
||||
use komorebi::core::config_generation::MatchingStrategy;
|
||||
use komorebi::window::Window;
|
||||
use komorebi::window::should_act;
|
||||
use komorebi::window::should_act_individual;
|
||||
use komorebi::window::should_act_window;
|
||||
use komorebi::window_manager::WindowManager;
|
||||
use komorebi::window_manager_event::KWinNotification;
|
||||
use komorebi::window_manager_event::SystemNotification;
|
||||
use komorebi::window_manager_event::WindowManagerEvent;
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn id(
|
||||
kind: ApplicationIdentifier,
|
||||
id: &str,
|
||||
strategy: Option<MatchingStrategy>,
|
||||
) -> IdWithIdentifier {
|
||||
IdWithIdentifier {
|
||||
kind,
|
||||
id: id.to_string(),
|
||||
matching_strategy: strategy,
|
||||
}
|
||||
}
|
||||
|
||||
fn simple(kind: ApplicationIdentifier, text: &str, strategy: MatchingStrategy) -> MatchingRule {
|
||||
MatchingRule::Simple(id(kind, text, Some(strategy)))
|
||||
}
|
||||
|
||||
fn no_regex() -> HashMap<String, Regex> {
|
||||
HashMap::new()
|
||||
}
|
||||
|
||||
/// The window every test asks about.
|
||||
const TITLE: &str = "komorebi-e2e: rule target";
|
||||
const EXE: &str = "kwrite";
|
||||
const CLASS: &str = "org.kde.kwrite";
|
||||
const PATH: &str = "/usr/bin/kwrite";
|
||||
|
||||
fn matches(rule: &IdWithIdentifier) -> bool {
|
||||
should_act_individual(TITLE, EXE, &[CLASS], PATH, rule, &no_regex())
|
||||
}
|
||||
|
||||
fn kinds() -> [ApplicationIdentifier; 4] {
|
||||
[
|
||||
ApplicationIdentifier::Title,
|
||||
ApplicationIdentifier::Class,
|
||||
ApplicationIdentifier::Exe,
|
||||
ApplicationIdentifier::Path,
|
||||
]
|
||||
}
|
||||
|
||||
fn text_of(kind: ApplicationIdentifier) -> &'static str {
|
||||
match kind {
|
||||
ApplicationIdentifier::Title => TITLE,
|
||||
ApplicationIdentifier::Class => CLASS,
|
||||
ApplicationIdentifier::Exe => EXE,
|
||||
ApplicationIdentifier::Path => PATH,
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: rules / a window an initial rule matches goes to the workspace the rule names (by title)
|
||||
// mirrors: rules_class / a window a class rule matches goes to the workspace the rule names
|
||||
// mirrors: rules_exe / a window an exe rule matches goes to the workspace the rule names
|
||||
#[test]
|
||||
fn equals_matches_the_whole_text_of_each_kind_and_nothing_else() {
|
||||
for kind in kinds() {
|
||||
let text = text_of(kind);
|
||||
assert!(
|
||||
matches(&id(kind, text, Some(MatchingStrategy::Equals))),
|
||||
"{kind:?}"
|
||||
);
|
||||
assert!(
|
||||
!matches(&id(
|
||||
kind,
|
||||
&text[..text.len() - 1],
|
||||
Some(MatchingStrategy::Equals)
|
||||
)),
|
||||
"{kind:?}: a prefix is not equal"
|
||||
);
|
||||
assert!(
|
||||
!matches(&id(
|
||||
kind,
|
||||
&format!("{text}x"),
|
||||
Some(MatchingStrategy::Equals)
|
||||
)),
|
||||
"{kind:?}: a longer text is not equal"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: rules / a window of another title stays (the rule does not catch it)
|
||||
// mirrors: rules_class / a window of another class stays on the first workspace
|
||||
// mirrors: rules_exe / a window of another program stays on the first workspace
|
||||
#[test]
|
||||
fn each_kind_looks_at_its_own_part_of_the_window_only() {
|
||||
// the title of the window as the id of a class rule, and so on: no kind reads another's text
|
||||
for kind in kinds() {
|
||||
for other in kinds().into_iter().filter(|o| *o != kind) {
|
||||
assert!(
|
||||
!matches(&id(kind, text_of(other), Some(MatchingStrategy::Equals))),
|
||||
"a {kind:?} rule matched the {other:?} of the window"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn starts_with_ends_with_and_contains_match_the_part_they_name() {
|
||||
for kind in kinds() {
|
||||
let text = text_of(kind);
|
||||
let head = &text[..4];
|
||||
let tail = &text[text.len() - 4..];
|
||||
let middle = &text[2..text.len() - 2];
|
||||
for (strategy, yes, no) in [
|
||||
(MatchingStrategy::StartsWith, head, tail),
|
||||
(MatchingStrategy::EndsWith, tail, head),
|
||||
(MatchingStrategy::Contains, middle, "not-in-the-window"),
|
||||
] {
|
||||
assert!(
|
||||
matches(&id(kind, yes, Some(strategy.clone()))),
|
||||
"{kind:?} {strategy}"
|
||||
);
|
||||
assert!(
|
||||
!matches(&id(kind, no, Some(strategy.clone()))),
|
||||
"{kind:?} {strategy}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_negated_strategy_is_the_opposite_of_its_positive_one() {
|
||||
for kind in kinds() {
|
||||
let text = text_of(kind);
|
||||
let head = &text[..4];
|
||||
let tail = &text[text.len() - 4..];
|
||||
for (positive, negative, text) in [
|
||||
(
|
||||
MatchingStrategy::Equals,
|
||||
MatchingStrategy::DoesNotEqual,
|
||||
text,
|
||||
),
|
||||
(
|
||||
MatchingStrategy::StartsWith,
|
||||
MatchingStrategy::DoesNotStartWith,
|
||||
head,
|
||||
),
|
||||
(
|
||||
MatchingStrategy::EndsWith,
|
||||
MatchingStrategy::DoesNotEndWith,
|
||||
tail,
|
||||
),
|
||||
(
|
||||
MatchingStrategy::Contains,
|
||||
MatchingStrategy::DoesNotContain,
|
||||
head,
|
||||
),
|
||||
] {
|
||||
for probe in [text, "zzzz-not-there"] {
|
||||
let p = matches(&id(kind, probe, Some(positive.clone())));
|
||||
let n = matches(&id(kind, probe, Some(negative.clone())));
|
||||
assert_ne!(p, n, "{kind:?}: {positive} and {negative} for {probe:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: rules / a window a rule by the name of a workspace matches goes to that workspace
|
||||
#[test]
|
||||
fn a_regex_rule_matches_with_the_compiled_regex_and_nothing_without_one() {
|
||||
let pattern = "^komorebi-e2e: .* target$";
|
||||
let rule = id(
|
||||
ApplicationIdentifier::Title,
|
||||
pattern,
|
||||
Some(MatchingStrategy::Regex),
|
||||
);
|
||||
let mut compiled = HashMap::new();
|
||||
compiled.insert(pattern.to_string(), Regex::new(pattern).unwrap());
|
||||
|
||||
assert!(should_act_individual(
|
||||
TITLE,
|
||||
EXE,
|
||||
&[CLASS],
|
||||
PATH,
|
||||
&rule,
|
||||
&compiled
|
||||
));
|
||||
assert!(!should_act_individual(
|
||||
"another",
|
||||
EXE,
|
||||
&[CLASS],
|
||||
PATH,
|
||||
&rule,
|
||||
&compiled
|
||||
));
|
||||
// the daemon compiles every regex when it loads the rules: an id it has not compiled matches nothing
|
||||
assert!(!should_act_individual(
|
||||
TITLE,
|
||||
EXE,
|
||||
&[CLASS],
|
||||
PATH,
|
||||
&rule,
|
||||
&no_regex()
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_regex_rule_can_catch_any_of_the_classes_of_a_window() {
|
||||
let pattern = "^org\\.kde\\.";
|
||||
let rule = id(
|
||||
ApplicationIdentifier::Class,
|
||||
pattern,
|
||||
Some(MatchingStrategy::Regex),
|
||||
);
|
||||
let mut compiled = HashMap::new();
|
||||
compiled.insert(pattern.to_string(), Regex::new(pattern).unwrap());
|
||||
assert!(should_act_individual(
|
||||
TITLE,
|
||||
EXE,
|
||||
&["x", CLASS],
|
||||
PATH,
|
||||
&rule,
|
||||
&compiled
|
||||
));
|
||||
assert!(!should_act_individual(
|
||||
TITLE,
|
||||
EXE,
|
||||
&["x", "y"],
|
||||
PATH,
|
||||
&rule,
|
||||
&compiled
|
||||
));
|
||||
}
|
||||
|
||||
// mirrors: rules_exe / a window an exe rule matches goes to the workspace the rule names
|
||||
// (a rule written the Windows way, `kwrite.exe`, names the same program)
|
||||
#[test]
|
||||
fn an_exe_suffix_in_a_rule_id_is_ignored() {
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Exe,
|
||||
"kwrite.exe",
|
||||
Some(MatchingStrategy::Equals)
|
||||
)));
|
||||
assert!(matches(&id(ApplicationIdentifier::Exe, "kwrite.exe", None)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rule_without_a_strategy_or_with_legacy_is_the_old_one() {
|
||||
for strategy in [None, Some(MatchingStrategy::Legacy)] {
|
||||
// title and class: starts or ends with the id
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Title,
|
||||
"komorebi-e2e",
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Title,
|
||||
"rule target",
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(!matches(&id(
|
||||
ApplicationIdentifier::Title,
|
||||
"e2e: rule",
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Class,
|
||||
"org.kde",
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Class,
|
||||
"kwrite",
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(!matches(&id(
|
||||
ApplicationIdentifier::Class,
|
||||
"kde.kw",
|
||||
strategy.clone()
|
||||
)));
|
||||
// exe and path: equal to the id
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Exe,
|
||||
EXE,
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(!matches(&id(
|
||||
ApplicationIdentifier::Exe,
|
||||
"kwri",
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(matches(&id(
|
||||
ApplicationIdentifier::Path,
|
||||
PATH,
|
||||
strategy.clone()
|
||||
)));
|
||||
assert!(!matches(&id(
|
||||
ApplicationIdentifier::Path,
|
||||
"/usr/bin",
|
||||
strategy.clone()
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: rules / a window an ignore rule matches is not managed (which window)
|
||||
#[test]
|
||||
fn a_simple_rule_is_matched_by_one_condition_and_a_composite_by_all_of_them() {
|
||||
let title = id(
|
||||
ApplicationIdentifier::Title,
|
||||
TITLE,
|
||||
Some(MatchingStrategy::Equals),
|
||||
);
|
||||
let class = id(
|
||||
ApplicationIdentifier::Class,
|
||||
CLASS,
|
||||
Some(MatchingStrategy::Equals),
|
||||
);
|
||||
let other = id(
|
||||
ApplicationIdentifier::Exe,
|
||||
"not-kwrite",
|
||||
Some(MatchingStrategy::Equals),
|
||||
);
|
||||
|
||||
let both = MatchingRule::Composite(vec![title.clone(), class.clone()]);
|
||||
let one_wrong = MatchingRule::Composite(vec![title.clone(), other.clone()]);
|
||||
let regex = no_regex();
|
||||
|
||||
assert_eq!(
|
||||
should_act(
|
||||
TITLE,
|
||||
EXE,
|
||||
&[CLASS],
|
||||
PATH,
|
||||
std::slice::from_ref(&both),
|
||||
®ex
|
||||
),
|
||||
Some(both.clone())
|
||||
);
|
||||
assert_eq!(
|
||||
should_act(TITLE, EXE, &[CLASS], PATH, &[one_wrong], ®ex),
|
||||
None
|
||||
);
|
||||
assert_eq!(
|
||||
should_act(
|
||||
TITLE,
|
||||
EXE,
|
||||
&[CLASS],
|
||||
PATH,
|
||||
&[MatchingRule::Simple(title.clone())],
|
||||
®ex
|
||||
),
|
||||
Some(MatchingRule::Simple(title))
|
||||
);
|
||||
}
|
||||
|
||||
// mirrors: rules / a rule that is not initial sends the window back at the next event (which
|
||||
// of two rules wins)
|
||||
#[test]
|
||||
fn of_two_rules_that_match_the_last_one_is_the_answer() {
|
||||
let first = simple(
|
||||
ApplicationIdentifier::Class,
|
||||
CLASS,
|
||||
MatchingStrategy::Equals,
|
||||
);
|
||||
let last = simple(
|
||||
ApplicationIdentifier::Title,
|
||||
"komorebi-e2e",
|
||||
MatchingStrategy::StartsWith,
|
||||
);
|
||||
let rules = [first.clone(), last.clone()];
|
||||
assert_eq!(
|
||||
should_act_window(TITLE, EXE, CLASS, PATH, &rules, &no_regex()),
|
||||
Some(last)
|
||||
);
|
||||
assert_eq!(
|
||||
should_act_window(TITLE, EXE, CLASS, PATH, &[first.clone()], &no_regex()),
|
||||
Some(first)
|
||||
);
|
||||
}
|
||||
|
||||
// mirrors: rules / once the rules are cleared, a window they matched stays on the workspace in view
|
||||
#[test]
|
||||
fn no_rules_match_nothing() {
|
||||
assert_eq!(
|
||||
should_act_window(TITLE, EXE, CLASS, PATH, &[], &no_regex()),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
// mirrors: title_rule / a window the ignore rule matches by its title is left alone
|
||||
// mirrors: title_rule / it gives itself another title (the same rule no longer matches)
|
||||
#[test]
|
||||
fn a_rule_by_title_follows_the_title_it_is_asked_about() {
|
||||
let rule = simple(
|
||||
ApplicationIdentifier::Title,
|
||||
"secret",
|
||||
MatchingStrategy::Contains,
|
||||
);
|
||||
let ask =
|
||||
|title: &str| should_act_window(title, EXE, CLASS, PATH, &[rule.clone()], &no_regex());
|
||||
assert!(ask("a secret window").is_some());
|
||||
assert!(ask("a renamed window").is_none());
|
||||
}
|
||||
|
||||
fn added(id: u32) -> WindowManagerEvent {
|
||||
WindowManagerEvent::Show(
|
||||
SystemNotification::KWin(KWinNotification::WindowAdded),
|
||||
Window::from(id),
|
||||
)
|
||||
}
|
||||
|
||||
// mirrors: manage_rules / a window an ignore rule by <kind> matches is not managed
|
||||
// mirrors: manage_rules / with a manage rule by <kind> too, a window it matches is managed
|
||||
// mirrors: manage_rules / ... and tiled: <base> gives it room
|
||||
#[test]
|
||||
fn a_manage_rule_rescues_a_window_an_ignore_rule_covers() {
|
||||
let fake = Arc::new(FakeBackend::with_one_monitor());
|
||||
let (_sender, receiver) = crossbeam_channel::bounded(1);
|
||||
let socket = std::path::PathBuf::from(format!("/tmp/kmr-{}.sock", std::process::id()));
|
||||
let mut wm = with_backend(fake.clone(), || {
|
||||
let mut wm = WindowManager::new(receiver, Some(socket)).unwrap();
|
||||
wm.init().unwrap();
|
||||
wm
|
||||
});
|
||||
|
||||
fake.open_window(10_901, "kwrite", "org.kde.kwrite", "ignored window");
|
||||
fake.open_window(10_902, "kwrite", "org.kde.kwrite", "rescued window");
|
||||
|
||||
let send = |wm: &mut WindowManager, message| {
|
||||
with_backend(fake.clone(), || wm.process_command(message, Vec::new())).unwrap();
|
||||
};
|
||||
// the rule tables are process-wide and this is the only test of this file that adds to them
|
||||
send(
|
||||
&mut wm,
|
||||
SocketMessage::IgnoreRule(ApplicationIdentifier::Class, "org.kde.kwrite".to_string()),
|
||||
);
|
||||
|
||||
with_backend(fake.clone(), || wm.process_event(added(10_901))).unwrap();
|
||||
assert!(!wm.focused_workspace().unwrap().contains_window(10_901));
|
||||
|
||||
send(
|
||||
&mut wm,
|
||||
SocketMessage::ManageRule(ApplicationIdentifier::Title, "rescued window".to_string()),
|
||||
);
|
||||
with_backend(fake.clone(), || wm.process_event(added(10_902))).unwrap();
|
||||
|
||||
assert!(wm.focused_workspace().unwrap().contains_window(10_902));
|
||||
assert!(!wm.focused_workspace().unwrap().contains_window(10_901));
|
||||
}
|
||||
@@ -13,8 +13,6 @@ use komorebi::core::config_generation::MatchingRule;
|
||||
use komorebi::core::config_generation::MatchingStrategy;
|
||||
use komorebi::state::GlobalState;
|
||||
use komorebi::transparency_manager;
|
||||
use komorebi::transparency_manager::TRANSPARENCY_ALPHA;
|
||||
use komorebi::transparency_manager::TRANSPARENCY_ENABLED;
|
||||
use komorebi::window::Window;
|
||||
use komorebi::window_manager::WindowManager;
|
||||
use komorebi::window_manager_event::KWinNotification;
|
||||
@@ -75,8 +73,10 @@ static TRANSPARENCY: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
/// The settings are process-wide, as they are on Windows: one test at a time, from the defaults
|
||||
fn transparency_settings() -> std::sync::MutexGuard<'static, ()> {
|
||||
let guard = TRANSPARENCY.lock().unwrap_or_else(|e| e.into_inner());
|
||||
TRANSPARENCY_ENABLED.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
TRANSPARENCY_ALPHA.store(200, std::sync::atomic::Ordering::SeqCst);
|
||||
komorebi::settings::settings().update(|settings| {
|
||||
settings.shared.transparency.enabled = false;
|
||||
settings.shared.transparency.alpha = 200;
|
||||
});
|
||||
TRANSPARENCY_BLACKLIST.lock().clear();
|
||||
guard
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ use komorebi::backend::with_backend;
|
||||
use komorebi::core::SocketMessage;
|
||||
use komorebi::static_config::StaticConfig;
|
||||
use komorebi::static_config::StaticConfigExt;
|
||||
use komorebi::transparency_manager;
|
||||
use komorebi::window::Window;
|
||||
use komorebi::window_manager::WindowManager;
|
||||
use komorebi::window_manager_event::KWinNotification;
|
||||
@@ -22,7 +21,6 @@ use parking_lot::Mutex;
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
fn write_config(name: &str, json: &str) -> PathBuf {
|
||||
let path = PathBuf::from(format!(
|
||||
@@ -61,9 +59,9 @@ fn the_transparency_keys_of_the_file_are_the_transparency_settings() {
|
||||
with_backend(fake.clone(), || StaticConfig::postload(&path, &wm)).unwrap();
|
||||
let _ = std::fs::remove_file(&socket);
|
||||
|
||||
assert!(transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst));
|
||||
assert!(komorebi::settings::transparency_enabled());
|
||||
assert_eq!(
|
||||
transparency_manager::TRANSPARENCY_ALPHA.load(Ordering::SeqCst),
|
||||
komorebi::settings::transparency_alpha(),
|
||||
120
|
||||
);
|
||||
|
||||
@@ -98,9 +96,9 @@ fn the_transparency_keys_of_the_file_are_the_transparency_settings() {
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
assert!(!transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst));
|
||||
assert!(!komorebi::settings::transparency_enabled());
|
||||
assert_eq!(
|
||||
transparency_manager::TRANSPARENCY_ALPHA.load(Ordering::SeqCst),
|
||||
komorebi::settings::transparency_alpha(),
|
||||
200
|
||||
);
|
||||
assert_eq!(fake.opacity_of(46_002), 255, "opaque again");
|
||||
|
||||
@@ -88,6 +88,66 @@ crate = "version-macos"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-backend"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-bar"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-bar-core"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-client"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-collections"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-config"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-core"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-protocol"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-settings"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebi-transport"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebic"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "komorebic-core"
|
||||
expression = "LicenseRef-Komorebi-2.0"
|
||||
license-files = []
|
||||
|
||||
[[licenses.clarify]]
|
||||
crate = "base16-egui-themes"
|
||||
expression = "MIT"
|
||||
|
||||
Generated
+3
-3
@@ -140,11 +140,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1767581716,
|
||||
"narHash": "sha256-FUbiUzdrGkLou37OGfb4vCLPnqdSIvtmJBxjh2iljiE=",
|
||||
"lastModified": 1793174968,
|
||||
"narHash": "sha256-u5nUf4cewaT36iIzG1s/VECktqUMiZaGF5BsgervsvQ=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "1d3f83babdd21e16bf5cfe0f1efcb4f49ee1bc2c",
|
||||
"rev": "19ecdd08213836b36c4296a3a4f4af5a3d5308db",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -111,6 +111,8 @@
|
||||
|| (builtins.match ".*/docs/.*" path != null)
|
||||
# embedded by include_str! in komorebic
|
||||
|| (pkgs.lib.hasSuffix "/komorebic/src/macos/applications.json" path)
|
||||
# include_str! by the tests of the macOS daemon
|
||||
|| (builtins.match ".*/komorebic/fixtures/.*" path != null)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -141,7 +143,9 @@
|
||||
cargoExtraArgs = "--locked ${packages}";
|
||||
inherit src version;
|
||||
strictDeps = true;
|
||||
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
|
||||
# a constant, so that the dependencies and every check are the same derivations for
|
||||
# every commit; only fullBuild stamps the real one
|
||||
COMMIT_HASH = "nix-check";
|
||||
nativeBuildInputs = [
|
||||
pkgs.darwin.cctools
|
||||
];
|
||||
@@ -169,6 +173,7 @@
|
||||
individualCrateArgs
|
||||
// {
|
||||
pname = "komorebi-workspace";
|
||||
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown"));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -254,7 +259,24 @@
|
||||
checks = {
|
||||
komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs;
|
||||
|
||||
komorebi-workspace-fmt = build.craneLib.cargoFmt (build.workspaceArgs // { inherit (build) src; cargoExtraArgs = build.packages; });
|
||||
# rustfmt over the macOS files only, with the nightly rustfmt this tree's rustfmt.toml
|
||||
# needs and the 2024 edition of the manifests. `cargo fmt` would follow the `mod windows;`
|
||||
# of the shared entry files (komorebi-bar, komorebi-client), which the macOS source does
|
||||
# not have. The entry files of the shared crates are not checked; their macos modules are.
|
||||
komorebi-workspace-fmt =
|
||||
pkgs.runCommand "komorebi-workspace-fmt"
|
||||
{
|
||||
nativeBuildInputs = [ nightlyRustfmt ];
|
||||
src = build.real;
|
||||
}
|
||||
''
|
||||
cd $src
|
||||
files=$( { find komorebi-for-mac -name '*.rs'; \
|
||||
find komorebic/src/macos komorebi-bar/src/macos -name '*.rs'; \
|
||||
echo komorebi-client/src/macos.rs; } )
|
||||
rustfmt --edition 2024 --config-path komorebi-for-mac/rustfmt.toml --check $files
|
||||
touch $out
|
||||
'';
|
||||
|
||||
komorebi-workspace-toml-fmt = build.craneLib.taploFmt (
|
||||
build.workspaceArgs
|
||||
|
||||
@@ -9,10 +9,17 @@ komorebi-themes = { path = "../../komorebi-themes" }
|
||||
komorebi-backend = { path = "../../crates/komorebi-backend" }
|
||||
komorebi-collections = { path = "../../crates/komorebi-collections" }
|
||||
komorebi-core = { path = "../../crates/komorebi-core" }
|
||||
komorebi-layouts = { path = "../../komorebi-layouts", features = ["darwin", "schemars"] }
|
||||
komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = ["schemars"] }
|
||||
komorebi-layouts = { path = "../../komorebi-layouts", features = [
|
||||
"darwin",
|
||||
"schemars",
|
||||
] }
|
||||
komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = [
|
||||
"schemars",
|
||||
] }
|
||||
komorebi-settings = { path = "../../crates/komorebi-settings" }
|
||||
komorebi-protocol = { path = "../../crates/komorebi-protocol", default-features = false, features = ["schemars"] }
|
||||
komorebi-protocol = { path = "../../crates/komorebi-protocol", default-features = false, features = [
|
||||
"schemars",
|
||||
] }
|
||||
komorebi-transport = { path = "../../crates/komorebi-transport" }
|
||||
quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" }
|
||||
version = { package = "version-macos", path = "../version" }
|
||||
@@ -118,7 +125,9 @@ regex = "1"
|
||||
reqwest = { version = "0.12", features = ["blocking"] }
|
||||
schemars = { version = "1.1", optional = true }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = { package = "serde_json_lenient", version = "0.2", features = ["preserve_order"] }
|
||||
serde_json = { package = "serde_json_lenient", version = "0.2", features = [
|
||||
"preserve_order",
|
||||
] }
|
||||
serde_with = { version = "3", features = ["schemars_1"] }
|
||||
shadow-rs = { version = "1" }
|
||||
strum = { version = "0.28", features = ["derive"] }
|
||||
@@ -134,7 +143,11 @@ uuid = { version = "1", features = ["v4"] }
|
||||
[features]
|
||||
default = ["schemars"]
|
||||
deadlock_detection = ["parking_lot/deadlock_detection"]
|
||||
schemars = ["dep:schemars", "komorebi-collections/schemars", "komorebi-core/schemars"]
|
||||
schemars = [
|
||||
"dep:schemars",
|
||||
"komorebi-collections/schemars",
|
||||
"komorebi-core/schemars",
|
||||
]
|
||||
|
||||
[lib]
|
||||
name = "komorebi"
|
||||
@@ -1,13 +1,7 @@
|
||||
use crate::core::animation::AnimationStyle;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
pub use prefix::AnimationPrefix;
|
||||
pub use komorebi_config::animation::PerAnimationPrefixConfig;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
@@ -35,27 +29,6 @@ pub const DEFAULT_ANIMATION_FPS: u64 = 60;
|
||||
/// How many operations have asked for animations to be skipped for as long as they run
|
||||
static ANIMATIONS_SUSPENDED: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub static ANIMATION_STYLE_GLOBAL: LazyLock<Arc<Mutex<AnimationStyle>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(DEFAULT_ANIMATION_STYLE)));
|
||||
|
||||
pub static ANIMATION_ENABLED_GLOBAL: LazyLock<Arc<AtomicBool>> =
|
||||
LazyLock::new(|| Arc::new(AtomicBool::new(DEFAULT_ANIMATION_ENABLED)));
|
||||
|
||||
pub static ANIMATION_DURATION_GLOBAL: LazyLock<Arc<AtomicU64>> =
|
||||
LazyLock::new(|| Arc::new(AtomicU64::new(DEFAULT_ANIMATION_DURATION)));
|
||||
|
||||
pub static ANIMATION_STYLE_PER_ANIMATION: LazyLock<
|
||||
Arc<Mutex<HashMap<AnimationPrefix, AnimationStyle>>>,
|
||||
> = LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
|
||||
|
||||
pub static ANIMATION_ENABLED_PER_ANIMATION: LazyLock<Arc<Mutex<HashMap<AnimationPrefix, bool>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
|
||||
|
||||
pub static ANIMATION_DURATION_PER_ANIMATION: LazyLock<Arc<Mutex<HashMap<AnimationPrefix, u64>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
|
||||
|
||||
pub static ANIMATION_FPS: AtomicU64 = AtomicU64::new(DEFAULT_ANIMATION_FPS);
|
||||
|
||||
/// Skips animations for as long as the guard is held
|
||||
///
|
||||
/// Some operations, such as stacking windows, rearrange a workspace in a way that animating would
|
||||
@@ -81,29 +54,16 @@ pub fn motion_for(prefix: AnimationPrefix) -> Option<MotionSpec> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let enabled = ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&prefix)
|
||||
.copied()
|
||||
.unwrap_or_else(|| ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst));
|
||||
|
||||
if !enabled {
|
||||
return None;
|
||||
}
|
||||
// one snapshot: enabled, duration and style are read from the same configuration
|
||||
let motion = crate::settings::settings()
|
||||
.snapshot()
|
||||
.shared
|
||||
.animation
|
||||
.motion_for(prefix)?;
|
||||
|
||||
Some(MotionSpec {
|
||||
duration: Duration::from_millis(
|
||||
ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&prefix)
|
||||
.copied()
|
||||
.unwrap_or_else(|| ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst)),
|
||||
),
|
||||
style: ANIMATION_STYLE_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&prefix)
|
||||
.copied()
|
||||
.unwrap_or_else(|| *ANIMATION_STYLE_GLOBAL.lock()),
|
||||
duration: Duration::from_millis(motion.duration_ms),
|
||||
style: motion.style,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -114,7 +74,7 @@ pub fn workspace_transitions_enabled() -> bool {
|
||||
|
||||
/// How long one frame takes, given the configured frames per second
|
||||
pub fn frame_period() -> Duration {
|
||||
let fps = ANIMATION_FPS.load(Ordering::Relaxed).clamp(1, 240);
|
||||
let fps = crate::settings::animation_fps().clamp(1, 240);
|
||||
|
||||
Duration::from_secs_f64(1.0 / fps as f64)
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
#![warn(clippy::all)]
|
||||
|
||||
use clap::Parser;
|
||||
use clap::ValueEnum;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
use crate::CoreFoundationRunLoop;
|
||||
use crate::DATA_DIR;
|
||||
use crate::HOME_DIR;
|
||||
@@ -24,6 +20,10 @@ use crate::theme_manager;
|
||||
use crate::window_manager::WindowManager;
|
||||
use crate::window_manager_event_listener;
|
||||
use crate::workspace_reconciliator;
|
||||
use clap::Parser;
|
||||
use clap::ValueEnum;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
use objc2::MainThreadMarker;
|
||||
use objc2::rc::autoreleasepool;
|
||||
use objc2_app_kit::NSApplication;
|
||||
|
||||
@@ -43,7 +43,6 @@ extern crate komorebi_collections;
|
||||
|
||||
pub use komorebi_collections::ring;
|
||||
|
||||
pub mod daemon;
|
||||
pub mod accessibility;
|
||||
pub mod animation;
|
||||
pub mod app_kit_notification_constants;
|
||||
@@ -54,6 +53,7 @@ pub mod border_manager;
|
||||
pub mod container;
|
||||
pub mod core;
|
||||
pub mod core_graphics;
|
||||
pub mod daemon;
|
||||
pub mod display_reconfiguration_listener;
|
||||
pub mod input_event_listener;
|
||||
pub mod ioreg;
|
||||
|
||||
@@ -9,18 +9,12 @@ use crate::SUBSCRIPTION_SOCKET_OPTIONS;
|
||||
use crate::SUBSCRIPTION_SOCKETS;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::application::Application;
|
||||
use crate::border_manager;
|
||||
use crate::cf_array_as;
|
||||
use crate::core::ApplicationIdentifier;
|
||||
use crate::core::Axis;
|
||||
use crate::core::CycleDirection;
|
||||
use crate::core::Layout;
|
||||
use crate::core::LayoutOptions;
|
||||
use crate::core::MonocleFocusBehaviour;
|
||||
@@ -112,6 +106,422 @@ impl CommandTarget for WindowManager {
|
||||
}
|
||||
|
||||
impl WindowManager {
|
||||
/// Switches the focused workspace between creating a container for a new window and adding it to the focused one
|
||||
pub fn toggle_workspace_window_container_behaviour(&mut self) -> eyre::Result<()> {
|
||||
let current_global_behaviour = self.window_management_behaviour.current_behaviour;
|
||||
if let Some(behaviour) = &mut self.focused_workspace_mut()?.window_container_behaviour {
|
||||
match behaviour {
|
||||
WindowContainerBehaviour::Create => *behaviour = WindowContainerBehaviour::Append,
|
||||
WindowContainerBehaviour::Append => *behaviour = WindowContainerBehaviour::Create,
|
||||
}
|
||||
} else {
|
||||
self.focused_workspace_mut()?.window_container_behaviour =
|
||||
Some(match current_global_behaviour {
|
||||
WindowContainerBehaviour::Create => WindowContainerBehaviour::Append,
|
||||
WindowContainerBehaviour::Append => WindowContainerBehaviour::Create,
|
||||
});
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the column and row ratios of the focused workspace's layout
|
||||
pub fn set_layout_ratios(
|
||||
&mut self,
|
||||
columns: &Option<Vec<f32>>,
|
||||
rows: &Option<Vec<f32>>,
|
||||
) -> eyre::Result<()> {
|
||||
use crate::core::validate_ratios;
|
||||
|
||||
let focused_workspace = self.focused_workspace_mut()?;
|
||||
|
||||
let mut options = focused_workspace.layout_options.unwrap_or(LayoutOptions {
|
||||
scrolling: None,
|
||||
grid: None,
|
||||
column_ratios: None,
|
||||
row_ratios: None,
|
||||
});
|
||||
|
||||
if let Some(cols) = columns {
|
||||
options.column_ratios = Some(validate_ratios(cols));
|
||||
}
|
||||
|
||||
if let Some(rws) = rows {
|
||||
options.row_ratios = Some(validate_ratios(rws));
|
||||
}
|
||||
|
||||
focused_workspace.layout_options = Some(options);
|
||||
self.update_focused_workspace(false, false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Writes the answer to a state query to `reply`
|
||||
pub fn answer_query(
|
||||
&mut self,
|
||||
query: StateQuery,
|
||||
reply: &mut impl std::io::Write,
|
||||
) -> eyre::Result<()> {
|
||||
let response = match query {
|
||||
StateQuery::FocusedMonitorIndex => self.focused_monitor_idx().to_string(),
|
||||
StateQuery::FocusedWorkspaceIndex => self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.focused_workspace_idx()
|
||||
.to_string(),
|
||||
StateQuery::FocusedContainerIndex => self
|
||||
.focused_workspace()?
|
||||
.focused_container_idx()
|
||||
.to_string(),
|
||||
StateQuery::FocusedWindowIndex => {
|
||||
self.focused_container()?.focused_window_idx().to_string()
|
||||
}
|
||||
StateQuery::FocusedWorkspaceName => {
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
focused_monitor
|
||||
.focused_workspace_name()
|
||||
.unwrap_or_else(|| focused_monitor.focused_workspace_idx().to_string())
|
||||
}
|
||||
StateQuery::Version => build::VERSION.to_string(),
|
||||
StateQuery::FocusedWorkspaceLayout => {
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
focused_monitor.focused_workspace_layout().map_or_else(
|
||||
|| "None".to_string(),
|
||||
|layout| match layout {
|
||||
Layout::Default(default_layout) => default_layout.to_string(),
|
||||
},
|
||||
)
|
||||
}
|
||||
StateQuery::FocusedContainerKind => {
|
||||
match self.focused_workspace()?.focused_container() {
|
||||
None => "None".to_string(),
|
||||
Some(container) => {
|
||||
if container.windows().len() > 1 {
|
||||
"Stack".to_string()
|
||||
} else {
|
||||
"Single".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
reply.write_all(response.as_bytes())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Adds a rule that puts the windows matching `id` on a named workspace, if the workspace exists
|
||||
pub fn add_named_workspace_rule(
|
||||
&mut self,
|
||||
identifier: ApplicationIdentifier,
|
||||
id: &str,
|
||||
workspace: &str,
|
||||
) -> eyre::Result<()> {
|
||||
if let Some((monitor_idx, workspace_idx)) = self.monitor_workspace_index_by_name(workspace)
|
||||
{
|
||||
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
|
||||
let workspace_matching_rule = WorkspaceMatchingRule {
|
||||
monitor_index: monitor_idx,
|
||||
workspace_index: workspace_idx,
|
||||
matching_rule: MatchingRule::Simple(IdWithIdentifier {
|
||||
kind: identifier,
|
||||
id: id.to_string(),
|
||||
matching_strategy: Some(MatchingStrategy::Legacy),
|
||||
}),
|
||||
initial_only: false,
|
||||
};
|
||||
|
||||
if !workspace_rules.contains(&workspace_matching_rule) {
|
||||
workspace_rules.push(workspace_matching_rule);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Adds a rule that puts a window matching `id` on a named workspace when it first appears, if the workspace exists
|
||||
pub fn add_initial_named_workspace_rule(
|
||||
&mut self,
|
||||
identifier: ApplicationIdentifier,
|
||||
id: &str,
|
||||
workspace: &str,
|
||||
) -> eyre::Result<()> {
|
||||
if let Some((monitor_idx, workspace_idx)) = self.monitor_workspace_index_by_name(workspace)
|
||||
{
|
||||
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
|
||||
let workspace_matching_rule = WorkspaceMatchingRule {
|
||||
monitor_index: monitor_idx,
|
||||
workspace_index: workspace_idx,
|
||||
matching_rule: MatchingRule::Simple(IdWithIdentifier {
|
||||
kind: identifier,
|
||||
id: id.to_string(),
|
||||
matching_strategy: Some(MatchingStrategy::Legacy),
|
||||
}),
|
||||
initial_only: true,
|
||||
};
|
||||
|
||||
if !workspace_rules.contains(&workspace_matching_rule) {
|
||||
workspace_rules.push(workspace_matching_rule);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the border colour of one kind of window
|
||||
pub fn set_border_colour(&mut self, kind: WindowKind, r: u32, g: u32, b: u32) {
|
||||
match kind {
|
||||
WindowKind::Single => {
|
||||
border_manager::FOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Stack => {
|
||||
border_manager::STACK.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Monocle => {
|
||||
border_manager::MONOCLE.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Unfocused => {
|
||||
border_manager::UNFOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::UnfocusedLocked => {
|
||||
border_manager::UNFOCUSED_LOCKED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Floating => {
|
||||
border_manager::FLOATING.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Focuses the next or previous workspace of the monitor that is focused, or of the monitor the pointer is on when its workspace is empty
|
||||
pub fn cycle_focus_workspace(&mut self, direction: CycleDirection) -> eyre::Result<()> {
|
||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// secondary monitor where the cursor is focused will be used as the target for
|
||||
// the workspace switch op
|
||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||
&& monitor_idx != self.focused_monitor_idx()
|
||||
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||
&& let Some(workspace) = monitor.focused_workspace()
|
||||
&& workspace.is_empty()
|
||||
{
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
let focused_workspace_idx = focused_monitor.focused_workspace_idx();
|
||||
let workspaces = focused_monitor.workspaces().len();
|
||||
|
||||
let workspace_idx = direction.next_idx(
|
||||
focused_workspace_idx,
|
||||
NonZeroUsize::new(workspaces).ok_or_eyre("there must be at least one workspace")?,
|
||||
);
|
||||
|
||||
self.focus_workspace(workspace_idx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Focuses the next or previous empty workspace of the focused monitor, if it has one
|
||||
pub fn cycle_focus_empty_workspace(&mut self, direction: CycleDirection) -> eyre::Result<()> {
|
||||
// TODO: figure out if we need to do this on macOS
|
||||
// // This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// // secondary monitor where the cursor is focused will be used as the target for
|
||||
// // the workspace switch op
|
||||
// if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
||||
// if monitor_idx != self.focused_monitor_idx() {
|
||||
// if let Some(monitor) = self.monitors().get(monitor_idx) {
|
||||
// if let Some(workspace) = monitor.focused_workspace() {
|
||||
// if workspace.is_empty() {
|
||||
// self.focus_monitor(monitor_idx)?;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
let focused_workspace_idx = focused_monitor.focused_workspace_idx();
|
||||
let workspaces = focused_monitor.workspaces().len();
|
||||
|
||||
let mut empty_workspaces = vec![];
|
||||
|
||||
for (idx, w) in focused_monitor.workspaces().iter().enumerate() {
|
||||
if w.is_empty() {
|
||||
empty_workspaces.push(idx);
|
||||
}
|
||||
}
|
||||
|
||||
if !empty_workspaces.is_empty() {
|
||||
let mut workspace_idx = direction.next_idx(
|
||||
focused_workspace_idx,
|
||||
NonZeroUsize::new(workspaces).ok_or_eyre("there must be at least one workspace")?,
|
||||
);
|
||||
|
||||
while !empty_workspaces.contains(&workspace_idx) {
|
||||
workspace_idx = direction.next_idx(
|
||||
workspace_idx,
|
||||
NonZeroUsize::new(workspaces)
|
||||
.ok_or_eyre("there must be at least one workspace")?,
|
||||
);
|
||||
}
|
||||
|
||||
self.focus_workspace(workspace_idx)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Removes the focused workspace when it is empty, unnamed and not the monitor's only one, and focuses the one before it
|
||||
pub fn close_workspace(&mut self) -> eyre::Result<()> {
|
||||
// TODO: figure out if we need to do this on macOS
|
||||
// // This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// // secondary monitor where the cursor is focused will be used as the target for
|
||||
// // the workspace switch op
|
||||
// if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
||||
// if monitor_idx != self.focused_monitor_idx() {
|
||||
// if let Some(monitor) = self.monitors().get(monitor_idx) {
|
||||
// if let Some(workspace) = monitor.focused_workspace() {
|
||||
// if workspace.is_empty() {
|
||||
// self.focus_monitor(monitor_idx)?;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
let mut can_close = false;
|
||||
|
||||
if let Some(monitor) = self.focused_monitor_mut() {
|
||||
let focused_workspace_idx = monitor.focused_workspace_idx();
|
||||
let next_focused_workspace_idx = focused_workspace_idx.saturating_sub(1);
|
||||
|
||||
if let Some(workspace) = monitor.focused_workspace()
|
||||
&& monitor.workspaces().len() > 1
|
||||
&& workspace.containers().is_empty()
|
||||
&& workspace.floating_windows().is_empty()
|
||||
&& workspace.monocle_container.is_none()
|
||||
&& workspace.maximized_window.is_none()
|
||||
&& workspace.name.is_none()
|
||||
{
|
||||
can_close = true;
|
||||
}
|
||||
|
||||
if can_close
|
||||
&& monitor
|
||||
.workspaces_mut()
|
||||
.remove(focused_workspace_idx)
|
||||
.is_some()
|
||||
{
|
||||
self.focus_workspace(next_focused_workspace_idx)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Moves the focused container to the workspace that was focused before this one, and follows it when `follow` is set
|
||||
pub fn move_container_to_last_workspace(&mut self, follow: bool) -> eyre::Result<()> {
|
||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// secondary monitor where the cursor is focused will be used as the target for
|
||||
// the workspace switch op
|
||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||
&& monitor_idx != self.focused_monitor_idx()
|
||||
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||
&& let Some(workspace) = monitor.focused_workspace()
|
||||
&& workspace.is_empty()
|
||||
{
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
let idx = self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.focused_workspace_idx();
|
||||
|
||||
if let Some(monitor) = self.focused_monitor_mut()
|
||||
&& let Some(last_focused_workspace) = monitor.last_focused_workspace
|
||||
{
|
||||
self.move_container_to_workspace(last_focused_workspace, follow, None)?;
|
||||
}
|
||||
|
||||
self.focused_monitor_mut()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.last_focused_workspace = Option::from(idx);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Looks for a window of the executable `exe` on every monitor and workspace, and focuses it
|
||||
pub fn eager_focus(&mut self, exe: &str) -> eyre::Result<()> {
|
||||
let focused_monitor_idx = self.focused_monitor_idx();
|
||||
let mouse_follows_focus = self.mouse_follows_focus;
|
||||
|
||||
let mut window_location = None;
|
||||
let mut monitor_to_focus = None;
|
||||
let mut needs_workspace_loading = false;
|
||||
|
||||
'search: for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
||||
for (workspace_idx, workspace) in monitor.workspaces().iter().enumerate() {
|
||||
if let Some(location) = workspace.location_from_exe(exe) {
|
||||
window_location = Some(location);
|
||||
|
||||
if monitor_idx != focused_monitor_idx {
|
||||
monitor_to_focus = Some(monitor_idx);
|
||||
}
|
||||
|
||||
// Focus workspace if it is not already the focused one, without
|
||||
// loading it so that we don't give focus to the wrong window, we will
|
||||
// load it later after focusing the wanted window
|
||||
let focused_ws_idx = monitor.focused_workspace_idx();
|
||||
if focused_ws_idx != workspace_idx {
|
||||
monitor.last_focused_workspace = Option::from(focused_ws_idx);
|
||||
monitor.focus_workspace(workspace_idx)?;
|
||||
needs_workspace_loading = true;
|
||||
}
|
||||
|
||||
break 'search;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(monitor_idx) = monitor_to_focus {
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
if let Some(location) = window_location {
|
||||
match location {
|
||||
WorkspaceWindowLocation::Monocle(window_idx) => {
|
||||
self.focus_container_window(window_idx)?;
|
||||
}
|
||||
WorkspaceWindowLocation::Maximized => {
|
||||
if let Some(window) = &mut self.focused_workspace_mut()?.maximized_window {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
}
|
||||
}
|
||||
WorkspaceWindowLocation::Container(container_idx, window_idx) => {
|
||||
let focused_container_idx = self.focused_container_idx()?;
|
||||
if container_idx != focused_container_idx {
|
||||
self.focused_workspace_mut()?.focus_container(container_idx);
|
||||
}
|
||||
|
||||
self.focus_container_window(window_idx)?;
|
||||
}
|
||||
WorkspaceWindowLocation::Floating(window_idx) => {
|
||||
if let Some(window) = self
|
||||
.focused_workspace_mut()?
|
||||
.floating_windows_mut()
|
||||
.get_mut(window_idx)
|
||||
{
|
||||
window.focus(mouse_follows_focus)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if needs_workspace_loading {
|
||||
let mouse_follows_focus = self.mouse_follows_focus;
|
||||
if let Some(monitor) = self.focused_monitor_mut() {
|
||||
monitor.load_focused_workspace(mouse_follows_focus)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, reply, message))]
|
||||
pub fn process_command(
|
||||
&mut self,
|
||||
@@ -146,81 +556,7 @@ impl WindowManager {
|
||||
self.focus_container_in_direction(direction)?;
|
||||
self.promote_container_to_front()?
|
||||
}
|
||||
SocketMessage::EagerFocus(ref exe) => {
|
||||
let focused_monitor_idx = self.focused_monitor_idx();
|
||||
let mouse_follows_focus = self.mouse_follows_focus;
|
||||
|
||||
let mut window_location = None;
|
||||
let mut monitor_to_focus = None;
|
||||
let mut needs_workspace_loading = false;
|
||||
|
||||
'search: for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
||||
for (workspace_idx, workspace) in monitor.workspaces().iter().enumerate() {
|
||||
if let Some(location) = workspace.location_from_exe(exe) {
|
||||
window_location = Some(location);
|
||||
|
||||
if monitor_idx != focused_monitor_idx {
|
||||
monitor_to_focus = Some(monitor_idx);
|
||||
}
|
||||
|
||||
// Focus workspace if it is not already the focused one, without
|
||||
// loading it so that we don't give focus to the wrong window, we will
|
||||
// load it later after focusing the wanted window
|
||||
let focused_ws_idx = monitor.focused_workspace_idx();
|
||||
if focused_ws_idx != workspace_idx {
|
||||
monitor.last_focused_workspace = Option::from(focused_ws_idx);
|
||||
monitor.focus_workspace(workspace_idx)?;
|
||||
needs_workspace_loading = true;
|
||||
}
|
||||
|
||||
break 'search;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(monitor_idx) = monitor_to_focus {
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
if let Some(location) = window_location {
|
||||
match location {
|
||||
WorkspaceWindowLocation::Monocle(window_idx) => {
|
||||
self.focus_container_window(window_idx)?;
|
||||
}
|
||||
WorkspaceWindowLocation::Maximized => {
|
||||
if let Some(window) =
|
||||
&mut self.focused_workspace_mut()?.maximized_window
|
||||
{
|
||||
window.focus(mouse_follows_focus)?;
|
||||
}
|
||||
}
|
||||
WorkspaceWindowLocation::Container(container_idx, window_idx) => {
|
||||
let focused_container_idx = self.focused_container_idx()?;
|
||||
if container_idx != focused_container_idx {
|
||||
self.focused_workspace_mut()?.focus_container(container_idx);
|
||||
}
|
||||
|
||||
self.focus_container_window(window_idx)?;
|
||||
}
|
||||
WorkspaceWindowLocation::Floating(window_idx) => {
|
||||
if let Some(window) = self
|
||||
.focused_workspace_mut()?
|
||||
.floating_windows_mut()
|
||||
.get_mut(window_idx)
|
||||
{
|
||||
window.focus(mouse_follows_focus)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if needs_workspace_loading {
|
||||
let mouse_follows_focus = self.mouse_follows_focus;
|
||||
if let Some(monitor) = self.focused_monitor_mut() {
|
||||
monitor.load_focused_workspace(mouse_follows_focus)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SocketMessage::EagerFocus(ref exe) => self.eager_focus(exe)?,
|
||||
SocketMessage::FocusWindow(direction) => {
|
||||
let focused_workspace = self.focused_workspace()?;
|
||||
match focused_workspace.layer {
|
||||
@@ -394,78 +730,10 @@ impl WindowManager {
|
||||
self.update_focused_workspace(self.mouse_follows_focus, true)?;
|
||||
}
|
||||
SocketMessage::CycleFocusWorkspace(direction) => {
|
||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// secondary monitor where the cursor is focused will be used as the target for
|
||||
// the workspace switch op
|
||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||
&& monitor_idx != self.focused_monitor_idx()
|
||||
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||
&& let Some(workspace) = monitor.focused_workspace()
|
||||
&& workspace.is_empty()
|
||||
{
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
let focused_workspace_idx = focused_monitor.focused_workspace_idx();
|
||||
let workspaces = focused_monitor.workspaces().len();
|
||||
|
||||
let workspace_idx = direction.next_idx(
|
||||
focused_workspace_idx,
|
||||
NonZeroUsize::new(workspaces)
|
||||
.ok_or_eyre("there must be at least one workspace")?,
|
||||
);
|
||||
|
||||
self.focus_workspace(workspace_idx)?;
|
||||
self.cycle_focus_workspace(direction)?
|
||||
}
|
||||
SocketMessage::CycleFocusEmptyWorkspace(direction) => {
|
||||
// TODO: figure out if we need to do this on macOS
|
||||
// // This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// // secondary monitor where the cursor is focused will be used as the target for
|
||||
// // the workspace switch op
|
||||
// if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
||||
// if monitor_idx != self.focused_monitor_idx() {
|
||||
// if let Some(monitor) = self.monitors().get(monitor_idx) {
|
||||
// if let Some(workspace) = monitor.focused_workspace() {
|
||||
// if workspace.is_empty() {
|
||||
// self.focus_monitor(monitor_idx)?;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
let focused_workspace_idx = focused_monitor.focused_workspace_idx();
|
||||
let workspaces = focused_monitor.workspaces().len();
|
||||
|
||||
let mut empty_workspaces = vec![];
|
||||
|
||||
for (idx, w) in focused_monitor.workspaces().iter().enumerate() {
|
||||
if w.is_empty() {
|
||||
empty_workspaces.push(idx);
|
||||
}
|
||||
}
|
||||
|
||||
if !empty_workspaces.is_empty() {
|
||||
let mut workspace_idx = direction.next_idx(
|
||||
focused_workspace_idx,
|
||||
NonZeroUsize::new(workspaces)
|
||||
.ok_or_eyre("there must be at least one workspace")?,
|
||||
);
|
||||
|
||||
while !empty_workspaces.contains(&workspace_idx) {
|
||||
workspace_idx = direction.next_idx(
|
||||
workspace_idx,
|
||||
NonZeroUsize::new(workspaces)
|
||||
.ok_or_eyre("there must be at least one workspace")?,
|
||||
);
|
||||
}
|
||||
|
||||
self.focus_workspace(workspace_idx)?;
|
||||
}
|
||||
self.cycle_focus_empty_workspace(direction)?
|
||||
}
|
||||
SocketMessage::FocusMonitorNumber(monitor_idx) => {
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
@@ -560,50 +828,7 @@ impl WindowManager {
|
||||
self.focus_workspace(workspace_idx)?;
|
||||
}
|
||||
}
|
||||
SocketMessage::CloseWorkspace => {
|
||||
// TODO: figure out if we need to do this on macOS
|
||||
// // This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// // secondary monitor where the cursor is focused will be used as the target for
|
||||
// // the workspace switch op
|
||||
// if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
||||
// if monitor_idx != self.focused_monitor_idx() {
|
||||
// if let Some(monitor) = self.monitors().get(monitor_idx) {
|
||||
// if let Some(workspace) = monitor.focused_workspace() {
|
||||
// if workspace.is_empty() {
|
||||
// self.focus_monitor(monitor_idx)?;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
let mut can_close = false;
|
||||
|
||||
if let Some(monitor) = self.focused_monitor_mut() {
|
||||
let focused_workspace_idx = monitor.focused_workspace_idx();
|
||||
let next_focused_workspace_idx = focused_workspace_idx.saturating_sub(1);
|
||||
|
||||
if let Some(workspace) = monitor.focused_workspace()
|
||||
&& monitor.workspaces().len() > 1
|
||||
&& workspace.containers().is_empty()
|
||||
&& workspace.floating_windows().is_empty()
|
||||
&& workspace.monocle_container.is_none()
|
||||
&& workspace.maximized_window.is_none()
|
||||
&& workspace.name.is_none()
|
||||
{
|
||||
can_close = true;
|
||||
}
|
||||
|
||||
if can_close
|
||||
&& monitor
|
||||
.workspaces_mut()
|
||||
.remove(focused_workspace_idx)
|
||||
.is_some()
|
||||
{
|
||||
self.focus_workspace(next_focused_workspace_idx)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
SocketMessage::CloseWorkspace => self.close_workspace()?,
|
||||
|
||||
SocketMessage::MoveContainerToWorkspaceNumber(workspace_idx) => {
|
||||
self.move_container_to_workspace(workspace_idx, true, None)?;
|
||||
@@ -794,25 +1019,7 @@ impl WindowManager {
|
||||
SocketMessage::Retile => self.retile_all(false)?,
|
||||
SocketMessage::RetileWithResizeDimensions => self.retile_all(true)?,
|
||||
SocketMessage::ToggleWorkspaceWindowContainerBehaviour => {
|
||||
let current_global_behaviour = self.window_management_behaviour.current_behaviour;
|
||||
if let Some(behaviour) =
|
||||
&mut self.focused_workspace_mut()?.window_container_behaviour
|
||||
{
|
||||
match behaviour {
|
||||
WindowContainerBehaviour::Create => {
|
||||
*behaviour = WindowContainerBehaviour::Append
|
||||
}
|
||||
WindowContainerBehaviour::Append => {
|
||||
*behaviour = WindowContainerBehaviour::Create
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.focused_workspace_mut()?.window_container_behaviour =
|
||||
Some(match current_global_behaviour {
|
||||
WindowContainerBehaviour::Create => WindowContainerBehaviour::Append,
|
||||
WindowContainerBehaviour::Append => WindowContainerBehaviour::Create,
|
||||
});
|
||||
};
|
||||
self.toggle_workspace_window_container_behaviour()?
|
||||
}
|
||||
SocketMessage::ToggleWorkspaceFloatOverride => {
|
||||
let current_global_override = self.window_management_behaviour.float_override;
|
||||
@@ -861,59 +1068,10 @@ impl WindowManager {
|
||||
self.toggle_tiling()?;
|
||||
}
|
||||
SocketMessage::MoveContainerToLastWorkspace => {
|
||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// secondary monitor where the cursor is focused will be used as the target for
|
||||
// the workspace switch op
|
||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||
&& monitor_idx != self.focused_monitor_idx()
|
||||
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||
&& let Some(workspace) = monitor.focused_workspace()
|
||||
&& workspace.is_empty()
|
||||
{
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
let idx = self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.focused_workspace_idx();
|
||||
|
||||
if let Some(monitor) = self.focused_monitor_mut()
|
||||
&& let Some(last_focused_workspace) = monitor.last_focused_workspace
|
||||
{
|
||||
self.move_container_to_workspace(last_focused_workspace, true, None)?;
|
||||
}
|
||||
|
||||
self.focused_monitor_mut()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.last_focused_workspace = Option::from(idx);
|
||||
self.move_container_to_last_workspace(true)?
|
||||
}
|
||||
SocketMessage::SendContainerToLastWorkspace => {
|
||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||
// secondary monitor where the cursor is focused will be used as the target for
|
||||
// the workspace switch op
|
||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||
&& monitor_idx != self.focused_monitor_idx()
|
||||
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||
&& let Some(workspace) = monitor.focused_workspace()
|
||||
&& workspace.is_empty()
|
||||
{
|
||||
self.focus_monitor(monitor_idx)?;
|
||||
}
|
||||
|
||||
let idx = self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.focused_workspace_idx();
|
||||
|
||||
if let Some(monitor) = self.focused_monitor_mut()
|
||||
&& let Some(last_focused_workspace) = monitor.last_focused_workspace
|
||||
{
|
||||
self.move_container_to_workspace(last_focused_workspace, false, None)?;
|
||||
}
|
||||
self.focused_monitor_mut()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.last_focused_workspace = Option::from(idx);
|
||||
self.move_container_to_last_workspace(false)?;
|
||||
}
|
||||
SocketMessage::CycleMoveContainerToWorkspace(direction) => {
|
||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
@@ -1084,57 +1242,7 @@ impl WindowManager {
|
||||
|
||||
reply.write_all(monitors_state.as_bytes())?;
|
||||
}
|
||||
SocketMessage::Query(query) => {
|
||||
let response = match query {
|
||||
StateQuery::FocusedMonitorIndex => self.focused_monitor_idx().to_string(),
|
||||
StateQuery::FocusedWorkspaceIndex => self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.focused_workspace_idx()
|
||||
.to_string(),
|
||||
StateQuery::FocusedContainerIndex => self
|
||||
.focused_workspace()?
|
||||
.focused_container_idx()
|
||||
.to_string(),
|
||||
StateQuery::FocusedWindowIndex => {
|
||||
self.focused_container()?.focused_window_idx().to_string()
|
||||
}
|
||||
StateQuery::FocusedWorkspaceName => {
|
||||
let focused_monitor =
|
||||
self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
focused_monitor
|
||||
.focused_workspace_name()
|
||||
.unwrap_or_else(|| focused_monitor.focused_workspace_idx().to_string())
|
||||
}
|
||||
StateQuery::Version => build::VERSION.to_string(),
|
||||
StateQuery::FocusedWorkspaceLayout => {
|
||||
let focused_monitor =
|
||||
self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||
|
||||
focused_monitor.focused_workspace_layout().map_or_else(
|
||||
|| "None".to_string(),
|
||||
|layout| match layout {
|
||||
Layout::Default(default_layout) => default_layout.to_string(),
|
||||
},
|
||||
)
|
||||
}
|
||||
StateQuery::FocusedContainerKind => {
|
||||
match self.focused_workspace()?.focused_container() {
|
||||
None => "None".to_string(),
|
||||
Some(container) => {
|
||||
if container.windows().len() > 1 {
|
||||
"Stack".to_string()
|
||||
} else {
|
||||
"Single".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
reply.write_all(response.as_bytes())?;
|
||||
}
|
||||
SocketMessage::Query(query) => self.answer_query(query, &mut reply)?,
|
||||
SocketMessage::SessionFloatRule => {
|
||||
let foreground_window =
|
||||
MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?;
|
||||
@@ -1202,25 +1310,7 @@ impl WindowManager {
|
||||
}
|
||||
}
|
||||
SocketMessage::InitialNamedWorkspaceRule(identifier, ref id, ref workspace) => {
|
||||
if let Some((monitor_idx, workspace_idx)) =
|
||||
self.monitor_workspace_index_by_name(workspace)
|
||||
{
|
||||
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
|
||||
let workspace_matching_rule = WorkspaceMatchingRule {
|
||||
monitor_index: monitor_idx,
|
||||
workspace_index: workspace_idx,
|
||||
matching_rule: MatchingRule::Simple(IdWithIdentifier {
|
||||
kind: identifier,
|
||||
id: id.to_string(),
|
||||
matching_strategy: Some(MatchingStrategy::Legacy),
|
||||
}),
|
||||
initial_only: true,
|
||||
};
|
||||
|
||||
if !workspace_rules.contains(&workspace_matching_rule) {
|
||||
workspace_rules.push(workspace_matching_rule);
|
||||
}
|
||||
}
|
||||
self.add_initial_named_workspace_rule(identifier, id, workspace)?
|
||||
}
|
||||
SocketMessage::WorkspaceRule(identifier, ref id, monitor_idx, workspace_idx) => {
|
||||
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
|
||||
@@ -1240,25 +1330,7 @@ impl WindowManager {
|
||||
}
|
||||
}
|
||||
SocketMessage::NamedWorkspaceRule(identifier, ref id, ref workspace) => {
|
||||
if let Some((monitor_idx, workspace_idx)) =
|
||||
self.monitor_workspace_index_by_name(workspace)
|
||||
{
|
||||
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
|
||||
let workspace_matching_rule = WorkspaceMatchingRule {
|
||||
monitor_index: monitor_idx,
|
||||
workspace_index: workspace_idx,
|
||||
matching_rule: MatchingRule::Simple(IdWithIdentifier {
|
||||
kind: identifier,
|
||||
id: id.to_string(),
|
||||
matching_strategy: Some(MatchingStrategy::Legacy),
|
||||
}),
|
||||
initial_only: false,
|
||||
};
|
||||
|
||||
if !workspace_rules.contains(&workspace_matching_rule) {
|
||||
workspace_rules.push(workspace_matching_rule);
|
||||
}
|
||||
}
|
||||
self.add_named_workspace_rule(identifier, id, workspace)?
|
||||
}
|
||||
SocketMessage::ClearWorkspaceRules(monitor_idx, workspace_idx) => {
|
||||
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
|
||||
@@ -1522,27 +1594,7 @@ impl WindowManager {
|
||||
self.update_focused_workspace(false, false)?;
|
||||
}
|
||||
SocketMessage::LayoutRatios(ref columns, ref rows) => {
|
||||
use crate::core::validate_ratios;
|
||||
|
||||
let focused_workspace = self.focused_workspace_mut()?;
|
||||
|
||||
let mut options = focused_workspace.layout_options.unwrap_or(LayoutOptions {
|
||||
scrolling: None,
|
||||
grid: None,
|
||||
column_ratios: None,
|
||||
row_ratios: None,
|
||||
});
|
||||
|
||||
if let Some(cols) = columns {
|
||||
options.column_ratios = Some(validate_ratios(cols));
|
||||
}
|
||||
|
||||
if let Some(rws) = rows {
|
||||
options.row_ratios = Some(validate_ratios(rws));
|
||||
}
|
||||
|
||||
focused_workspace.layout_options = Some(options);
|
||||
self.update_focused_workspace(false, false)?;
|
||||
self.set_layout_ratios(columns, rows)?
|
||||
}
|
||||
SocketMessage::NamedWorkspaceLayoutRule(ref workspace, at_container_count, layout) => {
|
||||
if let Some((monitor_idx, workspace_idx)) =
|
||||
@@ -1776,27 +1828,7 @@ impl WindowManager {
|
||||
border_manager::destroy_all_borders()?;
|
||||
}
|
||||
}
|
||||
SocketMessage::BorderColour(kind, r, g, b) => match kind {
|
||||
WindowKind::Single => {
|
||||
border_manager::FOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Stack => {
|
||||
border_manager::STACK.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Monocle => {
|
||||
border_manager::MONOCLE.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Unfocused => {
|
||||
border_manager::UNFOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::UnfocusedLocked => {
|
||||
border_manager::UNFOCUSED_LOCKED
|
||||
.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Floating => {
|
||||
border_manager::FLOATING.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
},
|
||||
SocketMessage::BorderColour(kind, r, g, b) => self.set_border_colour(kind, r, g, b),
|
||||
SocketMessage::BorderWidth(width) => {
|
||||
border_manager::BORDER_WIDTH.store(width, Ordering::SeqCst);
|
||||
border_manager::destroy_all_borders()?;
|
||||
@@ -1808,41 +1840,51 @@ impl WindowManager {
|
||||
SocketMessage::Theme(ref theme) => {
|
||||
theme_manager::send_notification(*theme.clone());
|
||||
}
|
||||
SocketMessage::Animation(enable, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(enable, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationDuration(duration, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_DURATION_GLOBAL.store(duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
ANIMATION_FPS.store(fps, Ordering::SeqCst);
|
||||
SocketMessage::Animation(enable, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.enabled_per_animation.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
animation.enabled = enable;
|
||||
animation.enabled_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationDuration(duration, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.duration_per_animation.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
animation.duration = duration;
|
||||
animation.duration_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
crate::settings::settings().update(|settings| settings.shared.animation.fps = fps);
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.style_per_animation.insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
animation.style = style;
|
||||
animation.style_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
// Messages of other platforms: answered, and nothing else happens
|
||||
SocketMessage::AddSubscriberPipe(..)
|
||||
| SocketMessage::AltFocusHack(..)
|
||||
|
||||
@@ -67,6 +67,11 @@ pub fn display_index_preferences() -> HashMap<usize, String> {
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// `animation.fps`.
|
||||
pub fn animation_fps() -> u64 {
|
||||
settings().snapshot().shared.animation.fps
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use komorebi_settings::shared::AnimationDelta;
|
||||
use komorebi_settings::shared::SharedDelta;
|
||||
use crate::CoreFoundationRunLoop;
|
||||
use crate::DATA_DIR;
|
||||
@@ -10,15 +11,6 @@ use crate::REGEX_IDENTIFIERS;
|
||||
use crate::TABBED_APPLICATIONS;
|
||||
use crate::TITLELESS_APPLICATIONS;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::animation::DEFAULT_ANIMATION_FPS;
|
||||
use crate::animation::PerAnimationPrefixConfig;
|
||||
use crate::border_manager;
|
||||
use crate::core::ApplicationIdentifier;
|
||||
use crate::core::CrossBoundaryBehaviour;
|
||||
@@ -421,44 +413,21 @@ impl ApplyGlobals for StaticConfig {
|
||||
// window::MINIMUM_WIDTH.store(width, Ordering::SeqCst);
|
||||
// }
|
||||
|
||||
// the animation block, as one update: a global value clears its per-animation map, a map
|
||||
// replaces the map, and a block without `fps` has the default (`SharedDelta::apply`)
|
||||
if let Some(animations) = &self.animation {
|
||||
match &animations.enabled {
|
||||
PerAnimationPrefixConfig::Prefix(enabled) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clone_from(enabled);
|
||||
crate::settings::settings().update(|settings| {
|
||||
SharedDelta {
|
||||
animation: Some(AnimationDelta {
|
||||
enabled: animations.enabled.clone(),
|
||||
style: animations.style.clone(),
|
||||
duration: animations.duration.clone(),
|
||||
fps: animations.fps,
|
||||
}),
|
||||
..SharedDelta::default()
|
||||
}
|
||||
PerAnimationPrefixConfig::Global(enabled) => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(*enabled, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
}
|
||||
|
||||
match &animations.style {
|
||||
Some(PerAnimationPrefixConfig::Prefix(style)) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clone_from(style);
|
||||
}
|
||||
Some(PerAnimationPrefixConfig::Global(style)) => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = *style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
match &animations.duration {
|
||||
Some(PerAnimationPrefixConfig::Prefix(duration)) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clone_from(duration);
|
||||
}
|
||||
Some(PerAnimationPrefixConfig::Global(duration)) => {
|
||||
ANIMATION_DURATION_GLOBAL.store(*duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
ANIMATION_FPS.store(
|
||||
animations.fps.unwrap_or(DEFAULT_ANIMATION_FPS),
|
||||
Ordering::SeqCst,
|
||||
);
|
||||
.apply(&mut settings.shared);
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(border_width) = self.border_width {
|
||||
|
||||
@@ -551,6 +551,16 @@ impl schemars::JsonSchema for Window {
|
||||
}
|
||||
}
|
||||
|
||||
/// The id of the window that has the focus, if any window does
|
||||
pub fn foreground_window_id() -> Option<u32> {
|
||||
MacosApi::foreground_window_id()
|
||||
}
|
||||
|
||||
/// The id of the monitor the pointer is on
|
||||
pub fn monitor_id_at_cursor() -> Option<u32> {
|
||||
MacosApi::monitor_from_point(MacosApi::cursor_pos())
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(
|
||||
element: CFRetained<AXUIElement>,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::monitor::MonitorExt;
|
||||
use crate::AccessibilityUiElement;
|
||||
use crate::CoreFoundationRunLoop;
|
||||
use crate::DATA_DIR;
|
||||
@@ -41,6 +40,7 @@ use crate::current_space_id;
|
||||
use crate::lockable_sequence::Lockable;
|
||||
use crate::macos_api::MacosApi;
|
||||
use crate::monitor::Monitor;
|
||||
use crate::monitor::MonitorExt;
|
||||
use crate::pan::Pan;
|
||||
use crate::ring::Ring;
|
||||
use crate::scrolling::WorkspaceScrolling;
|
||||
@@ -52,8 +52,10 @@ use crate::window::AdhocWindow;
|
||||
use crate::window::Snapping;
|
||||
use crate::window::Window;
|
||||
use crate::window::dragged_window;
|
||||
use crate::window::foreground_window_id;
|
||||
use crate::window::live_resize_begins;
|
||||
use crate::window::live_resize_ends;
|
||||
use crate::window::monitor_id_at_cursor;
|
||||
use crate::window::should_act_individual;
|
||||
use crate::window_manager_event::ManualNotification;
|
||||
use crate::window_manager_event::SystemNotification;
|
||||
@@ -267,8 +269,7 @@ impl WindowManager {
|
||||
let len = focused_workspace.floating_windows().len();
|
||||
|
||||
if len > 1 {
|
||||
let focused_window_id =
|
||||
MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let focused_rect = Rect::from(MacosApi::window_rect(
|
||||
MacosApi::foreground_window()
|
||||
.ok_or_eyre("no foreground window")?
|
||||
@@ -735,8 +736,7 @@ impl WindowManager {
|
||||
let focused_workspace = self.focused_workspace()?;
|
||||
let delta = self.resize_delta;
|
||||
|
||||
let focused_window_id =
|
||||
MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
for window in focused_workspace.floating_windows().iter() {
|
||||
if window.id == focused_window_id {
|
||||
let mut rect = Rect::from(window.window_rect()?);
|
||||
@@ -1548,7 +1548,8 @@ impl WindowManager {
|
||||
let hiding_position = self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.extra.window_hiding_position;
|
||||
.extra
|
||||
.window_hiding_position;
|
||||
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
workspace.new_monocle_container()?;
|
||||
@@ -1584,7 +1585,8 @@ impl WindowManager {
|
||||
let hiding_position = self
|
||||
.focused_monitor()
|
||||
.ok_or_eyre("there is no monitor")?
|
||||
.extra.window_hiding_position;
|
||||
.extra
|
||||
.window_hiding_position;
|
||||
|
||||
self.focused_workspace_mut()?
|
||||
.cycle_monocle_container(direction)?;
|
||||
@@ -1598,7 +1600,7 @@ impl WindowManager {
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn toggle_float(&mut self, force_float: bool) -> eyre::Result<()> {
|
||||
let window_id = MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
if workspace.monocle_container.is_some() {
|
||||
@@ -1674,7 +1676,7 @@ impl WindowManager {
|
||||
WorkspaceLayer::Floating => {
|
||||
let workspace = self.focused_workspace()?;
|
||||
let focused_window_id =
|
||||
MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
|
||||
let border_offset = 0;
|
||||
let border_width = 0;
|
||||
@@ -2466,7 +2468,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
pub fn monitor_idx_from_current_pos(&mut self) -> Option<usize> {
|
||||
let monitor_id = MacosApi::monitor_from_point(MacosApi::cursor_pos())?;
|
||||
let monitor_id = monitor_id_at_cursor()?;
|
||||
|
||||
for (i, monitor) in self.monitors().iter().enumerate() {
|
||||
if monitor.id == monitor_id {
|
||||
@@ -2570,8 +2572,7 @@ impl WindowManager {
|
||||
eyre::bail!("cannot move native maximized window to another monitor or workspace");
|
||||
}
|
||||
|
||||
let foreground_window_id =
|
||||
MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let foreground_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let floating_window_index = workspace
|
||||
.floating_windows()
|
||||
.iter()
|
||||
@@ -2836,8 +2837,7 @@ impl WindowManager {
|
||||
let len = focused_workspace.floating_windows().len();
|
||||
|
||||
if len > 1 {
|
||||
let focused_window_id =
|
||||
MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
let focused_window_id = foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
for (idx, window) in focused_workspace.floating_windows().iter().enumerate() {
|
||||
if window.id == focused_window_id {
|
||||
match direction {
|
||||
@@ -3270,7 +3270,7 @@ impl WindowManager {
|
||||
) {
|
||||
let workspace = self.focused_workspace()?;
|
||||
let focused_hwnd =
|
||||
MacosApi::foreground_window_id().ok_or_eyre("there is no foreground window")?;
|
||||
foreground_window_id().ok_or_eyre("there is no foreground window")?;
|
||||
if !workspace.contains_managed_window(focused_hwnd) {
|
||||
bail!("ignoring commands while active window is not managed by komorebi");
|
||||
}
|
||||
@@ -3675,7 +3675,7 @@ impl WindowManager {
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn manage_focused_window(&mut self) -> eyre::Result<()> {
|
||||
let element = MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?;
|
||||
let window_id = MacosApi::foreground_window_id();
|
||||
let window_id = foreground_window_id();
|
||||
if let Some(process_id) = AdhocWindow::process_id(&element)
|
||||
&& let Some(event) = WindowManagerEvent::from_system_notification(
|
||||
SystemNotification::Manual(ManualNotification::Manage),
|
||||
@@ -3696,7 +3696,7 @@ impl WindowManager {
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn unmanage_focused_window(&mut self) -> eyre::Result<()> {
|
||||
let element = MacosApi::foreground_window().ok_or_eyre("there is no foreground window")?;
|
||||
let window_id = MacosApi::foreground_window_id();
|
||||
let window_id = foreground_window_id();
|
||||
if let Some(process_id) = AdhocWindow::process_id(&element)
|
||||
&& let Some(event) = WindowManagerEvent::from_system_notification(
|
||||
SystemNotification::Manual(ManualNotification::Unmanage),
|
||||
@@ -4033,18 +4033,26 @@ mod tests {
|
||||
|
||||
impl AnimationsOn {
|
||||
fn new() -> Self {
|
||||
animation::ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(AnimationPrefix::Movement, true);
|
||||
crate::settings::settings().update(|settings| {
|
||||
settings
|
||||
.shared
|
||||
.animation
|
||||
.enabled_per_animation
|
||||
.insert(AnimationPrefix::Movement, true);
|
||||
});
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for AnimationsOn {
|
||||
fn drop(&mut self) {
|
||||
animation::ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.remove(&AnimationPrefix::Movement);
|
||||
crate::settings::settings().update(|settings| {
|
||||
settings
|
||||
.shared
|
||||
.animation
|
||||
.enabled_per_animation
|
||||
.remove(&AnimationPrefix::Movement);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ description = "The command-line interface for Komorebi, a tiling window manager
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = ["schemars"] }
|
||||
komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = [
|
||||
"schemars",
|
||||
] }
|
||||
komorebi-client = { package = "komorebi-client-macos", path = "../komorebi-client", default-features = false }
|
||||
komorebic-core = { path = "../../crates/komorebic-core" }
|
||||
version = { package = "version-macos", path = "../version" }
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
//! What the `layouts`, `flipping`, `layout_flip`, `padding` and `tiling` end-to-end scenarios
|
||||
//! assert about where the layout puts the windows, asserted on the arithmetic alone: every layout,
|
||||
//! with every count of windows the scenarios use (and more), is inside the work area, with no
|
||||
//! window over another, and mirrored by a flip.
|
||||
//!
|
||||
//! Not covered here, and so still end-to-end: that a daemon takes the layout's rectangles to the
|
||||
//! operating system and that the operating system's frames agree with them (border widths, client
|
||||
//! rounding, timing).
|
||||
|
||||
use komorebi_layouts::Arrangement;
|
||||
use komorebi_layouts::Axis;
|
||||
use komorebi_layouts::DefaultLayout;
|
||||
use komorebi_layouts::Rect;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
/// The layouts the `layouts` scenario goes through (its `LAYOUTS`).
|
||||
const LAYOUTS: [DefaultLayout; 8] = [
|
||||
DefaultLayout::BSP,
|
||||
DefaultLayout::Columns,
|
||||
DefaultLayout::Rows,
|
||||
DefaultLayout::VerticalStack,
|
||||
DefaultLayout::HorizontalStack,
|
||||
DefaultLayout::UltrawideVerticalStack,
|
||||
DefaultLayout::Grid,
|
||||
DefaultLayout::RightMainVerticalStack,
|
||||
];
|
||||
|
||||
/// The layouts that tile the whole of the work area (`Grid` leaves a gap with a count it cannot
|
||||
/// fill with whole cells).
|
||||
fn fills_the_area(layout: DefaultLayout) -> bool {
|
||||
layout != DefaultLayout::Grid
|
||||
}
|
||||
|
||||
const AREAS: [Rect; 3] = [
|
||||
Rect {
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 1920,
|
||||
bottom: 1080,
|
||||
},
|
||||
// a work area that is not at the origin, as one of a second monitor is
|
||||
Rect {
|
||||
left: 1920,
|
||||
top: 40,
|
||||
right: 1280,
|
||||
bottom: 984,
|
||||
},
|
||||
// one that is not a nice number
|
||||
Rect {
|
||||
left: -1366,
|
||||
top: 0,
|
||||
right: 1366,
|
||||
bottom: 728,
|
||||
},
|
||||
];
|
||||
|
||||
fn tiles(
|
||||
layout: DefaultLayout,
|
||||
area: &Rect,
|
||||
count: usize,
|
||||
padding: Option<i32>,
|
||||
flip: Option<Axis>,
|
||||
) -> Vec<Rect> {
|
||||
layout.calculate(
|
||||
area,
|
||||
NonZeroUsize::new(count).unwrap(),
|
||||
padding,
|
||||
flip,
|
||||
&[],
|
||||
0,
|
||||
None,
|
||||
&[],
|
||||
)
|
||||
}
|
||||
|
||||
fn inside(r: &Rect, area: &Rect) -> bool {
|
||||
r.left >= area.left
|
||||
&& r.top >= area.top
|
||||
&& r.left + r.right <= area.left + area.right
|
||||
&& r.top + r.bottom <= area.top + area.bottom
|
||||
}
|
||||
|
||||
fn overlap(a: &Rect, b: &Rect) -> bool {
|
||||
a.left < b.left + b.right
|
||||
&& b.left < a.left + a.right
|
||||
&& a.top < b.top + b.bottom
|
||||
&& b.top < a.top + a.bottom
|
||||
}
|
||||
|
||||
fn area_of(r: &Rect) -> i64 {
|
||||
i64::from(r.right) * i64::from(r.bottom)
|
||||
}
|
||||
|
||||
/// `r` mirrored in `area` along `axis`.
|
||||
fn mirrored(r: &Rect, area: &Rect, axis: Axis) -> Rect {
|
||||
let mut m = *r;
|
||||
if matches!(axis, Axis::Horizontal | Axis::HorizontalAndVertical) {
|
||||
m.left = area.left + (area.left + area.right) - (r.left + r.right);
|
||||
}
|
||||
if matches!(axis, Axis::Vertical | Axis::HorizontalAndVertical) {
|
||||
m.top = area.top + (area.top + area.bottom) - (r.top + r.bottom);
|
||||
}
|
||||
m
|
||||
}
|
||||
|
||||
fn sorted(mut v: Vec<Rect>) -> Vec<Rect> {
|
||||
v.sort_by_key(|r| (r.left, r.top, r.right, r.bottom));
|
||||
v
|
||||
}
|
||||
|
||||
// mirrors: layouts / <layout>, <n> windows: every window is where the layout says
|
||||
#[test]
|
||||
fn every_layout_gives_one_tile_per_window() {
|
||||
for layout in LAYOUTS {
|
||||
for area in &AREAS {
|
||||
for count in 1..=12 {
|
||||
assert_eq!(
|
||||
tiles(layout, area, count, None, None).len(),
|
||||
count,
|
||||
"{layout}, {count} windows"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: layouts / <layout>, <n> windows: ... inside the work area
|
||||
// mirrors: layouts / <layout>, <n> windows: ... and not on each other
|
||||
// mirrors: tiling / <title> is inside the work area; <a> and <b> do not overlap
|
||||
#[test]
|
||||
fn every_layout_keeps_every_tile_inside_the_work_area_and_off_the_others() {
|
||||
for layout in LAYOUTS {
|
||||
for area in &AREAS {
|
||||
for count in 1..=12 {
|
||||
for padding in [None, Some(0), Some(10), Some(30)] {
|
||||
let t = tiles(layout, area, count, padding, None);
|
||||
for (i, r) in t.iter().enumerate() {
|
||||
assert!(
|
||||
inside(r, area),
|
||||
"{layout}, {count} windows, padding {padding:?}: tile {i} {r:?} is outside {area:?}"
|
||||
);
|
||||
// BSP halves a tile per window: past eight windows, with padding on each
|
||||
// side, a tile of a 1080 px high area is legitimately nothing
|
||||
assert!(
|
||||
count > 8 || r.right > 0 && r.bottom > 0,
|
||||
"{layout}, {count} windows, padding {padding:?}: tile {i} {r:?} is empty"
|
||||
);
|
||||
for (j, o) in t.iter().enumerate().skip(i + 1) {
|
||||
assert!(
|
||||
!overlap(r, o),
|
||||
"{layout}, {count} windows, padding {padding:?}: tiles {i} {r:?} and {j} {o:?} overlap"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: tiling / the windows share the work area: none takes all of its width
|
||||
// mirrors: closing / the windows that are left take more room between them
|
||||
#[test]
|
||||
fn without_padding_the_tiles_fill_the_work_area_and_fewer_windows_get_more_room() {
|
||||
for layout in LAYOUTS.into_iter().filter(|l| fills_the_area(*l)) {
|
||||
for area in &AREAS {
|
||||
for count in 1..=12 {
|
||||
let t = tiles(layout, area, count, None, None);
|
||||
let total: i64 = t.iter().map(area_of).sum();
|
||||
assert_eq!(
|
||||
total,
|
||||
area_of(area),
|
||||
"{layout}, {count} windows leave a gap in {area:?}: {t:?}"
|
||||
);
|
||||
}
|
||||
// one window fewer: each of the others has at least as much room on average
|
||||
for count in 2..=12 {
|
||||
let more = tiles(layout, area, count - 1, None, None);
|
||||
let less = tiles(layout, area, count, None, None);
|
||||
let biggest = |v: &[Rect]| v.iter().map(area_of).max().unwrap();
|
||||
assert!(
|
||||
biggest(&more) >= biggest(&less),
|
||||
"{layout}: {count} windows has a bigger tile than {} windows",
|
||||
count - 1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: layouts / <layout>, 1 windows: ... (a single window has the whole work area, less
|
||||
// padding)
|
||||
#[test]
|
||||
fn a_single_window_has_the_work_area_less_the_container_padding() {
|
||||
for layout in LAYOUTS {
|
||||
for area in &AREAS {
|
||||
assert_eq!(tiles(layout, area, 1, None, None), vec![*area], "{layout}");
|
||||
let p = 10;
|
||||
let t = tiles(layout, area, 1, Some(p), None);
|
||||
assert_eq!(
|
||||
t,
|
||||
vec![Rect {
|
||||
left: area.left + p,
|
||||
top: area.top + p,
|
||||
right: area.right - 2 * p,
|
||||
bottom: area.bottom - 2 * p,
|
||||
}],
|
||||
"{layout}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: padding / a container padding 30 px more leaves the windows less room
|
||||
// mirrors: padding / with the padding as it was, the windows ... have the room they had
|
||||
#[test]
|
||||
fn container_padding_takes_room_from_every_tile_and_taking_it_away_gives_it_back() {
|
||||
for layout in LAYOUTS {
|
||||
let area = &AREAS[0];
|
||||
for count in 1..=8 {
|
||||
let plain = tiles(layout, area, count, None, None);
|
||||
let padded = tiles(layout, area, count, Some(30), None);
|
||||
for (i, (a, b)) in plain.iter().zip(&padded).enumerate() {
|
||||
assert!(
|
||||
area_of(b) < area_of(a),
|
||||
"{layout}, {count} windows: tile {i} did not shrink: {a:?} -> {b:?}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
plain,
|
||||
tiles(layout, area, count, None, None),
|
||||
"{layout}: deterministic"
|
||||
);
|
||||
assert_eq!(
|
||||
plain,
|
||||
tiles(layout, area, count, Some(0), None),
|
||||
"{layout}, {count} windows: padding 0 is no padding"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: flipping / after 'flip-layout horizontal' every window is where the mirror of its place is
|
||||
// mirrors: flipping / flipped again, every window is where it was
|
||||
// mirrors: layout_flip / <label>: flipped along both axes
|
||||
#[test]
|
||||
fn a_flipped_layout_is_the_layout_mirrored_as_a_set_of_tiles() {
|
||||
for layout in LAYOUTS {
|
||||
for area in &AREAS {
|
||||
for count in 1..=8 {
|
||||
for axis in [
|
||||
Axis::Horizontal,
|
||||
Axis::Vertical,
|
||||
Axis::HorizontalAndVertical,
|
||||
] {
|
||||
let plain = tiles(layout, area, count, None, None);
|
||||
let flipped = tiles(layout, area, count, None, Some(axis));
|
||||
let want: Vec<Rect> = plain.iter().map(|r| mirrored(r, area, axis)).collect();
|
||||
assert_eq!(
|
||||
sorted(flipped),
|
||||
sorted(want),
|
||||
"{layout}, {count} windows, flip {axis}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: layout_flip / <label>: ... the windows have only gone from top to bottom
|
||||
#[test]
|
||||
fn a_vertical_flip_only_moves_a_tile_up_or_down() {
|
||||
for layout in LAYOUTS {
|
||||
let area = &AREAS[0];
|
||||
for count in 1..=8 {
|
||||
let plain = tiles(layout, area, count, None, None);
|
||||
let flipped = tiles(layout, area, count, None, Some(Axis::Vertical));
|
||||
// the same widths and the same columns: each tile has a partner at the same left and width
|
||||
let columns = |v: &[Rect]| {
|
||||
sorted(
|
||||
v.iter()
|
||||
.map(|r| Rect {
|
||||
left: r.left,
|
||||
top: 0,
|
||||
right: r.right,
|
||||
bottom: 0,
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
};
|
||||
assert_eq!(
|
||||
columns(&plain),
|
||||
columns(&flipped),
|
||||
"{layout}, {count} windows"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mirrors: layouts / <layout>, <n> windows: every window is where the layout says (the layout
|
||||
// is the same whenever it is asked for, so the daemon can compare with the OS)
|
||||
#[test]
|
||||
fn the_layout_is_a_function_of_its_arguments() {
|
||||
for layout in LAYOUTS {
|
||||
for count in 1..=8 {
|
||||
let a = tiles(layout, &AREAS[1], count, Some(10), Some(Axis::Horizontal));
|
||||
let b = tiles(layout, &AREAS[1], count, Some(10), Some(Axis::Horizontal));
|
||||
assert_eq!(a, b, "{layout}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,9 @@ use color_eyre::eyre;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::cell::RefCell;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
||||
use super::ANIMATION_DURATION_GLOBAL;
|
||||
use super::ANIMATION_FPS;
|
||||
use super::ANIMATION_MANAGER;
|
||||
use super::RenderDispatcher;
|
||||
|
||||
@@ -32,7 +29,7 @@ impl AnimationEngine {
|
||||
}
|
||||
|
||||
std::thread::sleep(Duration::from_millis(
|
||||
ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst),
|
||||
crate::settings::animation_duration_global(),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -135,7 +132,7 @@ impl AnimationEngine {
|
||||
}
|
||||
|
||||
let target_frame_time =
|
||||
Duration::from_millis(1000 / ANIMATION_FPS.load(Ordering::Relaxed));
|
||||
Duration::from_millis(1000 / crate::settings::animation_fps());
|
||||
let animation_start = Instant::now();
|
||||
|
||||
let mut stats = FrameStats::default();
|
||||
|
||||
@@ -6,7 +6,6 @@ use prefix::AnimationPrefix;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -35,18 +34,6 @@ pub const DEFAULT_GHOST_MOVEMENT: bool = false;
|
||||
lazy_static! {
|
||||
pub static ref ANIMATION_MANAGER: Arc<Mutex<AnimationManager>> =
|
||||
Arc::new(Mutex::new(AnimationManager::new()));
|
||||
pub static ref ANIMATION_STYLE_GLOBAL: Arc<Mutex<AnimationStyle>> =
|
||||
Arc::new(Mutex::new(DEFAULT_ANIMATION_STYLE));
|
||||
pub static ref ANIMATION_ENABLED_GLOBAL: Arc<AtomicBool> =
|
||||
Arc::new(AtomicBool::new(DEFAULT_ANIMATION_ENABLED));
|
||||
pub static ref ANIMATION_DURATION_GLOBAL: Arc<AtomicU64> =
|
||||
Arc::new(AtomicU64::new(DEFAULT_ANIMATION_DURATION));
|
||||
pub static ref ANIMATION_STYLE_PER_ANIMATION: Arc<Mutex<HashMap<AnimationPrefix, AnimationStyle>>> =
|
||||
Arc::new(Mutex::new(HashMap::new()));
|
||||
pub static ref ANIMATION_ENABLED_PER_ANIMATION: Arc<Mutex<HashMap<AnimationPrefix, bool>>> =
|
||||
Arc::new(Mutex::new(HashMap::new()));
|
||||
pub static ref ANIMATION_DURATION_PER_ANIMATION: Arc<Mutex<HashMap<AnimationPrefix, u64>>> =
|
||||
Arc::new(Mutex::new(HashMap::new()));
|
||||
}
|
||||
|
||||
/// Whether the windows of a workspace slide out of a monitor and those of the
|
||||
@@ -87,32 +74,40 @@ fn style_for(
|
||||
|
||||
/// Whether workspaces slide in and out of the monitor when they are switched
|
||||
pub fn workspace_transitions_enabled() -> bool {
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
transitions_enabled_by(
|
||||
GHOST_MOVEMENT_ENABLED.load(Ordering::Relaxed),
|
||||
ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst),
|
||||
&ANIMATION_ENABLED_PER_ANIMATION.lock(),
|
||||
animation.enabled,
|
||||
&animation.enabled_per_animation,
|
||||
)
|
||||
}
|
||||
|
||||
/// How long a workspace takes to slide in and out of a monitor
|
||||
pub fn workspace_transition_duration() -> Duration {
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
duration_for(
|
||||
AnimationPrefix::Workspace,
|
||||
&ANIMATION_DURATION_PER_ANIMATION.lock(),
|
||||
ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst),
|
||||
&animation.duration_per_animation,
|
||||
animation.duration,
|
||||
)
|
||||
}
|
||||
|
||||
/// How a workspace eases as it slides in and out of a monitor
|
||||
pub fn workspace_transition_style() -> AnimationStyle {
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
style_for(
|
||||
AnimationPrefix::Workspace,
|
||||
&ANIMATION_STYLE_PER_ANIMATION.lock(),
|
||||
*ANIMATION_STYLE_GLOBAL.lock(),
|
||||
&animation.style_per_animation,
|
||||
animation.style,
|
||||
)
|
||||
}
|
||||
|
||||
pub static ANIMATION_FPS: AtomicU64 = AtomicU64::new(DEFAULT_ANIMATION_FPS);
|
||||
pub static GHOST_MOVEMENT_ENABLED: AtomicBool = AtomicBool::new(DEFAULT_GHOST_MOVEMENT);
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -834,8 +834,9 @@ mod tests {
|
||||
.expect("a window to put a border around");
|
||||
|
||||
let tracked_hwnd = tracked.0 as isize;
|
||||
let previous = crate::WINDOW_HANDLING_BEHAVIOUR.load();
|
||||
crate::WINDOW_HANDLING_BEHAVIOUR.store(handling);
|
||||
// put back when the guard is dropped, unless something else changed it meanwhile
|
||||
let handling_override = crate::settings::settings()
|
||||
.scoped(|settings| &mut settings.platform.window_handling_behaviour, handling);
|
||||
|
||||
let mut border =
|
||||
Border::create("komorebi-border-test", tracked_hwnd, 0).expect("a border to paint");
|
||||
@@ -854,7 +855,7 @@ mod tests {
|
||||
let painted =
|
||||
unsafe { std::ptr::read_volatile(&raw const border.rounded_rect.rect.right) } > 0.0;
|
||||
|
||||
crate::WINDOW_HANDLING_BEHAVIOUR.store(previous);
|
||||
drop(handling_override);
|
||||
|
||||
let border = Box::into_raw(border);
|
||||
unsafe {
|
||||
|
||||
@@ -20,8 +20,6 @@ use clap::ValueEnum;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::bail;
|
||||
use crossbeam_utils::Backoff;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::AnimationEngine;
|
||||
use crate::replace_env_in_path;
|
||||
use parking_lot::Mutex;
|
||||
@@ -364,8 +362,7 @@ pub fn run() -> eyre::Result<()> {
|
||||
let state = State::from(&*wm.lock());
|
||||
std::fs::write(dumped_state, serde_json::to_string_pretty(&state)?)?;
|
||||
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
ANIMATION_ENABLED_GLOBAL.store(false, Ordering::SeqCst);
|
||||
crate::settings::animation_off_for_good();
|
||||
wm.lock().restore_all_windows(false)?;
|
||||
AnimationEngine::wait_for_all_animations();
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ use crate::core::config_generation::MatchingRule;
|
||||
use crate::core::config_generation::MatchingStrategy;
|
||||
use crate::core::config_generation::WorkspaceMatchingRule;
|
||||
use color_eyre::eyre;
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use os_info::Version;
|
||||
use parking_lot::Mutex;
|
||||
use parking_lot::RwLock;
|
||||
@@ -277,9 +276,6 @@ pub static REMOVE_TITLEBARS: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub static SLOW_APPLICATION_COMPENSATION_TIME: AtomicU64 = AtomicU64::new(20);
|
||||
|
||||
pub static WINDOW_HANDLING_BEHAVIOUR: AtomicCell<WindowHandlingBehaviour> =
|
||||
AtomicCell::new(WindowHandlingBehaviour::Sync);
|
||||
|
||||
shadow_rs::shadow!(build);
|
||||
|
||||
pub const PUBLIC_KEY: [u8; 32] = [
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
//! it began puts the neighbours back.
|
||||
|
||||
use crate::WindowsApi;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::GHOST_MOVEMENT_ENABLED;
|
||||
use crate::animation::ghost::GhostWindow;
|
||||
use crate::animation::ghost::is_swap_chain_window;
|
||||
@@ -368,7 +367,7 @@ fn glide_frame(from: &Rect, to: &Rect, progress: f64) -> Rect {
|
||||
/// long as an animation takes, and nothing else is done until they are there. For the windows
|
||||
/// of a strip that is let go of, which then does not jump to where it comes to rest.
|
||||
pub fn glide() {
|
||||
let duration = Duration::from_millis(ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst));
|
||||
let duration = Duration::from_millis(crate::settings::animation_duration_global());
|
||||
|
||||
let mut covers = COVERS.lock();
|
||||
let Some(covers) = covers.as_mut() else {
|
||||
|
||||
@@ -47,13 +47,6 @@ use crate::TCP_CONNECTIONS;
|
||||
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
||||
use crate::WINDOWS_11;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::border_manager;
|
||||
use crate::border_manager::IMPLEMENTATION;
|
||||
use crate::border_manager::STYLE;
|
||||
@@ -1399,50 +1392,61 @@ impl WindowManager {
|
||||
border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
||||
force_update_borders = true;
|
||||
}
|
||||
SocketMessage::Animation(enable, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(enable, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationDuration(duration, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_DURATION_GLOBAL.store(duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
ANIMATION_FPS.store(fps, Ordering::SeqCst);
|
||||
SocketMessage::Animation(enable, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.enabled_per_animation.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
animation.enabled = enable;
|
||||
animation.enabled_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationDuration(duration, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.duration_per_animation.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
animation.duration = duration;
|
||||
animation.duration_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
crate::settings::settings().update(|settings| settings.shared.animation.fps = fps);
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.style_per_animation.insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
animation.style = style;
|
||||
animation.style_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::ToggleTransparency => {
|
||||
let current = transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst);
|
||||
transparency_manager::TRANSPARENCY_ENABLED.store(!current, Ordering::SeqCst);
|
||||
crate::settings::settings().update(|settings| {
|
||||
settings.shared.transparency.enabled = !settings.shared.transparency.enabled;
|
||||
});
|
||||
}
|
||||
SocketMessage::Transparency(enable) => {
|
||||
transparency_manager::TRANSPARENCY_ENABLED.store(enable, Ordering::SeqCst);
|
||||
crate::settings::settings().update(|settings| settings.shared.transparency.enabled = enable);
|
||||
}
|
||||
SocketMessage::TransparencyAlpha(alpha) => {
|
||||
transparency_manager::TRANSPARENCY_ALPHA.store(alpha, Ordering::SeqCst);
|
||||
crate::settings::settings().update(|settings| settings.shared.transparency.alpha = alpha);
|
||||
}
|
||||
SocketMessage::StackbarMode(mode) => {
|
||||
STACKBAR_MODE.store(mode);
|
||||
|
||||
Loaded 100 of 119 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user