GTK windows (Gajim, GNOME apps) resize from their shadow and all four edges
CI / test (push) Successful in 3m44s

GTK draws no border, only a shadow, and resizes only from a press in that
shadow, which Chandra never hands to the client. Chandra's own zones were
~4px wide around the visible edge and there was none on the top edge, so
Gajim (GTK 4) looked unresizable. Client-decorated windows now get zones
that reach up to 12px into the shadow (GTK's own handle size, at least 6px)
plus 3px over their edge, with 16px corners, top edge included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiu4r7mEXBdKY6cgv6
This commit is contained in:
Claude committed 2026-11-26 02:48:22 +00:00
1 parent b4f7149c72
commit fa932f9ac0
2 files changed
+148

No files matched your search

+63
View File
@@ -257,3 +257,66 @@ test "a GTK 3 window asking through org_kde_kwin_server_decoration gets Chandra'
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
assert_true(comp.windows.get(1UL).unwrap().csd)
}
///|
test "a GTK window resizes from its shadow and from every edge, top included" {
// Gajim (GTK 4) couldn't be resized: GTK only resizes from a press in its shadow, which
// Chandra keeps, and Chandra's own zones were a few pixels wide with none on the top edge.
let (comp, c, shm, surf, xdg, tl) = csd_setup("grips")
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
let drag = fn(px : Int, py : Int, dx : Int, dy : Int) -> @scene.Rect raise {
comp.handle_input(@nested.InputEvent::PointerMove(px.to_double(), py.to_double()), 30U)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, true), 31U)
assert_true(comp.wm.drag is Some(_))
comp.handle_input(@nested.InputEvent::PointerMove((px + dx).to_double(), (py + dy).to_double()), 32U)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, false), 33U)
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
comp.windows.get(1UL).unwrap().client_rect()
}
// 10px out into the shadow on the right: wider.
let r0 = comp.windows.get(1UL).unwrap().client_rect()
let r1 = drag(r0.x + r0.w + 10, r0.y + r0.h / 2, 30, 0)
assert_eq((r1.x, r1.y, r1.w, r1.h), (r0.x, r0.y, r0.w + 30, r0.h))
// The top edge (the header bar's top 2px): taller, growing upwards.
let r2 = drag(r1.x + r1.w / 2, r1.y + 1, 0, -20)
assert_eq((r2.x, r2.y, r2.w, r2.h), (r1.x, r1.y - 20, r1.w, r1.h + 20))
// 8px out past the bottom-left corner: both at once.
let r3 = drag(r2.x - 8, r2.y + r2.h + 8, -10, 10)
assert_eq((r3.x, r3.y, r3.w, r3.h), (r2.x - 10, r2.y, r2.w + 10, r2.h + 10))
// Further out than GTK's 12px handles is the desktop again, and the header bar itself
// (below its top edge) still goes to the client.
comp.handle_input(@nested.InputEvent::PointerMove((r3.x + r3.w + 20).to_double(), (r3.y + 100).to_double()), 40U)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, true), 41U)
assert_true(comp.wm.drag is None)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, false), 42U)
comp.handle_input(@nested.InputEvent::PointerMove((r3.x + r3.w / 2).to_double(), (r3.y + 15).to_double()), 43U)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, true), 44U)
assert_true(comp.wm.drag is None)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, false), 45U)
}
///|
test "a maximized GTK window has no resize zones, and restores to its size" {
let (comp, c, shm, surf, xdg, tl) = csd_setup("max")
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
let before = comp.windows.get(1UL).unwrap().client_rect()
// The header bar's maximize button: xdg_toplevel.set_maximized.
c.send(@wayland.WireWriter::new().finish_msg(tl, 9U))
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
let win = comp.windows.get(1UL).unwrap()
assert_true(win.maximized)
let m = win.client_rect()
assert_true(m.w > before.w && m.h > before.h)
comp.handle_input(@nested.InputEvent::PointerMove((m.x + m.w - 1).to_double(), (m.y + m.h / 2).to_double()), 50U)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, true), 51U)
assert_true(comp.wm.drag is None)
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, false), 52U)
// ... and unset_maximized puts it back.
c.send(@wayland.WireWriter::new().finish_msg(tl, 10U))
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
let after = comp.windows.get(1UL).unwrap().client_rect()
assert_false(comp.windows.get(1UL).unwrap().maximized)
assert_eq((after.w, after.h), (before.w, before.h))
}