From f9764ebd76ec1432237d60234a71cd6e5d4c5973 Mon Sep 17 00:00:00 2001 From: Francisco Madgaleno Date: Thu, 6 Feb 2020 14:45:31 -0800 Subject: [PATCH 1/3] Fix virtuals --- .../windows/testing/win32_flutter_window_test.cc | 1 - .../windows/testing/win32_flutter_window_test.h | 2 +- shell/platform/windows/win32_flutter_window.cc | 8 ++------ shell/platform/windows/win32_flutter_window.h | 11 ++++------- shell/platform/windows/win32_window.cc | 5 ----- shell/platform/windows/win32_window.h | 8 ++++---- shell/platform/windows/win32_window_unittests.cc | 1 - 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/shell/platform/windows/testing/win32_flutter_window_test.cc b/shell/platform/windows/testing/win32_flutter_window_test.cc index 080262ae4bf88..bae1d9cd8d5b3 100644 --- a/shell/platform/windows/testing/win32_flutter_window_test.cc +++ b/shell/platform/windows/testing/win32_flutter_window_test.cc @@ -1,5 +1,4 @@ #include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h" -#include namespace flutter { namespace testing { diff --git a/shell/platform/windows/testing/win32_flutter_window_test.h b/shell/platform/windows/testing/win32_flutter_window_test.h index 361a6960a5fc6..24a53f7c529c6 100644 --- a/shell/platform/windows/testing/win32_flutter_window_test.h +++ b/shell/platform/windows/testing/win32_flutter_window_test.h @@ -14,7 +14,7 @@ class Win32FlutterWindowTest : public Win32FlutterWindow { public: Win32FlutterWindowTest(int width, int height); - ~Win32FlutterWindowTest(); + virtual ~Win32FlutterWindowTest(); // |Win32Window| void OnFontChange() override; diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index b5d8de160a60d..a3c7fcd11c91e 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -4,7 +4,7 @@ namespace flutter { -// the Windows DPI system is based on this +// The Windows DPI system is based on this // constant for machines running at 100% scaling. constexpr int base_dpi = 96; @@ -15,7 +15,6 @@ Win32FlutterWindow::Win32FlutterWindow(int width, int height) { Win32FlutterWindow::~Win32FlutterWindow() { DestroyRenderSurface(); - Win32Window::Destroy(); } FlutterDesktopViewControllerRef Win32FlutterWindow::CreateWin32FlutterWindow( @@ -177,9 +176,7 @@ void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) { } } -void Win32FlutterWindow::OnClose() { - messageloop_running_ = false; -} +void Win32FlutterWindow::OnClose() {} void Win32FlutterWindow::OnFontChange() { if (engine_ == nullptr) { @@ -365,5 +362,4 @@ void Win32FlutterWindow::DestroyRenderSurface() { } render_surface = EGL_NO_SURFACE; } - } // namespace flutter diff --git a/shell/platform/windows/win32_flutter_window.h b/shell/platform/windows/win32_flutter_window.h index 4d08b4117dabf..6611d1493d4cb 100644 --- a/shell/platform/windows/win32_flutter_window.h +++ b/shell/platform/windows/win32_flutter_window.h @@ -33,7 +33,7 @@ class Win32FlutterWindow : public Win32Window { // Create flutter Window for use as child window Win32FlutterWindow(int width, int height); - ~Win32FlutterWindow(); + virtual ~Win32FlutterWindow(); static FlutterDesktopViewControllerRef Win32FlutterWindow::CreateWin32FlutterWindow(int width, int height); @@ -85,9 +85,6 @@ class Win32FlutterWindow : public Win32Window { // Create a surface for Flutter engine to render into. void CreateRenderSurface(); - // Destroy current rendering surface if one has been allocated. - void DestroyRenderSurface(); - // Callbacks for clearing context, settings context and swapping buffers. bool ClearContext(); bool MakeCurrent(); @@ -99,6 +96,9 @@ class Win32FlutterWindow : public Win32Window { void SendWindowMetrics(); private: + // Destroy current rendering surface if one has been allocated. + void DestroyRenderSurface(); + // Reports a mouse movement to Flutter engine. void SendPointerMove(double x, double y); @@ -174,9 +174,6 @@ class Win32FlutterWindow : public Win32Window { // should we forword input messages or not bool process_events_ = false; - - // flag indicating if the message loop should be running - bool messageloop_running_ = false; }; } // namespace flutter diff --git a/shell/platform/windows/win32_window.cc b/shell/platform/windows/win32_window.cc index e499bfbd129f8..abf031a2c35f6 100644 --- a/shell/platform/windows/win32_window.cc +++ b/shell/platform/windows/win32_window.cc @@ -112,10 +112,6 @@ Win32Window::MessageHandler(HWND hwnd, case kWmDpiChangedBeforeParent: return HandleDpiChange(window_handle_, wparam, lparam, false); break; - case WM_DESTROY: - window->OnClose(); - return 0; - break; case WM_SIZE: width = LOWORD(lparam); height = HIWORD(lparam); @@ -248,7 +244,6 @@ void Win32Window::Destroy() { DestroyWindow(window_handle_); window_handle_ = nullptr; } - UnregisterClass(window_class_name_.c_str(), nullptr); } diff --git a/shell/platform/windows/win32_window.h b/shell/platform/windows/win32_window.h index 63a00c355dea6..a972557d8d222 100644 --- a/shell/platform/windows/win32_window.h +++ b/shell/platform/windows/win32_window.h @@ -37,7 +37,7 @@ struct MouseState { class Win32Window { public: Win32Window(); - ~Win32Window(); + virtual ~Win32Window(); // Initializes as a child window with size using |width| and |height| and // |title| to identify the windowclass. Does not show window, window must be @@ -46,9 +46,6 @@ class Win32Window { unsigned int width, unsigned int height); - // Release OS resources asociated with window. - virtual void Destroy(); - HWND GetWindowHandle(); protected: @@ -150,6 +147,9 @@ class Win32Window { void SetMouseButtons(uint64_t buttons) { mouse_state_.buttons = buttons; } private: + // Release OS resources asociated with window. + void Destroy(); + // Activates tracking for a "mouse leave" event. void TrackMouseLeaveEvent(HWND hwnd); diff --git a/shell/platform/windows/win32_window_unittests.cc b/shell/platform/windows/win32_window_unittests.cc index d04458492dff1..dece5a280f807 100644 --- a/shell/platform/windows/win32_window_unittests.cc +++ b/shell/platform/windows/win32_window_unittests.cc @@ -15,7 +15,6 @@ TEST(Win32FlutterWindowTest, CanFontChange) { LRESULT result = SendMessage(hwnd, WM_FONTCHANGE, NULL, NULL); ASSERT_EQ(result, 0); ASSERT_TRUE(window.OnFontChangeWasCalled()); - ASSERT_TRUE(TRUE); } } // namespace testing From 3dcad49470866c0f271ddb72a75fc1f70d48e496 Mon Sep 17 00:00:00 2001 From: Francisco Madgaleno Date: Thu, 6 Feb 2020 14:49:42 -0800 Subject: [PATCH 2/3] space --- shell/platform/windows/win32_window.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/windows/win32_window.cc b/shell/platform/windows/win32_window.cc index abf031a2c35f6..1ecd1926bfd64 100644 --- a/shell/platform/windows/win32_window.cc +++ b/shell/platform/windows/win32_window.cc @@ -244,6 +244,7 @@ void Win32Window::Destroy() { DestroyWindow(window_handle_); window_handle_ = nullptr; } + UnregisterClass(window_class_name_.c_str(), nullptr); } From 3db587ef1defec1518f7cfaa1224a83e9e391b52 Mon Sep 17 00:00:00 2001 From: Francisco Madgaleno Date: Thu, 6 Feb 2020 15:48:09 -0800 Subject: [PATCH 3/3] Remove onClose --- shell/platform/windows/win32_flutter_window.cc | 2 -- shell/platform/windows/win32_flutter_window.h | 3 --- shell/platform/windows/win32_window.h | 3 --- 3 files changed, 8 deletions(-) diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index a3c7fcd11c91e..803732a20754f 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -176,8 +176,6 @@ void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) { } } -void Win32FlutterWindow::OnClose() {} - void Win32FlutterWindow::OnFontChange() { if (engine_ == nullptr) { return; diff --git a/shell/platform/windows/win32_flutter_window.h b/shell/platform/windows/win32_flutter_window.h index 6611d1493d4cb..5e43ca4f34912 100644 --- a/shell/platform/windows/win32_flutter_window.h +++ b/shell/platform/windows/win32_flutter_window.h @@ -65,9 +65,6 @@ class Win32FlutterWindow : public Win32Window { // |Win32Window| void OnScroll(double delta_x, double delta_y) override; - // |Win32Window| - void OnClose(); - // |Win32Window| void OnFontChange() override; diff --git a/shell/platform/windows/win32_window.h b/shell/platform/windows/win32_window.h index a972557d8d222..d64e8097de645 100644 --- a/shell/platform/windows/win32_window.h +++ b/shell/platform/windows/win32_window.h @@ -113,9 +113,6 @@ class Win32Window { // Called when mouse scrollwheel input occurs. virtual void OnScroll(double delta_x, double delta_y) = 0; - // Called when the user closes the Windows. - virtual void OnClose() = 0; - // Called when the system font change. virtual void OnFontChange() = 0;