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

+30 -6
View File
@@ -143,6 +143,8 @@ pub(all) struct WmState {
mut border_w : Int
mut cascade_step : Int
mut drag : DragSession?
/// Dialogs and the window each belongs to: a floating dialog is raised with its window.
transient_for : Map[UInt64, UInt64]
}
///|
@@ -163,6 +165,7 @@ pub fn WmState::new(
border_w,
cascade_step: 0,
drag: None,
transient_for: {},
}
}
@@ -385,7 +388,7 @@ fn push_top(arr : Array[UInt64], id : UInt64) -> Unit {
}
///|
fn WmState::inner_work_area(self : WmState, work_area : Rect) -> Rect {
pub fn WmState::inner_work_area(self : WmState, work_area : Rect) -> Rect {
let g = self.outer_gap
let w = if work_area.w > 2 * g { work_area.w - 2 * g } else { work_area.w }
let h = if work_area.h > 2 * g { work_area.h - 2 * g } else { work_area.h }
@@ -509,6 +512,18 @@ fn WmState::set_focus(self : WmState, id : UInt64?) -> Array[WmAction] {
push_mru_front(ws.mru, nid)
if w.is_floating {
push_top(ws.floating, nid)
// Its dialogs stay above it. One pass over the order as it was, so a client naming
// dialogs in a circle can't loop.
let raised = [nid]
for id in ws.floating.copy() {
match self.transient_for.get(id) {
Some(p) if id != nid && raised.contains(p) => {
push_top(ws.floating, id)
raised.push(id)
}
_ => ()
}
}
}
actions.push(Focus(nid))
actions.push(Raise(nid))
@@ -561,7 +576,8 @@ pub fn WmState::open_window(
}
push_mru_front(ws.mru, win.id)
let actions : Array[WmAction] = []
if auto_float {
// A window that opens maximized gets its one size from the relayout.
if auto_float && !win.maximized {
actions.push(SetGeometry(win.id, win.geometry))
}
for a in self.relayout(win.workspace, work_area) {
@@ -586,6 +602,7 @@ pub fn WmState::close_window(
let ws_id = win.workspace
let ws = self.ensure_workspace(ws_id)
ignore(self.windows.remove(id))
self.transient_for.remove(id)
ws.tree = remove_leaf(ws.tree, id)
remove_id(ws.floating, id)
remove_id(ws.mru, id)
@@ -803,7 +820,7 @@ pub fn WmState::stacking_order(self : WmState) -> Array[UInt64] {
}
collect_tree(ws.tree, order, ws.fullscreen, self.windows)
// Maximized tiled windows are drawn above their neighbours.
// Maximized tiled windows are drawn above their neighbours, the last used one on top.
let below : Array[UInt64] = []
let above : Array[UInt64] = []
for id in order {
@@ -812,6 +829,13 @@ pub fn WmState::stacking_order(self : WmState) -> Array[UInt64] {
None => below.push(id)
}
}
let rank = fn(id : UInt64) {
match ws.mru.search(id) {
Some(i) => -i
None => -ws.mru.length()
}
}
above.sort_by((a, b) => rank(a).compare(rank(b)))
order.clear()
order.append(below)
order.append(above)
@@ -903,7 +927,7 @@ pub fn WmState::float_window(
}
}
///|
///| Start moving or resizing a window. A maximized or fullscreen window stays where it is.
pub fn WmState::start_drag(
self : WmState,
win_id : UInt64,
@@ -913,7 +937,7 @@ pub fn WmState::start_drag(
) -> Bool {
match self.windows.get(win_id) {
Some(win) =>
if !win.fullscreen {
if !win.fullscreen && !win.maximized {
self.drag = Some({
win_id,
mode,
@@ -1090,7 +1114,7 @@ test "split handles: divider position, drag, and row gap leaves room for the tit
}
///| Keep a floating rectangle inside `area`: shrunk to fit, then moved back on screen.
fn fit_rect(r : Rect, area : Rect) -> Rect {
pub 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)