Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions shell/platform/windows/keyboard_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace {

// The maximum number of pending events to keep before
// emitting a warning on the console about unhandled events.
static constexpr int kMaxPendingEvents = 1000;
constexpr int kMaxPendingEvents = 1000;

// Returns true if this key is an AltRight key down event.
//
Expand All @@ -40,40 +40,38 @@ static constexpr int kMaxPendingEvents = 1000;
// would be rare, and a misrecognition would only cause a minor consequence
// where the CtrlLeft is released early; the later, real, CtrlLeft up event will
// be ignored.
static bool IsKeyDownAltRight(int action, int virtual_key, bool extended) {
bool IsKeyDownAltRight(int action, int virtual_key, bool extended) {
return virtual_key == VK_RMENU && extended &&
(action == WM_KEYDOWN || action == WM_SYSKEYDOWN);
}

// Returns true if this key is a key up event of AltRight.
//
// This is used to assist a corner case described in |IsKeyDownAltRight|.
static bool IsKeyUpAltRight(int action, int virtual_key, bool extended) {
bool IsKeyUpAltRight(int action, int virtual_key, bool extended) {
return virtual_key == VK_RMENU && extended &&
(action == WM_KEYUP || action == WM_SYSKEYUP);
}

// Returns true if this key is a key down event of CtrlLeft.
//
// This is used to assist a corner case described in |IsKeyDownAltRight|.
static bool IsKeyDownCtrlLeft(int action, int virtual_key) {
bool IsKeyDownCtrlLeft(int action, int virtual_key) {
return virtual_key == VK_LCONTROL &&
(action == WM_KEYDOWN || action == WM_SYSKEYDOWN);
}

// Returns if a character sent by Win32 is a dead key.
static bool IsDeadKey(uint32_t ch) {
bool IsDeadKey(uint32_t ch) {
return (ch & kDeadKeyCharMask) != 0;
}

static char32_t CodePointFromSurrogatePair(wchar_t high, wchar_t low) {
char32_t CodePointFromSurrogatePair(wchar_t high, wchar_t low) {
return 0x10000 + ((static_cast<char32_t>(high) & 0x000003FF) << 10) +
(low & 0x3FF);
}

static uint16_t ResolveKeyCode(uint16_t original,
bool extended,
uint8_t scancode) {
uint16_t ResolveKeyCode(uint16_t original, bool extended, uint8_t scancode) {
switch (original) {
case VK_SHIFT:
case VK_LSHIFT:
Expand All @@ -89,13 +87,13 @@ static uint16_t ResolveKeyCode(uint16_t original,
}
}

static bool IsPrintable(uint32_t c) {
bool IsPrintable(uint32_t c) {
constexpr char32_t kMinPrintable = ' ';
constexpr char32_t kDelete = 0x7F;
return c >= kMinPrintable && c != kDelete;
}

static bool IsSysAction(UINT action) {
bool IsSysAction(UINT action) {
return action == WM_SYSKEYDOWN || action == WM_SYSKEYUP ||
action == WM_SYSCHAR || action == WM_SYSDEADCHAR;
}
Expand Down
10 changes: 5 additions & 5 deletions shell/platform/windows/keyboard_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ namespace flutter {
// system calls (to allow mocking) and where to send the results of key calls
// and text calls to.
//
// 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.
// Typically, |KeyboardManager| is owned by a |FlutterWindow|, which also
// implements the window delegate. The key calls and text calls are forwarded to
// the |FlutterWindow|, and consequently, to the |FlutterWindowsView|.
//
// ## Terminology
//
// The keyboard system follows the following terminology instead of the
// inconsistent/incomplete one used by Win32:
// The keyboard system uses the following terminology (which is different
// than Win32's terminology):
//
// * Message: An invocation of |WndProc|, which consists of an
// action, an lparam, and a wparam.
Expand Down