Consistent naming for Win32 emebedder (flutter/engine#24686)

Under shell/platform/windows, we have a mix of two naming schemes:
   * foo_bar_win32.h
   * win32_foo_bar.h

This renames files and identifiers to consistently use a Win32
suffix-based approach.
This commit is contained in:
Chris Bracken 2021-02-28 01:13:02 -08:00 committed by GitHub
parent 1ec8477938
commit ead87f659d
22 changed files with 179 additions and 179 deletions

View File

@ -1485,12 +1485,18 @@ FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/plu
FILE: ../../../flutter/shell/platform/windows/client_wrapper/plugin_registrar_windows_unittests.cc
FILE: ../../../flutter/shell/platform/windows/cursor_handler.cc
FILE: ../../../flutter/shell/platform/windows/cursor_handler.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/external_texture_gl.cc
FILE: ../../../flutter/shell/platform/windows/external_texture_gl.h
FILE: ../../../flutter/shell/platform/windows/flutter_key_map.cc
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle.cc
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle.h
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle_unittests.cc
FILE: ../../../flutter/shell/platform/windows/flutter_window_win32.cc
FILE: ../../../flutter/shell/platform/windows/flutter_window_win32.h
FILE: ../../../flutter/shell/platform/windows/flutter_window_win32_unittests.cc
FILE: ../../../flutter/shell/platform/windows/flutter_window_winuwp.cc
FILE: ../../../flutter/shell/platform/windows/flutter_window_winuwp.h
FILE: ../../../flutter/shell/platform/windows/flutter_windows.cc
@ -1540,21 +1546,15 @@ FILE: ../../../flutter/shell/platform/windows/text_input_plugin.cc
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin_delegate.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin_unittest.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.h
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils_unittests.cc
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.cc
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.h
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window_unittests.cc
FILE: ../../../flutter/shell/platform/windows/win32_window.cc
FILE: ../../../flutter/shell/platform/windows/win32_window.h
FILE: ../../../flutter/shell/platform/windows/win32_window_proc_delegate_manager.cc
FILE: ../../../flutter/shell/platform/windows/win32_window_proc_delegate_manager.h
FILE: ../../../flutter/shell/platform/windows/win32_window_proc_delegate_manager_unittests.cc
FILE: ../../../flutter/shell/platform/windows/win32_window_unittests.cc
FILE: ../../../flutter/shell/platform/windows/window_binding_handler.h
FILE: ../../../flutter/shell/platform/windows/window_binding_handler_delegate.h
FILE: ../../../flutter/shell/platform/windows/window_proc_delegate_manager_win32.cc
FILE: ../../../flutter/shell/platform/windows/window_proc_delegate_manager_win32.h
FILE: ../../../flutter/shell/platform/windows/window_proc_delegate_manager_win32_unittests.cc
FILE: ../../../flutter/shell/platform/windows/window_state.h
FILE: ../../../flutter/shell/platform/windows/window_win32.cc
FILE: ../../../flutter/shell/platform/windows/window_win32.h
FILE: ../../../flutter/shell/platform/windows/window_win32_unittests.cc
FILE: ../../../flutter/shell/profiling/sampling_profiler.cc
FILE: ../../../flutter/shell/profiling/sampling_profiler.h
FILE: ../../../flutter/shell/profiling/sampling_profiler_unittest.cc

View File

@ -93,6 +93,10 @@ source_set("flutter_windows_source") {
]
} else {
sources += [
"dpi_utils_win32.cc",
"dpi_utils_win32.h",
"flutter_window_win32.cc",
"flutter_window_win32.h",
"flutter_windows_win32.cc",
"platform_handler_win32.cc",
"platform_handler_win32.h",
@ -101,14 +105,10 @@ source_set("flutter_windows_source") {
"task_runner_win32.h",
"text_input_manager_win32.cc",
"text_input_manager_win32.h",
"win32_dpi_utils.cc",
"win32_dpi_utils.h",
"win32_flutter_window.cc",
"win32_flutter_window.h",
"win32_window.cc",
"win32_window.h",
"win32_window_proc_delegate_manager.cc",
"win32_window_proc_delegate_manager.h",
"window_proc_delegate_manager_win32.cc",
"window_proc_delegate_manager_win32.h",
"window_win32.cc",
"window_win32.h",
]
libs = [
@ -197,23 +197,23 @@ executable("flutter_windows_unittests") {
} else {
sources += [
# TODO move first two tests to common once above TODO's unblocked.
"dpi_utils_win32_unittests.cc",
"flutter_project_bundle_unittests.cc",
"flutter_window_win32_unittests.cc",
"flutter_windows_engine_unittests.cc",
"flutter_windows_texture_registrar_unittests.cc",
"keyboard_key_channel_handler_unittests.cc",
"keyboard_key_embedder_handler_unittests.cc",
"keyboard_key_handler_unittests.cc",
"testing/mock_win32_window.cc",
"testing/mock_win32_window.h",
"testing/flutter_window_win32_test.cc",
"testing/flutter_window_win32_test.h",
"testing/mock_window_binding_handler.cc",
"testing/mock_window_binding_handler.h",
"testing/win32_flutter_window_test.cc",
"testing/win32_flutter_window_test.h",
"testing/mock_window_win32.cc",
"testing/mock_window_win32.h",
"text_input_plugin_unittest.cc",
"win32_dpi_utils_unittests.cc",
"win32_flutter_window_unittests.cc",
"win32_window_proc_delegate_manager_unittests.cc",
"win32_window_unittests.cc",
"window_proc_delegate_manager_win32_unittests.cc",
"window_win32_unittests.cc",
]
}

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "win32_dpi_utils.h"
#include "dpi_utils_win32.h"
namespace flutter {
@ -26,11 +26,11 @@ bool AssignProcAddress(HMODULE comBaseModule, const char* name, T*& outProc) {
/// A helper class for abstracting various Windows DPI related functions across
/// Windows OS versions.
class Win32DpiHelper {
class DpiHelperWin32 {
public:
Win32DpiHelper();
DpiHelperWin32();
~Win32DpiHelper();
~DpiHelperWin32();
/// Returns the DPI for |hwnd|. Supports all DPI awareness modes, and is
/// backward compatible down to Windows Vista. If |hwnd| is nullptr, returns
@ -60,7 +60,7 @@ class Win32DpiHelper {
bool dpi_for_monitor_supported_ = false;
};
Win32DpiHelper::Win32DpiHelper() {
DpiHelperWin32::DpiHelperWin32() {
if ((user32_module_ = LoadLibraryA("User32.dll")) != nullptr) {
dpi_for_window_supported_ = (AssignProcAddress(
user32_module_, "GetDpiForWindow", get_dpi_for_window_));
@ -71,7 +71,7 @@ Win32DpiHelper::Win32DpiHelper() {
}
}
Win32DpiHelper::~Win32DpiHelper() {
DpiHelperWin32::~DpiHelperWin32() {
if (user32_module_ != nullptr) {
FreeLibrary(user32_module_);
}
@ -80,7 +80,7 @@ Win32DpiHelper::~Win32DpiHelper() {
}
}
UINT Win32DpiHelper::GetDpiForWindow(HWND hwnd) {
UINT DpiHelperWin32::GetDpiForWindow(HWND hwnd) {
// GetDpiForWindow returns the DPI for any awareness mode. If not available,
// or no |hwnd| is provided, fallback to a per monitor, system, or default
// DPI.
@ -101,7 +101,7 @@ UINT Win32DpiHelper::GetDpiForWindow(HWND hwnd) {
return dpi;
}
UINT Win32DpiHelper::GetDpiForMonitor(HMONITOR monitor) {
UINT DpiHelperWin32::GetDpiForMonitor(HMONITOR monitor) {
if (dpi_for_monitor_supported_) {
if (monitor == nullptr) {
const POINT target_point = {0, 0};
@ -117,8 +117,8 @@ UINT Win32DpiHelper::GetDpiForMonitor(HMONITOR monitor) {
return kDefaultDpi;
} // namespace
Win32DpiHelper* GetHelper() {
static Win32DpiHelper* dpi_helper = new Win32DpiHelper();
DpiHelperWin32* GetHelper() {
static DpiHelperWin32* dpi_helper = new DpiHelperWin32();
return dpi_helper;
}
} // namespace

View File

@ -4,7 +4,7 @@
#include <windows.h>
#include "flutter/shell/platform/windows/win32_dpi_utils.h"
#include "flutter/shell/platform/windows/dpi_utils_win32.h"
#include "gtest/gtest.h"
namespace flutter {

View File

@ -2,7 +2,7 @@
// 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/win32_flutter_window.h"
#include "flutter/shell/platform/windows/flutter_window_win32.h"
#include <dwmapi.h>
#include <chrono>
@ -65,35 +65,35 @@ static HCURSOR GetCursorByName(const std::string& cursor_name) {
} // namespace
Win32FlutterWindow::Win32FlutterWindow(int width, int height)
FlutterWindowWin32::FlutterWindowWin32(int width, int height)
: binding_handler_delegate_(nullptr) {
Win32Window::InitializeChild("FLUTTERVIEW", width, height);
WindowWin32::InitializeChild("FLUTTERVIEW", width, height);
current_cursor_ = ::LoadCursor(nullptr, IDC_ARROW);
}
Win32FlutterWindow::~Win32FlutterWindow() {}
FlutterWindowWin32::~FlutterWindowWin32() {}
void Win32FlutterWindow::SetView(WindowBindingHandlerDelegate* window) {
void FlutterWindowWin32::SetView(WindowBindingHandlerDelegate* window) {
binding_handler_delegate_ = window;
}
WindowsRenderTarget Win32FlutterWindow::GetRenderTarget() {
WindowsRenderTarget FlutterWindowWin32::GetRenderTarget() {
return WindowsRenderTarget(GetWindowHandle());
}
float Win32FlutterWindow::GetDpiScale() {
float FlutterWindowWin32::GetDpiScale() {
return static_cast<float>(GetCurrentDPI()) / static_cast<float>(base_dpi);
}
PhysicalWindowBounds Win32FlutterWindow::GetPhysicalWindowBounds() {
PhysicalWindowBounds FlutterWindowWin32::GetPhysicalWindowBounds() {
return {GetCurrentWidth(), GetCurrentHeight()};
}
void Win32FlutterWindow::UpdateFlutterCursor(const std::string& cursor_name) {
void FlutterWindowWin32::UpdateFlutterCursor(const std::string& cursor_name) {
current_cursor_ = GetCursorByName(cursor_name);
}
void Win32FlutterWindow::OnWindowResized() {
void FlutterWindowWin32::OnWindowResized() {
// Blocking the raster thread until DWM flushes alleviates glitches where
// previous size surface is stretched over current size view.
DwmFlush();
@ -120,21 +120,21 @@ static uint64_t ConvertWinButtonToFlutterButton(UINT button) {
return 0;
}
void Win32FlutterWindow::OnDpiScale(unsigned int dpi){};
void FlutterWindowWin32::OnDpiScale(unsigned int dpi){};
// When DesktopWindow notifies that a WM_Size message has come in
// lets FlutterEngine know about the new size.
void Win32FlutterWindow::OnResize(unsigned int width, unsigned int height) {
void FlutterWindowWin32::OnResize(unsigned int width, unsigned int height) {
if (binding_handler_delegate_ != nullptr) {
binding_handler_delegate_->OnWindowSizeChanged(width, height);
}
}
void Win32FlutterWindow::OnPointerMove(double x, double y) {
void FlutterWindowWin32::OnPointerMove(double x, double y) {
binding_handler_delegate_->OnPointerMove(x, y);
}
void Win32FlutterWindow::OnPointerDown(double x, double y, UINT button) {
void FlutterWindowWin32::OnPointerDown(double x, double y, UINT button) {
uint64_t flutter_button = ConvertWinButtonToFlutterButton(button);
if (flutter_button != 0) {
binding_handler_delegate_->OnPointerDown(
@ -142,7 +142,7 @@ void Win32FlutterWindow::OnPointerDown(double x, double y, UINT button) {
}
}
void Win32FlutterWindow::OnPointerUp(double x, double y, UINT button) {
void FlutterWindowWin32::OnPointerUp(double x, double y, UINT button) {
uint64_t flutter_button = ConvertWinButtonToFlutterButton(button);
if (flutter_button != 0) {
binding_handler_delegate_->OnPointerUp(
@ -150,19 +150,19 @@ void Win32FlutterWindow::OnPointerUp(double x, double y, UINT button) {
}
}
void Win32FlutterWindow::OnPointerLeave() {
void FlutterWindowWin32::OnPointerLeave() {
binding_handler_delegate_->OnPointerLeave();
}
void Win32FlutterWindow::OnSetCursor() {
void FlutterWindowWin32::OnSetCursor() {
::SetCursor(current_cursor_);
}
void Win32FlutterWindow::OnText(const std::u16string& text) {
void FlutterWindowWin32::OnText(const std::u16string& text) {
binding_handler_delegate_->OnText(text);
}
bool Win32FlutterWindow::OnKey(int key,
bool FlutterWindowWin32::OnKey(int key,
int scancode,
int action,
char32_t character,
@ -172,20 +172,20 @@ bool Win32FlutterWindow::OnKey(int key,
extended, was_down);
}
void Win32FlutterWindow::OnComposeBegin() {
void FlutterWindowWin32::OnComposeBegin() {
binding_handler_delegate_->OnComposeBegin();
}
void Win32FlutterWindow::OnComposeEnd() {
void FlutterWindowWin32::OnComposeEnd() {
binding_handler_delegate_->OnComposeEnd();
}
void Win32FlutterWindow::OnComposeChange(const std::u16string& text,
void FlutterWindowWin32::OnComposeChange(const std::u16string& text,
int cursor_pos) {
binding_handler_delegate_->OnComposeChange(text, cursor_pos);
}
void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) {
void FlutterWindowWin32::OnScroll(double delta_x, double delta_y) {
POINT point;
GetCursorPos(&point);
@ -194,7 +194,7 @@ void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) {
kScrollOffsetMultiplier);
}
void Win32FlutterWindow::OnCursorRectUpdated(const Rect& rect) {
void FlutterWindowWin32::OnCursorRectUpdated(const Rect& rect) {
// Convert the rect from Flutter logical coordinates to device coordinates.
auto scale = GetDpiScale();
Point origin(rect.left() * scale, rect.top() * scale);

View File

@ -14,8 +14,8 @@
#include "flutter/shell/platform/common/geometry.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/windows/flutter_windows_view.h"
#include "flutter/shell/platform/windows/win32_window.h"
#include "flutter/shell/platform/windows/window_binding_handler.h"
#include "flutter/shell/platform/windows/window_win32.h"
namespace flutter {
@ -23,38 +23,38 @@ namespace flutter {
// future, there will likely be a CoreWindow-based FlutterWindow as well. At
// the point may make sense to dependency inject the native window rather than
// inherit.
class Win32FlutterWindow : public Win32Window, public WindowBindingHandler {
class FlutterWindowWin32 : public WindowWin32, public WindowBindingHandler {
public:
// Create flutter Window for use as child window
Win32FlutterWindow(int width, int height);
FlutterWindowWin32(int width, int height);
virtual ~Win32FlutterWindow();
virtual ~FlutterWindowWin32();
// |Win32Window|
// |WindowWin32|
void OnDpiScale(unsigned int dpi) override;
// |Win32Window|
// |WindowWin32|
void OnResize(unsigned int width, unsigned int height) override;
// |Win32Window|
// |WindowWin32|
void OnPointerMove(double x, double y) override;
// |Win32Window|
// |WindowWin32|
void OnPointerDown(double x, double y, UINT button) override;
// |Win32Window|
// |WindowWin32|
void OnPointerUp(double x, double y, UINT button) override;
// |Win32Window|
// |WindowWin32|
void OnPointerLeave() override;
// |Win32Window|
// |WindowWin32|
void OnSetCursor() override;
// |Win32Window|
// |WindowWin32|
void OnText(const std::u16string& text) override;
// |Win32Window|
// |WindowWin32|
bool OnKey(int key,
int scancode,
int action,
@ -62,19 +62,19 @@ class Win32FlutterWindow : public Win32Window, public WindowBindingHandler {
bool extended,
bool was_down) override;
// |Win32Window|
// |WindowWin32|
void OnComposeBegin() override;
// |Win32Window|
// |WindowWin32|
void OnComposeEnd() override;
// |Win32Window|
// |WindowWin32|
void OnComposeChange(const std::u16string& text, int cursor_pos) override;
// |FlutterWindowBindingHandler|
void OnCursorRectUpdated(const Rect& rect) override;
// |Win32Window|
// |WindowWin32|
void OnScroll(double delta_x, double delta_y) override;
// |FlutterWindowBindingHandler|

View File

@ -9,8 +9,8 @@
#include "flutter/shell/platform/windows/keyboard_key_channel_handler.h"
#include "flutter/shell/platform/windows/keyboard_key_handler.h"
#include "flutter/shell/platform/windows/testing/engine_embedder_api_modifier.h"
#include "flutter/shell/platform/windows/testing/flutter_window_win32_test.h"
#include "flutter/shell/platform/windows/testing/mock_window_binding_handler.h"
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
#include "flutter/shell/platform/windows/text_input_plugin.h"
#include "flutter/shell/platform/windows/text_input_plugin_delegate.h"
@ -122,17 +122,17 @@ class SpyTextInputPlugin : public KeyboardHandlerBase,
std::unique_ptr<TextInputPlugin> real_implementation_;
};
class MockWin32FlutterWindow : public Win32FlutterWindow {
class MockFlutterWindowWin32 : public FlutterWindowWin32 {
public:
MockWin32FlutterWindow() : Win32FlutterWindow(800, 600) {
MockFlutterWindowWin32() : FlutterWindowWin32(800, 600) {
ON_CALL(*this, GetDpiScale())
.WillByDefault(Return(this->Win32FlutterWindow::GetDpiScale()));
.WillByDefault(Return(this->FlutterWindowWin32::GetDpiScale()));
}
virtual ~MockWin32FlutterWindow() {}
virtual ~MockFlutterWindowWin32() {}
// Prevent copying.
MockWin32FlutterWindow(MockWin32FlutterWindow const&) = delete;
MockWin32FlutterWindow& operator=(MockWin32FlutterWindow const&) = delete;
MockFlutterWindowWin32(MockFlutterWindowWin32 const&) = delete;
MockFlutterWindowWin32& operator=(MockFlutterWindowWin32 const&) = delete;
// Wrapper for GetCurrentDPI() which is a protected method.
UINT GetDpi() { return GetCurrentDPI(); }
@ -171,7 +171,7 @@ class TestFlutterWindowsView : public FlutterWindowsView {
SpyKeyboardKeyHandler* key_event_handler;
SpyTextInputPlugin* text_input_plugin;
void InjectPendingEvents(MockWin32FlutterWindow* win32window) {
void InjectPendingEvents(MockFlutterWindowWin32* win32window) {
while (pending_responds_.size() > 0) {
SimulatedEvent event = pending_responds_.front();
win32window->InjectWindowMessage(event.message, event.wparam,
@ -292,19 +292,19 @@ std::unique_ptr<FlutterWindowsEngine> GetTestEngine() {
} // namespace
TEST(Win32FlutterWindowTest, CreateDestroy) {
Win32FlutterWindowTest window(800, 600);
TEST(FlutterWindowWin32Test, CreateDestroy) {
FlutterWindowWin32Test window(800, 600);
ASSERT_TRUE(TRUE);
}
// Tests key event propagation of non-printable, non-modifier key down events.
TEST(Win32FlutterWindowTest, NonPrintableKeyDownPropagation) {
TEST(FlutterWindowWin32Test, NonPrintableKeyDownPropagation) {
::testing::InSequence in_sequence;
constexpr WPARAM virtual_key = VK_LEFT;
constexpr WPARAM scan_code = 10;
constexpr char32_t character = 0;
MockWin32FlutterWindow win32window;
MockFlutterWindowWin32 win32window;
std::deque<SimulatedEvent> pending_events;
auto window_binding_handler =
std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
@ -359,14 +359,14 @@ TEST(Win32FlutterWindowTest, NonPrintableKeyDownPropagation) {
// Tests key event propagation of printable character key down events. These
// differ from non-printable characters in that they follow a different code
// path in the WndProc (HandleMessage), producing a follow-on WM_CHAR event.
TEST(Win32FlutterWindowTest, CharKeyDownPropagation) {
TEST(FlutterWindowWin32Test, CharKeyDownPropagation) {
// ::testing::InSequence in_sequence;
constexpr WPARAM virtual_key = 65; // The "A" key, which produces a character
constexpr WPARAM scan_code = 30;
constexpr char32_t character = 65;
MockWin32FlutterWindow win32window;
MockFlutterWindowWin32 win32window;
auto window_binding_handler =
std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
TestFlutterWindowsView flutter_windows_view(
@ -426,11 +426,11 @@ TEST(Win32FlutterWindowTest, CharKeyDownPropagation) {
// Tests key event propagation of modifier key down events. This are different
// from non-printable events in that they call MapVirtualKey, resulting in a
// slightly different code path.
TEST(Win32FlutterWindowTest, ModifierKeyDownPropagation) {
TEST(FlutterWindowWin32Test, ModifierKeyDownPropagation) {
constexpr WPARAM virtual_key = VK_LSHIFT;
constexpr WPARAM scan_code = 20;
constexpr char32_t character = 0;
MockWin32FlutterWindow win32window;
MockFlutterWindowWin32 win32window;
std::deque<SimulatedEvent> pending_events;
auto window_binding_handler =
std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
@ -481,8 +481,8 @@ TEST(Win32FlutterWindowTest, ModifierKeyDownPropagation) {
// Tests that composing rect updates are transformed from Flutter logical
// coordinates to device coordinates and passed to the text input manager
// when the DPI scale is 100% (96 DPI).
TEST(Win32FlutterWindowTest, OnCursorRectUpdatedRegularDPI) {
MockWin32FlutterWindow win32window;
TEST(FlutterWindowWin32Test, OnCursorRectUpdatedRegularDPI) {
MockFlutterWindowWin32 win32window;
ON_CALL(win32window, GetDpiScale()).WillByDefault(Return(1.0));
EXPECT_CALL(win32window, GetDpiScale()).Times(1);
@ -495,8 +495,8 @@ TEST(Win32FlutterWindowTest, OnCursorRectUpdatedRegularDPI) {
// Tests that composing rect updates are transformed from Flutter logical
// coordinates to device coordinates and passed to the text input manager
// when the DPI scale is 150% (144 DPI).
TEST(Win32FlutterWindowTest, OnCursorRectUpdatedHighDPI) {
MockWin32FlutterWindow win32window;
TEST(FlutterWindowWin32Test, OnCursorRectUpdatedHighDPI) {
MockFlutterWindowWin32 win32window;
ON_CALL(win32window, GetDpiScale()).WillByDefault(Return(1.5));
EXPECT_CALL(win32window, GetDpiScale()).Times(1);

View File

@ -145,7 +145,7 @@ FlutterWindowsEngine::FlutterWindowsEngine(const FlutterProjectBundle& project)
texture_registrar_ = std::make_unique<FlutterWindowsTextureRegistrar>(this);
#ifndef WINUWP
window_proc_delegate_manager_ =
std::make_unique<Win32WindowProcDelegateManager>();
std::make_unique<WindowProcDelegateManagerWin32>();
#endif
// Set up internal channels.

View File

@ -22,7 +22,7 @@
#include "third_party/rapidjson/include/rapidjson/document.h"
#ifndef WINUWP
#include "flutter/shell/platform/windows/win32_window_proc_delegate_manager.h" // nogncheck
#include "flutter/shell/platform/windows/window_proc_delegate_manager_win32.h" // nogncheck
#endif
namespace flutter {
@ -86,7 +86,7 @@ class FlutterWindowsEngine {
}
#ifndef WINUWP
Win32WindowProcDelegateManager* window_proc_delegate_manager() {
WindowProcDelegateManagerWin32* window_proc_delegate_manager() {
return window_proc_delegate_manager_.get();
}
#endif
@ -184,7 +184,7 @@ class FlutterWindowsEngine {
#ifndef WINUWP
// The manager for WindowProc delegate registration and callbacks.
std::unique_ptr<Win32WindowProcDelegateManager> window_proc_delegate_manager_;
std::unique_ptr<WindowProcDelegateManagerWin32> window_proc_delegate_manager_;
#endif
};

View File

@ -15,9 +15,9 @@
#include <memory>
#include <vector>
#include "flutter/shell/platform/windows/dpi_utils_win32.h"
#include "flutter/shell/platform/windows/flutter_window_win32.h"
#include "flutter/shell/platform/windows/task_runner_win32.h"
#include "flutter/shell/platform/windows/win32_dpi_utils.h"
#include "flutter/shell/platform/windows/win32_flutter_window.h"
// Returns the engine corresponding to the given opaque API handle.
static flutter::FlutterWindowsEngine* EngineFromHandle(
@ -30,7 +30,7 @@ FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(
int height,
FlutterDesktopEngineRef engine) {
std::unique_ptr<flutter::WindowBindingHandler> window_wrapper =
std::make_unique<flutter::Win32FlutterWindow>(width, height);
std::make_unique<flutter::FlutterWindowWin32>(width, height);
auto state = std::make_unique<FlutterDesktopViewControllerState>();
state->view =

View File

@ -2,15 +2,15 @@
// 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/testing/win32_flutter_window_test.h"
#include "flutter/shell/platform/windows/testing/flutter_window_win32_test.h"
namespace flutter {
namespace testing {
Win32FlutterWindowTest::Win32FlutterWindowTest(int width, int height)
: Win32FlutterWindow(width, height){};
FlutterWindowWin32Test::FlutterWindowWin32Test(int width, int height)
: FlutterWindowWin32(width, height){};
Win32FlutterWindowTest::~Win32FlutterWindowTest() = default;
FlutterWindowWin32Test::~FlutterWindowWin32Test() = default;
} // namespace testing
} // namespace flutter

View File

@ -5,20 +5,20 @@
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WIN32_FLUTTER_WINDOW_TEST_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WIN32_FLUTTER_WINDOW_TEST_H_
#include "flutter/shell/platform/windows/win32_flutter_window.h"
#include "flutter/shell/platform/windows/flutter_window_win32.h"
namespace flutter {
namespace testing {
/// Test class for Win32FlutterWindow.
class Win32FlutterWindowTest : public Win32FlutterWindow {
/// Test class for FlutterWindowWin32.
class FlutterWindowWin32Test : public FlutterWindowWin32 {
public:
Win32FlutterWindowTest(int width, int height);
virtual ~Win32FlutterWindowTest();
FlutterWindowWin32Test(int width, int height);
virtual ~FlutterWindowWin32Test();
// Prevent copying.
Win32FlutterWindowTest(Win32FlutterWindowTest const&) = delete;
Win32FlutterWindowTest& operator=(Win32FlutterWindowTest const&) = delete;
FlutterWindowWin32Test(FlutterWindowWin32Test const&) = delete;
FlutterWindowWin32Test& operator=(FlutterWindowWin32Test const&) = delete;
};
} // namespace testing

View File

@ -13,7 +13,7 @@
namespace flutter {
namespace testing {
/// Mock for the Win32Window base class.
/// Mock for the |WindowWin32| base class.
class MockWindowBindingHandler : public WindowBindingHandler {
public:
MockWindowBindingHandler();

View File

@ -2,12 +2,12 @@
// 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/testing/mock_win32_window.h"
#include "flutter/shell/platform/windows/testing/mock_window_win32.h"
namespace flutter {
namespace testing {
MockWin32Window::MockWin32Window() : Win32Window(){};
MockWin32Window::MockWin32Window() : WindowWin32(){};
MockWin32Window::~MockWin32Window() = default;

View File

@ -7,14 +7,14 @@
#include <windowsx.h>
#include "flutter/shell/platform/windows/win32_window.h"
#include "flutter/shell/platform/windows/window_win32.h"
#include "gmock/gmock.h"
namespace flutter {
namespace testing {
/// Mock for the Win32Window base class.
class MockWin32Window : public Win32Window {
/// Mock for the |WindowWin32| base class.
class MockWin32Window : public WindowWin32 {
public:
MockWin32Window();
virtual ~MockWin32Window();

View File

@ -2,27 +2,27 @@
// 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/win32_window_proc_delegate_manager.h"
#include "flutter/shell/platform/windows/window_proc_delegate_manager_win32.h"
#include "flutter/shell/platform/embedder/embedder.h"
namespace flutter {
Win32WindowProcDelegateManager::Win32WindowProcDelegateManager() = default;
Win32WindowProcDelegateManager::~Win32WindowProcDelegateManager() = default;
WindowProcDelegateManagerWin32::WindowProcDelegateManagerWin32() = default;
WindowProcDelegateManagerWin32::~WindowProcDelegateManagerWin32() = default;
void Win32WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate(
void WindowProcDelegateManagerWin32::RegisterTopLevelWindowProcDelegate(
FlutterDesktopWindowProcCallback delegate,
void* user_data) {
top_level_window_proc_handlers_[delegate] = user_data;
}
void Win32WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate(
void WindowProcDelegateManagerWin32::UnregisterTopLevelWindowProcDelegate(
FlutterDesktopWindowProcCallback delegate) {
top_level_window_proc_handlers_.erase(delegate);
}
std::optional<LRESULT> Win32WindowProcDelegateManager::OnTopLevelWindowProc(
std::optional<LRESULT> WindowProcDelegateManagerWin32::OnTopLevelWindowProc(
HWND hwnd,
UINT message,
WPARAM wparam,

View File

@ -16,16 +16,16 @@ namespace flutter {
// Handles registration, unregistration, and dispatching for WindowProc
// delegation.
class Win32WindowProcDelegateManager {
class WindowProcDelegateManagerWin32 {
public:
explicit Win32WindowProcDelegateManager();
~Win32WindowProcDelegateManager();
explicit WindowProcDelegateManagerWin32();
~WindowProcDelegateManagerWin32();
// Prevent copying.
Win32WindowProcDelegateManager(Win32WindowProcDelegateManager const&) =
WindowProcDelegateManagerWin32(WindowProcDelegateManagerWin32 const&) =
delete;
Win32WindowProcDelegateManager& operator=(
Win32WindowProcDelegateManager const&) = delete;
WindowProcDelegateManagerWin32& operator=(
WindowProcDelegateManagerWin32 const&) = delete;
// Adds |delegate| as a delegate to be called for |OnTopLevelWindowProc|.
//

View File

@ -2,7 +2,7 @@
// 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/win32_window_proc_delegate_manager.h"
#include "flutter/shell/platform/windows/window_proc_delegate_manager_win32.h"
#include "gtest/gtest.h"
namespace flutter {
@ -44,8 +44,8 @@ bool TestWindowProcCallback2(HWND hwnd,
} // namespace
TEST(Win32WindowProcDelegateManagerTest, CallsCorrectly) {
Win32WindowProcDelegateManager manager;
TEST(WindowProcDelegateManagerWin32Test, CallsCorrectly) {
WindowProcDelegateManagerWin32 manager;
HWND dummy_hwnd;
bool called = false;
@ -66,8 +66,8 @@ TEST(Win32WindowProcDelegateManagerTest, CallsCorrectly) {
EXPECT_FALSE(result);
}
TEST(Win32WindowProcDelegateManagerTest, ReplacementRegister) {
Win32WindowProcDelegateManager manager;
TEST(WindowProcDelegateManagerWin32Test, ReplacementRegister) {
WindowProcDelegateManagerWin32 manager;
bool called_a = false;
TestWindowProcDelegate delegate_a =
@ -92,8 +92,8 @@ TEST(Win32WindowProcDelegateManagerTest, ReplacementRegister) {
EXPECT_TRUE(called_b);
}
TEST(Win32WindowProcDelegateManagerTest, RegisterMultiple) {
Win32WindowProcDelegateManager manager;
TEST(WindowProcDelegateManagerWin32Test, RegisterMultiple) {
WindowProcDelegateManagerWin32 manager;
bool called_a = false;
TestWindowProcDelegate delegate_a =
@ -118,8 +118,8 @@ TEST(Win32WindowProcDelegateManagerTest, RegisterMultiple) {
EXPECT_TRUE(called_b);
}
TEST(Win32WindowProcDelegateManagerTest, ConflictingDelegates) {
Win32WindowProcDelegateManager manager;
TEST(WindowProcDelegateManagerWin32Test, ConflictingDelegates) {
WindowProcDelegateManagerWin32 manager;
bool called_a = false;
TestWindowProcDelegate delegate_a =
@ -147,8 +147,8 @@ TEST(Win32WindowProcDelegateManagerTest, ConflictingDelegates) {
EXPECT_NE(called_a, called_b);
}
TEST(Win32WindowProcDelegateManagerTest, Unregister) {
Win32WindowProcDelegateManager manager;
TEST(WindowProcDelegateManagerWin32Test, Unregister) {
WindowProcDelegateManagerWin32 manager;
bool called = false;
TestWindowProcDelegate delegate = [&called](HWND hwnd, UINT message,

View File

@ -2,13 +2,13 @@
// 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/win32_window.h"
#include "flutter/shell/platform/windows/window_win32.h"
#include <imm.h>
#include <cstring>
#include "win32_dpi_utils.h"
#include "dpi_utils_win32.h"
namespace flutter {
@ -19,18 +19,18 @@ char32_t CodePointFromSurrogatePair(wchar_t high, wchar_t low) {
}
} // namespace
Win32Window::Win32Window() {
WindowWin32::WindowWin32() {
// Get the DPI of the primary monitor as the initial DPI. If Per-Monitor V2 is
// supported, |current_dpi_| should be updated in the
// kWmDpiChangedBeforeParent message.
current_dpi_ = GetDpiForHWND(nullptr);
}
Win32Window::~Win32Window() {
WindowWin32::~WindowWin32() {
Destroy();
}
void Win32Window::InitializeChild(const char* title,
void WindowWin32::InitializeChild(const char* title,
unsigned int width,
unsigned int height) {
Destroy();
@ -56,7 +56,7 @@ void Win32Window::InitializeChild(const char* title,
}
}
std::wstring Win32Window::NarrowToWide(const char* source) {
std::wstring WindowWin32::NarrowToWide(const char* source) {
size_t length = strlen(source);
size_t outlen = 0;
std::wstring wideTitle(length, L'#');
@ -64,7 +64,7 @@ std::wstring Win32Window::NarrowToWide(const char* source) {
return wideTitle;
}
WNDCLASS Win32Window::RegisterWindowClass(std::wstring& title) {
WNDCLASS WindowWin32::RegisterWindowClass(std::wstring& title) {
window_class_name_ = title;
WNDCLASS window_class{};
@ -82,7 +82,7 @@ WNDCLASS Win32Window::RegisterWindowClass(std::wstring& title) {
return window_class;
}
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
LRESULT CALLBACK WindowWin32::WndProc(HWND const window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
@ -91,17 +91,17 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
SetWindowLongPtr(window, GWLP_USERDATA,
reinterpret_cast<LONG_PTR>(cs->lpCreateParams));
auto that = static_cast<Win32Window*>(cs->lpCreateParams);
auto that = static_cast<WindowWin32*>(cs->lpCreateParams);
that->window_handle_ = window;
that->text_input_manager_.SetWindowHandle(window);
} else if (Win32Window* that = GetThisFromHandle(window)) {
} else if (WindowWin32* that = GetThisFromHandle(window)) {
return that->HandleMessage(message, wparam, lparam);
}
return DefWindowProc(window, message, wparam, lparam);
}
void Win32Window::TrackMouseLeaveEvent(HWND hwnd) {
void WindowWin32::TrackMouseLeaveEvent(HWND hwnd) {
if (!tracking_mouse_leave_) {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
@ -112,7 +112,7 @@ void Win32Window::TrackMouseLeaveEvent(HWND hwnd) {
}
}
void Win32Window::OnImeSetContext(UINT const message,
void WindowWin32::OnImeSetContext(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
if (wparam != 0) {
@ -120,14 +120,14 @@ void Win32Window::OnImeSetContext(UINT const message,
}
}
void Win32Window::OnImeStartComposition(UINT const message,
void WindowWin32::OnImeStartComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
text_input_manager_.CreateImeWindow();
OnComposeBegin();
}
void Win32Window::OnImeComposition(UINT const message,
void WindowWin32::OnImeComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
// Update the IME window position.
@ -158,14 +158,14 @@ void Win32Window::OnImeComposition(UINT const message,
}
}
void Win32Window::OnImeEndComposition(UINT const message,
void WindowWin32::OnImeEndComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
text_input_manager_.DestroyImeWindow();
OnComposeEnd();
}
void Win32Window::OnImeRequest(UINT const message,
void WindowWin32::OnImeRequest(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
// TODO(cbracken): Handle IMR_RECONVERTSTRING, IMR_DOCUMENTFEED,
@ -173,12 +173,12 @@ void Win32Window::OnImeRequest(UINT const message,
// https://github.com/flutter/flutter/issues/74547
}
void Win32Window::UpdateCursorRect(const Rect& rect) {
void WindowWin32::UpdateCursorRect(const Rect& rect) {
text_input_manager_.UpdateCaretRect(rect);
}
LRESULT
Win32Window::HandleMessage(UINT const message,
WindowWin32::HandleMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
LPARAM result_lparam = lparam;
@ -399,23 +399,23 @@ Win32Window::HandleMessage(UINT const message,
return DefWindowProc(window_handle_, message, wparam, result_lparam);
}
UINT Win32Window::GetCurrentDPI() {
UINT WindowWin32::GetCurrentDPI() {
return current_dpi_;
}
UINT Win32Window::GetCurrentWidth() {
UINT WindowWin32::GetCurrentWidth() {
return current_width_;
}
UINT Win32Window::GetCurrentHeight() {
UINT WindowWin32::GetCurrentHeight() {
return current_height_;
}
HWND Win32Window::GetWindowHandle() {
HWND WindowWin32::GetWindowHandle() {
return window_handle_;
}
void Win32Window::Destroy() {
void WindowWin32::Destroy() {
if (window_handle_) {
DestroyWindow(window_handle_);
window_handle_ = nullptr;
@ -424,18 +424,18 @@ void Win32Window::Destroy() {
UnregisterClass(window_class_name_.c_str(), nullptr);
}
void Win32Window::HandleResize(UINT width, UINT height) {
void WindowWin32::HandleResize(UINT width, UINT height) {
current_width_ = width;
current_height_ = height;
OnResize(width, height);
}
Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
return reinterpret_cast<Win32Window*>(
WindowWin32* WindowWin32::GetThisFromHandle(HWND const window) noexcept {
return reinterpret_cast<WindowWin32*>(
GetWindowLongPtr(window, GWLP_USERDATA));
}
LRESULT Win32Window::DefaultWindowProc(HWND hWnd,
LRESULT WindowWin32::DefaultWindowProc(HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam) {

View File

@ -18,10 +18,10 @@ namespace flutter {
// A class abstraction for a high DPI aware Win32 Window. Intended to be
// inherited from by classes that wish to specialize with custom
// rendering and input handling.
class Win32Window {
class WindowWin32 {
public:
Win32Window();
virtual ~Win32Window();
WindowWin32();
virtual ~WindowWin32();
// Initializes as a child window with size using |width| and |height| and
// |title| to identify the windowclass. Does not show window, window must be
@ -169,7 +169,7 @@ class Win32Window {
void HandleResize(UINT width, UINT height);
// Retrieves a class instance pointer for |window|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
static WindowWin32* GetThisFromHandle(HWND const window) noexcept;
int current_dpi_ = 0;
int current_width_ = 0;
int current_height_ = 0;

View File

@ -2,7 +2,7 @@
// 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/testing/mock_win32_window.h"
#include "flutter/shell/platform/windows/testing/mock_window_win32.h"
#include "gtest/gtest.h"
using testing::_;