From 2be59f6edd07e94899df5e4213f2bb82e8c83a72 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Mon, 19 Jul 2021 15:52:36 +0000 Subject: [PATCH] Translate additional CEF modifiers to EF_* flags (see issue #2597) --- include/internal/cef_types.h | 1 + libcef/browser/browser_platform_delegate.cc | 16 ++++++++++------ libcef/browser/browser_util.cc | 8 ++++++++ .../browser_platform_delegate_native_aura.cc | 12 ++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index b66a71fcc..ad17392de 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -1842,6 +1842,7 @@ typedef enum { EVENTFLAG_IS_LEFT = 1 << 10, EVENTFLAG_IS_RIGHT = 1 << 11, EVENTFLAG_ALTGR_DOWN = 1 << 12, + EVENTFLAG_IS_REPEAT = 1 << 13, } cef_event_flags_t; /// diff --git a/libcef/browser/browser_platform_delegate.cc b/libcef/browser/browser_platform_delegate.cc index 31f3a811a..e26e1a031 100644 --- a/libcef/browser/browser_platform_delegate.cc +++ b/libcef/browser/browser_platform_delegate.cc @@ -397,29 +397,33 @@ int CefBrowserPlatformDelegate::TranslateWebEventModifiers( uint32 cef_modifiers) { int result = 0; // Set modifiers based on key state. + if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) + result |= blink::WebInputEvent::kCapsLockOn; if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) result |= blink::WebInputEvent::kShiftKey; if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) result |= blink::WebInputEvent::kControlKey; if (cef_modifiers & EVENTFLAG_ALT_DOWN) result |= blink::WebInputEvent::kAltKey; - if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) - result |= blink::WebInputEvent::kMetaKey; if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) result |= blink::WebInputEvent::kLeftButtonDown; if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) result |= blink::WebInputEvent::kMiddleButtonDown; if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) result |= blink::WebInputEvent::kRightButtonDown; - if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) - result |= blink::WebInputEvent::kCapsLockOn; + if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) + result |= blink::WebInputEvent::kMetaKey; if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) result |= blink::WebInputEvent::kNumLockOn; + if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) + result |= blink::WebInputEvent::kIsKeyPad; if (cef_modifiers & EVENTFLAG_IS_LEFT) result |= blink::WebInputEvent::kIsLeft; if (cef_modifiers & EVENTFLAG_IS_RIGHT) result |= blink::WebInputEvent::kIsRight; - if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) - result |= blink::WebInputEvent::kIsKeyPad; + if (cef_modifiers & EVENTFLAG_ALTGR_DOWN) + result |= blink::WebInputEvent::kAltGrKey; + if (cef_modifiers & EVENTFLAG_IS_REPEAT) + result |= blink::WebInputEvent::kIsAutoRepeat; return result; } diff --git a/libcef/browser/browser_util.cc b/libcef/browser/browser_util.cc index 1b0bb3997..19a92ae8b 100644 --- a/libcef/browser/browser_util.cc +++ b/libcef/browser/browser_util.cc @@ -38,6 +38,14 @@ bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event, cef_event.modifiers |= EVENTFLAG_COMMAND_DOWN; if (event.GetModifiers() & blink::WebKeyboardEvent::kIsKeyPad) cef_event.modifiers |= EVENTFLAG_IS_KEY_PAD; + if (event.GetModifiers() & blink::WebKeyboardEvent::kIsLeft) + cef_event.modifiers |= EVENTFLAG_IS_LEFT; + if (event.GetModifiers() & blink::WebKeyboardEvent::kIsRight) + cef_event.modifiers |= EVENTFLAG_IS_RIGHT; + if (event.GetModifiers() & blink::WebKeyboardEvent::kAltGrKey) + cef_event.modifiers |= EVENTFLAG_ALTGR_DOWN; + if (event.GetModifiers() & blink::WebKeyboardEvent::kIsAutoRepeat) + cef_event.modifiers |= EVENTFLAG_IS_REPEAT; cef_event.windows_key_code = event.windows_key_code; cef_event.native_key_code = event.native_key_code; diff --git a/libcef/browser/native/browser_platform_delegate_native_aura.cc b/libcef/browser/native/browser_platform_delegate_native_aura.cc index 518f67754..32f567c92 100644 --- a/libcef/browser/native/browser_platform_delegate_native_aura.cc +++ b/libcef/browser/native/browser_platform_delegate_native_aura.cc @@ -192,26 +192,30 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers( uint32 cef_modifiers) { int result = 0; // Set modifiers based on key state. + if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) + result |= ui::EF_CAPS_LOCK_ON; if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) result |= ui::EF_SHIFT_DOWN; if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) result |= ui::EF_CONTROL_DOWN; if (cef_modifiers & EVENTFLAG_ALT_DOWN) result |= ui::EF_ALT_DOWN; - if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) - result |= ui::EF_COMMAND_DOWN; if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) result |= ui::EF_LEFT_MOUSE_BUTTON; if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) result |= ui::EF_MIDDLE_MOUSE_BUTTON; if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) result |= ui::EF_RIGHT_MOUSE_BUTTON; - if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) - result |= ui::EF_CAPS_LOCK_ON; + if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) + result |= ui::EF_COMMAND_DOWN; if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) result |= ui::EF_NUM_LOCK_ON; + if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) + result |= ui::EF_IS_EXTENDED_KEY; if (cef_modifiers & EVENTFLAG_ALTGR_DOWN) result |= ui::EF_ALTGR_DOWN; + if (cef_modifiers & EVENTFLAG_IS_REPEAT) + result |= ui::EF_IS_REPEAT; return result; }