From efd03ad7ee2bf8535809932d8146e6b9f8d6a9e2 Mon Sep 17 00:00:00 2001 From: moko256 Date: Fri, 29 Apr 2022 17:10:24 +0900 Subject: [PATCH] Windows: Add SettingsPlugin to add theme change support in win32 (flutter/engine#29303) * Windows: Add SettingsPlugin to separate sending and watching * remove OnColorValuesChanged * remove functions and test to handle brightness change from top-level window message * add settings plugin test * add files to licenses * fix license * use std::optional * treat error * fix comment based on code review --- .../ci/licenses_golden/licenses_flutter | 9 ++ .../flutter/shell/platform/windows/BUILD.gn | 9 ++ .../windows/client_wrapper/flutter_engine.cc | 4 - .../flutter_engine_unittests.cc | 20 ----- .../testing/stub_flutter_windows_api.cc | 7 -- .../testing/stub_flutter_windows_api.h | 3 - .../platform/windows/event_watcher_win32.cc | 34 ++++++++ .../platform/windows/event_watcher_win32.h | 37 ++++++++ .../platform/windows/flutter_window_winuwp.cc | 9 -- .../platform/windows/flutter_window_winuwp.h | 8 -- .../shell/platform/windows/flutter_windows.cc | 5 -- .../windows/flutter_windows_engine.cc | 32 ++----- .../platform/windows/flutter_windows_engine.h | 12 ++- .../platform/windows/flutter_windows_view.cc | 9 -- .../platform/windows/flutter_windows_view.h | 6 -- .../platform/windows/public/flutter_windows.h | 3 - .../shell/platform/windows/settings_plugin.cc | 48 +++++++++++ .../shell/platform/windows/settings_plugin.h | 63 ++++++++++++++ .../windows/settings_plugin_unittests.cc | 62 +++++++++++++ .../platform/windows/settings_plugin_win32.cc | 86 +++++++++++++++++++ .../platform/windows/settings_plugin_win32.h | 54 ++++++++++++ .../windows/settings_plugin_winuwp.cc | 67 +++++++++++++++ .../platform/windows/settings_plugin_winuwp.h | 56 ++++++++++++ .../shell/platform/windows/system_utils.h | 8 -- .../windows/system_utils_unittests.cc | 5 -- .../platform/windows/system_utils_win32.cc | 18 ---- .../platform/windows/system_utils_winuwp.cc | 14 --- .../windows/window_binding_handler_delegate.h | 3 - 28 files changed, 537 insertions(+), 154 deletions(-) create mode 100644 engine/src/flutter/shell/platform/windows/event_watcher_win32.cc create mode 100644 engine/src/flutter/shell/platform/windows/event_watcher_win32.h create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin.cc create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin.h create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin_unittests.cc create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin_win32.cc create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin_win32.h create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.cc create mode 100644 engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 669df2e40f..b3526bdf5a 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -2227,6 +2227,8 @@ FILE: ../../../flutter/shell/platform/windows/display_helper_winuwp.h FILE: ../../../flutter/shell/platform/windows/dpi_utils_win32.cc FILE: ../../../flutter/shell/platform/windows/dpi_utils_win32.h FILE: ../../../flutter/shell/platform/windows/dpi_utils_win32_unittests.cc +FILE: ../../../flutter/shell/platform/windows/event_watcher_win32.cc +FILE: ../../../flutter/shell/platform/windows/event_watcher_win32.h FILE: ../../../flutter/shell/platform/windows/external_texture_gl.cc FILE: ../../../flutter/shell/platform/windows/external_texture_gl.h FILE: ../../../flutter/shell/platform/windows/flutter_key_map.cc @@ -2283,6 +2285,13 @@ FILE: ../../../flutter/shell/platform/windows/public/flutter_windows.h FILE: ../../../flutter/shell/platform/windows/sequential_id_generator.cc FILE: ../../../flutter/shell/platform/windows/sequential_id_generator.h FILE: ../../../flutter/shell/platform/windows/sequential_id_generator_unittests.cc +FILE: ../../../flutter/shell/platform/windows/settings_plugin.cc +FILE: ../../../flutter/shell/platform/windows/settings_plugin.h +FILE: ../../../flutter/shell/platform/windows/settings_plugin_unittests.cc +FILE: ../../../flutter/shell/platform/windows/settings_plugin_win32.cc +FILE: ../../../flutter/shell/platform/windows/settings_plugin_win32.h +FILE: ../../../flutter/shell/platform/windows/settings_plugin_winuwp.cc +FILE: ../../../flutter/shell/platform/windows/settings_plugin_winuwp.h FILE: ../../../flutter/shell/platform/windows/system_utils.h FILE: ../../../flutter/shell/platform/windows/system_utils_unittests.cc FILE: ../../../flutter/shell/platform/windows/system_utils_win32.cc diff --git a/engine/src/flutter/shell/platform/windows/BUILD.gn b/engine/src/flutter/shell/platform/windows/BUILD.gn index ee8504033e..d09531e49a 100644 --- a/engine/src/flutter/shell/platform/windows/BUILD.gn +++ b/engine/src/flutter/shell/platform/windows/BUILD.gn @@ -79,6 +79,8 @@ source_set("flutter_windows_source") { "platform_handler.h", "sequential_id_generator.cc", "sequential_id_generator.h", + "settings_plugin.cc", + "settings_plugin.h", "system_utils.h", "task_runner.cc", "task_runner.h", @@ -107,6 +109,8 @@ source_set("flutter_windows_source") { "game_pad_winuwp.h", "platform_handler_winuwp.cc", "platform_handler_winuwp.h", + "settings_plugin_winuwp.cc", + "settings_plugin_winuwp.h", "system_utils_winuwp.cc", "task_runner_winuwp.cc", "task_runner_winuwp.h", @@ -117,6 +121,8 @@ source_set("flutter_windows_source") { "accessibility_bridge_delegate_win32.h", "dpi_utils_win32.cc", "dpi_utils_win32.h", + "event_watcher_win32.cc", + "event_watcher_win32.h", "flutter_platform_node_delegate_win32.cc", "flutter_platform_node_delegate_win32.h", "flutter_window_win32.cc", @@ -124,6 +130,8 @@ source_set("flutter_windows_source") { "flutter_windows_win32.cc", "platform_handler_win32.cc", "platform_handler_win32.h", + "settings_plugin_win32.cc", + "settings_plugin_win32.h", "system_utils_win32.cc", "task_runner_win32.cc", "task_runner_win32.h", @@ -226,6 +234,7 @@ executable("flutter_windows_unittests") { # "flutter_project_bundle_unittests.cc", //TODO failing due to switches test failing. Blocked on https://github.com/flutter/flutter/issues/74153 # "flutter_windows_engine_unittests.cc", //TODO failing to send / receive platform message get plugins working first. Blocked on https://github.com/flutter/flutter/issues/74155 "sequential_id_generator_unittests.cc", + "settings_plugin_unittests.cc", "system_utils_unittests.cc", "task_runner_unittests.cc", "testing/engine_modifier.h", diff --git a/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine.cc b/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine.cc index 3172a1f0b8..2463a84cf5 100644 --- a/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine.cc +++ b/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine.cc @@ -74,10 +74,6 @@ void FlutterEngine::ReloadSystemFonts() { FlutterDesktopEngineReloadSystemFonts(engine_); } -void FlutterEngine::ReloadPlatformBrightness() { - FlutterDesktopEngineReloadPlatformBrightness(engine_); -} - FlutterDesktopPluginRegistrarRef FlutterEngine::GetRegistrarForPlugin( const std::string& plugin_name) { if (!engine_) { diff --git a/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine_unittests.cc b/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine_unittests.cc index 15053b293a..e52fb336a3 100644 --- a/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine_unittests.cc +++ b/engine/src/flutter/shell/platform/windows/client_wrapper/flutter_engine_unittests.cc @@ -49,11 +49,6 @@ class TestFlutterWindowsApi : public testing::StubFlutterWindowsApi { // |flutter::testing::StubFlutterWindowsApi| void EngineReloadSystemFonts() override { reload_fonts_called_ = true; } - // |flutter::testing::StubFlutterWindowsApi| - void EngineReloadPlatformBrightness() override { - reload_brightness_called_ = true; - } - bool create_called() { return create_called_; } bool run_called() { return run_called_; } @@ -62,8 +57,6 @@ class TestFlutterWindowsApi : public testing::StubFlutterWindowsApi { bool reload_fonts_called() { return reload_fonts_called_; } - bool reload_brightness_called() { return reload_brightness_called_; } - const std::vector& dart_entrypoint_arguments() { return dart_entrypoint_arguments_; } @@ -73,7 +66,6 @@ class TestFlutterWindowsApi : public testing::StubFlutterWindowsApi { bool run_called_ = false; bool destroy_called_ = false; bool reload_fonts_called_ = false; - bool reload_brightness_called_ = false; std::vector dart_entrypoint_arguments_; }; @@ -132,18 +124,6 @@ TEST(FlutterEngineTest, ReloadFonts) { EXPECT_TRUE(test_api->reload_fonts_called()); } -TEST(FlutterEngineTest, ReloadBrightness) { - testing::ScopedStubFlutterWindowsApi scoped_api_stub( - std::make_unique()); - auto test_api = static_cast(scoped_api_stub.stub()); - - FlutterEngine engine(DartProject(L"fake/project/path")); - engine.Run(); - - engine.ReloadPlatformBrightness(); - EXPECT_TRUE(test_api->reload_brightness_called()); -} - TEST(FlutterEngineTest, GetMessenger) { DartProject project(L"data"); testing::ScopedStubFlutterWindowsApi scoped_api_stub( diff --git a/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc b/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc index ae3b048de6..a829326a61 100644 --- a/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc +++ b/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc @@ -117,13 +117,6 @@ void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine) { } } -void FlutterDesktopEngineReloadPlatformBrightness( - FlutterDesktopEngineRef engine) { - if (s_stub_implementation) { - s_stub_implementation->EngineReloadPlatformBrightness(); - } -} - FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar( FlutterDesktopEngineRef engine, const char* plugin_name) { diff --git a/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h b/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h index 81d00ac820..b795eab1a6 100644 --- a/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h +++ b/engine/src/flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h @@ -65,9 +65,6 @@ class StubFlutterWindowsApi { // Called for FlutterDesktopEngineReloadSystemFonts. virtual void EngineReloadSystemFonts() {} - // Called for FlutterDesktopEngineReloadPlatformBrightness. - virtual void EngineReloadPlatformBrightness() {} - // Called for FlutterDesktopViewGetHWND. virtual HWND ViewGetHWND() { return reinterpret_cast(1); } diff --git a/engine/src/flutter/shell/platform/windows/event_watcher_win32.cc b/engine/src/flutter/shell/platform/windows/event_watcher_win32.cc new file mode 100644 index 0000000000..94be666c7a --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/event_watcher_win32.cc @@ -0,0 +1,34 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/windows/event_watcher_win32.h" + +namespace flutter { + +EventWatcherWin32::EventWatcherWin32(std::function callback) + : callback_(callback) { + handle_ = CreateEvent(NULL, TRUE, FALSE, NULL); + + RegisterWaitForSingleObject(&handle_for_wait_, handle_, &CallbackForWait, + reinterpret_cast(this), INFINITE, + WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD); +} + +EventWatcherWin32::~EventWatcherWin32() { + UnregisterWait(handle_for_wait_); + CloseHandle(handle_); +} + +HANDLE EventWatcherWin32::GetHandle() { + return handle_; +} + +// static +VOID CALLBACK EventWatcherWin32::CallbackForWait(PVOID context, BOOLEAN) { + EventWatcherWin32* self = reinterpret_cast(context); + ResetEvent(self->handle_); + self->callback_(); +} + +} // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/event_watcher_win32.h b/engine/src/flutter/shell/platform/windows/event_watcher_win32.h new file mode 100644 index 0000000000..ab48d8ee7c --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/event_watcher_win32.h @@ -0,0 +1,37 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_EVENT_WATCHER_WIN32_H_ +#define FLUTTER_SHELL_PLATFORM_WINDOWS_EVENT_WATCHER_WIN32_H_ + +#include + +#include + +namespace flutter { + +// A win32 `HANDLE` wrapper for use as a one-time callback. +class EventWatcherWin32 { + public: + explicit EventWatcherWin32(std::function callback); + ~EventWatcherWin32(); + + // Returns `HANDLE`, which can be used to register an event listener. + HANDLE GetHandle(); + + private: + static VOID CALLBACK CallbackForWait(PVOID context, BOOLEAN); + + std::function callback_; + + HANDLE handle_; + HANDLE handle_for_wait_; + + EventWatcherWin32(const EventWatcherWin32&) = delete; + EventWatcherWin32& operator=(const EventWatcherWin32&) = delete; +}; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_EVENT_WATCHER_WIN32_H_ diff --git a/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc b/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc index 9a2dc80092..476694d588 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc +++ b/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc @@ -166,9 +166,6 @@ void FlutterWindowWinUWP::SetEventHandlers() { window_.PointerWheelChanged( {this, &FlutterWindowWinUWP::OnPointerWheelChanged}); - ui_settings_.ColorValuesChanged( - {this, &FlutterWindowWinUWP::OnColorValuesChanged}); - // TODO(clarkezone) support mouse leave handling // https://github.com/flutter/flutter/issues/70199 @@ -383,12 +380,6 @@ void FlutterWindowWinUWP::OnCharacterReceived( } } -void FlutterWindowWinUWP::OnColorValuesChanged( - winrt::Windows::Foundation::IInspectable const&, - winrt::Windows::Foundation::IInspectable const&) { - binding_handler_delegate_->OnPlatformBrightnessChanged(); -} - bool FlutterWindowWinUWP::OnBitmapSurfaceUpdated(const void* allocation, size_t row_bytes, size_t height) { diff --git a/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.h b/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.h index 065841fc2a..81e059dfdd 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.h +++ b/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.h @@ -118,11 +118,6 @@ class FlutterWindowWinUWP : public WindowBindingHandler { winrt::Windows::Foundation::IInspectable const&, winrt::Windows::UI::Core::CharacterReceivedEventArgs const& args); - // Notifies current |WindowBindingHandlerDelegate| of color values changed - // events. - void OnColorValuesChanged(winrt::Windows::Foundation::IInspectable const&, - winrt::Windows::Foundation::IInspectable const&); - // Converts from logical point to physical X value. double GetPosX(winrt::Windows::UI::Core::PointerEventArgs const& args); @@ -168,9 +163,6 @@ class FlutterWindowWinUWP : public WindowBindingHandler { // SwapChain to the CoreWindow. winrt::Windows::UI::Composition::SpriteVisual render_target_{nullptr}; - // UISettings for observing the color change. - winrt::Windows::UI::ViewManagement::UISettings ui_settings_; - // GamepadCursorWinUWP object used to manage an emulated cursor visual driven // by gamepad. std::unique_ptr game_pad_cursor_{nullptr}; diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows.cc b/engine/src/flutter/shell/platform/windows/flutter_windows.cc index 0b9199f2a7..41c3d76595 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_windows.cc +++ b/engine/src/flutter/shell/platform/windows/flutter_windows.cc @@ -107,11 +107,6 @@ void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine) { EngineFromHandle(engine)->ReloadSystemFonts(); } -void FlutterDesktopEngineReloadPlatformBrightness( - FlutterDesktopEngineRef engine) { - EngineFromHandle(engine)->ReloadPlatformBrightness(); -} - FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar( FlutterDesktopEngineRef engine, const char* plugin_name) { diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc b/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc index 4d0d41160d..a9d7d72284 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc +++ b/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc @@ -10,13 +10,10 @@ #include "flutter/fml/platform/win/wstring_conversion.h" #include "flutter/shell/platform/common/client_wrapper/binary_messenger_impl.h" -#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h" -#include "flutter/shell/platform/common/json_message_codec.h" #include "flutter/shell/platform/common/path_utils.h" #include "flutter/shell/platform/windows/flutter_windows_view.h" #include "flutter/shell/platform/windows/system_utils.h" #include "flutter/shell/platform/windows/task_runner.h" -#include "third_party/rapidjson/include/rapidjson/document.h" #if defined(WINUWP) #include "flutter/shell/platform/windows/accessibility_bridge_delegate_winuwp.h" @@ -197,10 +194,8 @@ FlutterWindowsEngine::FlutterWindowsEngine(const FlutterProjectBundle& project) // Set up internal channels. // TODO: Replace this with an embedder.h API. See // https://github.com/flutter/flutter/issues/71099 - settings_channel_ = - std::make_unique>( - messenger_wrapper_.get(), "flutter/settings", - &JsonMessageCodec::GetInstance()); + settings_plugin_ = + SettingsPlugin::Create(messenger_wrapper_.get(), task_runner_.get()); } FlutterWindowsEngine::~FlutterWindowsEngine() { @@ -341,7 +336,10 @@ bool FlutterWindowsEngine::RunWithEntrypoint(const char* entrypoint) { kFlutterEngineDisplaysUpdateTypeStartup, displays.data(), displays.size()); - SendSystemSettings(); + SendSystemLocales(); + + settings_plugin_->StartWatching(); + settings_plugin_->SendSettings(); return true; } @@ -485,13 +483,7 @@ void FlutterWindowsEngine::ReloadSystemFonts() { embedder_api_.ReloadSystemFonts(engine_); } -void FlutterWindowsEngine::ReloadPlatformBrightness() { - if (engine_) { - SendSystemSettings(); - } -} - -void FlutterWindowsEngine::SendSystemSettings() { +void FlutterWindowsEngine::SendSystemLocales() { std::vector languages = GetPreferredLanguageInfo(); std::vector flutter_locales; flutter_locales.reserve(languages.size()); @@ -507,16 +499,6 @@ void FlutterWindowsEngine::SendSystemSettings() { [](const auto& arg) -> const auto* { return &arg; }); embedder_api_.UpdateLocales(engine_, flutter_locale_list.data(), flutter_locale_list.size()); - - rapidjson::Document settings(rapidjson::kObjectType); - auto& allocator = settings.GetAllocator(); - settings.AddMember("alwaysUse24HourFormat", - Prefer24HourTime(GetUserTimeFormat()), allocator); - settings.AddMember("textScaleFactor", 1.0, allocator); - settings.AddMember("platformBrightness", - fml::WideStringToUtf8(GetPreferredBrightness()), - allocator); - settings_channel_->Send(settings); } bool FlutterWindowsEngine::RegisterExternalTexture(int64_t texture_id) { diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows_engine.h b/engine/src/flutter/shell/platform/windows/flutter_windows_engine.h index 07030c748a..8f7820b9b8 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_windows_engine.h +++ b/engine/src/flutter/shell/platform/windows/flutter_windows_engine.h @@ -20,6 +20,7 @@ #include "flutter/shell/platform/windows/flutter_project_bundle.h" #include "flutter/shell/platform/windows/flutter_windows_texture_registrar.h" #include "flutter/shell/platform/windows/public/flutter_windows.h" +#include "flutter/shell/platform/windows/settings_plugin.h" #include "flutter/shell/platform/windows/task_runner.h" #include "flutter/shell/platform/windows/window_state.h" #include "third_party/rapidjson/include/rapidjson/document.h" @@ -164,9 +165,6 @@ class FlutterWindowsEngine { // Informs the engine that the system font list has changed. void ReloadSystemFonts(); - // Informs the engine that the platform brightness has changed. - void ReloadPlatformBrightness(); - // Attempts to register the texture with the given |texture_id|. bool RegisterExternalTexture(int64_t texture_id); @@ -198,11 +196,11 @@ class FlutterWindowsEngine { // Allows swapping out embedder_api_ calls in tests. friend class EngineModifier; - // Sends system settings (e.g., locale) to the engine. + // Sends system locales to the engine. // // Should be called just after the engine is run, and after any relevant // system changes. - void SendSystemSettings(); + void SendSystemLocales(); // The handle to the embedder.h engine instance. FLUTTER_API_SYMBOL(FlutterEngine) engine_ = nullptr; @@ -243,8 +241,8 @@ class FlutterWindowsEngine { // May be nullptr if ANGLE failed to initialize. std::unique_ptr surface_manager_; - // The MethodChannel used for communication with the Flutter engine. - std::unique_ptr> settings_channel_; + // The settings plugin. + std::unique_ptr settings_plugin_; // Callbacks to be called when the engine (and thus the plugin registrar) is // being destroyed. diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows_view.cc b/engine/src/flutter/shell/platform/windows/flutter_windows_view.cc index 611d142222..0a4e434b40 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_windows_view.cc +++ b/engine/src/flutter/shell/platform/windows/flutter_windows_view.cc @@ -236,10 +236,6 @@ void FlutterWindowsView::OnScroll(double x, device_id); } -void FlutterWindowsView::OnPlatformBrightnessChanged() { - SendPlatformBrightnessChanged(); -} - void FlutterWindowsView::OnUpdateSemanticsEnabled(bool enabled) { engine_->UpdateSemanticsEnabled(enabled); } @@ -479,11 +475,6 @@ void FlutterWindowsView::SendPointerEventWithData( } } -void FlutterWindowsView::SendPlatformBrightnessChanged() { - engine_->task_runner()->RunNowOrPostTask( - [this]() { engine_->ReloadPlatformBrightness(); }); -}; - bool FlutterWindowsView::MakeCurrent() { return engine_->surface_manager()->MakeCurrent(); } diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows_view.h b/engine/src/flutter/shell/platform/windows/flutter_windows_view.h index 6ae49d4711..51a4a6ca2b 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_windows_view.h +++ b/engine/src/flutter/shell/platform/windows/flutter_windows_view.h @@ -156,9 +156,6 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate, FlutterPointerDeviceKind device_kind, int32_t device_id) override; - // |WindowBindingHandlerDelegate| - void OnPlatformBrightnessChanged() override; - // |WindowBindingHandlerDelegate| virtual void OnUpdateSemanticsEnabled(bool enabled) override; @@ -309,9 +306,6 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate, void SendPointerEventWithData(const FlutterPointerEvent& event_data, PointerState* state); - // Reports platform brightness change to Flutter engine. - void SendPlatformBrightnessChanged(); - // Currently configured WindowsRenderTarget for this view used by // surface_manager for creation of render surfaces and bound to the physical // os window. diff --git a/engine/src/flutter/shell/platform/windows/public/flutter_windows.h b/engine/src/flutter/shell/platform/windows/public/flutter_windows.h index 0aeb6fdc15..14f8ea464a 100644 --- a/engine/src/flutter/shell/platform/windows/public/flutter_windows.h +++ b/engine/src/flutter/shell/platform/windows/public/flutter_windows.h @@ -174,9 +174,6 @@ FlutterDesktopEngineProcessMessages(FlutterDesktopEngineRef engine); FLUTTER_EXPORT void FlutterDesktopEngineReloadSystemFonts( FlutterDesktopEngineRef engine); -FLUTTER_EXPORT void FlutterDesktopEngineReloadPlatformBrightness( - FlutterDesktopEngineRef engine); - // Returns the plugin registrar handle for the plugin with the given name. // // The name must be unique across the application. diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin.cc b/engine/src/flutter/shell/platform/windows/settings_plugin.cc new file mode 100644 index 0000000000..3bca2b4438 --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin.cc @@ -0,0 +1,48 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/windows/settings_plugin.h" + +#include "flutter/shell/platform/common/json_message_codec.h" + +namespace flutter { + +namespace { +constexpr char kChannelName[] = "flutter/settings"; + +constexpr char kAlwaysUse24HourFormat[] = "alwaysUse24HourFormat"; +constexpr char kTextScaleFactor[] = "textScaleFactor"; +constexpr char kPlatformBrightness[] = "platformBrightness"; + +constexpr char kPlatformBrightnessDark[] = "dark"; +constexpr char kPlatformBrightnessLight[] = "light"; +} // namespace + +SettingsPlugin::SettingsPlugin(BinaryMessenger* messenger, + TaskRunner* task_runner) + : channel_(std::make_unique>( + messenger, + kChannelName, + &JsonMessageCodec::GetInstance())), + task_runner_(task_runner) {} + +SettingsPlugin::~SettingsPlugin() = default; + +void SettingsPlugin::SendSettings() { + rapidjson::Document settings(rapidjson::kObjectType); + auto& allocator = settings.GetAllocator(); + settings.AddMember(kAlwaysUse24HourFormat, GetAlwaysUse24HourFormat(), + allocator); + settings.AddMember(kTextScaleFactor, GetTextScaleFactor(), allocator); + + if (GetPreferredBrightness() == PlatformBrightness::kDark) { + settings.AddMember(kPlatformBrightness, kPlatformBrightnessDark, allocator); + } else { + settings.AddMember(kPlatformBrightness, kPlatformBrightnessLight, + allocator); + } + channel_->Send(settings); +} + +} // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin.h b/engine/src/flutter/shell/platform/windows/settings_plugin.h new file mode 100644 index 0000000000..a54c09e061 --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin.h @@ -0,0 +1,63 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_H_ +#define FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_H_ + +#include + +#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h" +#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" +#include "flutter/shell/platform/windows/task_runner.h" +#include "rapidjson/document.h" + +namespace flutter { + +// Abstract settings plugin. +// +// Used to look up and notify Flutter of user-configured system settings. +// These are typically set in the control panel. +class SettingsPlugin { + public: + explicit SettingsPlugin(BinaryMessenger* messenger, TaskRunner* task_runner); + + virtual ~SettingsPlugin(); + + static std::unique_ptr Create(BinaryMessenger* messenger, + TaskRunner* task_runner); + + // Sends settings (e.g., platform brightness) to the engine. + void SendSettings(); + + // Start watching settings changes and notify the engine of the update. + virtual void StartWatching() = 0; + + // Stop watching settings change. The `SettingsPlugin` destructor will call + // this automatically. + virtual void StopWatching() = 0; + + protected: + enum struct PlatformBrightness { kDark, kLight }; + + // Returns `true` if the user uses 24 hour time. + virtual bool GetAlwaysUse24HourFormat() = 0; + + // Returns the user-preferred text scale factor. + virtual float GetTextScaleFactor() = 0; + + // Returns the user-preferred brightness. + virtual PlatformBrightness GetPreferredBrightness() = 0; + + TaskRunner* task_runner_; + + private: + std::unique_ptr> channel_; + + SettingsPlugin(const SettingsPlugin&) = delete; + SettingsPlugin& operator=(const SettingsPlugin&) = delete; +}; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_H_ diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin_unittests.cc b/engine/src/flutter/shell/platform/windows/settings_plugin_unittests.cc new file mode 100644 index 0000000000..3158e5a41c --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin_unittests.cc @@ -0,0 +1,62 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "flutter/shell/platform/windows/settings_plugin.h" + +#include "flutter/shell/platform/windows/task_runner.h" +#include "flutter/shell/platform/windows/testing/test_binary_messenger.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace flutter { +namespace testing { + +namespace { + +class MockSettingsPlugin : public SettingsPlugin { + public: + explicit MockSettingsPlugin(BinaryMessenger* messenger, + TaskRunner* task_runner) + : SettingsPlugin(messenger, task_runner) {} + + virtual ~MockSettingsPlugin() = default; + + // |SettingsPlugin| + MOCK_METHOD0(StartWatching, void()); + MOCK_METHOD0(StopWatching, void()); + + MOCK_METHOD0(GetAlwaysUse24HourFormat, bool()); + MOCK_METHOD0(GetTextScaleFactor, float()); + MOCK_METHOD0(GetPreferredBrightness, PlatformBrightness()); +}; + +} // namespace + +TEST(SettingsPluginTest, SendSettingsSendsMessage) { + bool message_is_sent = false; + TestBinaryMessenger messenger( + [&message_is_sent](const std::string& channel, const uint8_t* message, + size_t message_size, + BinaryReply reply) { message_is_sent = true; }); + ::testing::NiceMock settings_plugin(&messenger, nullptr); + + settings_plugin.SendSettings(); + + EXPECT_TRUE(message_is_sent); +} + +TEST(SettingsPluginTest, SendSettingsGetsSettings) { + TestBinaryMessenger messenger([](const std::string& channel, + const uint8_t* message, size_t message_size, + BinaryReply reply) {}); + ::testing::NiceMock settings_plugin(&messenger, nullptr); + + EXPECT_CALL(settings_plugin, GetAlwaysUse24HourFormat).Times(1); + EXPECT_CALL(settings_plugin, GetTextScaleFactor).Times(1); + EXPECT_CALL(settings_plugin, GetPreferredBrightness).Times(1); + + settings_plugin.SendSettings(); +} + +} // namespace testing +} // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin_win32.cc b/engine/src/flutter/shell/platform/windows/settings_plugin_win32.cc new file mode 100644 index 0000000000..0da7e2ac5b --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin_win32.cc @@ -0,0 +1,86 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/windows/settings_plugin_win32.h" + +#include "flutter/shell/platform/windows/system_utils.h" + +namespace flutter { + +namespace { +constexpr wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; +} // namespace + +// static +std::unique_ptr SettingsPlugin::Create( + BinaryMessenger* messenger, + TaskRunner* task_runner) { + return std::make_unique(messenger, task_runner); +} + +SettingsPluginWin32::SettingsPluginWin32(BinaryMessenger* messenger, + TaskRunner* task_runner) + : SettingsPlugin(messenger, task_runner) { + RegOpenKeyEx(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + RRF_RT_REG_DWORD, KEY_NOTIFY, &preferred_brightness_reg_hkey_); +} + +SettingsPluginWin32::~SettingsPluginWin32() { + StopWatching(); + RegCloseKey(preferred_brightness_reg_hkey_); +} + +void SettingsPluginWin32::StartWatching() { + if (preferred_brightness_reg_hkey_ != NULL) { + WatchPreferredBrightnessChanged(); + } +} + +void SettingsPluginWin32::StopWatching() { + preferred_brightness_changed_watcher_ = nullptr; +} + +bool SettingsPluginWin32::GetAlwaysUse24HourFormat() { + return Prefer24HourTime(GetUserTimeFormat()); +} + +float SettingsPluginWin32::GetTextScaleFactor() { + return 1.0; +} + +SettingsPlugin::PlatformBrightness +SettingsPluginWin32::GetPreferredBrightness() { + DWORD use_light_theme; + DWORD use_light_theme_size = sizeof(use_light_theme); + LONG result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD, + nullptr, &use_light_theme, &use_light_theme_size); + + if (result == 0) { + return use_light_theme ? SettingsPlugin::PlatformBrightness::kLight + : SettingsPlugin::PlatformBrightness::kDark; + } else { + // The current OS does not support dark mode. (Older Windows 10 or before + // Windows 10) + return SettingsPlugin::PlatformBrightness::kLight; + } +} + +void SettingsPluginWin32::WatchPreferredBrightnessChanged() { + preferred_brightness_changed_watcher_ = + std::make_unique([this]() { + task_runner_->PostTask([this]() { + SendSettings(); + WatchPreferredBrightnessChanged(); + }); + }); + + RegNotifyChangeKeyValue( + preferred_brightness_reg_hkey_, FALSE, REG_NOTIFY_CHANGE_LAST_SET, + preferred_brightness_changed_watcher_->GetHandle(), TRUE); +} + +} // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin_win32.h b/engine/src/flutter/shell/platform/windows/settings_plugin_win32.h new file mode 100644 index 0000000000..a5d2b30cfb --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin_win32.h @@ -0,0 +1,54 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_WIN32_H_ +#define FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_WIN32_H_ + +#include "flutter/shell/platform/windows/settings_plugin.h" + +#include + +#include "flutter/shell/platform/windows/event_watcher_win32.h" + +namespace flutter { + +// A settings plugin implementation for win32. +class SettingsPluginWin32 : public SettingsPlugin { + public: + explicit SettingsPluginWin32(BinaryMessenger* messenger, + TaskRunner* task_runner); + + virtual ~SettingsPluginWin32(); + + // |SettingsPlugin| + void StartWatching() override; + + // |SettingsPlugin| + void StopWatching() override; + + protected: + // |SettingsPlugin| + bool GetAlwaysUse24HourFormat() override; + + // |SettingsPlugin| + float GetTextScaleFactor() override; + + // |SettingsPlugin| + PlatformBrightness GetPreferredBrightness() override; + + private: + void WatchPreferredBrightnessChanged(); + + HKEY preferred_brightness_reg_hkey_ = NULL; + + std::unique_ptr preferred_brightness_changed_watcher_{ + nullptr}; + + SettingsPluginWin32(const SettingsPluginWin32&) = delete; + SettingsPluginWin32& operator=(const SettingsPluginWin32&) = delete; +}; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_WIN32_H_ diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.cc b/engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.cc new file mode 100644 index 0000000000..88f1aa066a --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.cc @@ -0,0 +1,67 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/windows/settings_plugin_winuwp.h" + +#include "flutter/shell/platform/windows/system_utils.h" + +#include "third_party/cppwinrt/generated/winrt/base.h" + +namespace flutter { + +// static +std::unique_ptr SettingsPlugin::Create( + BinaryMessenger* messenger, + TaskRunner* task_runner) { + return std::make_unique(messenger, task_runner); +} + +SettingsPluginWinUwp::SettingsPluginWinUwp(BinaryMessenger* messenger, + TaskRunner* task_runner) + : SettingsPlugin(messenger, task_runner) {} + +SettingsPluginWinUwp::~SettingsPluginWinUwp() { + StopWatching(); +} + +void SettingsPluginWinUwp::StartWatching() { + color_values_changed_ = ui_settings_.ColorValuesChanged( + {this, &SettingsPluginWinUwp::OnColorValuesChanged}); +} + +void SettingsPluginWinUwp::StopWatching() { + if (color_values_changed_.has_value()) { + ui_settings_.ColorValuesChanged(color_values_changed_.value()); + color_values_changed_ = std::nullopt; + } +} + +bool SettingsPluginWinUwp::GetAlwaysUse24HourFormat() { + return Prefer24HourTime(GetUserTimeFormat()); +} + +float SettingsPluginWinUwp::GetTextScaleFactor() { + return 1.0; +} + +SettingsPlugin::PlatformBrightness +SettingsPluginWinUwp::GetPreferredBrightness() { + winrt::Windows::UI::ViewManagement::UISettings ui_settings; + auto background_color = ui_settings_.GetColorValue( + winrt::Windows::UI::ViewManagement::UIColorType::Background); + // Assuming that Windows return `Colors::Black` when being dark theme. + if (background_color == winrt::Windows::UI::Colors::Black()) { + return SettingsPlugin::PlatformBrightness::kDark; + } else { + return SettingsPlugin::PlatformBrightness::kLight; + } +} + +void SettingsPluginWinUwp::OnColorValuesChanged( + winrt::Windows::Foundation::IInspectable const&, + winrt::Windows::Foundation::IInspectable const&) { + task_runner_->RunNowOrPostTask([this]() { SendSettings(); }); +} + +} // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.h b/engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.h new file mode 100644 index 0000000000..ac2f05f7bd --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/settings_plugin_winuwp.h @@ -0,0 +1,56 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_WINUWP_H_ +#define FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_WINUWP_H_ + +#include "flutter/shell/platform/windows/settings_plugin.h" + +#include +#include + +#include "third_party/cppwinrt/generated/winrt/Windows.Foundation.h" +#include "third_party/cppwinrt/generated/winrt/Windows.UI.ViewManagement.h" + +namespace flutter { + +// A settings plugin implementation for UWP. +class SettingsPluginWinUwp : public SettingsPlugin { + public: + explicit SettingsPluginWinUwp(BinaryMessenger* messenger, + TaskRunner* task_runner); + + virtual ~SettingsPluginWinUwp(); + + // |SettingsPlugin| + void StartWatching() override; + + // |SettingsPlugin| + void StopWatching() override; + + protected: + // |SettingsPlugin| + bool GetAlwaysUse24HourFormat() override; + + // |SettingsPlugin| + float GetTextScaleFactor() override; + + // |SettingsPlugin| + PlatformBrightness GetPreferredBrightness() override; + + private: + void OnColorValuesChanged(winrt::Windows::Foundation::IInspectable const&, + winrt::Windows::Foundation::IInspectable const&); + + winrt::Windows::UI::ViewManagement::UISettings ui_settings_; + + std::optional color_values_changed_ = std::nullopt; + + SettingsPluginWinUwp(const SettingsPluginWinUwp&) = delete; + SettingsPluginWinUwp& operator=(const SettingsPluginWinUwp&) = delete; +}; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_WINUWP_H_ diff --git a/engine/src/flutter/shell/platform/windows/system_utils.h b/engine/src/flutter/shell/platform/windows/system_utils.h index 1d39cb8b25..60137d964b 100644 --- a/engine/src/flutter/shell/platform/windows/system_utils.h +++ b/engine/src/flutter/shell/platform/windows/system_utils.h @@ -12,11 +12,6 @@ namespace flutter { -namespace { -static constexpr wchar_t kPlatformBrightnessLight[] = L"light"; -static constexpr wchar_t kPlatformBrightnessDark[] = L"dark"; -} // namespace - // Components of a system language/locale. struct LanguageInfo { std::string language; @@ -42,9 +37,6 @@ std::wstring GetUserTimeFormat(); // Returns true if the time_format is set to use 24 hour time. bool Prefer24HourTime(std::wstring time_format); -// Returns the user-preferred brightness. -std::wstring GetPreferredBrightness(); - } // namespace flutter #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_SYSTEM_UTILS_H_ diff --git a/engine/src/flutter/shell/platform/windows/system_utils_unittests.cc b/engine/src/flutter/shell/platform/windows/system_utils_unittests.cc index 00e5fd48fd..6fecfbcc11 100644 --- a/engine/src/flutter/shell/platform/windows/system_utils_unittests.cc +++ b/engine/src/flutter/shell/platform/windows/system_utils_unittests.cc @@ -88,10 +88,5 @@ TEST(SystemUtils, Prefer24HourTimeHandles24Hour) { EXPECT_TRUE(Prefer24HourTime(L"HH:mm:ss")); } -TEST(SystemUtils, GetPreferredBrightness) { - std::wstring brightness = GetPreferredBrightness(); - EXPECT_TRUE(brightness == L"light" || brightness == L"dark"); -} - } // namespace testing } // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/system_utils_win32.cc b/engine/src/flutter/shell/platform/windows/system_utils_win32.cc index 7df7794477..bd8389dfe1 100644 --- a/engine/src/flutter/shell/platform/windows/system_utils_win32.cc +++ b/engine/src/flutter/shell/platform/windows/system_utils_win32.cc @@ -106,22 +106,4 @@ bool Prefer24HourTime(std::wstring time_format) { return time_format.find(L"H") != std::wstring::npos; } -std::wstring GetPreferredBrightness() { - DWORD use_light_theme; - DWORD use_light_theme_size = sizeof(use_light_theme); - LONG result = RegGetValue( - HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", - L"AppsUseLightTheme", RRF_RT_REG_DWORD, nullptr, &use_light_theme, - &use_light_theme_size); - - if (result == 0) { - return use_light_theme ? kPlatformBrightnessLight : kPlatformBrightnessDark; - } else { - // The current OS does not support dark mode. (Older Windows 10 or before - // Windows 10) - return kPlatformBrightnessLight; - } -} - } // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/system_utils_winuwp.cc b/engine/src/flutter/shell/platform/windows/system_utils_winuwp.cc index 698fb1e70a..ed5d3b9b8c 100644 --- a/engine/src/flutter/shell/platform/windows/system_utils_winuwp.cc +++ b/engine/src/flutter/shell/platform/windows/system_utils_winuwp.cc @@ -10,8 +10,6 @@ #include "third_party/cppwinrt/generated/winrt/Windows.Foundation.Collections.h" #include "third_party/cppwinrt/generated/winrt/Windows.System.UserProfile.h" -#include "third_party/cppwinrt/generated/winrt/Windows.UI.ViewManagement.h" -#include "third_party/cppwinrt/generated/winrt/Windows.UI.h" #include "flutter/fml/platform/win/wstring_conversion.h" @@ -82,16 +80,4 @@ bool Prefer24HourTime(std::wstring time_format) { return time_format.find(L"H") != std::wstring::npos; } -std::wstring GetPreferredBrightness() { - winrt::Windows::UI::ViewManagement::UISettings ui_settings; - auto background_color = ui_settings.GetColorValue( - winrt::Windows::UI::ViewManagement::UIColorType::Background); - // Assuming that Windows return `Colors::Black` when being dark theme. - if (background_color == winrt::Windows::UI::Colors::Black()) { - return kPlatformBrightnessDark; - } else { - return kPlatformBrightnessLight; - } -} - } // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/window_binding_handler_delegate.h b/engine/src/flutter/shell/platform/windows/window_binding_handler_delegate.h index 54768de4f3..ff7f67e39f 100644 --- a/engine/src/flutter/shell/platform/windows/window_binding_handler_delegate.h +++ b/engine/src/flutter/shell/platform/windows/window_binding_handler_delegate.h @@ -102,9 +102,6 @@ class WindowBindingHandlerDelegate { FlutterPointerDeviceKind device_kind, int32_t device_id) = 0; - // Notifies delegate that backing window has received brightness change event. - virtual void OnPlatformBrightnessChanged() = 0; - // Notifies delegate that the Flutter semantics tree should be enabled or // disabled. virtual void OnUpdateSemanticsEnabled(bool enabled) = 0;