CI / test (push) Canceled after 52s
The default frame now follows codegod100/kde aurorae (Flatkit / Flatkit Dark): the kit's neutral title bar, a 1px outline with 10px top corners, a hairline under the title, a soft 16px shadow all round, a centred title and 24px flat buttons with hover and pressed fills (close turns red). 38px title bar, 1px border. Maximized: no shadow, square corners. - scene: WindowStyle (frame sizes, button layout, hit test) and build_window_decoration; the shadow is part of the decoration ops, so the three rasterisers lost their own offset shadow and redraw 18px around a changed window. - host: the frame size follows the style (work area, wm title-bar room, CSD client boxes, hit zones, screenshots); title-bar buttons track hover, show pressed, act on release. - Settings > Session > Flat window frames (off: the old Breeze-like frame), saved as :window-style :breeze; an unknown value is logged. - docs/window-frames.md; tests for both styles' pixels, button states and switching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hmKDDLLES2aBrrnPxT
93 lines
4.1 KiB
MoonBit
93 lines
4.1 KiB
MoonBit
///| Window frames: the flat (Flatkit Aurorae) style's button states, and switching styles.
|
|
|
|
///|
|
|
test "title-bar buttons hover, show pressed, act on release and cancel when left" {
|
|
let socket_path = "/tmp/wayland-moon-decohover-" + @sys.getpid().to_string() + ".sock"
|
|
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
|
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
|
ignore(comp.compose_frame())
|
|
let (mx, my) = button_centre(comp, 1UL, 2)
|
|
let move = fn(x : Int, y : Int, t : UInt) {
|
|
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
|
|
}
|
|
move(mx, my, 1U)
|
|
assert_eq(comp.deco_hover, Some((1UL, 2)))
|
|
move(mx - 28, my, 2U)
|
|
assert_eq(comp.deco_hover, Some((1UL, 1)))
|
|
// Press maximize: shown pressed, nothing happens yet.
|
|
move(mx, my, 3U)
|
|
let w0 = comp.windows.get(1UL).unwrap().geometry.w
|
|
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 4U)
|
|
assert_eq(comp.deco_pressed, Some((1UL, 2)))
|
|
assert_eq(comp.windows.get(1UL).unwrap().geometry.w, w0)
|
|
ignore(comp.compose_frame())
|
|
// Moving off and releasing cancels.
|
|
move(mx, my + 60, 5U)
|
|
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 6U)
|
|
assert_eq(comp.deco_pressed, None)
|
|
assert_eq(comp.windows.get(1UL).unwrap().geometry.w, w0)
|
|
// Press and release over it: it maximizes.
|
|
move(mx, my, 7U)
|
|
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 8U)
|
|
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 9U)
|
|
assert_true(comp.windows.get(1UL).unwrap().maximized)
|
|
// Off the title bar nothing is hovered.
|
|
move(600, 400, 10U)
|
|
assert_eq(comp.deco_hover, None)
|
|
}
|
|
|
|
///|
|
|
test "Flat window frames off switches to the classic frame: sizes, layout and state.edn follow" {
|
|
let socket_path = "/tmp/wayland-moon-decostyle-" + @sys.getpid().to_string() + ".sock"
|
|
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
|
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
|
ignore(comp.compose_frame())
|
|
let flat_area = comp.work_area
|
|
assert_eq(comp.shell.window_style, @scene.WindowStyle::Flat)
|
|
assert_eq(comp.wm.titlebar_h, 38)
|
|
// The settings module's sixth switch, "Flat window frames", off.
|
|
comp.shell.set_session_setting(5, false)
|
|
ignore(comp.compose_frame())
|
|
assert_eq(comp.shell.window_style, @scene.WindowStyle::Breeze)
|
|
assert_eq((comp.wm.titlebar_h, comp.wm.border_w), (32, 2))
|
|
assert_eq(comp.work_area.y, flat_area.y - 6)
|
|
// The tiled window moved up with the work area.
|
|
let g = comp.windows.get(1UL).unwrap().geometry
|
|
assert_eq(g.y, comp.work_area.y + 8)
|
|
// The classic buttons are where they are drawn: the close button 10px from the right edge.
|
|
let outer_w = g.w + 4
|
|
let close = @scene.WindowStyle::Breeze.buttons(outer_w)[2].1
|
|
assert_eq(close.x, outer_w - 28)
|
|
comp.shell.set_session_setting(5, true)
|
|
ignore(comp.compose_frame())
|
|
assert_eq(comp.work_area, flat_area)
|
|
}
|
|
|
|
///|
|
|
test "state.edn :window-style :breeze turns Flat window frames off" {
|
|
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
|
let dir = @sys.getenv("XDG_CONFIG_HOME") + "/chandra"
|
|
assert_true(@sys.mkdir_p(dir))
|
|
let state0 = @sys.read_file_bytes(dir + "/state.edn")
|
|
ignore(@sys.write_file_bytes(dir + "/state.edn", @utf8.encode("{:window-style :breeze}\n")))
|
|
let boot = fn() {
|
|
let s = @shell.DesktopShell::new("x")
|
|
s.persist = true
|
|
s.set_output(@scene.ThemeTokens::moon_night(), 1280, 720)
|
|
ignore(s.slots())
|
|
s.apply_state(s.load_state())
|
|
s
|
|
}
|
|
let a = boot()
|
|
assert_eq(a.window_style, @scene.WindowStyle::Breeze)
|
|
a.set_session_setting(5, true)
|
|
let text = @utf8.decode_lossy(@sys.read_file_bytes(dir + "/state.edn"))
|
|
assert_false(text.contains("window-style"))
|
|
a.set_session_setting(5, false)
|
|
let text = @utf8.decode_lossy(@sys.read_file_bytes(dir + "/state.edn"))
|
|
assert_true(text.contains(":window-style :breeze"))
|
|
assert_eq(boot().window_style, @scene.WindowStyle::Breeze)
|
|
ignore(@sys.write_file_bytes(dir + "/state.edn", state0))
|
|
}
|
|
}
|