Remove WindowingOwner.hasTopLevelWindows (#178033)
This function doesn't seem to serve any purpose.
Top level is not a term we are currently using in the multi window code.
If we want to track if we have open windows, this can be done in the
Flutter framework - it doesn't need to be done at the platform level.
diff --git a/engine/src/flutter/shell/platform/windows/window_manager.cc b/engine/src/flutter/shell/platform/windows/window_manager.cc
index 93fdccd..b41e5af 100644
--- a/engine/src/flutter/shell/platform/windows/window_manager.cc
+++ b/engine/src/flutter/shell/platform/windows/window_manager.cc
@@ -27,10 +27,6 @@
isolate_ = Isolate::Current();
}
-bool WindowManager::HasTopLevelWindows() const {
- return !active_windows_.empty();
-}
-
FlutterViewId WindowManager::CreateRegularWindow(
const RegularWindowCreationRequest* request) {
auto window = HostWindow::CreateRegularWindow(
@@ -121,13 +117,6 @@
engine->window_manager()->Initialize(request);
}
-bool InternalFlutterWindows_WindowManager_HasTopLevelWindows(
- int64_t engine_id) {
- flutter::FlutterWindowsEngine* engine =
- flutter::FlutterWindowsEngine::GetEngineForId(engine_id);
- return engine->window_manager()->HasTopLevelWindows();
-}
-
FlutterViewId InternalFlutterWindows_WindowManager_CreateRegularWindow(
int64_t engine_id,
const flutter::RegularWindowCreationRequest* request) {
diff --git a/engine/src/flutter/shell/platform/windows/window_manager.h b/engine/src/flutter/shell/platform/windows/window_manager.h
index c37ba56..226411b 100644
--- a/engine/src/flutter/shell/platform/windows/window_manager.h
+++ b/engine/src/flutter/shell/platform/windows/window_manager.h
@@ -88,8 +88,6 @@
void Initialize(const WindowingInitRequest* request);
- bool HasTopLevelWindows() const;
-
FlutterViewId CreateRegularWindow(
const RegularWindowCreationRequest* request);
@@ -133,9 +131,6 @@
const flutter::WindowingInitRequest* request);
FLUTTER_EXPORT
-bool InternalFlutterWindows_WindowManager_HasTopLevelWindows(int64_t engine_id);
-
-FLUTTER_EXPORT
FlutterViewId InternalFlutterWindows_WindowManager_CreateRegularWindow(
int64_t engine_id,
const flutter::RegularWindowCreationRequest* request);
diff --git a/engine/src/flutter/shell/platform/windows/window_manager_unittests.cc b/engine/src/flutter/shell/platform/windows/window_manager_unittests.cc
index 6e7c915..e3fa8cc 100644
--- a/engine/src/flutter/shell/platform/windows/window_manager_unittests.cc
+++ b/engine/src/flutter/shell/platform/windows/window_manager_unittests.cc
@@ -82,20 +82,6 @@
EXPECT_TRUE(received_message);
}
-TEST_F(WindowManagerTest, HasTopLevelWindows) {
- IsolateScope isolate_scope(isolate());
-
- bool has_top_level_windows =
- InternalFlutterWindows_WindowManager_HasTopLevelWindows(engine_id());
- EXPECT_FALSE(has_top_level_windows);
-
- InternalFlutterWindows_WindowManager_CreateRegularWindow(
- engine_id(), regular_creation_request());
- has_top_level_windows =
- InternalFlutterWindows_WindowManager_HasTopLevelWindows(engine_id());
- EXPECT_TRUE(has_top_level_windows);
-}
-
TEST_F(WindowManagerTest, CreateRegularWindow) {
IsolateScope isolate_scope(isolate());
diff --git a/packages/flutter/lib/src/widgets/_window.dart b/packages/flutter/lib/src/widgets/_window.dart
index 05ff9d3..c4929bd 100644
--- a/packages/flutter/lib/src/widgets/_window.dart
+++ b/packages/flutter/lib/src/widgets/_window.dart
@@ -657,13 +657,6 @@
BaseWindowController? parent,
String? title,
});
-
- /// Returns whether the application has any top level windows created by this
- /// windowing owner.
- ///
- /// {@macro flutter.widgets.windowing.experimental}
- @internal
- bool hasTopLevelWindows();
}
/// Creates default windowing owner for standard desktop embedders.
@@ -709,11 +702,6 @@
}) {
throw UnsupportedError(errorMessage);
}
-
- @override
- bool hasTopLevelWindows() {
- throw UnsupportedError(errorMessage);
- }
}
/// The [RegularWindow] widget provides a way to render a regular window in the
diff --git a/packages/flutter/lib/src/widgets/_window_linux.dart b/packages/flutter/lib/src/widgets/_window_linux.dart
index 89b7aec..e0ce024 100644
--- a/packages/flutter/lib/src/widgets/_window_linux.dart
+++ b/packages/flutter/lib/src/widgets/_window_linux.dart
@@ -512,9 +512,6 @@
);
}
- /// Number of windows being managed by Flutter.
- int _windowCount = 0;
-
@internal
@override
RegularWindowController createRegularWindowController({
@@ -523,9 +520,7 @@
String? title,
required RegularWindowControllerDelegate delegate,
}) {
- _windowCount++;
return RegularWindowControllerLinux(
- owner: this,
delegate: delegate,
preferredSize: preferredSize,
preferredConstraints: preferredConstraints,
@@ -544,12 +539,6 @@
}) {
throw UnimplementedError('Dialog windows are not yet implemented on Linux.');
}
-
- @internal
- @override
- bool hasTopLevelWindows() {
- return _windowCount > 0;
- }
}
/// Implementation of [RegularWindowController] for the Linux platform.
@@ -572,13 +561,11 @@
/// * [RegularWindowController], the base class for regular windows.
@internal
RegularWindowControllerLinux({
- required WindowingOwnerLinux owner,
required RegularWindowControllerDelegate delegate,
Size? preferredSize,
BoxConstraints? preferredConstraints,
String? title,
- }) : _owner = owner,
- _delegate = delegate,
+ }) : _delegate = delegate,
_window = _GtkWindow(),
super.empty() {
if (!isWindowingEnabled) {
@@ -621,7 +608,6 @@
_window.present();
}
- final WindowingOwnerLinux _owner;
final RegularWindowControllerDelegate _delegate;
final _GtkWindow _window;
late final _FlWindowMonitor _windowMonitor;
@@ -640,7 +626,6 @@
_windowMonitor.close();
_windowMonitor.unref();
_destroyed = true;
- _owner._windowCount--;
}
@override
diff --git a/packages/flutter/lib/src/widgets/_window_macos.dart b/packages/flutter/lib/src/widgets/_window_macos.dart
index 16c4dac..1148370 100644
--- a/packages/flutter/lib/src/widgets/_window_macos.dart
+++ b/packages/flutter/lib/src/widgets/_window_macos.dart
@@ -90,11 +90,6 @@
return res;
}
- @override
- bool hasTopLevelWindows() {
- return _activeControllers.isNotEmpty;
- }
-
final List<BaseWindowController> _activeControllers = <BaseWindowController>[];
/// Returns the window handle for the given [view], or null is the window
diff --git a/packages/flutter/lib/src/widgets/_window_win32.dart b/packages/flutter/lib/src/widgets/_window_win32.dart
index 505b1c2..4d1df40 100644
--- a/packages/flutter/lib/src/widgets/_window_win32.dart
+++ b/packages/flutter/lib/src/widgets/_window_win32.dart
@@ -219,12 +219,6 @@
}
}
}
-
- @internal
- @override
- bool hasTopLevelWindows() {
- return _Win32PlatformInterface.hasTopLevelWindows(PlatformDispatcher.instance.engineId!);
- }
}
class _RegularWindowMesageHandler implements _WindowsMessageHandler {
@@ -673,11 +667,6 @@
}
class _Win32PlatformInterface {
- @ffi.Native<ffi.Bool Function(ffi.Int64)>(
- symbol: 'InternalFlutterWindows_WindowManager_HasTopLevelWindows',
- )
- external static bool hasTopLevelWindows(int engineId);
-
static void initializeWindowing(
ffi.Allocator allocator,
int engineId,
diff --git a/packages/flutter/test/widgets/windowing_test.dart b/packages/flutter/test/widgets/windowing_test.dart
index c14aa3b..9cc7163 100644
--- a/packages/flutter/test/widgets/windowing_test.dart
+++ b/packages/flutter/test/widgets/windowing_test.dart
@@ -136,21 +136,6 @@
);
});
- test('default WindowingOwner throws when accessing hasTopLevelWindows', () {
- final WindowingOwner owner = createDefaultWindowingOwner();
- expect(() => owner.hasTopLevelWindows(), throwsUnsupportedError);
- });
-
- testWidgets('RegularWindow throws UnsupportedError', (WidgetTester tester) async {
- expect(
- () => RegularWindow(
- controller: _StubRegularWindowController(tester),
- child: const Text('Test'),
- ),
- throwsUnsupportedError,
- );
- });
-
testWidgets('DialogWindow throws UnsupportedError', (WidgetTester tester) async {
expect(
() => DialogWindow(