[Windows] Rename WindowWin32 to Window (flutter/engine#34920)

With the removal of the UWP embedder, there's no longer any need to call
out that a given class is Win32-specific, since the Win32 embedder is
now our only embedder.

Issue: https://github.com/flutter/flutter/issues/108386
This commit is contained in:
Chris Bracken
2022-07-27 18:51:03 +01:00
committed by GitHub
parent 57ffd65615
commit 97e03b7033
15 changed files with 201 additions and 205 deletions

View File

@@ -2423,15 +2423,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/window.cc
FILE: ../../../flutter/shell/platform/windows/window.h
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/platform/windows/window_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

@@ -103,13 +103,13 @@ source_set("flutter_windows_source") {
"text_input_manager_win32.h",
"text_input_plugin.cc",
"text_input_plugin.h",
"window.cc",
"window.h",
"window_binding_handler.h",
"window_binding_handler_delegate.h",
"window_proc_delegate_manager_win32.cc",
"window_proc_delegate_manager_win32.h",
"window_state.h",
"window_win32.cc",
"window_win32.h",
]
libs = [
@@ -198,10 +198,10 @@ executable("flutter_windows_unittests") {
"testing/mock_gl_functions.h",
"testing/mock_text_input_manager_win32.cc",
"testing/mock_text_input_manager_win32.h",
"testing/mock_window.cc",
"testing/mock_window.h",
"testing/mock_window_binding_handler.cc",
"testing/mock_window_binding_handler.h",
"testing/mock_window_win32.cc",
"testing/mock_window_win32.h",
"testing/test_keyboard.cc",
"testing/test_keyboard.h",
"testing/test_keyboard_unittests.cc",
@@ -209,7 +209,7 @@ executable("flutter_windows_unittests") {
"testing/wm_builders.h",
"text_input_plugin_unittest.cc",
"window_proc_delegate_manager_win32_unittests.cc",
"window_win32_unittests.cc",
"window_unittests.cc",
]
public_configs = [ "//flutter:config" ]

View File

@@ -5,8 +5,8 @@
#include "flutter/fml/logging.h"
#include "flutter/shell/platform/windows/direct_manipulation.h"
#include "flutter/shell/platform/windows/window.h"
#include "flutter/shell/platform/windows/window_binding_handler_delegate.h"
#include "flutter/shell/platform/windows/window_win32.h"
#define RETURN_IF_FAILED(operation) \
if (FAILED(operation)) { \
@@ -128,7 +128,7 @@ ULONG STDMETHODCALLTYPE DirectManipulationEventHandler::Release() {
return 0;
}
DirectManipulationOwner::DirectManipulationOwner(WindowWin32* window)
DirectManipulationOwner::DirectManipulationOwner(Window* window)
: window_(window) {}
int DirectManipulationOwner::Init(unsigned int width, unsigned int height) {

View File

@@ -12,7 +12,7 @@
namespace flutter {
class WindowWin32;
class Window;
class WindowBindingHandlerDelegate;
class DirectManipulationEventHandler;
@@ -21,7 +21,7 @@ class DirectManipulationEventHandler;
// DirectManipulation and WindowBindingHandlerDelegate.
class DirectManipulationOwner {
public:
explicit DirectManipulationOwner(WindowWin32* window);
explicit DirectManipulationOwner(Window* window);
// Initialize a DirectManipulation viewport with specified width and height.
// These should match the width and height of the application window.
int Init(unsigned int width, unsigned int height);
@@ -46,7 +46,7 @@ class DirectManipulationOwner {
private:
// The window gesture input is occuring on.
WindowWin32* window_;
Window* window_;
// Cookie needed to register child event handler with viewport.
DWORD viewportHandlerCookie_;
// Object needed for operation of the DirectManipulation API.

View File

@@ -63,7 +63,7 @@ static HCURSOR GetCursorByName(const std::string& cursor_name) {
FlutterWindowWin32::FlutterWindowWin32(int width, int height)
: binding_handler_delegate_(nullptr) {
WindowWin32::InitializeChild("FLUTTERVIEW", width, height);
Window::InitializeChild("FLUTTERVIEW", width, height);
current_cursor_ = ::LoadCursor(nullptr, IDC_ARROW);
}

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/window.h"
#include "flutter/shell/platform/windows/window_binding_handler.h"
#include "flutter/shell/platform/windows/window_win32.h"
namespace flutter {
@@ -23,55 +23,55 @@ namespace flutter {
// the 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 FlutterWindowWin32 : public WindowWin32, public WindowBindingHandler {
class FlutterWindowWin32 : public Window, public WindowBindingHandler {
public:
// Create flutter Window for use as child window
FlutterWindowWin32(int width, int height);
virtual ~FlutterWindowWin32();
// |WindowWin32|
// |Window|
void OnDpiScale(unsigned int dpi) override;
// |WindowWin32|
// |Window|
void OnResize(unsigned int width, unsigned int height) override;
// |WindowWin32|
// |Window|
void OnPaint() override;
// |WindowWin32|
// |Window|
void OnPointerMove(double x,
double y,
FlutterPointerDeviceKind device_kind,
int32_t device_id) override;
// |WindowWin32|
// |Window|
void OnPointerDown(double x,
double y,
FlutterPointerDeviceKind device_kind,
int32_t device_id,
UINT button) override;
// |WindowWin32|
// |Window|
void OnPointerUp(double x,
double y,
FlutterPointerDeviceKind device_kind,
int32_t device_id,
UINT button) override;
// |WindowWin32|
// |Window|
void OnPointerLeave(double x,
double y,
FlutterPointerDeviceKind device_kind,
int32_t device_id) override;
// |WindowWin32|
// |Window|
void OnSetCursor() override;
// |WindowWin32|
// |Window|
void OnText(const std::u16string& text) override;
// |WindowWin32|
// |Window|
void OnKey(int key,
int scancode,
int action,
@@ -80,16 +80,16 @@ class FlutterWindowWin32 : public WindowWin32, public WindowBindingHandler {
bool was_down,
KeyEventCallback callback) override;
// |WindowWin32|
// |Window|
void OnComposeBegin() override;
// |WindowWin32|
// |Window|
void OnComposeCommit() override;
// |WindowWin32|
// |Window|
void OnComposeEnd() override;
// |WindowWin32|
// |Window|
void OnComposeChange(const std::u16string& text, int cursor_pos) override;
// |FlutterWindowBindingHandler|
@@ -98,16 +98,16 @@ class FlutterWindowWin32 : public WindowWin32, public WindowBindingHandler {
// |FlutterWindowBindingHandler|
void OnResetImeComposing() override;
// |WindowWin32|
// |Window|
void OnUpdateSemanticsEnabled(bool enabled) override;
// |WindowWin32|
// |Window|
void OnScroll(double delta_x,
double delta_y,
FlutterPointerDeviceKind device_kind,
int32_t device_id) override;
// |WindowWin32|
// |Window|
gfx::NativeViewAccessible GetNativeViewAccessible() override;
// |FlutterWindowBindingHandler|

View File

@@ -23,10 +23,9 @@ namespace flutter {
// access Win32 system calls (to allow mocking) and where to send the results
// of key calls and text calls to.
//
// Typically, |KeyboardManagerWin32| is owned by a |WindowWin32|, which also
// Typically, |KeyboardManagerWin32| is owned by a |Window|, which also
// implements the window delegate. The key calls and text calls are forwarded
// to those of |WindowWin32|'s, and consequently, those of
// |FlutterWindowsView|'s.
// to those of |Window|'s, and consequently, those of |FlutterWindowsView|'s.
//
// ## Terminology
//
@@ -46,7 +45,7 @@ class KeyboardManagerWin32 {
// Define how the keyboard manager accesses Win32 system calls (to allow
// mocking) and sends key calls and and text calls.
//
// Typically implemented by |WindowWin32|.
// Typically implemented by |Window|.
class WindowDelegate {
public:
using KeyEventCallback = std::function<void(bool)>;
@@ -102,7 +101,7 @@ class KeyboardManagerWin32 {
// this message synchronously. It doesn't mean that the Flutter framework
// handles it, which is reported asynchronously later. Not handling this
// message here usually means that this message is a redispatched message,
// but there are other rare cases too. |WindowWin32| should forward unhandled
// but there are other rare cases too. |Window| should forward unhandled
// messages to |DefWindowProc|.
bool HandleMessage(UINT const message,
WPARAM const wparam,

View File

@@ -15,7 +15,7 @@
namespace flutter {
namespace testing {
/// Mock for the |WindowWin32| base class.
/// Mock for the |Window| base class.
class MockTextInputManagerWin32 : public TextInputManagerWin32 {
public:
MockTextInputManagerWin32();

View File

@@ -0,0 +1,51 @@
// 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/testing/mock_window.h"
namespace flutter {
namespace testing {
MockWindow::MockWindow() : Window(){};
MockWindow::MockWindow(
std::unique_ptr<TextInputManagerWin32> text_input_manager)
: Window(std::move(text_input_manager)){};
MockWindow::~MockWindow() = default;
UINT MockWindow::GetDpi() {
return GetCurrentDPI();
}
LRESULT MockWindow::Win32DefWindowProc(HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam) {
return kWmResultDefault;
}
LRESULT MockWindow::InjectWindowMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
return HandleMessage(message, wparam, lparam);
}
void MockWindow::InjectMessageList(int count, const Win32Message* messages) {
for (int message_id = 0; message_id < count; message_id += 1) {
const Win32Message& message = messages[message_id];
LRESULT result =
InjectWindowMessage(message.message, message.wParam, message.lParam);
if (message.expected_result != kWmResultDontCheck) {
EXPECT_EQ(result, message.expected_result);
}
}
}
void MockWindow::CallOnImeComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
Window::OnImeComposition(message, wparam, lparam);
}
} // namespace testing
} // namespace flutter

View File

@@ -8,22 +8,22 @@
#include <windowsx.h>
#include "flutter/shell/platform/windows/testing/test_keyboard.h"
#include "flutter/shell/platform/windows/window_win32.h"
#include "flutter/shell/platform/windows/window.h"
#include "gmock/gmock.h"
namespace flutter {
namespace testing {
/// Mock for the |WindowWin32| base class.
class MockWin32Window : public WindowWin32 {
/// Mock for the |Window| base class.
class MockWindow : public Window {
public:
MockWin32Window();
MockWin32Window(std::unique_ptr<TextInputManagerWin32> text_input_manager);
virtual ~MockWin32Window();
MockWindow();
MockWindow(std::unique_ptr<TextInputManagerWin32> text_input_manager);
virtual ~MockWindow();
// Prevent copying.
MockWin32Window(MockWin32Window const&) = delete;
MockWin32Window& operator=(MockWin32Window const&) = delete;
MockWindow(MockWindow const&) = delete;
MockWindow& operator=(MockWindow const&) = delete;
// Wrapper for GetCurrentDPI() which is a protected method.
UINT GetDpi();

View File

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

View File

@@ -1,52 +0,0 @@
// 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/testing/mock_window_win32.h"
namespace flutter {
namespace testing {
MockWin32Window::MockWin32Window() : WindowWin32(){};
MockWin32Window::MockWin32Window(
std::unique_ptr<TextInputManagerWin32> text_input_manager)
: WindowWin32(std::move(text_input_manager)){};
MockWin32Window::~MockWin32Window() = default;
UINT MockWin32Window::GetDpi() {
return GetCurrentDPI();
}
LRESULT MockWin32Window::Win32DefWindowProc(HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam) {
return kWmResultDefault;
}
LRESULT MockWin32Window::InjectWindowMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
return HandleMessage(message, wparam, lparam);
}
void MockWin32Window::InjectMessageList(int count,
const Win32Message* messages) {
for (int message_id = 0; message_id < count; message_id += 1) {
const Win32Message& message = messages[message_id];
LRESULT result =
InjectWindowMessage(message.message, message.wParam, message.lParam);
if (message.expected_result != kWmResultDontCheck) {
EXPECT_EQ(result, message.expected_result);
}
}
}
void MockWin32Window::CallOnImeComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
WindowWin32::OnImeComposition(message, wparam, lparam);
}
} // namespace testing
} // 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/window_win32.h"
#include "flutter/shell/platform/windows/window.h"
#include "base/win/atl.h" // NOLINT(build/include_order)
@@ -53,10 +53,9 @@ static const int kLinesPerScrollWindowsDefault = 3;
} // namespace
WindowWin32::WindowWin32() : WindowWin32(nullptr) {}
Window::Window() : Window(nullptr) {}
WindowWin32::WindowWin32(
std::unique_ptr<TextInputManagerWin32> text_input_manager)
Window::Window(std::unique_ptr<TextInputManagerWin32> text_input_manager)
: touch_id_generator_(kMinTouchDeviceId, kMaxTouchDeviceId),
text_input_manager_(std::move(text_input_manager)) {
// Get the DPI of the primary monitor as the initial DPI. If Per-Monitor V2 is
@@ -75,13 +74,13 @@ WindowWin32::WindowWin32(
keyboard_manager_ = std::make_unique<KeyboardManagerWin32>(this);
}
WindowWin32::~WindowWin32() {
Window::~Window() {
Destroy();
}
void WindowWin32::InitializeChild(const char* title,
unsigned int width,
unsigned int height) {
void Window::InitializeChild(const char* title,
unsigned int width,
unsigned int height) {
Destroy();
std::wstring converted_title = NarrowToWide(title);
@@ -121,7 +120,7 @@ void WindowWin32::InitializeChild(const char* title,
direct_manipulation_owner_->Init(width, height);
}
std::wstring WindowWin32::NarrowToWide(const char* source) {
std::wstring Window::NarrowToWide(const char* source) {
size_t length = strlen(source);
size_t outlen = 0;
std::wstring wideTitle(length, L'#');
@@ -129,7 +128,7 @@ std::wstring WindowWin32::NarrowToWide(const char* source) {
return wideTitle;
}
WNDCLASS WindowWin32::RegisterWindowClass(std::wstring& title) {
WNDCLASS Window::RegisterWindowClass(std::wstring& title) {
window_class_name_ = title;
WNDCLASS window_class{};
@@ -147,27 +146,27 @@ WNDCLASS WindowWin32::RegisterWindowClass(std::wstring& title) {
return window_class;
}
LRESULT CALLBACK WindowWin32::WndProc(HWND const window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
LRESULT CALLBACK Window::WndProc(HWND const window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
if (message == WM_NCCREATE) {
auto cs = reinterpret_cast<CREATESTRUCT*>(lparam);
SetWindowLongPtr(window, GWLP_USERDATA,
reinterpret_cast<LONG_PTR>(cs->lpCreateParams));
auto that = static_cast<WindowWin32*>(cs->lpCreateParams);
auto that = static_cast<Window*>(cs->lpCreateParams);
that->window_handle_ = window;
that->text_input_manager_->SetWindowHandle(window);
RegisterTouchWindow(window, 0);
} else if (WindowWin32* that = GetThisFromHandle(window)) {
} else if (Window* that = GetThisFromHandle(window)) {
return that->HandleMessage(message, wparam, lparam);
}
return DefWindowProc(window, message, wparam, lparam);
}
void WindowWin32::TrackMouseLeaveEvent(HWND hwnd) {
void Window::TrackMouseLeaveEvent(HWND hwnd) {
if (!tracking_mouse_leave_) {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
@@ -178,9 +177,9 @@ void WindowWin32::TrackMouseLeaveEvent(HWND hwnd) {
}
}
LRESULT WindowWin32::OnGetObject(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
LRESULT Window::OnGetObject(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
LRESULT reference_result = static_cast<LRESULT>(0L);
// Only the lower 32 bits of lparam are valid when checking the object id
@@ -215,24 +214,24 @@ LRESULT WindowWin32::OnGetObject(UINT const message,
return 0;
}
void WindowWin32::OnImeSetContext(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
void Window::OnImeSetContext(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
if (wparam != 0) {
text_input_manager_->CreateImeWindow();
}
}
void WindowWin32::OnImeStartComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
void Window::OnImeStartComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
text_input_manager_->CreateImeWindow();
OnComposeBegin();
}
void WindowWin32::OnImeComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
void Window::OnImeComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
// Update the IME window position.
text_input_manager_->UpdateImeWindow();
@@ -265,26 +264,26 @@ void WindowWin32::OnImeComposition(UINT const message,
}
}
void WindowWin32::OnImeEndComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
void Window::OnImeEndComposition(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
text_input_manager_->DestroyImeWindow();
OnComposeEnd();
}
void WindowWin32::OnImeRequest(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
void Window::OnImeRequest(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
// TODO(cbracken): Handle IMR_RECONVERTSTRING, IMR_DOCUMENTFEED,
// and IMR_QUERYCHARPOSITION messages.
// https://github.com/flutter/flutter/issues/74547
}
void WindowWin32::AbortImeComposing() {
void Window::AbortImeComposing() {
text_input_manager_->AbortComposing();
}
void WindowWin32::UpdateCursorRect(const Rect& rect) {
void Window::UpdateCursorRect(const Rect& rect) {
text_input_manager_->UpdateCaretRect(rect);
}
@@ -313,9 +312,9 @@ static bool IsPrintable(uint32_t c) {
}
LRESULT
WindowWin32::HandleMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
Window::HandleMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
LPARAM result_lparam = lparam;
int xPos = 0, yPos = 0;
UINT width = 0, height = 0;
@@ -551,27 +550,27 @@ WindowWin32::HandleMessage(UINT const message,
return Win32DefWindowProc(window_handle_, message, wparam, result_lparam);
}
UINT WindowWin32::GetCurrentDPI() {
UINT Window::GetCurrentDPI() {
return current_dpi_;
}
UINT WindowWin32::GetCurrentWidth() {
UINT Window::GetCurrentWidth() {
return current_width_;
}
UINT WindowWin32::GetCurrentHeight() {
UINT Window::GetCurrentHeight() {
return current_height_;
}
HWND WindowWin32::GetWindowHandle() {
HWND Window::GetWindowHandle() {
return window_handle_;
}
float WindowWin32::GetScrollOffsetMultiplier() {
float Window::GetScrollOffsetMultiplier() {
return scroll_offset_multiplier_;
}
void WindowWin32::UpdateScrollOffsetMultiplier() {
void Window::UpdateScrollOffsetMultiplier() {
UINT lines_per_scroll = kLinesPerScrollWindowsDefault;
// Get lines per scroll wheel value from Windows
@@ -583,7 +582,7 @@ void WindowWin32::UpdateScrollOffsetMultiplier() {
static_cast<float>(lines_per_scroll) * 100.0 / 3.0;
}
void WindowWin32::Destroy() {
void Window::Destroy() {
if (window_handle_) {
text_input_manager_->SetWindowHandle(nullptr);
DestroyWindow(window_handle_);
@@ -593,7 +592,7 @@ void WindowWin32::Destroy() {
UnregisterClass(window_class_name_.c_str(), nullptr);
}
void WindowWin32::HandleResize(UINT width, UINT height) {
void Window::HandleResize(UINT width, UINT height) {
current_width_ = width;
current_height_ = height;
if (direct_manipulation_owner_) {
@@ -602,31 +601,30 @@ void WindowWin32::HandleResize(UINT width, UINT height) {
OnResize(width, height);
}
WindowWin32* WindowWin32::GetThisFromHandle(HWND const window) noexcept {
return reinterpret_cast<WindowWin32*>(
GetWindowLongPtr(window, GWLP_USERDATA));
Window* Window::GetThisFromHandle(HWND const window) noexcept {
return reinterpret_cast<Window*>(GetWindowLongPtr(window, GWLP_USERDATA));
}
LRESULT WindowWin32::Win32DefWindowProc(HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam) {
LRESULT Window::Win32DefWindowProc(HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam) {
return ::DefWindowProc(hWnd, Msg, wParam, lParam);
}
BOOL WindowWin32::Win32PeekMessage(LPMSG lpMsg,
UINT wMsgFilterMin,
UINT wMsgFilterMax,
UINT wRemoveMsg) {
BOOL Window::Win32PeekMessage(LPMSG lpMsg,
UINT wMsgFilterMin,
UINT wMsgFilterMax,
UINT wRemoveMsg) {
return ::PeekMessage(lpMsg, window_handle_, wMsgFilterMin, wMsgFilterMax,
wRemoveMsg);
}
uint32_t WindowWin32::Win32MapVkToChar(uint32_t virtual_key) {
uint32_t Window::Win32MapVkToChar(uint32_t virtual_key) {
return ::MapVirtualKey(virtual_key, MAPVK_VK_TO_CHAR);
}
UINT WindowWin32::Win32DispatchMessage(UINT Msg, WPARAM wParam, LPARAM lParam) {
UINT Window::Win32DispatchMessage(UINT Msg, WPARAM wParam, LPARAM lParam) {
return ::SendMessage(window_handle_, Msg, wParam, lParam);
}

View File

@@ -25,11 +25,11 @@ 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 WindowWin32 : public KeyboardManagerWin32::WindowDelegate {
class Window : public KeyboardManagerWin32::WindowDelegate {
public:
WindowWin32();
WindowWin32(std::unique_ptr<TextInputManagerWin32> text_input_manager);
virtual ~WindowWin32();
Window();
Window(std::unique_ptr<TextInputManagerWin32> text_input_manager);
virtual ~Window();
// Initializes as a child window with size using |width| and |height| and
// |title| to identify the windowclass. Does not show window, window must be
@@ -233,7 +233,7 @@ class WindowWin32 : public KeyboardManagerWin32::WindowDelegate {
void HandleResize(UINT width, UINT height);
// Retrieves a class instance pointer for |window|
static WindowWin32* GetThisFromHandle(HWND const window) noexcept;
static Window* GetThisFromHandle(HWND const window) noexcept;
// Updates the cached scroll_offset_multiplier_ value based off OS settings.
void UpdateScrollOffsetMultiplier();

View File

@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "flutter/shell/platform/windows/testing/mock_text_input_manager_win32.h"
#include "flutter/shell/platform/windows/testing/mock_window_win32.h"
#include "flutter/shell/platform/windows/testing/mock_window.h"
#include "gtest/gtest.h"
using testing::_;
@@ -14,18 +14,18 @@ using testing::Return;
namespace flutter {
namespace testing {
TEST(MockWin32Window, CreateDestroy) {
MockWin32Window window;
TEST(MockWindow, CreateDestroy) {
MockWindow window;
ASSERT_TRUE(TRUE);
}
TEST(MockWin32Window, GetDpiAfterCreate) {
MockWin32Window window;
TEST(MockWindow, GetDpiAfterCreate) {
MockWindow window;
ASSERT_TRUE(window.GetDpi() > 0);
}
TEST(MockWin32Window, VerticalScroll) {
MockWin32Window window;
TEST(MockWindow, VerticalScroll) {
MockWindow window;
const int scroll_amount = 10;
// Vertical scroll should be passed along, adjusted for scroll tick size
// and direction.
@@ -36,12 +36,12 @@ TEST(MockWin32Window, VerticalScroll) {
window.InjectWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, scroll_amount), 0);
}
TEST(MockWin32Window, OnImeCompositionCompose) {
TEST(MockWindow, OnImeCompositionCompose) {
MockTextInputManagerWin32* text_input_manager =
new MockTextInputManagerWin32();
std::unique_ptr<TextInputManagerWin32> text_input_manager_ptr(
text_input_manager);
MockWin32Window window(std::move(text_input_manager_ptr));
MockWindow window(std::move(text_input_manager_ptr));
EXPECT_CALL(*text_input_manager, GetComposingString())
.WillRepeatedly(
Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
@@ -55,19 +55,19 @@ TEST(MockWin32Window, OnImeCompositionCompose) {
EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 0)).Times(0);
EXPECT_CALL(window, OnComposeCommit()).Times(0);
ON_CALL(window, OnImeComposition)
.WillByDefault(Invoke(&window, &MockWin32Window::CallOnImeComposition));
.WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
// Send an IME_COMPOSITION event that contains just the composition string.
window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_COMPSTR);
}
TEST(MockWin32Window, OnImeCompositionResult) {
TEST(MockWindow, OnImeCompositionResult) {
MockTextInputManagerWin32* text_input_manager =
new MockTextInputManagerWin32();
std::unique_ptr<TextInputManagerWin32> text_input_manager_ptr(
text_input_manager);
MockWin32Window window(std::move(text_input_manager_ptr));
MockWindow window(std::move(text_input_manager_ptr));
EXPECT_CALL(*text_input_manager, GetComposingString())
.WillRepeatedly(
Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
@@ -81,19 +81,19 @@ TEST(MockWin32Window, OnImeCompositionResult) {
EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 0)).Times(1);
EXPECT_CALL(window, OnComposeCommit()).Times(1);
ON_CALL(window, OnImeComposition)
.WillByDefault(Invoke(&window, &MockWin32Window::CallOnImeComposition));
.WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
// Send an IME_COMPOSITION event that contains just the result string.
window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
}
TEST(MockWin32Window, OnImeCompositionResultAndCompose) {
TEST(MockWindow, OnImeCompositionResultAndCompose) {
MockTextInputManagerWin32* text_input_manager =
new MockTextInputManagerWin32();
std::unique_ptr<TextInputManagerWin32> text_input_manager_ptr(
text_input_manager);
MockWin32Window window(std::move(text_input_manager_ptr));
MockWindow window(std::move(text_input_manager_ptr));
// This situation is that Google Japanese Input finished composing "今日" in
// "今日は" but is still composing "は".
@@ -117,7 +117,7 @@ TEST(MockWin32Window, OnImeCompositionResultAndCompose) {
.WillRepeatedly(Return((int)0));
ON_CALL(window, OnImeComposition)
.WillByDefault(Invoke(&window, &MockWin32Window::CallOnImeComposition));
.WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
// send an IME_COMPOSITION event that contains both the result string and the
@@ -126,16 +126,16 @@ TEST(MockWin32Window, OnImeCompositionResultAndCompose) {
GCS_COMPSTR | GCS_RESULTSTR);
}
TEST(MockWin32Window, OnImeCompositionClearChange) {
TEST(MockWindow, OnImeCompositionClearChange) {
MockTextInputManagerWin32* text_input_manager =
new MockTextInputManagerWin32();
std::unique_ptr<TextInputManagerWin32> text_input_manager_ptr(
text_input_manager);
MockWin32Window window(std::move(text_input_manager_ptr));
MockWindow window(std::move(text_input_manager_ptr));
EXPECT_CALL(window, OnComposeChange(std::u16string(u""), 0)).Times(1);
EXPECT_CALL(window, OnComposeCommit()).Times(1);
ON_CALL(window, OnImeComposition)
.WillByDefault(Invoke(&window, &MockWin32Window::CallOnImeComposition));
.WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
// send an IME_COMPOSITION event that contains both the result string and the
@@ -143,8 +143,8 @@ TEST(MockWin32Window, OnImeCompositionClearChange) {
window.InjectWindowMessage(WM_IME_COMPOSITION, 0, 0);
}
TEST(MockWin32Window, HorizontalScroll) {
MockWin32Window window;
TEST(MockWindow, HorizontalScroll) {
MockWindow window;
const int scroll_amount = 10;
// Vertical scroll should be passed along, adjusted for scroll tick size.
EXPECT_CALL(window, OnScroll(scroll_amount / 120.0, 0,
@@ -154,8 +154,8 @@ TEST(MockWin32Window, HorizontalScroll) {
window.InjectWindowMessage(WM_MOUSEHWHEEL, MAKEWPARAM(0, scroll_amount), 0);
}
TEST(MockWin32Window, MouseLeave) {
MockWin32Window window;
TEST(MockWindow, MouseLeave) {
MockWindow window;
const double mouse_x = 10.0;
const double mouse_y = 20.0;
@@ -170,40 +170,40 @@ TEST(MockWin32Window, MouseLeave) {
window.InjectWindowMessage(WM_MOUSELEAVE, 0, 0);
}
TEST(MockWin32Window, KeyDown) {
MockWin32Window window;
TEST(MockWindow, KeyDown) {
MockWindow window;
EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
LPARAM lparam = CreateKeyEventLparam(42, false, false);
// send a "Shift" key down event.
window.InjectWindowMessage(WM_KEYDOWN, 16, lparam);
}
TEST(MockWin32Window, KeyUp) {
MockWin32Window window;
TEST(MockWindow, KeyUp) {
MockWindow window;
EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
LPARAM lparam = CreateKeyEventLparam(42, false, true);
// send a "Shift" key up event.
window.InjectWindowMessage(WM_KEYUP, 16, lparam);
}
TEST(MockWin32Window, SysKeyDown) {
MockWin32Window window;
TEST(MockWindow, SysKeyDown) {
MockWindow window;
EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
LPARAM lparam = CreateKeyEventLparam(42, false, false);
// send a "Shift" key down event.
window.InjectWindowMessage(WM_SYSKEYDOWN, 16, lparam);
}
TEST(MockWin32Window, SysKeyUp) {
MockWin32Window window;
TEST(MockWindow, SysKeyUp) {
MockWindow window;
EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
LPARAM lparam = CreateKeyEventLparam(42, false, true);
// send a "Shift" key up event.
window.InjectWindowMessage(WM_SYSKEYUP, 16, lparam);
}
TEST(MockWin32Window, KeyDownPrintable) {
MockWin32Window window;
TEST(MockWindow, KeyDownPrintable) {
MockWindow window;
LPARAM lparam = CreateKeyEventLparam(30, false, false);
auto respond_false = [](int key, int scancode, int action, char32_t character,
@@ -220,8 +220,8 @@ TEST(MockWin32Window, KeyDownPrintable) {
window.InjectMessageList(2, messages);
}
TEST(MockWin32Window, KeyDownWithCtrl) {
MockWin32Window window;
TEST(MockWindow, KeyDownWithCtrl) {
MockWindow window;
// Simulate CONTROL pressed
BYTE keyboard_state[256];
@@ -242,8 +242,8 @@ TEST(MockWin32Window, KeyDownWithCtrl) {
SetKeyboardState(keyboard_state);
}
TEST(MockWin32Window, KeyDownWithCtrlToggled) {
MockWin32Window window;
TEST(MockWindow, KeyDownWithCtrlToggled) {
MockWindow window;
auto respond_false = [](int key, int scancode, int action, char32_t character,
bool extended, bool was_down,
@@ -273,8 +273,8 @@ TEST(MockWin32Window, KeyDownWithCtrlToggled) {
SetKeyboardState(keyboard_state);
}
TEST(MockWin32Window, Paint) {
MockWin32Window window;
TEST(MockWindow, Paint) {
MockWindow window;
EXPECT_CALL(window, OnPaint()).Times(1);
window.InjectWindowMessage(WM_PAINT, 0, 0);
}