Files
komorebi/komorebi/tests/borders.rs
T
LGUG2Z 2c35e4bb6f feat(kwin): borders drawn by the compositor
komorebi draws no border. KWin's KDE Rounded Corners effect does, outside each
window in the gap the layout leaves, and komorebi says how it looks. The window
manager describes a Look (a border with a width, a radius and two colors) and
asks the backend for it with Backend::apply_look after every event, message and
retile. The backend answers whether borders are being drawn, and the layout
leaves room around the windows only while they are: a border with no effect to
draw it takes none.

The KWin backend writes the effect's settings into the user's kwinrc, with every
inner outline off (the effect's default draws one over the title bar), loads the
effect when borders are on and has it read them again. It unloads the effect and
puts the user's settings back when the borders go or komorebi exits. The module
installs the effect (effects.borders), which is built to stay unloaded until
komorebi asks, and vm-look reads the pixels around two windows in a real
session.

The session library of the VM tests also waits for the panel of the Plasma shell
now: a window komorebi tiles before the panel is made is tiled under it, which
hides the bottom of its border from a screenshot.

Kde.wait_for_panel_room waits until the daemon's work area is not the whole of
its monitor, which is the daemon having learned that the panel takes room, and
vm-look calls it where the daemon starts, before the windows open. The shell
makes its panel and KWin takes room for it a while later, which the daemon
learns of up to a second after, so a daemon that tiles in between puts the
windows under the panel and tiles them again, and a screenshot taken between the
two shows frames as high as the screen. It is a wait and not a check, since a
session that is too slow, as TCG often is, may never take the room.

komorebic gets border, border-width and border-offset, and visible-windows.

komorebi.json takes the same settings as border, border_width and border_offset,
and border_radius, which has no command. The module warns when config asks for
borders and the effect is not installed.
2026-10-28 07:20:49 -07:00

74 lines
2.7 KiB
Rust

//! The layout leaves room for a border the compositor draws outside each window, and only then.
//!
//! This file has one test because it changes the process-wide border settings, which every other
//! test that tiles windows would see.
use komorebi::backend::fake::FakeBackend;
use komorebi::backend::with_backend;
use komorebi::border_manager;
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;
use std::sync::atomic::Ordering;
#[test]
fn a_border_the_compositor_draws_takes_room_around_each_window_and_none_is_taken_without_one() {
let fake = Arc::new(FakeBackend::with_one_monitor());
fake.set_borders_drawn(true);
let (_sender, receiver) = crossbeam_channel::bounded(1);
let socket = std::path::PathBuf::from(format!("/tmp/kmb-borders-{}.sock", std::process::id()));
let mut wm = with_backend(fake.clone(), || {
let mut wm = WindowManager::new(receiver, Some(socket)).unwrap();
wm.init().unwrap();
wm
});
// opened after the window manager started, so that it is managed (and tiled) by this event
fake.open_window(90_001, "foot", "foot", "terminal");
with_backend(fake.clone(), || {
wm.process_event(WindowManagerEvent::Show(
SystemNotification::KWin(KWinNotification::WindowAdded),
Window::from(90_001),
))
.unwrap();
});
let without = fake.rect_of(90_001).unwrap();
// borders on, and the compositor says it is drawing them
border_manager::BORDER_WIDTH.store(10, Ordering::SeqCst);
border_manager::BORDER_OFFSET.store(2, Ordering::SeqCst);
with_backend(fake.clone(), || {
border_manager::send_notification();
wm.retile_all(false).unwrap();
});
assert!(border_manager::BORDER_DRAWN.load(Ordering::SeqCst));
let with = fake.rect_of(90_001).unwrap();
let room = 10 + 2;
assert_eq!(with.left, without.left + room, "{without:?} -> {with:?}");
assert_eq!(with.top, without.top + room, "{without:?} -> {with:?}");
assert_eq!(
with.right,
without.right - 2 * room,
"{without:?} -> {with:?}"
);
assert_eq!(
with.bottom,
without.bottom - 2 * room,
"{without:?} -> {with:?}"
);
// borders off: the room is given back
border_manager::BORDER_ENABLED.store(false, Ordering::SeqCst);
with_backend(fake.clone(), || {
border_manager::send_notification();
wm.retile_all(false).unwrap();
});
assert!(!border_manager::BORDER_DRAWN.load(Ordering::SeqCst));
assert_eq!(fake.rect_of(90_001).unwrap(), without);
}