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
+20
View File
@@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'window_focus.dart';
import 'window_layer.dart';
import 'window_manager.dart';
import 'window_shortcuts.dart';
/// The app's floating windows, drawn in the shell page above the
/// destinations and the terminal panel: plain children of one stack, in the
@@ -33,6 +35,7 @@ class _WindowHostState extends State<WindowHost> {
void initState() {
super.initState();
widget.manager.addListener(_changed);
FocusManager.instance.addEarlyKeyEventHandler(_key);
// The shell page is not the top route while a popup or page covers it.
_focus.covered = () =>
mounted && !(ModalRoute.of(context)?.isCurrent ?? true);
@@ -51,6 +54,7 @@ class _WindowHostState extends State<WindowHost> {
@override
void dispose() {
FocusManager.instance.removeEarlyKeyEventHandler(_key);
widget.manager.removeListener(_changed);
_focus.dispose();
super.dispose();
@@ -81,6 +85,22 @@ class _WindowHostState extends State<WindowHost> {
setState(() {});
}
/// Alt+` and Alt+Shift+` bring the next or previous window to the front,
/// from anywhere (a composer, the terminal). With fewer than two windows
/// showing, or while a popup covers the app, the key is left alone.
KeyEventResult _key(KeyEvent event) {
if (!mounted) return KeyEventResult.ignored;
final step = windowCycleShortcut(event, HardwareKeyboard.instance);
final manager = widget.manager;
if (step == null ||
(_focus.covered?.call() ?? false) ||
manager.windows.where(manager.isVisible).length < 2) {
return KeyEventResult.ignored;
}
manager.cycle(step);
return KeyEventResult.handled;
}
/// The window takes the keyboard, then its content places it.
void _focusWindow(String id) {
_focus.focusSoon(id);