[M130 Migration][VD]Fix wrong key and text issue 09/322509/2
authorjiangyuwei <yuwei.jiang@samsung.com>
Thu, 10 Apr 2025 07:21:10 +0000 (15:21 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 10 Apr 2025 13:55:57 +0000 (13:55 +0000)
1.[VD]Fix wrong key issue

The keys after IME filtered, WebEngine can only receive text on
callback, then WebEngine make fake key event with the text;
compared with the original key event, the fake event lost many
key properties(such as without the modifiers).

If get the DomKey from DomCode, will get wrong key,such as:
input uppercase letter "A" with IME, the key of key up event is lowercase key "a";
input "+" with IME, the key of key up event is "=".

So keep same with M94, if there is no key value, return empty directly,
don't get the DomKey from DomCode, for avoid getting wrong key value.

2.[EFL] Fix wrong text and wrong unmodifiedText issue

For EFL key event,keep same with M94, should get the text and unmodifiedText
from evt->string, not from evt->key.

On most case, the evt->string same with the evt->key;
but on some case, the evt->string may not same with the evt->key, such as:
when number lock, press the number key on the Numeric keypad area of the
usb-keboard, the evt->string is empty, it not same with the evt->key.
And press the number key when number lock, should not show the number.

Reference:
 - https://archive.tizen.org/gerrit/310853/

Change-Id: Idde0d3803b1f75a37ba8d93bbccf36ac1a33b094
Signed-off-by: jiangyuwei <yuwei.jiang@samsung.com>
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc
ui/events/event.cc
ui/events/event.h

index 0c2afa43a3768cf054f2485a8bad2749202c8059..a314e059b54cb19382c6de9bb8624495d26e6bff 100644 (file)
@@ -151,6 +151,16 @@ float GetDeviceScaleFactor() {
   return device_scale_factor;
 }
 
+static char16_t CharacterFromEflString(const char* string) {
+  if (string) {
+    std::u16string result;
+    base::UTF8ToUTF16(string, strlen(string), &result);
+    return result.length() == 1 ? result[0] : 0;
+  }
+
+  return 0;
+}
+
 }  // namespace
 
 EflEventHandler::EflEventHandler(EflWindow* window)
@@ -308,6 +318,9 @@ KeyEvent MakeWebKeyEvent(bool pressed, const EVT* evt) {
                  base::TimeTicks::Now(), false);
 
 #if BUILDFLAG(IS_EFL)
+  if (evt->string)
+    event.efl_character = CharacterFromEflString(evt->string);
+
   event.text = event.GetText();
   event.unmodified_text = event.GetUnmodifiedText();
 #endif
index 2fbd69c13aa16eda0dac9a9f18bb15ee81794897..4efcadba117ad2750f50096c8881d91fcd94c819 100644 (file)
@@ -1029,6 +1029,10 @@ KeyEvent** KeyEvent::GetLastKeyEvent() {
 }
 
 DomKey KeyEvent::GetDomKey() const {
+#if BUILDFLAG(IS_TIZEN_TV)
+  return key_;
+#endif
+
   // Determination of key_ may be done lazily.
   if (key_ == DomKey::NONE)
     ApplyLayout();
@@ -1097,7 +1101,11 @@ char16_t KeyEvent::GetUnmodifiedText() const {
     return 0;
 #endif
 
+#if BUILDFLAG(IS_EFL)
+  return efl_character;
+#else
   return GetCharacter();
+#endif
 }
 
 bool KeyEvent::IsUnicodeKeyCode() const {
index 6e31be8c9b28f22c48b7bdb237096dd802cb3ed5..b0cca8f8477fe5ae5c907f3418ee13be7a54c3d1 100644 (file)
@@ -961,6 +961,7 @@ class EVENTS_EXPORT KeyEvent : public Event {
   bool is_system_key = false;
   char16_t unmodified_text = 0xFFFF;
   char16_t text = 0xFFFF;
+  char16_t efl_character = 0;
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)