diff --git a/komorebi-for-kde/CONTRIBUTING.md b/komorebi-for-kde/CONTRIBUTING.md index 6ab1df26..4dbcc490 100644 --- a/komorebi-for-kde/CONTRIBUTING.md +++ b/komorebi-for-kde/CONTRIBUTING.md @@ -103,8 +103,9 @@ older KWin does not have. [`docs/dev/COMPARE.md`](docs/dev/COMPARE.md) compares komorebi for KDE with komorebi for Windows and komorebi for Mac, and its tables are generated by [`scripts/compare-gen.py`](scripts/compare-gen.py) (Python 3 and nothing else) from -this checkout and from checkouts of the other two, `~/komorebi` and -`~/komorebi-for-mac` unless `--kfw` and `--kfm` say otherwise. Continuous +this checkout and from checkouts of the other two: the komorebi repository around it and its +`komorebi-for-mac/` when this is `komorebi-for-kde/` of that repository, else `~/komorebi` and +`~/komorebi-for-mac`, unless `--kfw` and `--kfm` say otherwise. Continuous integration has neither checkout, so it does not run the script. A change to a `komorebic` command, a `SocketMessage`, a key of `komorebi.json`, a `WindowManagerEvent`, a method of `Backend` or a list of keys in `check.rs` is diff --git a/komorebi-for-kde/flake.nix b/komorebi-for-kde/flake.nix index b3929dc9..dcdf6649 100644 --- a/komorebi-for-kde/flake.nix +++ b/komorebi-for-kde/flake.nix @@ -88,7 +88,7 @@ fullBuild = craneLib.buildPackage ( individualCrateArgs // { - COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" self.dirtyRev); + COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" (self.dirtyRev or "unknown")); } ); diff --git a/komorebi-for-kde/komorebi/src/static_config.rs b/komorebi-for-kde/komorebi/src/static_config.rs index e97890e2..3dab9fb3 100644 --- a/komorebi-for-kde/komorebi/src/static_config.rs +++ b/komorebi-for-kde/komorebi/src/static_config.rs @@ -993,16 +993,18 @@ impl StaticConfig { transparency_manager::TRANSPARENCY_ALPHA .store(self.transparency_alpha.unwrap_or(200), Ordering::SeqCst); + // 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 + let mut floating_applications = FLOATING_APPLICATIONS.lock(); + let mut transparency_blacklist = TRANSPARENCY_BLACKLIST.lock(); let mut ignore_identifiers = IGNORE_IDENTIFIERS.lock(); - let mut regex_identifiers = REGEX_IDENTIFIERS.lock(); let mut manage_identifiers = MANAGE_IDENTIFIERS.lock(); + let mut regex_identifiers = REGEX_IDENTIFIERS.lock(); // let mut tray_and_multi_window_identifiers = TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock(); // let mut object_name_change_identifiers = OBJECT_NAME_CHANGE_ON_LAUNCH.lock(); // let mut object_name_change_title_ignore_list = OBJECT_NAME_CHANGE_TITLE_IGNORE_LIST.lock(); // let mut layered_identifiers = LAYERED_WHITELIST.lock(); - let mut transparency_blacklist = TRANSPARENCY_BLACKLIST.lock(); // let mut slow_application_identifiers = SLOW_APPLICATION_IDENTIFIERS.lock(); - let mut floating_applications = FLOATING_APPLICATIONS.lock(); // let mut no_titlebar_applications = NO_TITLEBAR.lock(); if let Some(rules) = &mut self.ignore_rules { diff --git a/komorebi-for-kde/komorebi/src/window.rs b/komorebi-for-kde/komorebi/src/window.rs index 6c3a7f60..0cfbe64f 100644 --- a/komorebi-for-kde/komorebi/src/window.rs +++ b/komorebi-for-kde/komorebi/src/window.rs @@ -529,9 +529,13 @@ fn window_is_eligible( } } - let regex_identifiers = REGEX_IDENTIFIERS.lock(); - + // Every place that holds two of the rule lists takes them in this order: floating, transparency, + // ignore, manage, regex. A thread that takes two in another order can wait for one that holds + // what it needs, and both wait for ever. + let floating_identifiers = FLOATING_APPLICATIONS.lock(); let ignore_identifiers = IGNORE_IDENTIFIERS.lock(); + let manage_identifiers = MANAGE_IDENTIFIERS.lock(); + let regex_identifiers = REGEX_IDENTIFIERS.lock(); let should_ignore = if let Some(rule) = should_act( title, exe_name, @@ -546,7 +550,6 @@ fn window_is_eligible( false }; - let manage_identifiers = MANAGE_IDENTIFIERS.lock(); let managed_override = if let Some(rule) = should_act( title, exe_name, @@ -561,7 +564,6 @@ fn window_is_eligible( false }; - let floating_identifiers = FLOATING_APPLICATIONS.lock(); if let Some(rule) = should_act( title, exe_name, diff --git a/komorebi-for-kde/komorebi/tests/schemas.rs b/komorebi-for-kde/komorebi/tests/schemas.rs index 06157045..b1e80e9d 100644 --- a/komorebi-for-kde/komorebi/tests/schemas.rs +++ b/komorebi-for-kde/komorebi/tests/schemas.rs @@ -11,11 +11,21 @@ use komorebi::core::SocketMessage; use komorebi::window_manager::WindowManager; use serde_json::json; use std::sync::Arc; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +/// The tests of this binary run in parallel in one process, so a socket named by the pid alone is +/// bound by two at once. +static NEXT: AtomicUsize = AtomicUsize::new(0); fn answer(message: SocketMessage) -> serde_json::Value { let fake = Arc::new(FakeBackend::with_one_monitor()); let (_sender, receiver) = crossbeam_channel::bounded(1); - let socket = std::path::PathBuf::from(format!("/tmp/kms-{}.sock", std::process::id())); + let socket = std::path::PathBuf::from(format!( + "/tmp/kms-{}-{}.sock", + std::process::id(), + NEXT.fetch_add(1, Ordering::Relaxed) + )); let mut reply = Vec::new(); with_backend(fake, || { diff --git a/komorebi-for-kde/scripts/compare-gen.py b/komorebi-for-kde/scripts/compare-gen.py index 05f1048a..5834502a 100644 --- a/komorebi-for-kde/scripts/compare-gen.py +++ b/komorebi-for-kde/scripts/compare-gen.py @@ -30,7 +30,9 @@ leaves everything outside them (the prose) alone. --check exits 1 when a block o what would be generated now, and names the blocks; the block `sources` (the revisions read) is skipped, because it changes whenever a source tree moves. --block prints one block. -Defaults: kfw ~/komorebi, kfm ~/komorebi-for-mac, kfde the checkout this script is in. +Defaults: kfde the checkout this script is in; kfw and kfm are the repository around it and its +komorebi-for-mac/ when it is komorebi-for-kde/ of the komorebi repository, else ~/komorebi and +~/komorebi-for-mac. The script is read-only: it reads files, and runs `git log -1` and `git status` in the checkouts of kfw and kfm; it never asks for a remote. @@ -45,6 +47,11 @@ from pathlib import Path HOME = Path.home() HERE = Path(__file__).resolve().parent.parent +# in the komorebi repository this tree is komorebi-for-kde/, next to komorebi-for-mac/, and kfw is the +# repository itself; on its own it sits beside ~/komorebi and ~/komorebi-for-mac +MONOREPO = (HERE.parent / "komorebi-for-mac").is_dir() and (HERE.parent / "komorebi" / "Cargo.toml").is_file() +DEFAULT_KFW = HERE.parent if MONOREPO else HOME / "komorebi" +DEFAULT_KFM = HERE.parent / "komorebi-for-mac" if MONOREPO else HOME / "komorebi-for-mac" ERRORS = [] @@ -1133,8 +1140,8 @@ MARK = re.compile(r"\n(.*?)", re.S) def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - ap.add_argument("--kfw", default=str(HOME / "komorebi")) - ap.add_argument("--kfm", default=str(HOME / "komorebi-for-mac")) + ap.add_argument("--kfw", default=str(DEFAULT_KFW)) + ap.add_argument("--kfm", default=str(DEFAULT_KFM)) ap.add_argument("--kfde", default=str(HERE)) ap.add_argument("--update", metavar="FILE") ap.add_argument("--check", metavar="FILE") diff --git a/komorebi-for-kde/scripts/run-kde b/komorebi-for-kde/scripts/run-kde index 123cffe6..d06c99e2 100644 --- a/komorebi-for-kde/scripts/run-kde +++ b/komorebi-for-kde/scripts/run-kde @@ -39,7 +39,8 @@ source and downloads Plasma: there is no binary cache. --rdp-port PORT the host's port for RDP into the guest (default: 3389) -h, --help this text -The repository the guest mounts at /repo is the current checkout, or KOMOREBI_REPO. +The repository the guest mounts at /repo is the checkout this file is in (or, from the flake, the current +checkout: the komorebi-for-kde directory of a bigger repository), or KOMOREBI_REPO. EOF } @@ -550,7 +551,21 @@ fi repo=${KOMOREBI_REPO:-} if [ -z "$repo" ]; then - repo=$(git rev-parse --show-toplevel 2> /dev/null || pwd) + # This tree may be a subdirectory of a bigger repository, whose toplevel has a flake.nix of its own, + # so the toplevel is not the answer. A run of the file by hand is in scripts/ of the tree; the + # flake's wrapper is in the store, and falls back to the checkout the command is run from. + here=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." 2> /dev/null && pwd || true) + top=$(git rev-parse --show-toplevel 2> /dev/null || pwd) + case $here in + /nix/store/* | "") here= ;; + esac + if [ -n "$here" ] && [ -e "$here/flake.nix" ]; then + repo=$here + elif [ -e "$top/komorebi-for-kde/flake.nix" ]; then + repo=$top/komorebi-for-kde + else + repo=$top + fi fi if [ ! -e "$repo/flake.nix" ]; then echo "run-kde: $repo is not a checkout of the repository (there is no flake.nix): run it from one, or set KOMOREBI_REPO" >&2 diff --git a/komorebi-for-kde/scripts/sync-e2e-core b/komorebi-for-kde/scripts/sync-e2e-core index 395d6f14..ec4429bf 100755 --- a/komorebi-for-kde/scripts/sync-e2e-core +++ b/komorebi-for-kde/scripts/sync-e2e-core @@ -1,12 +1,16 @@ #!/usr/bin/env bash -# Keeps a copy of the platform-neutral part of the VM library in step with this repository, while -# that part is on its way to kfw (the plan in docs/dev/vm-tests.md, "Writing a scenario"): the -# package komorebi_vm.core, and the unit tests that belong to it. The source is this repository until -# the move is made, and the script goes with it. +# Checks that the copy of the platform-neutral part of the VM library in this tree is in step with +# the root e2e/lib of the komorebi repository (the plan in docs/dev/vm-tests.md, "Writing a +# scenario"): the package komorebi_vm.core, and the unit tests that belong to it. The SOURCE OF TRUTH +# IS THE ROOT e2e/lib, where the core is on its way to the Windows tree, and this tree's copy follows +# it. The script goes away once the root flake builds the KDE VM tests from e2e/lib; until then the +# KDE flake cannot reach ../, so the copy stays. # -# scripts/sync-e2e-core DEST copy into DEST/komorebi_vm/core, DEST/tests and -# DEST/tests/fixtures -# scripts/sync-e2e-core --check DEST say what differs, and exit 1 if anything does +# scripts/sync-e2e-core --check ../e2e/lib say what differs, and exit 1 if anything does +# scripts/sync-e2e-core DEST copy THIS tree's core into DEST/komorebi_vm/core, +# DEST/tests and DEST/tests/fixtures. That is the direction +# from before the move: the root is the source now, so +# do not point it at ../e2e/lib; copy the other way by hand. # # Nothing else of DEST is touched, and a file of DEST that is not here is reported and left alone. set -euo pipefail diff --git a/komorebi-for-kde/scripts/vm-mac b/komorebi-for-kde/scripts/vm-mac index 537fdb99..07d69988 100755 --- a/komorebi-for-kde/scripts/vm-mac +++ b/komorebi-for-kde/scripts/vm-mac @@ -17,8 +17,17 @@ name="${1:?usage: scripts/vm-mac NAME [driver arguments]}" shift builder="${KOMOREBI_BUILDER:?set KOMOREBI_BUILDER to the store URL of a Linux builder}" cd "$(dirname "$0")/.." -test="path:$PWD#legacyPackages.aarch64-darwin.vm.$name" -[ -d .git ] && test="git+file://$PWD#legacyPackages.aarch64-darwin.vm.$name" +attr="legacyPackages.aarch64-darwin.vm.$name" +test="path:$PWD#$attr" +# a git checkout is a flake source without its untracked files (.vm, target); this tree may be the +# komorebi-for-kde directory of a bigger repository, whose toplevel is not $PWD +if top=$(git rev-parse --show-toplevel 2> /dev/null); then + if [ "$top" = "$PWD" ]; then + test="git+file://$PWD#$attr" + else + test="git+file://$top?dir=${PWD#"$top"/}#$attr" + fi +fi echo "== building the guests on $builder" nix eval --json "$test.nodes" --apply 'nodes: builtins.mapAttrs (_: node: node.system.build.toplevel.drvPath) nodes' |