import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'window_entry.dart'; import 'window_manager.dart'; /// The floating window some content is in: its entry and the manager. Absent /// outside a window, so shared content can tell the tiled app from a window. /// /// Content depends on what it can read of the entry, not on where the window /// is drawn: moving, resizing, minimising or maximising a window keeps its /// content as it is. class WindowScope extends InheritedWidget { const WindowScope({ super.key, required this.manager, required this.entry, required super.child, }); final WindowManager manager; final WindowEntry entry; static WindowScope? maybeOf(BuildContext context) => context.dependOnInheritedWidgetOfExactType(); static WindowScope of(BuildContext context) => maybeOf(context)!; @override bool updateShouldNotify(WindowScope oldWidget) => oldWidget.manager != manager || oldWidget.entry.id != entry.id || oldWidget.entry.kind != entry.kind || oldWidget.entry.contentId != entry.contentId || oldWidget.entry.serverKey != entry.serverKey || !mapEquals(oldWidget.entry.data, entry.data); } /// Where a window's content area is drawn in the window host. Kept apart from /// [WindowScope] so a move or a resize repositions the page without rebuilding /// what the page shows. class WindowBodyScope extends InheritedWidget { const WindowBodyScope({super.key, required this.body, required super.child}); /// The content area (the window less its title bar), in the host's /// coordinates. final Rect body; static Rect? maybeOf(BuildContext context) => context.dependOnInheritedWidgetOfExactType()?.body; @override bool updateShouldNotify(WindowBodyScope oldWidget) => oldWidget.body != body; }