Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Code cleanup on destructors (flutter#16481)
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscojma86 authored Feb 7, 2020
1 parent 477527b commit eb8691f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
#include <iostream>

namespace flutter {
namespace testing {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/testing/win32_flutter_window_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Win32FlutterWindowTest : public Win32FlutterWindow {
public:
Win32FlutterWindowTest(int width, int height);

~Win32FlutterWindowTest();
virtual ~Win32FlutterWindowTest();

// |Win32Window|
void OnFontChange() override;
Expand Down
8 changes: 1 addition & 7 deletions shell/platform/windows/win32_flutter_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -15,7 +15,6 @@ Win32FlutterWindow::Win32FlutterWindow(int width, int height) {

Win32FlutterWindow::~Win32FlutterWindow() {
DestroyRenderSurface();
Win32Window::Destroy();
}

FlutterDesktopViewControllerRef Win32FlutterWindow::CreateWin32FlutterWindow(
Expand Down Expand Up @@ -177,10 +176,6 @@ void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) {
}
}

void Win32FlutterWindow::OnClose() {
messageloop_running_ = false;
}

void Win32FlutterWindow::OnFontChange() {
if (engine_ == nullptr) {
return;
Expand Down Expand Up @@ -358,5 +353,4 @@ void Win32FlutterWindow::DestroyRenderSurface() {
}
render_surface = EGL_NO_SURFACE;
}

} // namespace flutter
14 changes: 4 additions & 10 deletions shell/platform/windows/win32_flutter_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 CreateWin32FlutterWindow(int width,
int height);
Expand Down Expand Up @@ -65,9 +65,6 @@ class Win32FlutterWindow : public Win32Window {
// |Win32Window|
void OnScroll(double delta_x, double delta_y) override;

// |Win32Window|
void OnClose() override;

// |Win32Window|
void OnFontChange() override;

Expand All @@ -85,9 +82,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();
Expand All @@ -99,6 +93,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);

Expand Down Expand Up @@ -174,9 +171,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
Expand Down
4 changes: 0 additions & 4 deletions shell/platform/windows/win32_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 4 additions & 7 deletions shell/platform/windows/win32_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,9 +46,6 @@ class Win32Window {
unsigned int width,
unsigned int height);

// Release OS resources asociated with window.
virtual void Destroy();

HWND GetWindowHandle();

protected:
Expand Down Expand Up @@ -116,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;

Expand Down Expand Up @@ -150,6 +144,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);

Expand Down
1 change: 0 additions & 1 deletion shell/platform/windows/win32_window_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb8691f

Please sign in to comment.