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:
9 files changed
+220
-22
No files matched your search
@@ -142,6 +142,8 @@ pub(all) struct WmState {
|
||||
pub fn WmState::close_window(Self, UInt64, Rect) -> Array[WmAction]
|
||||
pub fn WmState::drag_split(Self, SplitHandle, Int32, Int32, Rect) -> Array[WmAction]
|
||||
pub fn WmState::end_drag(Self) -> Unit
|
||||
pub fn WmState::fit_work_area(Self, Rect) -> Array[WmAction]
|
||||
pub fn WmState::float_window(Self, UInt64, Rect) -> Array[WmAction]
|
||||
pub fn WmState::handle_request(Self, UInt64, WindowRequest, Rect) -> Array[WmAction]
|
||||
pub fn WmState::hit_test(Self, Int32, Int32, Rect?) -> InputHit
|
||||
pub fn WmState::new(inner_gap? : Int32, outer_gap? : Int32, titlebar_h? : Int32, border_w? : Int32) -> Self
|
||||
|
||||
@@ -1088,3 +1088,39 @@ test "split handles: divider position, drag, and row gap leaves room for the tit
|
||||
let w3 = wm.windows[3UL].geometry
|
||||
assert_eq(w3.y - (w2.y + w2.h), 8 + 32)
|
||||
}
|
||||
|
||||
///| Keep a floating rectangle inside `area`: shrunk to fit, then moved back on screen.
|
||||
fn fit_rect(r : Rect, area : Rect) -> Rect {
|
||||
let w = if r.w > area.w { area.w } else { r.w }
|
||||
let h = if r.h > area.h { area.h } else { r.h }
|
||||
let x = clamp_int(r.x, area.x, area.x + area.w - w)
|
||||
let y = clamp_int(r.y, area.y, area.y + area.h - h)
|
||||
{ x, y, w, h }
|
||||
}
|
||||
|
||||
///| The output changed size: reflow every workspace into the new work area and pull floating
|
||||
/// windows back inside it, so no window is left cut off past the new edge.
|
||||
pub fn WmState::fit_work_area(self : WmState, work_area : Rect) -> Array[WmAction] {
|
||||
let actions : Array[WmAction] = []
|
||||
for ws in self.workspaces {
|
||||
for id in ws.floating {
|
||||
match self.windows.get(id) {
|
||||
Some(win) => {
|
||||
win.floating_geometry = fit_rect(win.floating_geometry, work_area)
|
||||
if !win.maximized && !win.fullscreen && !win.minimized {
|
||||
let g = fit_rect(win.geometry, work_area)
|
||||
if g != win.geometry {
|
||||
win.geometry = g
|
||||
actions.push(SetGeometry(id, g))
|
||||
}
|
||||
}
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
for a in self.relayout(ws.id, work_area) {
|
||||
actions.push(a)
|
||||
}
|
||||
}
|
||||
actions
|
||||
}
|
||||
@@ -135,3 +135,18 @@ test "interactive drag move and resize clamps to min_size" {
|
||||
assert_eq(wm.update_drag(250, 140), Some(SetGeometry(5UL, { x: 150, y: 140, w: 200, h: 150 })))
|
||||
wm.end_drag()
|
||||
}
|
||||
|
||||
///|
|
||||
test "shrinking the work area reflows tiles and pulls floating windows back on screen" {
|
||||
let wm = WmState::new(inner_gap=10, outer_gap=10)
|
||||
let big : Rect = { x: 0, y: 0, w: 1280, h: 700 }
|
||||
ignore(wm.open_window(mk_win(1UL), big))
|
||||
ignore(wm.open_window(mk_win(2UL, floating=true), big))
|
||||
wm.windows[2UL].geometry = { x: 900, y: 400, w: 360, h: 280 }
|
||||
let small : Rect = { x: 0, y: 0, w: 800, h: 500 }
|
||||
ignore(wm.fit_work_area(small))
|
||||
// The tile fills the new padded area.
|
||||
assert_eq(wm.windows[1UL].geometry, { x: 10, y: 10, w: 780, h: 480 })
|
||||
// The floating window keeps its size but moves back inside.
|
||||
assert_eq(wm.windows[2UL].geometry, { x: 440, y: 220, w: 360, h: 280 })
|
||||
}
|
||||
Reference in new issue
Block a user