Add the Windows menu, window cycling, edge snapping and size per kind

Phase 4 of docs/plans/floating-windows.md. A bar button lists the app's
windows on every tab (show one, Show all, Minimise all, Close all). Alt+`
and Alt+Shift+` bring the next or previous window to the front. Dropping a
title at the left or right edge fills that half, at the top it maximises.
A new window of a kind opens at the size that kind was last given.
This commit is contained in:
2026-11-11 00:05:16 +00:00
parent e9fa1b6ec9
commit ef1c120f57
12 changed files with 593 additions and 15 deletions
+42 -7
View File
@@ -93,11 +93,46 @@ class _WindowLayerState extends State<WindowLayer>
return drawnWindowFrame(entry, widget.bounds, widget.kind.minSize);
}
void _move(Offset delta) => widget.manager.setFrame(
_id,
fitWindowFrame(_current.shift(delta), widget.bounds, widget.kind.minSize),
save: false,
);
/// Where the pointer is in the host while the title is dragged.
Offset? _pointer;
void _move(Offset delta, Offset globalPosition) {
final box = context.findRenderObject();
_pointer = box is RenderBox ? box.globalToLocal(globalPosition) : null;
widget.manager.setFrame(
_id,
fitWindowFrame(_current.shift(delta), widget.bounds, widget.kind.minSize),
save: false,
);
}
/// Dropping the title at the app's left or right edge fills that half;
/// at the top edge it maximises.
void _moveEnded() {
final pointer = _pointer;
_pointer = null;
final bounds = widget.bounds;
final snap = pointer == null ? null : windowSnapFor(pointer, bounds);
if (snap == WindowSnap.maximize) {
widget.manager.setMaximized(_id, true);
return;
}
if (snap != null) {
widget.manager.setFrame(
_id,
fitWindowFrame(
windowSnapRect(snap, bounds),
bounds,
widget.kind.minSize,
),
save: false,
);
// A snapped half is not the size to give this kind's next window.
widget.manager.commit();
return;
}
widget.manager.commit(_id);
}
void _resize(Offset delta) {
final rect = _current;
@@ -156,7 +191,7 @@ class _WindowLayerState extends State<WindowLayer>
actions: kind.actions(context, entry),
maximized: entry.maximized,
onMove: _move,
onMoveEnd: manager.commit,
onMoveEnd: _moveEnded,
onMinimize: () => manager.setMinimized(_id, true),
onToggleMaximized: () =>
manager.setMaximized(_id, !entry.maximized),
@@ -200,7 +235,7 @@ class _WindowLayerState extends State<WindowLayer>
bottom: widget.bounds.height - frame.bottom,
child: WindowResizeCorner(
onResize: _resize,
onResizeEnd: manager.commit,
onResizeEnd: () => manager.commit(_id),
),
),
],