Windows: on a handset, apps open maximized and dialogs float above
Deploy to the handset / build-and-deploy (push) Successful in 2m7s
CI / test (push) Failing after 2m42s

- Apps open maximized on a touchscreen whose short side is under 720px. Restore gives a floating window that fits the screen.
- Maximized windows can't be dragged or resized.
- Dialogs (xdg_toplevel.set_parent) open floating and centered, and stay above their app when it is activated.
- Under tiling, the last used app is drawn on top.
- Add transient_for to WmState and make inner_work_area and fit_rect public for the compositor.
- Tests cover maximized opening, dialog stacking, drag suppression and restore.
- Document the handset window behavior in docs/handset.md.
This commit is contained in:
nandi committed 2026-11-29 23:11:34 -08:00
1 parent 7029c92e6e
commit 5c83cdaa22
5 files changed
+148 -10

No files matched your search

+26 -3
View File
@@ -780,6 +780,12 @@ fn ChandraCompositor::configure_window(self : ChandraCompositor, win : HostWindo
)
}
///| A phone's screen: a touchscreen, and the short side (whichever way it is turned) too narrow
/// for windows side by side.
fn ChandraCompositor::is_handset(self : ChandraCompositor) -> Bool {
self.server.touch && self.output_w.min(self.output_h) < 720
}
///|
pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
self.flush_configures()
@@ -811,8 +817,17 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
geo_y: 0,
}
self.windows.set(wid, win)
// On a handset apps open maximized, and float so the last used one is on top. Dialogs
// float above their app.
let handset = self.is_handset()
let dialog = self.server.toplevel_has_parent(wid)
match self.server.toplevel_parent(wid) {
Some(p) => self.wm.transient_for.set(wid, p)
None => ()
}
win.maximized = handset && !dialog
// An app whose window was last left somewhere reopens there, floating, kept on screen.
let saved = self.shell.saved_window(app_id)
let saved = if handset && dialog { None } else { self.shell.saved_window(app_id) }
let g : @wm.Rect = match saved {
Some((sx, sy, sw, sh)) => {
let w = if sw > self.output_w { self.output_w } else { sw }
@@ -823,6 +838,14 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
}
None => { x: 100, y: 100, w: 640, h: 480 }
}
// (Maximized, this is the size Restore goes back to.)
let g = if handset {
let a = self.wm.inner_work_area(self.work_area)
let r = @wm.fit_rect(g, a)
if dialog { { ..r, x: a.x + (a.w - r.w) / 2, y: a.y + (a.h - r.h) / 2 } } else { r }
} else {
g
}
win.geometry = @scene.Rect::new(g.x, g.y, g.w, g.h)
let rec : @wm.WindowRecord = {
id: wid,
@@ -833,10 +856,10 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
min_size: { w: min_w, h: min_h },
max_size: None,
focused: true,
maximized: false,
maximized: win.maximized,
fullscreen: false,
minimized: false,
is_floating: saved is Some(_),
is_floating: handset || saved is Some(_),
workspace: 0U,
can_move: true,
can_resize: true,
+66
View File
@@ -205,3 +205,69 @@ test "a finger scrolls the launcher's list: a drag moves it, a flick keeps it go
assert_eq((st.scroll, st.offset), (0, 0))
comp.close()
}
///|
test "on a handset apps open maximized, dialogs float above their app, and a drag leaves them be" {
let (comp, _, _, _) = touch_setup("maximized", false)
let one = comp.windows.get(1UL).unwrap()
assert_true(one.maximized)
assert_true(one.geometry.w > 500 && one.geometry.h > 900)
// Opened with its one size: the client was never asked for another.
let path = "/tmp/wayland-moon-touch-maximized-" + @sys.getpid().to_string() + ".sock"
let (c2, shm, surf, xdg, top, _) = open_and_configure_client(comp, path, "U", "u")
let two = comp.windows.get(2UL).unwrap()
assert_true(two.maximized)
assert_eq((c2.configured_w, c2.configured_h), (two.geometry.w, two.geometry.h))
commit_shm_frame(comp, c2, shm, surf, xdg, 2UL)
assert_eq(comp.wm.stacking_order(), [1UL, 2UL])
// A drag on the title bar doesn't move it.
let g = two.geometry
let (tx, ty) = ((g.x + 60).to_double(), (g.y - 12).to_double())
comp.handle_input(Touch(Down(0, tx, ty)), 10U)
comp.handle_input(Touch(Motion(0, tx, ty + 90.0)), 20U)
comp.handle_input(Touch(Up(0)), 30U)
assert_eq(two.geometry, g)
// A dialog of the second: same client, set_parent before its first commit.
let objs = fn(target : UInt, op : UInt, arg : UInt?) {
let id = c2.alloc_id()
let w = @wayland.WireWriter::new()
w.u32(id)
match arg {
Some(a) => w.u32(a)
None => ()
}
c2.send(w.finish_msg(target, op))
id
}
let reg = objs(1U, 1U, None)
let dsurf = objs(bind_global(c2, reg, "wl_compositor", 5U), 0U, None)
let dxdg = objs(bind_global(c2, reg, "xdg_wm_base", 5U), 2U, Some(dsurf))
let dtop = objs(dxdg, 1U, None)
let w = @wayland.WireWriter::new()
w.u32(top)
c2.send(w.finish_msg(dtop, 1U))
c2.send(@wayland.WireWriter::new().finish_msg(dsurf, 6U))
for _i = 0; _i < 5; _i = _i + 1 {
comp.step()
@sys.sleep_ms(2)
}
let d = comp.windows.get(3UL).unwrap()
assert_false(d.maximized)
assert_true(d.geometry.x >= 0 && d.geometry.x + d.geometry.w <= 540)
// Switching apps raises the app, and going back brings the dialog along.
ignore(comp.wm.handle_request(1UL, @wm.WindowRequest::Activate, comp.work_area))
assert_eq(comp.wm.stacking_order(), [2UL, 3UL, 1UL])
ignore(comp.wm.handle_request(2UL, @wm.WindowRequest::Activate, comp.work_area))
assert_eq(comp.wm.stacking_order(), [1UL, 2UL, 3UL])
// Restore: a floating window inside the screen.
ignore(comp.wm.handle_request(2UL, @wm.WindowRequest::Maximize(false), comp.work_area))
let r = comp.wm.windows.get(2UL).unwrap().geometry
assert_true(r.x >= 0 && r.x + r.w <= 540 && r.h < g.h)
// Under Tiling too (the windows go into the tree), the last used app is on top.
ignore(comp.wm.handle_request(2UL, @wm.WindowRequest::Maximize(true), comp.work_area))
comp.set_layout_mode(@wm.LayoutMode::Floating)
comp.set_layout_mode(@wm.LayoutMode::Tiling)
ignore(comp.wm.handle_request(1UL, @wm.WindowRequest::Activate, comp.work_area))
assert_eq(comp.wm.stacking_order(), [3UL, 2UL, 1UL])
comp.close()
}