Eliminate Win32 suffixes in KeyboardManager (flutter/engine#35008)

This renames KeyboardManagerWin32 to KeyboardManager and updates all
usage sites and tests.

This is a followup to 89bbfcc, which applied most of the straightforward
renamings of FooWin32 to Foo (or where a superclass Foo exists,
FooWindows) to the Windows embedding. In that patch I missed
KeyboardManagerWin32, as well as two straightforward file renames:
* keyboard_win32_common.{h,cc} -> keyboard_utils.{h,cc}
* system_utils_win32.cc -> system_utils.cc

No new tests since this is a rename with no semantic change intended.

Issue: https://github.com/flutter/flutter/issues/108386
This commit is contained in:
Chris Bracken
2022-07-29 21:51:36 +01:00
committed by GitHub
parent 61fbf5a9c6
commit 4d4da408e0
15 changed files with 74 additions and 80 deletions

View File

@@ -2403,12 +2403,12 @@ FILE: ../../../flutter/shell/platform/windows/keyboard_key_embedder_handler_unit
FILE: ../../../flutter/shell/platform/windows/keyboard_key_handler.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_key_handler.h
FILE: ../../../flutter/shell/platform/windows/keyboard_key_handler_unittests.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_manager_win32.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_manager_win32.h
FILE: ../../../flutter/shell/platform/windows/keyboard_win32_common.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_win32_common.h
FILE: ../../../flutter/shell/platform/windows/keyboard_win32_common_unittests.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_win32_unittests.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_manager.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_manager.h
FILE: ../../../flutter/shell/platform/windows/keyboard_unittests.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_utils.cc
FILE: ../../../flutter/shell/platform/windows/keyboard_utils.h
FILE: ../../../flutter/shell/platform/windows/keyboard_utils_unittests.cc
FILE: ../../../flutter/shell/platform/windows/platform_handler.cc
FILE: ../../../flutter/shell/platform/windows/platform_handler.h
FILE: ../../../flutter/shell/platform/windows/platform_handler_unittests.cc
@@ -2424,9 +2424,9 @@ 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/system_utils.cc
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
FILE: ../../../flutter/shell/platform/windows/task_runner.cc
FILE: ../../../flutter/shell/platform/windows/task_runner.h
FILE: ../../../flutter/shell/platform/windows/task_runner_unittests.cc

View File

@@ -76,10 +76,10 @@ source_set("flutter_windows_source") {
"keyboard_key_embedder_handler.h",
"keyboard_key_handler.cc",
"keyboard_key_handler.h",
"keyboard_manager_win32.cc",
"keyboard_manager_win32.h",
"keyboard_win32_common.cc",
"keyboard_win32_common.h",
"keyboard_manager.cc",
"keyboard_manager.h",
"keyboard_utils.cc",
"keyboard_utils.h",
"platform_handler.cc",
"platform_handler.h",
"platform_handler_win32.cc",
@@ -90,8 +90,8 @@ source_set("flutter_windows_source") {
"settings_plugin.h",
"settings_plugin_win32.cc",
"settings_plugin_win32.h",
"system_utils.cc",
"system_utils.h",
"system_utils_win32.cc",
"task_runner.cc",
"task_runner.h",
"task_runner_win32.cc",
@@ -183,8 +183,8 @@ executable("flutter_windows_unittests") {
"keyboard_key_channel_handler_unittests.cc",
"keyboard_key_embedder_handler_unittests.cc",
"keyboard_key_handler_unittests.cc",
"keyboard_win32_common_unittests.cc",
"keyboard_win32_unittests.cc",
"keyboard_unittests.cc",
"keyboard_utils_unittests.cc",
"platform_handler_unittests.cc",
"platform_handler_win32_unittests.cc",
"sequential_id_generator_unittests.cc",

View File

@@ -137,7 +137,7 @@ class MockFlutterWindow : public FlutterWindow {
MOCK_METHOD1(Win32MapVkToChar, uint32_t(uint32_t));
protected:
// |KeyboardManagerWin32::WindowDelegate|
// |KeyboardManager::WindowDelegate|
LRESULT Win32DefWindowProc(HWND hWnd,
UINT Msg,
WPARAM wParam,

View File

@@ -9,7 +9,7 @@
#include <iostream>
#include "flutter/shell/platform/common/json_message_codec.h"
#include "flutter/shell/platform/windows/keyboard_win32_common.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"
namespace flutter {

View File

@@ -11,7 +11,7 @@
#include <iostream>
#include <string>
#include "flutter/shell/platform/windows/keyboard_win32_common.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"
namespace flutter {

View File

@@ -8,7 +8,7 @@
#include <iostream>
#include "flutter/shell/platform/windows/keyboard_win32_common.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"
namespace flutter {

View File

@@ -7,9 +7,8 @@
#include <memory>
#include <string>
#include "keyboard_manager_win32.h"
#include "keyboard_win32_common.h"
#include "flutter/shell/platform/windows/keyboard_manager.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"
namespace flutter {
@@ -104,14 +103,13 @@ static bool IsSysAction(UINT action) {
} // namespace
KeyboardManagerWin32::KeyboardManagerWin32(WindowDelegate* delegate)
KeyboardManager::KeyboardManager(WindowDelegate* delegate)
: window_delegate_(delegate),
last_key_is_ctrl_left_down(false),
should_synthesize_ctrl_left_up(false),
processing_event_(false) {}
void KeyboardManagerWin32::RedispatchEvent(
std::unique_ptr<PendingEvent> event) {
void KeyboardManager::RedispatchEvent(std::unique_ptr<PendingEvent> event) {
for (const Win32Message& message : event->session) {
// Never redispatch sys keys, because their original messages have been
// passed to the system default processor.
@@ -134,9 +132,9 @@ void KeyboardManagerWin32::RedispatchEvent(
}
}
bool KeyboardManagerWin32::RemoveRedispatchedMessage(UINT const action,
WPARAM const wparam,
LPARAM const lparam) {
bool KeyboardManager::RemoveRedispatchedMessage(UINT const action,
WPARAM const wparam,
LPARAM const lparam) {
for (auto iter = pending_redispatches_.begin();
iter != pending_redispatches_.end(); ++iter) {
if (action == iter->action && wparam == iter->wparam) {
@@ -147,9 +145,9 @@ bool KeyboardManagerWin32::RemoveRedispatchedMessage(UINT const action,
return false;
}
bool KeyboardManagerWin32::HandleMessage(UINT const action,
WPARAM const wparam,
LPARAM const lparam) {
bool KeyboardManager::HandleMessage(UINT const action,
WPARAM const wparam,
LPARAM const lparam) {
if (RemoveRedispatchedMessage(action, wparam, lparam)) {
return false;
}
@@ -331,7 +329,7 @@ bool KeyboardManagerWin32::HandleMessage(UINT const action,
return false;
}
void KeyboardManagerWin32::ProcessNextEvent() {
void KeyboardManager::ProcessNextEvent() {
if (processing_event_ || pending_events_.empty()) {
return;
}
@@ -345,9 +343,8 @@ void KeyboardManagerWin32::ProcessNextEvent() {
});
}
void KeyboardManagerWin32::PerformProcessEvent(
std::unique_ptr<PendingEvent> event,
std::function<void()> callback) {
void KeyboardManager::PerformProcessEvent(std::unique_ptr<PendingEvent> event,
std::function<void()> callback) {
// PendingEvent::action being WM_CHAR means this is a char message without
// a preceding key message, and should be dispatched immediately.
if (event->action == WM_CHAR) {
@@ -369,9 +366,8 @@ void KeyboardManagerWin32::PerformProcessEvent(
});
}
void KeyboardManagerWin32::HandleOnKeyResult(
std::unique_ptr<PendingEvent> event,
bool framework_handled) {
void KeyboardManager::HandleOnKeyResult(std::unique_ptr<PendingEvent> event,
bool framework_handled) {
const UINT last_action = event->session.back().action;
// SYS messages must not be redispached, and their text content is not
// dispatched either.
@@ -391,7 +387,7 @@ void KeyboardManagerWin32::HandleOnKeyResult(
RedispatchEvent(std::move(event));
}
void KeyboardManagerWin32::DispatchText(const PendingEvent& event) {
void KeyboardManager::DispatchText(const PendingEvent& event) {
// Check if the character is printable based on the last wparam, which works
// even if the last wparam is a low surrogate, because the only unprintable
// keys defined by `IsPrintable` are certain characters at lower ASCII range.
@@ -406,8 +402,8 @@ void KeyboardManagerWin32::DispatchText(const PendingEvent& event) {
}
}
UINT KeyboardManagerWin32::PeekNextMessageType(UINT wMsgFilterMin,
UINT wMsgFilterMax) {
UINT KeyboardManager::PeekNextMessageType(UINT wMsgFilterMin,
UINT wMsgFilterMax) {
MSG next_message;
BOOL has_msg = window_delegate_->Win32PeekMessage(
&next_message, wMsgFilterMin, wMsgFilterMax, PM_NOREMOVE);

View File

@@ -15,17 +15,17 @@ namespace flutter {
// Handles keyboard and text messages on Win32.
//
// |KeyboardManagerWin32| consumes raw Win32 messages related to key and chars,
// and converts them to key calls (|WindowDelegate::OnKey|) and possibly
// text calls (|WindowDelegate::OnText|).
// |KeyboardManager| consumes raw Win32 messages related to key and chars, and
// converts them to key calls (|WindowDelegate::OnKey|) and possibly text calls
// (|WindowDelegate::OnText|).
//
// |KeyboardManagerWin32| requires a |WindowDelegate| to define how to
// access Win32 system calls (to allow mocking) and where to send the results
// of key calls and text calls to.
// |KeyboardManager| requires a |WindowDelegate| to define how to 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 |Window|, which also
// implements the window delegate. The key calls and text calls are forwarded
// to those of |Window|'s, and consequently, those of |FlutterWindowsView|'s.
// Typically, |KeyboardManager| is owned by a |Window|, which also implements
// the window delegate. The key calls and text calls are forwarded to those of
// |Window|'s, and consequently, those of |FlutterWindowsView|'s.
//
// ## Terminology
//
@@ -40,7 +40,7 @@ namespace flutter {
// * Event: A FlutterKeyEvent/ui.KeyData sent to the framework.
// * Call: A call to |WindowDelegate::OnKey| or |WindowDelegate::OnText|,
// which contains semi-processed messages.
class KeyboardManagerWin32 {
class KeyboardManager {
public:
// Define how the keyboard manager accesses Win32 system calls (to allow
// mocking) and sends key calls and and text calls.
@@ -89,7 +89,7 @@ class KeyboardManagerWin32 {
using KeyEventCallback = WindowDelegate::KeyEventCallback;
explicit KeyboardManagerWin32(WindowDelegate* delegate);
explicit KeyboardManager(WindowDelegate* delegate);
// Processes Win32 messages related to keyboard and text.
//

View File

@@ -10,7 +10,7 @@
#include "flutter/shell/platform/windows/keyboard_key_channel_handler.h"
#include "flutter/shell/platform/windows/keyboard_key_embedder_handler.h"
#include "flutter/shell/platform/windows/keyboard_key_handler.h"
#include "flutter/shell/platform/windows/keyboard_manager_win32.h"
#include "flutter/shell/platform/windows/keyboard_manager.h"
#include "flutter/shell/platform/windows/testing/engine_modifier.h"
#include "flutter/shell/platform/windows/testing/mock_window_binding_handler.h"
#include "flutter/shell/platform/windows/testing/test_keyboard.h"
@@ -94,10 +94,10 @@ UINT LayoutFrench(UINT uCode, UINT uMapType) {
}
}
class TestKeyboardManagerWin32 : public KeyboardManagerWin32 {
class TestKeyboardManager : public KeyboardManager {
public:
explicit TestKeyboardManagerWin32(WindowDelegate* delegate)
: KeyboardManagerWin32(delegate) {}
explicit TestKeyboardManager(WindowDelegate* delegate)
: KeyboardManager(delegate) {}
bool DuringRedispatch() { return during_redispatch_; }
@@ -105,7 +105,7 @@ class TestKeyboardManagerWin32 : public KeyboardManagerWin32 {
void RedispatchEvent(std::unique_ptr<PendingEvent> event) override {
assert(!during_redispatch_);
during_redispatch_ = true;
KeyboardManagerWin32::RedispatchEvent(std::move(event));
KeyboardManager::RedispatchEvent(std::move(event));
during_redispatch_ = false;
}
@@ -175,18 +175,17 @@ class TestKeystate {
std::map<uint32_t, SHORT> state_;
};
class MockKeyboardManagerWin32Delegate
: public KeyboardManagerWin32::WindowDelegate,
protected MockMessageQueue {
class MockKeyboardManagerDelegate : public KeyboardManager::WindowDelegate,
protected MockMessageQueue {
public:
MockKeyboardManagerWin32Delegate(WindowBindingHandlerDelegate* view,
MapVirtualKeyToChar map_vk_to_char)
MockKeyboardManagerDelegate(WindowBindingHandlerDelegate* view,
MapVirtualKeyToChar map_vk_to_char)
: view_(view), map_vk_to_char_(std::move(map_vk_to_char)) {
keyboard_manager_ = std::make_unique<TestKeyboardManagerWin32>(this);
keyboard_manager_ = std::make_unique<TestKeyboardManager>(this);
}
virtual ~MockKeyboardManagerWin32Delegate() {}
virtual ~MockKeyboardManagerDelegate() {}
// |KeyboardManagerWin32::WindowDelegate|
// |KeyboardManager::WindowDelegate|
void OnKey(int key,
int scancode,
int action,
@@ -198,7 +197,7 @@ class MockKeyboardManagerWin32Delegate
callback);
}
// |KeyboardManagerWin32::WindowDelegate|
// |KeyboardManager::WindowDelegate|
void OnText(const std::u16string& text) override { view_->OnText(text); }
SHORT GetKeyState(int virtual_key) { return key_state_.Get(virtual_key); }
@@ -306,7 +305,7 @@ class MockKeyboardManagerWin32Delegate
};
WindowBindingHandlerDelegate* view_;
std::unique_ptr<TestKeyboardManagerWin32> keyboard_manager_;
std::unique_ptr<TestKeyboardManager> keyboard_manager_;
std::list<ForgedMessageExpectation> forged_message_expectations_;
MapVirtualKeyToChar map_vk_to_char_;
TestKeystate key_state_;
@@ -446,14 +445,14 @@ class KeyboardTester {
});
callback_handler(event, callback);
}));
window_ = std::make_unique<MockKeyboardManagerWin32Delegate>(
window_ = std::make_unique<MockKeyboardManagerDelegate>(
view_.get(), [this](UINT virtual_key) -> SHORT {
return map_virtual_key_layout_(virtual_key, MAPVK_VK_TO_CHAR);
});
}
TestFlutterWindowsView& GetView() { return *view_; }
MockKeyboardManagerWin32Delegate& GetWindow() { return *window_; }
MockKeyboardManagerDelegate& GetWindow() { return *window_; }
// Set all events to be handled (true) or unhandled (false).
void Responding(bool response) { callback_handler_ = RespondValue(response); }
@@ -489,7 +488,7 @@ class KeyboardTester {
private:
std::unique_ptr<TestFlutterWindowsView> view_;
std::unique_ptr<MockKeyboardManagerWin32Delegate> window_;
std::unique_ptr<MockKeyboardManagerDelegate> window_;
MockKeyResponseController::EmbedderCallbackHandler callback_handler_;
MapVirtualKeyLayout map_virtual_key_layout_;

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 "keyboard_win32_common.h"
#include "keyboard_utils.h"
namespace flutter {

View File

@@ -1,7 +1,7 @@
// 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/keyboard_win32_common.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"
#include "gtest/gtest.h"

View File

@@ -14,8 +14,7 @@
#include <cstring>
#include "dpi_utils.h"
#include "keyboard_win32_common.h"
#include "flutter/shell/platform/windows/dpi_utils.h"
namespace flutter {
@@ -71,7 +70,7 @@ Window::Window(std::unique_ptr<TextInputManager> text_input_manager)
if (text_input_manager_ == nullptr) {
text_input_manager_ = std::make_unique<TextInputManager>();
}
keyboard_manager_ = std::make_unique<KeyboardManagerWin32>(this);
keyboard_manager_ = std::make_unique<KeyboardManager>(this);
}
Window::~Window() {

View File

@@ -15,7 +15,7 @@
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/windows/direct_manipulation.h"
#include "flutter/shell/platform/windows/keyboard_manager_win32.h"
#include "flutter/shell/platform/windows/keyboard_manager.h"
#include "flutter/shell/platform/windows/sequential_id_generator.h"
#include "flutter/shell/platform/windows/text_input_manager.h"
#include "flutter/third_party/accessibility/gfx/native_widget_types.h"
@@ -25,7 +25,7 @@ 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 Window : public KeyboardManagerWin32::WindowDelegate {
class Window : public KeyboardManager::WindowDelegate {
public:
Window();
Window(std::unique_ptr<TextInputManager> text_input_manager);
@@ -40,16 +40,16 @@ class Window : public KeyboardManagerWin32::WindowDelegate {
HWND GetWindowHandle();
// |KeyboardManagerWin32::WindowDelegate|
// |KeyboardManager::WindowDelegate|
virtual BOOL Win32PeekMessage(LPMSG lpMsg,
UINT wMsgFilterMin,
UINT wMsgFilterMax,
UINT wRemoveMsg) override;
// |KeyboardManagerWin32::WindowDelegate|
// |KeyboardManager::WindowDelegate|
virtual uint32_t Win32MapVkToChar(uint32_t virtual_key) override;
// |KeyboardManagerWin32::WindowDelegate|
// |KeyboardManager::WindowDelegate|
virtual UINT Win32DispatchMessage(UINT Msg,
WPARAM wParam,
LPARAM lParam) override;
@@ -270,7 +270,7 @@ class Window : public KeyboardManagerWin32::WindowDelegate {
std::unique_ptr<TextInputManager> text_input_manager_;
// Manages IME state.
std::unique_ptr<KeyboardManagerWin32> keyboard_manager_;
std::unique_ptr<KeyboardManager> keyboard_manager_;
// Used for temporarily storing the WM_TOUCH-provided touch points.
std::vector<TOUCHINPUT> touch_points_;