Files
komorebi/nix/tests/effects.nix
T
LGUG2Z 22c14ba5be feat(kwin): a border color for each kind of window
The stock KDE Rounded Corners has one color for the active window and one for
the others, and komorebi colors a window by what it is to the layout: the
focused window, the others, a locked container that does not have the focus, a
floating window that has it, a stack, a monocle. komorebi's build of the effect
takes a color for each window over D-Bus. After every event and message the
border manager works out the kind of each window and tells the backend, which
sends the effect what changed, and tells it that no window has a color when
borders are off. Without that build the borders are the look's two colors, and
the backend says so once.

komorebic gets border-colour. The fake desktop keeps the colors it was told, and
gets window_commands, which leaves the look out of the list of what the window
manager asked for. vm-features reads the colors of the kinds of window in a real
session.

The colors of a stack and of a monocled window are read from the fake and, in
vm-features, from the pixels. The border_colours key of komorebi.json is not
here: its colors are written as the Colour of komorebi-themes, which the themes
(49) bring, and 49 adds the key.

The maximize check of vm-features, which was the whole suite, reads a pixel a
quarter of the way into the window and not the middle one: komorebi puts the
pointer in the middle of the window it focuses, and a screenshot has the arrow
on it, white. It read the arrow on most runs once the border effect was loaded.

vm-features waits for the panel's room too, where it starts the daemon for its
sections B to E: the border colors of section C are read from the pixels around
a window, which the panel can cover.
2026-10-28 07:20:49 -07:00

61 lines
2.4 KiB
Nix

# Install checks of the KWin effects komorebi drives: each package is built and its files are
# inspected the way KWin finds them, without a session. Whether an effect loads in a real KWin is a
# question for the VM tests.
{ pkgs, packages }:
let
inherit (pkgs.kdePackages) kwin qttools;
in
{
kde-rounded-corners-komorebi-install =
pkgs.runCommand "kde-rounded-corners-komorebi-install"
{
nativeBuildInputs = [
pkgs.jq
pkgs.patchelf
# qtplugininfo reads a plugin's metadata as Qt and KWin read it
qttools
];
}
''
fail() {
echo "FAIL: $*" >&2
exit 1
}
plugin=${packages.kde-rounded-corners-komorebi}/lib/qt-6/plugins/kwin/effects/plugins/kwin4_effect_shapecorners.so
[ -f "$plugin" ] || fail "no plugin at $plugin"
echo "ok: the plugin is where KWin looks for effect plugins"
# The metadata is compiled into the plugin; KWin does not read metadata.json at run time.
qtplugininfo --full-json "$plugin" > metadata.json || fail "qtplugininfo cannot read $plugin"
if ! jq -e '.MetaData.KPlugin.EnabledByDefault == false' metadata.json > /dev/null; then
cat metadata.json
fail "the plugin's metadata does not say EnabledByDefault false"
fi
echo "ok: the plugin's metadata says EnabledByDefault false"
# The plugin is loaded into KWin, so it has to link the libkwin of that KWin: the dynamic
# loader takes the first directory of the RUNPATH that has the library.
needed=$(patchelf --print-needed "$plugin" | grep -m 1 -x 'libkwin\.so\.[0-9]*') ||
fail "the plugin does not link libkwin"
found=
IFS=: read -r -a dirs <<< "$(patchelf --print-rpath "$plugin")"
for dir in "''${dirs[@]}"; do
if [ -e "$dir/$needed" ]; then
found=$dir/$needed
break
fi
done
[ "$found" = "${kwin}/lib/$needed" ] ||
fail "$needed resolves to '$found', not to the KWin of this nixpkgs (${kwin})"
echo "ok: $needed is ${kwin}/lib/$needed"
# komorebi's patch: the interface that takes a color for each window
grep -q -a -F org.komorebi.BorderColours1 "$plugin" ||
fail "the plugin has no org.komorebi.BorderColours1: komorebi-border-colours.patch is not in it"
echo "ok: the plugin has org.komorebi.BorderColours1"
touch $out
'';
}