[M108 Migration][VD] Handle "Up","Select" and "Cancel" key 79/288779/5
authorliuxd <xd123.liu@samsung.com>
Thu, 23 Feb 2023 01:33:58 +0000 (09:33 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 2 Mar 2023 09:11:47 +0000 (09:11 +0000)
1.Handle Up key on top of IME as same as Return Back
key
2.For TV IME "Select" and "Cancel" key, handle as hide IME
3.[VD][Remote Access] Block "Cancel" key event in non webapp scene

Refer:
https://review.tizen.org/gerrit/#/c/280444

Change-Id: I8e924d2c55ce3d1a765c7b5baf8687caed77a020
Signed-off-by: liuxd <xd123.liu@samsung.com>
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.h

index 544c3ca..c07f30e 100644 (file)
 #include "ui/events/keycodes/keyboard_code_conversion.h"
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "tizen_src/ewk/efl_integration/common/application_type.h"
+#endif
+
 namespace ui {
 
 namespace {
@@ -584,6 +588,17 @@ void EflEventHandler::OnKeyDown(void* data,
     }
   }
 #endif
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (IsTvProfile()) {
+    thiz->ConvertUpToReturnBackIfNeeded(key_down, true);
+
+    // In non webapp scene,"Cancel" key haven't added on the map,the keycode is
+    // 0. "Cancel" key is delivered by IME, for hiding IME panel,no need deliver
+    // the key event. Or else,the keycode 0 may exception handling by website.
+    if (!strcmp(key_down->key, "Cancel") && !content::IsTIZENWRT())
+      return;
+  }
+#endif
 
   KeyEvent event = MakeWebKeyEvent(true, key_down);
   auto im_context_efl = thiz->GetIMContextEfl();
@@ -621,11 +636,23 @@ void EflEventHandler::OnKeyUp(void* data,
 #endif
 
   if (IsTvProfile()) {
+#if BUILDFLAG(IS_TIZEN_TV)
+    thiz->ConvertUpToReturnBackIfNeeded(key_up, false);
+#endif
+
     // For TV IME "Select" and "Cancel" key
     if (thiz->im_context_efl_ && thiz->im_context_efl_->IsVisible()) {
       if (!strcmp(key_up->key, "Select") || !strcmp(key_up->key, "Cancel"))
         thiz->im_context_efl_->HidePanel();
     }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+    // In non webapp scene,"Cancel" key haven't added on the map,the keycode is
+    // 0. "Cancel" key is delivered by IME, for hiding IME panel,no need deliver
+    // the key event. Or else,the keycode 0 may exception handling by website.
+    if (!strcmp(key_up->key, "Cancel") && !content::IsTIZENWRT())
+      return;
+#endif
   }
 
   KeyEvent event = MakeWebKeyEvent(false, key_up);
@@ -713,6 +740,46 @@ bool EflEventHandler::FilterIMEKeyUpEvent(Evas_Event_Key_Up* key_up) {
   return false;
 }
 
+// New requirement from tizen 6.5:
+// press "up" key on the top of IME panel should handled as same behavior as
+// press "Return Back" key on IME panel behavior:
+// For WebBrowser, need hide IME panel and don't deliver the Return Back key
+// event to WebBrowser; For WebApp, need hide IME panel and deliver the Return
+// Back key event to WebApp.
+#if BUILDFLAG(IS_TIZEN_TV)
+template <typename EVT>
+void EflEventHandler::ConvertUpToReturnBackIfNeeded(EVT* evt, bool is_press) {
+  if (!im_context_efl_ || !im_context_efl_->IsVisible() ||
+      strcmp(evt->key, "Up"))
+    return;
+
+  // No need hide IME panel when press the IME panel's up key.
+  Evas_Device_Class device_id = evas_device_class_get(evt->dev);
+  const char* device_name = evas_device_name_get(evt->dev);
+  if (device_id != EVAS_DEVICE_CLASS_KEYBOARD || !strcmp(device_name, "ime"))
+    return;
+
+  if (is_press) {
+    was_up_keypress_on_ime_top_ = true;
+  } else {
+    // make sure "press up key on the top of IME" scenes
+    if (!was_up_keypress_on_ime_top_)
+      return;
+
+    was_up_keypress_on_ime_top_ = false;
+  }
+
+  if (content::IsWebBrowser() || content::IsTIZENWRT()) {
+    evt->keyname = (char*)"Cancel"; /*Return Back key name*/
+    evt->key = (char*)"Cancel";     /*Return Back key*/
+    evt->string = (char*)"";        /*Return Back string*/
+    evt->keycode = 0;               /*Return Back keycode*/
+    LOG(INFO) << "Press Up key on the top of IME panel, handle the Up key as "
+                 "same as Return Back key!";
+  }
+}
+#endif
+
 void EflEventHandler::OnMultiTouchDownEvent(void* data,
                                             Evas* evas,
                                             Evas_Object* obj,
index 1ad3fac..cbeb94e 100644 (file)
@@ -81,6 +81,11 @@ class EflEventHandler {
   template <typename EVT>
   bool GetTouchEventsEnabled(const EVT* evas_evt);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  template <typename EVT>
+  void ConvertUpToReturnBackIfNeeded(EVT* evt, bool is_press);
+#endif
+
   bool FilterIMEKeyDownEvent(Evas_Event_Key_Down* key_down);
   bool FilterIMEKeyUpEvent(Evas_Event_Key_Up* key_up);
   bool IsIMEHandleKeyEventEnabled();