Make the terminal's floating mode a window of the window system

Phase 3 of docs/plans/floating-windows.md. The terminal window kind reuses
TerminalHub; TerminalWindows keeps the window in step with TerminalLayout
(show opens or shows it, hide minimises it, Minimise and Close hide the
terminal). The bottom panel stays a shell panel. The first window takes the
frame and maximised state pipelines.terminal-layout.v1 saved.

The terminal's own float chrome and FloatingLayer are deleted.
This commit is contained in:
2026-11-10 22:19:30 +00:00
parent 31f495fc18
commit 75a61dbd8c
15 changed files with 409 additions and 578 deletions
-99
View File
@@ -1,99 +0,0 @@
import 'package:flutter/widgets.dart';
/// A layer of floating windows painted in the app's root overlay, above the
/// page, while it keeps its place in the tree (its inherited widgets, focus
/// and state stay where it is built). Every [FloatingLayer] shares that one
/// overlay. Only the terminal's floating window still uses it; the app's
/// other windows are in the shell's window host.
///
/// [builder] returns the windows as [Positioned] children of a [Stack] the
/// size of [bounds]: this widget's own box, or the whole overlay when
/// [coverOverlay] is set. Space between windows takes no input. Without an
/// overlay (a bare widget test) the layer paints in place.
class FloatingLayer extends StatefulWidget {
const FloatingLayer({
super.key,
required this.builder,
this.open = true,
this.coverOverlay = false,
});
final List<Widget> Function(BuildContext context, Size bounds) builder;
/// Turning true brings the layer to the top, as its window opens.
final bool open;
final bool coverOverlay;
@override
State<FloatingLayer> createState() => _FloatingLayerState();
}
class _FloatingLayerState extends State<FloatingLayer> {
final OverlayPortalController _portal = OverlayPortalController(
debugLabel: 'floating layer',
);
@override
void initState() {
super.initState();
_portal.show();
}
@override
void didUpdateWidget(covariant FloatingLayer oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.open && !oldWidget.open) {
WidgetsBinding.instance.addPostFrameCallback((_) => _raise());
}
}
void _raise() {
if (mounted) _portal.show();
}
Widget _layer(BuildContext context, Size bounds) => Listener(
behavior: HitTestBehavior.deferToChild,
onPointerDown: (_) => _raise(),
child: Focus(
canRequestFocus: false,
skipTraversal: true,
onFocusChange: (focused) {
if (focused) _raise();
},
child: SizedBox.fromSize(
size: bounds,
child: Stack(
clipBehavior: Clip.none,
children: widget.builder(context, bounds),
),
),
),
);
@override
Widget build(BuildContext context) {
if (Overlay.maybeOf(context, rootOverlay: true) == null) {
return LayoutBuilder(
builder: (context, constraints) => _layer(context, constraints.biggest),
);
}
return OverlayPortal.overlayChildLayoutBuilder(
controller: _portal,
overlayLocation: OverlayChildLocation.rootOverlay,
overlayChildBuilder: (context, info) => widget.coverOverlay
? Positioned.fill(child: _layer(context, info.overlaySize))
: Positioned(
left: 0,
top: 0,
width: info.childSize.width,
height: info.childSize.height,
child: Transform(
transform: info.childPaintTransform,
child: _layer(context, info.childSize),
),
),
child: const SizedBox.expand(),
);
}
}