[M108 Migration][VD] Support device 02/288602/3
authorliuxd <xd123.liu@samsung.com>
Mon, 20 Feb 2023 07:44:46 +0000 (15:44 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 21 Feb 2023 23:04:59 +0000 (23:04 +0000)
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 <xd123.liu@samsung.com>
Change-Id: I05d8e28afe2b12ccf1d281c7634bab380a0e5b90

tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h
ui/events/blink/web_input_event.cc
ui/events/event.cc
ui/events/event.h
ui/events/event_utils.h
ui/events/events_default.cc

index 3031154..544c3ca 100644 (file)
@@ -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
index aa8a622..7c0e258 100644 (file)
 
 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<std::string, ui::KeyboardCode> code_from_key_map({
       {"Shift_L", ui::VKEY_SHIFT},
index bacbcac..9933003 100644 (file)
@@ -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;
 }
index 21cafe7..9e35019 100644 (file)
@@ -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());
index fc78a03..5543e94 100644 (file)
@@ -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;
 
index ca4e631..6bd2233 100644 (file)
@@ -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);
index c434740..741e925 100644 (file)
@@ -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<const ui::KeyEvent*>(native_event);
+  DCHECK(event->IsKeyEvent());
+  return event->is_from_rc;
+}
+
+std::string DeviceNameFromNative(const PlatformEvent& native_event) {
+  const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event);
+  DCHECK(event->IsKeyEvent());
+  return event->device_name;
+}
+#endif
+
 bool IsCharFromNative(const PlatformEvent& native_event) {
   const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event);
   DCHECK(event->IsKeyEvent());