Float several chats and keep them working on every tab
Floating chats were stuck on other destinations: the hidden Chat tab muted the window's hide animation, so the window stayed painted but took no input. The reveal now uses its own ticker, each floating pane's focus scope hangs from a FloatingFocusRoot above the destination stack, and the windows show over every destination like the terminal. Any number of chats can float; the shortcut, a window's X and the menu show or hide them together. Each pane keeps its own frame (also while docked), saved in record version 2; version 1 records still load. Drags read the live frame so fast pointer events no longer lose movement.
This commit is contained in:
@@ -97,3 +97,51 @@ class _FloatingLayerState extends State<FloatingLayer> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A focus parent for floating windows placed above the app's destinations,
|
||||
/// so a window built inside one destination keeps the keyboard while another
|
||||
/// destination shows (a hidden destination excludes its own subtree from
|
||||
/// focus). Windows attach their focus scope here with [maybeOf].
|
||||
class FloatingFocusRoot extends StatefulWidget {
|
||||
const FloatingFocusRoot({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
/// The nearest root's focus node, or null outside one.
|
||||
static FocusNode? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<_FloatingFocusScope>()?.node;
|
||||
|
||||
@override
|
||||
State<FloatingFocusRoot> createState() => _FloatingFocusRootState();
|
||||
}
|
||||
|
||||
class _FloatingFocusRootState extends State<FloatingFocusRoot> {
|
||||
final FocusNode _node = FocusNode(
|
||||
debugLabel: 'floating windows',
|
||||
canRequestFocus: false,
|
||||
skipTraversal: true,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_node.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Focus(
|
||||
focusNode: _node,
|
||||
includeSemantics: false,
|
||||
child: _FloatingFocusScope(node: _node, child: widget.child),
|
||||
);
|
||||
}
|
||||
|
||||
class _FloatingFocusScope extends InheritedWidget {
|
||||
const _FloatingFocusScope({required this.node, required super.child});
|
||||
|
||||
final FocusNode node;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(_FloatingFocusScope oldWidget) =>
|
||||
oldWidget.node != node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user