Nested window: follow the host's size instead of being cropped

The --window backend pinned its xdg_toplevel to a fixed size (min == max ==
1280x720 or --size) and ignored xdg_toplevel.configure. Whenever the host gave
the window less room than that (a tiling host, a maximized/snapped window, a
screen smaller than the default once its own panels and title bar are taken
off), the host cropped the 1280x720 buffer and the right/bottom of the desktop,
panel included, was cut off. Fullscreen only looked right when the screen
happened to be at least that big.

- nested: drop the max size (min 640x400), read the configure size and, on
  xdg_wm_base v4, configure_bounds to fit the first size on screen; report a
  new size through take_resize.
- compositor: MoonPlasmaCompositor::resize recomputes the work area, tells
  clients the new wl_output mode, reflows every workspace and pulls floating
  windows back inside (WmState::fit_work_area), and forces a full redraw.
- both main loops (wasm component and native) resize before presenting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkYa7dkDnotDeMSdX7
This commit is contained in:
Claude authored and V committed 2026-11-25 17:07:33 +00:00
1 parent 0f4c84b966
commit 7248e0ca6e
9 files changed
+220 -22

No files matched your search

+31 -9
View File
@@ -33,9 +33,9 @@ pub(all) struct MoonPlasmaCompositor {
server : @wayland.WaylandServer
wm : @wm.WmState
theme : @scene.ThemeTokens
output_w : Int
output_h : Int
work_area : @wm.Rect
mut output_w : Int
mut output_h : Int
mut work_area : @wm.Rect
windows : Map[UInt64, HostWindow]
damage : @scene.DamageTracker
shell : @shell.DesktopShell
@@ -91,12 +91,7 @@ pub fn MoonPlasmaCompositor::new(
titlebar_h=32,
border_w=2,
)
let out_rect : @wm.Rect = { x: 0, y: 0, w: output_w, h: output_h }
let work_area = @wm.compute_work_area(
out_rect,
excl_top=32, // room for the server-side title bar drawn above each client
excl_bottom=theme.panel_height,
)
let work_area = work_area_for(output_w, output_h, theme)
let shell = @shell.DesktopShell::new(socket_path)
shell.set_output(theme, output_w, output_h)
Some({
@@ -135,6 +130,33 @@ pub fn MoonPlasmaCompositor::new(
})
}
///| The part of a `w` x `h` output windows are laid out in.
fn work_area_for(w : Int, h : Int, theme : @scene.ThemeTokens) -> @wm.Rect {
@wm.compute_work_area(
{ x: 0, y: 0, w, h },
excl_top=32, // room for the server-side title bar drawn above each client
excl_bottom=theme.panel_height,
)
}
///| The output changed size (the nested window was resized, maximized or made fullscreen):
/// lay the desktop out for the new size, so nothing is drawn past the edge and cropped away.
pub fn MoonPlasmaCompositor::resize(self : MoonPlasmaCompositor, w : Int, h : Int) -> Unit {
if w <= 0 || h <= 0 || (w == self.output_w && h == self.output_h) {
return
}
self.output_w = w
self.output_h = h
self.work_area = work_area_for(w, h, self.theme)
self.server.set_output_size(w, h)
self.shell.set_output(self.theme, w, h)
self.apply_actions(self.wm.fit_work_area(self.work_area))
self.last_frame = None
self.last_sig = None
self.frame_changed = true
self.damage.mark_full()
}
///|
pub fn MoonPlasmaCompositor::close(self : MoonPlasmaCompositor) -> Unit {
for _, win in self.windows {
+16
View File
@@ -0,0 +1,16 @@
///| Resizing the output (the nested window was resized): the desktop is drawn at the new size.
///|
test "resize redraws the desktop at the new output size" {
let socket_path = "/tmp/wayland-moon-resize-" + @sys.getpid().to_string() + ".sock"
let comp = @host.MoonPlasmaCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
let before = comp.compose_frame()
assert_eq((before.width, before.height), (1280, 720))
comp.resize(900, 560)
let after = comp.compose_frame()
assert_eq((after.width, after.height), (900, 560))
assert_eq((comp.output_w, comp.output_h), (900, 560))
assert_eq(comp.work_area.h, 560 - 32 - comp.theme.panel_height)
assert_eq(comp.server.output_w, 900)
comp.close()
}