Skip to content

Commit 81cdb36

Browse files
authored
Enable windowing with flutter config (#40)
## What's new Multi-window support is now enabled via `flutter config --enable-windowing`. This replaces the `--enable-multi-window=true` flag previously passed as an argument to `flutter run`. `--enable-windowing` is available on `master`, `beta` and `stable` branches, but disabled by default. It takes effect only on macOS, Linux, and Windows. When running the executable directly, continue setting the environment variable for engine switches as before. Note that `enable-multi-window` has been renamed to `enable-windowing`: ``` FLUTTER_ENGINE_SWITCHES=1 FLUTTER_ENGINE_SWITCH_1=enable-windowing ```
2 parents da9cccc + 1b131ad commit 81cdb36

File tree

15 files changed

+80
-36
lines changed

15 files changed

+80
-36
lines changed

engine/src/flutter/common/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ struct Settings {
363363

364364
// Enable support for multiple windows. Ignored if not supported on the
365365
// platform.
366-
bool enable_multi_window = false;
366+
bool enable_windowing = false;
367367
};
368368

369369
} // namespace flutter

engine/src/flutter/shell/common/switches.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -536,16 +536,17 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
536536
command_line.HasOption(FlagForSwitch(Switch::ImpellerLazyShaderMode));
537537
settings.impeller_antialiased_lines =
538538
command_line.HasOption(FlagForSwitch(Switch::ImpellerAntialiasLines));
539-
#if FML_OS_WIN
540-
// Process the EnableMultiWindow switch on Windows.
539+
540+
#if FML_OS_MACOSX || FML_OS_LINUX || FML_OS_WIN
541+
// Process the EnableWindowing switch on macOS, Linux, and Windows.
541542
{
542-
std::string enable_multi_window_value;
543-
if (command_line.GetOptionValue(FlagForSwitch(Switch::EnableMultiWindow),
544-
&enable_multi_window_value)) {
545-
settings.enable_multi_window = "true" == enable_multi_window_value;
543+
std::string enable_windowing_value;
544+
if (command_line.GetOptionValue(FlagForSwitch(Switch::EnableWindowing),
545+
&enable_windowing_value)) {
546+
settings.enable_windowing = "true" == enable_windowing_value;
546547
}
547548
}
548-
#endif // FML_OS_WIN
549+
#endif // FML_OS_MACOSX || FML_OS_LINUX || FML_OS_WIN
549550

550551
return settings;
551552
}

engine/src/flutter/shell/common/switches.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ DEF_SWITCH(EnablePlatformIsolates,
297297
DEF_SWITCH(DisableMergedPlatformUIThread,
298298
"no-enable-merged-platform-ui-thread",
299299
"Merge the ui thread and platform thread.")
300-
DEF_SWITCH(EnableMultiWindow,
301-
"enable-multi-window",
300+
DEF_SWITCH(EnableWindowing,
301+
"enable-windowing",
302302
"Enable support for multiple windows. Ignored if not supported on "
303303
"the platform.")
304304
DEF_SWITCH(EnableAndroidSurfaceControl,

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,8 @@ FlutterWindowsEngine::FlutterWindowsEngine(
196196
enable_impeller_ = std::find(switches.begin(), switches.end(),
197197
"--enable-impeller=true") != switches.end();
198198

199-
enable_multi_window_ =
200-
std::find(switches.begin(), switches.end(),
201-
"--enable-multi-window=true") != switches.end();
199+
enable_windowing_ = std::find(switches.begin(), switches.end(),
200+
"--enable-windowing=true") != switches.end();
202201

203202
egl_manager_ = egl::Manager::Create(
204203
static_cast<egl::GpuPreference>(project_->gpu_preference()));
@@ -239,7 +238,7 @@ FlutterWindowsEngine::FlutterWindowsEngine(
239238
std::make_unique<CursorHandler>(messenger_wrapper_.get(), this);
240239
platform_handler_ =
241240
std::make_unique<PlatformHandler>(messenger_wrapper_.get(), this);
242-
if (enable_multi_window_) {
241+
if (enable_windowing_) {
243242
host_window_controller_ =
244243
std::make_unique<FlutterHostWindowController>(this);
245244
}
@@ -321,7 +320,7 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) {
321320

322321
if (project_->ui_thread_policy() ==
323322
FlutterUIThreadPolicy::RunOnPlatformThread ||
324-
enable_multi_window_) {
323+
enable_windowing_) {
325324
FML_LOG(WARNING)
326325
<< "Running with merged platform and UI thread. Experimental.";
327326
custom_task_runners.ui_task_runner = &platform_task_runner;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class FlutterWindowsEngine {
494494

495495
bool enable_impeller_ = false;
496496

497-
bool enable_multi_window_ = false;
497+
bool enable_windowing_ = false;
498498

499499
// The manager for WindowProc delegate registration and callbacks.
500500
std::unique_ptr<WindowProcDelegateManager> window_proc_delegate_manager_;

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
220220
addEnableImpellerFlag(verboseHelp: verboseHelp);
221221
addEnableVulkanValidationFlag(verboseHelp: verboseHelp);
222222
addEnableEmbedderApiFlag(verboseHelp: verboseHelp);
223-
addMultiWindowFlag(verboseHelp: verboseHelp);
223+
addWindowingFlag(verboseHelp: verboseHelp);
224224
}
225225

226226
bool get traceStartup => boolArg('trace-startup');
@@ -236,7 +236,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
236236
bool get enableVulkanValidation => boolArg('enable-vulkan-validation');
237237
bool get uninstallFirst => boolArg('uninstall-first');
238238
bool get enableEmbedderApi => boolArg('enable-embedder-api');
239-
bool get enableMultiWindow => boolArg('enable-multi-window');
240239

241240
@override
242241
bool get refreshWirelessDevices => true;
@@ -303,7 +302,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
303302
uninstallFirst: uninstallFirst,
304303
enableDartProfiling: enableDartProfiling,
305304
enableEmbedderApi: enableEmbedderApi,
306-
enableMultiWindow: enableMultiWindow,
305+
enableWindowing: featureFlags.isWindowingEnabled,
307306
usingCISystem: usingCISystem,
308307
debugLogsDirectoryPath: debugLogsDirectoryPath,
309308
);
@@ -369,7 +368,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
369368
serveObservatory: boolArg('serve-observatory'),
370369
enableDartProfiling: enableDartProfiling,
371370
enableEmbedderApi: enableEmbedderApi,
372-
enableMultiWindow: enableMultiWindow,
371+
enableWindowing: featureFlags.isWindowingEnabled,
373372
usingCISystem: usingCISystem,
374373
debugLogsDirectoryPath: debugLogsDirectoryPath,
375374
enableDevTools: boolArg(FlutterCommand.kEnableDevTools),

packages/flutter_tools/lib/src/commands/test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
7878
usesDeviceUserOption();
7979
usesFlavorOption();
8080
addEnableImpellerFlag(verboseHelp: verboseHelp);
81-
addMultiWindowFlag(verboseHelp: verboseHelp);
81+
addWindowingFlag(verboseHelp: verboseHelp);
8282

8383
argParser
8484
..addFlag(

packages/flutter_tools/lib/src/custom_devices/custom_device.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ class CustomDeviceAppSession {
304304
if (debuggingOptions.useTestFonts) 'use-test-fonts=true',
305305
if (debuggingOptions.verboseSystemLogs) 'verbose-logging=true',
306306
],
307-
if (debuggingOptions.enableMultiWindow)
308-
'enable-multi-window=true',
307+
if (debuggingOptions.enableWindowing) 'enable-windowing=true',
309308
];
310309
}
311310

packages/flutter_tools/lib/src/desktop_device.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ abstract class DesktopDevice extends Device {
295295
case ImpellerStatus.platformDefault:
296296
addFlag('enable-impeller=false');
297297
}
298-
if (debuggingOptions.enableMultiWindow) {
299-
addFlag('enable-multi-window=true');
298+
if (debuggingOptions.enableWindowing) {
299+
addFlag('enable-windowing=true');
300300
}
301301
// Options only supported when there is a VM Service connection between the
302302
// tool and the device, usually in debug or profile mode.

packages/flutter_tools/lib/src/device.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ class DebuggingOptions {
971971
this.serveObservatory = false,
972972
this.enableDartProfiling = true,
973973
this.enableEmbedderApi = false,
974-
this.enableMultiWindow = false,
974+
this.enableWindowing = false,
975975
this.usingCISystem = false,
976976
this.debugLogsDirectoryPath,
977977
this.enableDevTools = true,
@@ -1005,7 +1005,7 @@ class DebuggingOptions {
10051005
this.uninstallFirst = false,
10061006
this.enableDartProfiling = true,
10071007
this.enableEmbedderApi = false,
1008-
this.enableMultiWindow = false,
1008+
this.enableWindowing = false,
10091009
this.usingCISystem = false,
10101010
this.debugLogsDirectoryPath,
10111011
}) : debuggingEnabled = false,
@@ -1090,7 +1090,7 @@ class DebuggingOptions {
10901090
required this.serveObservatory,
10911091
required this.enableDartProfiling,
10921092
required this.enableEmbedderApi,
1093-
required this.enableMultiWindow,
1093+
required this.enableWindowing,
10941094
required this.usingCISystem,
10951095
required this.debugLogsDirectoryPath,
10961096
required this.enableDevTools,
@@ -1137,7 +1137,7 @@ class DebuggingOptions {
11371137
final bool serveObservatory;
11381138
final bool enableDartProfiling;
11391139
final bool enableEmbedderApi;
1140-
final bool enableMultiWindow;
1140+
final bool enableWindowing;
11411141
final bool usingCISystem;
11421142
final String? debugLogsDirectoryPath;
11431143
final bool enableDevTools;
@@ -1237,7 +1237,7 @@ class DebuggingOptions {
12371237
if (interfaceType == DeviceConnectionInterface.wireless)
12381238
'--vm-service-host=${ipv6 ? '::0' : '0.0.0.0'}',
12391239
if (enableEmbedderApi) '--enable-embedder-api',
1240-
if (enableMultiWindow) '--enable-multi-window=true',
1240+
if (enableWindowing) '--enable-windowing=true',
12411241
];
12421242
}
12431243

@@ -1289,7 +1289,7 @@ class DebuggingOptions {
12891289
'serveObservatory': serveObservatory,
12901290
'enableDartProfiling': enableDartProfiling,
12911291
'enableEmbedderApi': enableEmbedderApi,
1292-
'enableMultiWindow': enableMultiWindow,
1292+
'enableWindowing': enableWindowing,
12931293
'usingCISystem': usingCISystem,
12941294
'debugLogsDirectoryPath': debugLogsDirectoryPath,
12951295
'enableDevTools': enableDevTools,
@@ -1360,7 +1360,7 @@ class DebuggingOptions {
13601360
serveObservatory: (json['serveObservatory'] as bool?) ?? false,
13611361
enableDartProfiling: (json['enableDartProfiling'] as bool?) ?? true,
13621362
enableEmbedderApi: (json['enableEmbedderApi'] as bool?) ?? false,
1363-
enableMultiWindow: (json['enableMultiWindow']! as bool?) ?? false,
1363+
enableWindowing: (json['enableWindowing']! as bool?) ?? false,
13641364
usingCISystem: (json['usingCISystem'] as bool?) ?? false,
13651365
debugLogsDirectoryPath: json['debugLogsDirectoryPath'] as String?,
13661366
enableDevTools: (json['enableDevTools'] as bool?) ?? true,

packages/flutter_tools/lib/src/features.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ abstract class FeatureFlags {
5454
/// Whether explicit package dependency management is enabled.
5555
bool get isExplicitPackageDependenciesEnabled => false;
5656

57+
/// Whether multi-window support is enabled.
58+
bool get isWindowingEnabled => false;
59+
5760
/// Whether a particular feature is enabled for the current channel.
5861
///
5962
/// Prefer using one of the specific getters above instead of this API.
@@ -74,6 +77,7 @@ const List<Feature> allFeatures = <Feature>[
7477
nativeAssets,
7578
swiftPackageManager,
7679
explicitPackageDependencies,
80+
windowing,
7781
];
7882

7983
/// All current Flutter feature flags that can be configured.
@@ -180,6 +184,16 @@ const Feature explicitPackageDependencies = Feature.fullyEnabled(
180184
'* https://flutter.dev/to/flutter-gen-deprecation.',
181185
);
182186

187+
/// Enable multi-window support.
188+
const Feature windowing = Feature(
189+
name: 'support for multiple windows',
190+
configSetting: 'enable-windowing',
191+
environmentOverride: 'FLUTTER_WINDOWING',
192+
master: FeatureChannelSetting(available: true),
193+
beta: FeatureChannelSetting(available: true),
194+
stable: FeatureChannelSetting(available: true),
195+
);
196+
183197
/// A [Feature] is a process for conditionally enabling tool features.
184198
///
185199
/// All settings are optional, and if not provided will generally default to

packages/flutter_tools/lib/src/flutter_features.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class FlutterFeatureFlags implements FeatureFlags {
6161
@override
6262
bool get isExplicitPackageDependenciesEnabled => isEnabled(explicitPackageDependencies);
6363

64+
@override
65+
bool get isWindowingEnabled => isEnabled(windowing);
66+
6467
@override
6568
bool isEnabled(Feature feature) {
6669
final String currentChannel = _flutterVersion.channel;

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,12 +1290,12 @@ abstract class FlutterCommand extends Command<void> {
12901290
);
12911291
}
12921292

1293-
void addMultiWindowFlag({required bool verboseHelp}) {
1294-
argParser.addFlag('enable-multi-window',
1293+
void addWindowingFlag({required bool verboseHelp}) {
1294+
argParser.addFlag('enable-windowing',
12951295
hide: !verboseHelp,
12961296
help: 'Whether to enable support for multiple windows. '
1297-
'This flag is only available on Windows, is disabled by default, '
1298-
'and will be ignored on other platforms.',
1297+
'Disabled by default. Ignored on platforms other than '
1298+
'macOS, Linux, and Windows.',
12991299
);
13001300
}
13011301

packages/flutter_tools/test/general.shard/features_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,5 +424,29 @@ void main() {
424424
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
425425
});
426426
});
427+
428+
test('Windowing availability and default enabled', () {
429+
expect(windowing.master.enabledByDefault, false);
430+
expect(windowing.master.available, true);
431+
expect(windowing.beta.enabledByDefault, false);
432+
expect(windowing.beta.available, true);
433+
expect(windowing.stable.enabledByDefault, false);
434+
expect(windowing.stable.available, true);
435+
});
436+
437+
for (final String channel in <String>['master', 'beta', 'stable']) {
438+
testWithoutContext('Windowing can be enabled with flag on $channel', () {
439+
final FeatureFlags featureFlags = createFlags(channel);
440+
testConfig.setValue('enable-windowing', true);
441+
expect(featureFlags.isWindowingEnabled, true);
442+
});
443+
444+
testWithoutContext('Windowing can be enabled with environment variable on $channel', () {
445+
final FeatureFlags featureFlags = createFlags(channel);
446+
platform.environment = <String, String>{'FLUTTER_WINDOWING': 'true'};
447+
expect(featureFlags.isWindowingEnabled, true);
448+
});
449+
}
450+
427451
});
428452
}

packages/flutter_tools/test/src/fakes.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ class TestFeatureFlags implements FeatureFlags {
494494
this.isNativeAssetsEnabled = false,
495495
this.isSwiftPackageManagerEnabled = false,
496496
this.isExplicitPackageDependenciesEnabled = false,
497+
this.isWindowingEnabled = false,
497498
});
498499

499500
@override
@@ -532,6 +533,9 @@ class TestFeatureFlags implements FeatureFlags {
532533
@override
533534
final bool isExplicitPackageDependenciesEnabled;
534535

536+
@override
537+
final bool isWindowingEnabled;
538+
535539
@override
536540
bool isEnabled(Feature feature) {
537541
return switch (feature) {
@@ -546,6 +550,7 @@ class TestFeatureFlags implements FeatureFlags {
546550
cliAnimation => isCliAnimationEnabled,
547551
nativeAssets => isNativeAssetsEnabled,
548552
explicitPackageDependencies => isExplicitPackageDependenciesEnabled,
553+
windowing => isWindowingEnabled,
549554
_ => false,
550555
};
551556
}

0 commit comments

Comments
 (0)