From a43f40781444e8d4f4bdb72295de8bc9da03c6c9 Mon Sep 17 00:00:00 2001 From: liuxd Date: Mon, 20 Feb 2023 15:44:46 +0800 Subject: [PATCH] [M108 Migration][VD] Support device 1. Allow to show IME by the Enter key in RC device For TV profile, to support the new requirement that allow to show IME by the Enter key in Remote Control device. Now add a parameter in web keyboard event to mark if the key event is from RC; and use "is_from_rc" and "windows_key_code == ui::VKEY_RETURN" to distinguish the Enter key in Remote Control device. Migrated from M94_aura: https://review.tizen.org/gerrit/#/c/281776 2.Support device name property in keyboard event There is a requirement from HotelTV product team to support device name property in keyboard event: Some 3rd-party want to distinguish by device name when key event fired between devices. Refer: https://review.tizen.org/gerrit/#/c/+/282276 Signed-off-by: liuxd Change-Id: I05d8e28afe2b12ccf1d281c7634bab380a0e5b90 --- .../ui/ozone/platform/efl/efl_event_handler.cc | 12 ++++++++++++ .../ui/ozone/platform/efl/efl_keycode_map.h | 20 -------------------- ui/events/blink/web_input_event.cc | 7 +++++++ ui/events/event.cc | 4 ++++ ui/events/event.h | 5 +++++ ui/events/event_utils.h | 9 +++++++++ ui/events/events_default.cc | 14 ++++++++++++++ 7 files changed, 51 insertions(+), 20 deletions(-) diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc index 3031154..544c3ca 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc @@ -303,6 +303,18 @@ KeyEvent MakeWebKeyEvent(bool pressed, const EVT* evt) { KeyEvent event(type, windows_key_code, domCode, key_modifiers, domKey, base::TimeTicks::Now(), false); +#if BUILDFLAG(IS_TIZEN_TV) + const char* device_name = evas_device_name_get(evt->dev); + if (device_name) { + // We need distinguish if key is from RC in render process + if (IsRCDevice(evas_device_class_get(evt->dev), device_name)) + event.is_from_rc = true; + + // Add device name property in keyboard event. + event.device_name = device_name; + } +#endif + #else KeyEvent event(type, windows_key_code, key_modifiers, base::TimeTicks::Now()); #endif diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h index aa8a622..7c0e258 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h @@ -11,26 +11,6 @@ namespace ui { -// TV RC device names -const std::string kDeviceNameSmartView = "SMART_VIEW"; -const std::string kDeviceNamePanelKey = "wt61p807 panel key device"; -const std::string kDeviceNameRemote = "wt61p807 rc device"; -const std::string kDeviceNameSmartRC = "Smart Control"; -// To allow to receive Tomato send key events -const std::string kDeviceNameAutoModeDevice = "AUTO_MODE_DEVICE"; -const std::string kDeviceNameIME = "ime"; - -bool IsRCDevice(Evas_Device_Class device_id, const std::string device_name) { - if (device_id == EVAS_DEVICE_CLASS_KEYBOARD) { - return (!device_name.compare(kDeviceNameRemote) || - !device_name.compare(kDeviceNameSmartView) || - !device_name.compare(kDeviceNamePanelKey) || - !device_name.compare(kDeviceNameAutoModeDevice) || - device_name.find(kDeviceNameSmartRC) != std::string::npos); - } - return false; -} - static ui::KeyboardCode UIKeyCodeFromEflKey(const char* key) { static std::unordered_map code_from_key_map({ {"Shift_L", ui::VKEY_SHIFT}, diff --git a/ui/events/blink/web_input_event.cc b/ui/events/blink/web_input_event.cc index bacbcac..9933003 100644 --- a/ui/events/blink/web_input_event.cc +++ b/ui/events/blink/web_input_event.cc @@ -95,6 +95,13 @@ blink::WebKeyboardEvent MakeWebKeyboardEventFromUiEvent(const KeyEvent& event) { #if BUILDFLAG(IS_EFL) webkit_event.is_system_key = event.is_system_key; #endif +#if BUILDFLAG(IS_TIZEN_TV) + webkit_event.is_from_rc = event.is_from_rc; + + strncpy(webkit_event.device_name, event.device_name.c_str(), + sizeof(webkit_event.device_name) - 1); + webkit_event.device_name[sizeof(webkit_event.device_name) - 1] = '\0'; +#endif return webkit_event; } diff --git a/ui/events/event.cc b/ui/events/event.cc index 21cafe7..9e35019 100644 --- a/ui/events/event.cc +++ b/ui/events/event.cc @@ -831,6 +831,10 @@ KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags) #if BUILDFLAG(IS_EFL) is_system_key(IsSystemKeyFromNative(native_event)), #endif +#if BUILDFLAG(IS_TIZEN_TV) + is_from_rc(IsFromRCFromNative(native_event)), + device_name(DeviceNameFromNative(native_event)), +#endif is_char_(IsCharFromNative(native_event)) { #if defined(USE_OZONE) DCHECK(native_event->IsKeyEvent()); diff --git a/ui/events/event.h b/ui/events/event.h index fc78a03..5543e94 100644 --- a/ui/events/event.h +++ b/ui/events/event.h @@ -911,6 +911,11 @@ class EVENTS_EXPORT KeyEvent : public Event { bool is_system_key = false; #endif +#if BUILDFLAG(IS_TIZEN_TV) + bool is_from_rc = false; + std::string device_name; +#endif + protected: friend class KeyEventTestApi; diff --git a/ui/events/event_utils.h b/ui/events/event_utils.h index ca4e631..6bd2233 100644 --- a/ui/events/event_utils.h +++ b/ui/events/event_utils.h @@ -126,6 +126,15 @@ EVENTS_EXPORT DomKey KeyFromNative(const PlatformEvent& native_event); EVENTS_EXPORT bool IsSystemKeyFromNative(const PlatformEvent& native_event); #endif +#if BUILDFLAG(IS_TIZEN_TV) +// Returns the |is_from_rc| value from a native event. +EVENTS_EXPORT bool IsFromRCFromNative(const PlatformEvent& native_event); + +// Returns the |device_name| value from a native event. +EVENTS_EXPORT std::string DeviceNameFromNative( + const PlatformEvent& native_event); +#endif + // Returns true if the keyboard event is a character event rather than // a keystroke event. EVENTS_EXPORT bool IsCharFromNative(const PlatformEvent& native_event); diff --git a/ui/events/events_default.cc b/ui/events/events_default.cc index c434740..741e925 100644 --- a/ui/events/events_default.cc +++ b/ui/events/events_default.cc @@ -99,6 +99,20 @@ bool IsSystemKeyFromNative(const PlatformEvent& native_event) { } #endif +#if BUILDFLAG(IS_TIZEN_TV) +bool IsFromRCFromNative(const PlatformEvent& native_event) { + const ui::KeyEvent* event = static_cast(native_event); + DCHECK(event->IsKeyEvent()); + return event->is_from_rc; +} + +std::string DeviceNameFromNative(const PlatformEvent& native_event) { + const ui::KeyEvent* event = static_cast(native_event); + DCHECK(event->IsKeyEvent()); + return event->device_name; +} +#endif + bool IsCharFromNative(const PlatformEvent& native_event) { const ui::KeyEvent* event = static_cast(native_event); DCHECK(event->IsKeyEvent()); -- 2.7.4