Terminal surface: lazy activation, settings mode choice, open in terminal, tests

This commit is contained in:
2026-11-09 21:55:29 +00:00
parent acd160b49e
commit e79a120ac7
7 changed files with 633 additions and 6 deletions
@@ -55,14 +55,22 @@ class _TerminalSurfaceState extends State<TerminalSurface>
void initState() {
super.initState();
HardwareKeyboard.instance.addHandler(_key);
widget.layout.addListener(_layoutChanged);
// A terminal left shown before a reload reattaches at once.
WidgetsBinding.instance.addPostFrameCallback((_) => _layoutChanged());
}
@override
void dispose() {
HardwareKeyboard.instance.removeHandler(_key);
widget.layout.removeListener(_layoutChanged);
super.dispose();
}
void _layoutChanged() {
if (mounted && widget.layout.visible && !_narrow) widget.hub.activate();
}
bool get _narrow => MediaQuery.sizeOf(context).width < terminalNarrowWidth;
/// The shortcut is handled before the focused widget, so it toggles even
@@ -98,6 +106,7 @@ class _TerminalSurfaceState extends State<TerminalSurface>
}
Future<void> _openPage() async {
widget.hub.activate();
if (_pageOpen) return;
_pageOpen = true;
try {