Skip to content

Commit c5e809a

Browse files
Remove WindowingOwner.hasTopLevelWindows (flutter#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.
1 parent c093967 commit c5e809a

File tree

8 files changed

+1
-89
lines changed

8 files changed

+1
-89
lines changed

engine/src/flutter/shell/platform/windows/window_manager.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ void WindowManager::Initialize(const WindowingInitRequest* request) {
2727
isolate_ = Isolate::Current();
2828
}
2929

30-
bool WindowManager::HasTopLevelWindows() const {
31-
return !active_windows_.empty();
32-
}
33-
3430
FlutterViewId WindowManager::CreateRegularWindow(
3531
const RegularWindowCreationRequest* request) {
3632
auto window = HostWindow::CreateRegularWindow(
@@ -121,13 +117,6 @@ void InternalFlutterWindows_WindowManager_Initialize(
121117
engine->window_manager()->Initialize(request);
122118
}
123119

124-
bool InternalFlutterWindows_WindowManager_HasTopLevelWindows(
125-
int64_t engine_id) {
126-
flutter::FlutterWindowsEngine* engine =
127-
flutter::FlutterWindowsEngine::GetEngineForId(engine_id);
128-
return engine->window_manager()->HasTopLevelWindows();
129-
}
130-
131120
FlutterViewId InternalFlutterWindows_WindowManager_CreateRegularWindow(
132121
int64_t engine_id,
133122
const flutter::RegularWindowCreationRequest* request) {

engine/src/flutter/shell/platform/windows/window_manager.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ class WindowManager {
8888

8989
void Initialize(const WindowingInitRequest* request);
9090

91-
bool HasTopLevelWindows() const;
92-
9391
FlutterViewId CreateRegularWindow(
9492
const RegularWindowCreationRequest* request);
9593

@@ -132,9 +130,6 @@ void InternalFlutterWindows_WindowManager_Initialize(
132130
int64_t engine_id,
133131
const flutter::WindowingInitRequest* request);
134132

135-
FLUTTER_EXPORT
136-
bool InternalFlutterWindows_WindowManager_HasTopLevelWindows(int64_t engine_id);
137-
138133
FLUTTER_EXPORT
139134
FlutterViewId InternalFlutterWindows_WindowManager_CreateRegularWindow(
140135
int64_t engine_id,

engine/src/flutter/shell/platform/windows/window_manager_unittests.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@ TEST_F(WindowManagerTest, WindowingInitialize) {
8282
EXPECT_TRUE(received_message);
8383
}
8484

85-
TEST_F(WindowManagerTest, HasTopLevelWindows) {
86-
IsolateScope isolate_scope(isolate());
87-
88-
bool has_top_level_windows =
89-
InternalFlutterWindows_WindowManager_HasTopLevelWindows(engine_id());
90-
EXPECT_FALSE(has_top_level_windows);
91-
92-
InternalFlutterWindows_WindowManager_CreateRegularWindow(
93-
engine_id(), regular_creation_request());
94-
has_top_level_windows =
95-
InternalFlutterWindows_WindowManager_HasTopLevelWindows(engine_id());
96-
EXPECT_TRUE(has_top_level_windows);
97-
}
98-
9985
TEST_F(WindowManagerTest, CreateRegularWindow) {
10086
IsolateScope isolate_scope(isolate());
10187

packages/flutter/lib/src/widgets/_window.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -657,13 +657,6 @@ abstract class WindowingOwner {
657657
BaseWindowController? parent,
658658
String? title,
659659
});
660-
661-
/// Returns whether the application has any top level windows created by this
662-
/// windowing owner.
663-
///
664-
/// {@macro flutter.widgets.windowing.experimental}
665-
@internal
666-
bool hasTopLevelWindows();
667660
}
668661

669662
/// Creates default windowing owner for standard desktop embedders.
@@ -709,11 +702,6 @@ class _WindowingOwnerUnsupported extends WindowingOwner {
709702
}) {
710703
throw UnsupportedError(errorMessage);
711704
}
712-
713-
@override
714-
bool hasTopLevelWindows() {
715-
throw UnsupportedError(errorMessage);
716-
}
717705
}
718706

719707
/// The [RegularWindow] widget provides a way to render a regular window in the

packages/flutter/lib/src/widgets/_window_linux.dart

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,6 @@ class WindowingOwnerLinux extends WindowingOwner {
512512
);
513513
}
514514

515-
/// Number of windows being managed by Flutter.
516-
int _windowCount = 0;
517-
518515
@internal
519516
@override
520517
RegularWindowController createRegularWindowController({
@@ -523,9 +520,7 @@ class WindowingOwnerLinux extends WindowingOwner {
523520
String? title,
524521
required RegularWindowControllerDelegate delegate,
525522
}) {
526-
_windowCount++;
527523
return RegularWindowControllerLinux(
528-
owner: this,
529524
delegate: delegate,
530525
preferredSize: preferredSize,
531526
preferredConstraints: preferredConstraints,
@@ -544,12 +539,6 @@ class WindowingOwnerLinux extends WindowingOwner {
544539
}) {
545540
throw UnimplementedError('Dialog windows are not yet implemented on Linux.');
546541
}
547-
548-
@internal
549-
@override
550-
bool hasTopLevelWindows() {
551-
return _windowCount > 0;
552-
}
553542
}
554543

555544
/// Implementation of [RegularWindowController] for the Linux platform.
@@ -572,13 +561,11 @@ class RegularWindowControllerLinux extends RegularWindowController {
572561
/// * [RegularWindowController], the base class for regular windows.
573562
@internal
574563
RegularWindowControllerLinux({
575-
required WindowingOwnerLinux owner,
576564
required RegularWindowControllerDelegate delegate,
577565
Size? preferredSize,
578566
BoxConstraints? preferredConstraints,
579567
String? title,
580-
}) : _owner = owner,
581-
_delegate = delegate,
568+
}) : _delegate = delegate,
582569
_window = _GtkWindow(),
583570
super.empty() {
584571
if (!isWindowingEnabled) {
@@ -621,7 +608,6 @@ class RegularWindowControllerLinux extends RegularWindowController {
621608
_window.present();
622609
}
623610

624-
final WindowingOwnerLinux _owner;
625611
final RegularWindowControllerDelegate _delegate;
626612
final _GtkWindow _window;
627613
late final _FlWindowMonitor _windowMonitor;
@@ -640,7 +626,6 @@ class RegularWindowControllerLinux extends RegularWindowController {
640626
_windowMonitor.close();
641627
_windowMonitor.unref();
642628
_destroyed = true;
643-
_owner._windowCount--;
644629
}
645630

646631
@override

packages/flutter/lib/src/widgets/_window_macos.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ class WindowingOwnerMacOS extends WindowingOwner {
9090
return res;
9191
}
9292

93-
@override
94-
bool hasTopLevelWindows() {
95-
return _activeControllers.isNotEmpty;
96-
}
97-
9893
final List<BaseWindowController> _activeControllers = <BaseWindowController>[];
9994

10095
/// Returns the window handle for the given [view], or null is the window

packages/flutter/lib/src/widgets/_window_win32.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,6 @@ class WindowingOwnerWin32 extends WindowingOwner {
219219
}
220220
}
221221
}
222-
223-
@internal
224-
@override
225-
bool hasTopLevelWindows() {
226-
return _Win32PlatformInterface.hasTopLevelWindows(PlatformDispatcher.instance.engineId!);
227-
}
228222
}
229223

230224
class _RegularWindowMesageHandler implements _WindowsMessageHandler {
@@ -673,11 +667,6 @@ class DialogWindowControllerWin32 extends DialogWindowController {
673667
}
674668

675669
class _Win32PlatformInterface {
676-
@ffi.Native<ffi.Bool Function(ffi.Int64)>(
677-
symbol: 'InternalFlutterWindows_WindowManager_HasTopLevelWindows',
678-
)
679-
external static bool hasTopLevelWindows(int engineId);
680-
681670
static void initializeWindowing(
682671
ffi.Allocator allocator,
683672
int engineId,

packages/flutter/test/widgets/windowing_test.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,6 @@ void main() {
136136
);
137137
});
138138

139-
test('default WindowingOwner throws when accessing hasTopLevelWindows', () {
140-
final WindowingOwner owner = createDefaultWindowingOwner();
141-
expect(() => owner.hasTopLevelWindows(), throwsUnsupportedError);
142-
});
143-
144-
testWidgets('RegularWindow throws UnsupportedError', (WidgetTester tester) async {
145-
expect(
146-
() => RegularWindow(
147-
controller: _StubRegularWindowController(tester),
148-
child: const Text('Test'),
149-
),
150-
throwsUnsupportedError,
151-
);
152-
});
153-
154139
testWidgets('DialogWindow throws UnsupportedError', (WidgetTester tester) async {
155140
expect(
156141
() => DialogWindow(

0 commit comments

Comments
 (0)