Translate additional CEF modifiers to EF_* flags (see issue #2597)

This commit is contained in:
Vladislav 2021-07-19 15:52:36 +00:00 committed by Marshall Greenblatt
parent 103fe12b72
commit 2be59f6edd
4 changed files with 27 additions and 10 deletions

View File

@ -1842,6 +1842,7 @@ typedef enum {
EVENTFLAG_IS_LEFT = 1 << 10, EVENTFLAG_IS_LEFT = 1 << 10,
EVENTFLAG_IS_RIGHT = 1 << 11, EVENTFLAG_IS_RIGHT = 1 << 11,
EVENTFLAG_ALTGR_DOWN = 1 << 12, EVENTFLAG_ALTGR_DOWN = 1 << 12,
EVENTFLAG_IS_REPEAT = 1 << 13,
} cef_event_flags_t; } cef_event_flags_t;
/// ///

View File

@ -397,29 +397,33 @@ int CefBrowserPlatformDelegate::TranslateWebEventModifiers(
uint32 cef_modifiers) { uint32 cef_modifiers) {
int result = 0; int result = 0;
// Set modifiers based on key state. // Set modifiers based on key state.
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
result |= blink::WebInputEvent::kCapsLockOn;
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
result |= blink::WebInputEvent::kShiftKey; result |= blink::WebInputEvent::kShiftKey;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
result |= blink::WebInputEvent::kControlKey; result |= blink::WebInputEvent::kControlKey;
if (cef_modifiers & EVENTFLAG_ALT_DOWN) if (cef_modifiers & EVENTFLAG_ALT_DOWN)
result |= blink::WebInputEvent::kAltKey; result |= blink::WebInputEvent::kAltKey;
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
result |= blink::WebInputEvent::kMetaKey;
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result |= blink::WebInputEvent::kLeftButtonDown; result |= blink::WebInputEvent::kLeftButtonDown;
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result |= blink::WebInputEvent::kMiddleButtonDown; result |= blink::WebInputEvent::kMiddleButtonDown;
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result |= blink::WebInputEvent::kRightButtonDown; result |= blink::WebInputEvent::kRightButtonDown;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
result |= blink::WebInputEvent::kCapsLockOn; result |= blink::WebInputEvent::kMetaKey;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
result |= blink::WebInputEvent::kNumLockOn; result |= blink::WebInputEvent::kNumLockOn;
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
result |= blink::WebInputEvent::kIsKeyPad;
if (cef_modifiers & EVENTFLAG_IS_LEFT) if (cef_modifiers & EVENTFLAG_IS_LEFT)
result |= blink::WebInputEvent::kIsLeft; result |= blink::WebInputEvent::kIsLeft;
if (cef_modifiers & EVENTFLAG_IS_RIGHT) if (cef_modifiers & EVENTFLAG_IS_RIGHT)
result |= blink::WebInputEvent::kIsRight; result |= blink::WebInputEvent::kIsRight;
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) if (cef_modifiers & EVENTFLAG_ALTGR_DOWN)
result |= blink::WebInputEvent::kIsKeyPad; result |= blink::WebInputEvent::kAltGrKey;
if (cef_modifiers & EVENTFLAG_IS_REPEAT)
result |= blink::WebInputEvent::kIsAutoRepeat;
return result; return result;
} }

View File

@ -38,6 +38,14 @@ bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
cef_event.modifiers |= EVENTFLAG_COMMAND_DOWN; cef_event.modifiers |= EVENTFLAG_COMMAND_DOWN;
if (event.GetModifiers() & blink::WebKeyboardEvent::kIsKeyPad) if (event.GetModifiers() & blink::WebKeyboardEvent::kIsKeyPad)
cef_event.modifiers |= EVENTFLAG_IS_KEY_PAD; 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.windows_key_code = event.windows_key_code;
cef_event.native_key_code = event.native_key_code; cef_event.native_key_code = event.native_key_code;

View File

@ -192,26 +192,30 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers(
uint32 cef_modifiers) { uint32 cef_modifiers) {
int result = 0; int result = 0;
// Set modifiers based on key state. // 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) if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
result |= ui::EF_SHIFT_DOWN; result |= ui::EF_SHIFT_DOWN;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
result |= ui::EF_CONTROL_DOWN; result |= ui::EF_CONTROL_DOWN;
if (cef_modifiers & EVENTFLAG_ALT_DOWN) if (cef_modifiers & EVENTFLAG_ALT_DOWN)
result |= ui::EF_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) if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
result |= ui::EF_LEFT_MOUSE_BUTTON; result |= ui::EF_LEFT_MOUSE_BUTTON;
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
result |= ui::EF_MIDDLE_MOUSE_BUTTON; result |= ui::EF_MIDDLE_MOUSE_BUTTON;
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
result |= ui::EF_RIGHT_MOUSE_BUTTON; result |= ui::EF_RIGHT_MOUSE_BUTTON;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
result |= ui::EF_CAPS_LOCK_ON; result |= ui::EF_COMMAND_DOWN;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
result |= ui::EF_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) if (cef_modifiers & EVENTFLAG_ALTGR_DOWN)
result |= ui::EF_ALTGR_DOWN; result |= ui::EF_ALTGR_DOWN;
if (cef_modifiers & EVENTFLAG_IS_REPEAT)
result |= ui::EF_IS_REPEAT;
return result; return result;
} }