Files
komorebi/nix/tests/vm/nodes/session.nix
T
LGUG2Z 9a0693f5d1 feat(kwin): focus follows mouse through KWin's focus policy
KWin has a focus policy that gives the focus to the window under the pointer, so
komorebi asks for it and follows where the focus goes, as it does for any change
of focus. Both implementations komorebi for Windows names are the same thing
here. The KWin backend sets the focus policy and no delay in the user's kwinrc
and has KWin read it, and puts the two keys back as the user had them when it is
turned off and, with every other setting, when komorebi exits. The state of the
daemon says whether it is on.

komorebic gets focus-follows-mouse and toggle-focus-follows-mouse. The session
node gets a pointer that a test drives from inside the guest: the program
komorebi-pointer makes an absolute device with uinput, and komorebi_vm.Pointer
sends it commands. vm-focus-follows-mouse moves it over each of two windows and
checks the focus, then the policy that is put back.

komorebi.json takes focus_follows_mouse, which is on with Windows or Komorebi,
and a file that leaves it out turns it off and gives the user's focus policy
back.

Loading a configuration asks the backend for the focus policy now, so the tests
that load one do it with a backend installed.
2026-10-28 07:20:49 -07:00

71 lines
2.7 KiB
Nix

# A real Plasma Wayland session that logs in by itself, on a machine that can draw. Everything the
# headless node has is here too, so a test can still start a virtual KWin next to it. The module's
# unit, `komorebi.service`, starts komorebi in the session when the user logs in, as on a user's
# machine; a suite that wants the session without it sets `services.komorebi.enable = false` in
# its `node`.
#
# The choice of login manager is made here and nowhere else. nixpkgs' own `plasma6` test uses
# plasma-login-manager, so that is what this node follows; sddm with a Wayland greeter is the other
# one that has been seen to work, and replacing the first block below with
# `services.displayManager.sddm = { enable = true; wayland.enable = true; };` and
# `services.displayManager.defaultSession = "plasma";` switches to it.
{ pkgs, ... }:
{
imports = [ ./headless.nix ];
# the one display this node has is the one screenshots are taken of
komorebi.vm.renderNode = false;
services.xserver.enable = true;
services.displayManager = {
plasma-login-manager.enable = true;
autoLogin = {
enable = true;
user = "komorebi";
};
};
virtualisation = {
memorySize = 4096;
cores = 4;
};
# An idle lock screen or a dimmed display changes what a screenshot shows, and a display that has
# gone to sleep gets no frame callbacks from KWin, so clients stop answering resizes.
environment.etc."xdg/kscreenlockerrc".text = ''
[Daemon]
Autolock=false
LockOnResume=false
'';
environment.etc."xdg/powerdevilrc".text = ''
[AC][Display]
DimDisplayWhenIdle=false
TurnOffDisplayWhenIdle=false
[AC][SuspendAndShutdown]
AutoSuspendAction=0
'';
# A pointer device the test drives from inside the guest (`komorebi_vm.Pointer`): the program
# makes it with uinput, which the test user may open.
hardware.uinput.enable = true;
users.users.komorebi.extraGroups = [ "uinput" ];
environment.systemPackages = [
pkgs.kdePackages.konsole
(pkgs.writeScriptBin "komorebi-pointer" ''
#!${pkgs.python3.interpreter}
${builtins.readFile ../lib/komorebi_vm/uinput.py}
'')
];
# KWin loads no effect that animates under software rendering, which is all a guest has, unless
# it is told to: with this it loads Geometry Change, which komorebi asks it to load
environment.sessionVariables.KWIN_EFFECTS_FORCE_ANIMATIONS = "1";
# Nothing adds a display device here (see komorebi.vm.renderNode above). The test driver gives
# every aarch64 guest a virtio-gpu, and an x86_64 guest has the default VGA; screenshots are taken
# of that one, and a second device would be a second head that KWin draws on and the screenshot
# never shows.
}