Files
alan ef1c120f57 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.
2026-11-11 00:05:16 +00:00

29 lines
1.1 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
/// The step Alt+` (1) or Alt+Shift+` (-1) moves between the app's floating
/// windows, or null for any other key. A browser keeps Ctrl+Tab and the
/// system keeps Cmd+`, so the chord is Alt (Option), which every platform
/// delivers; Option+` types a dead key on a Mac, so the key is matched by
/// its position too. Ctrl+` stays the terminal's.
int? windowCycleShortcut(KeyEvent event, HardwareKeyboard keyboard) {
if (event is KeyUpEvent ||
!keyboard.isAltPressed ||
keyboard.isControlPressed ||
keyboard.isMetaPressed) {
return null;
}
final backquote =
event.logicalKey == LogicalKeyboardKey.backquote ||
event.physicalKey == PhysicalKeyboardKey.backquote;
if (!backquote) return null;
return keyboard.isShiftPressed ? -1 : 1;
}
/// The chord as it reads on this platform, for the Windows menu.
String windowCycleShortcutLabel([TargetPlatform? platform]) =>
switch (platform ?? defaultTargetPlatform) {
TargetPlatform.macOS || TargetPlatform.iOS => 'Option+`',
_ => 'Alt+`',
};