From b764e9b98d194b0f9a77026991173f81fac2577f Mon Sep 17 00:00:00 2001 From: liuxd Date: Thu, 23 Feb 2023 09:33:58 +0800 Subject: [PATCH] [M108 Migration][VD] Handle "Up","Select" and "Cancel" key 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 --- .../ui/ozone/platform/efl/efl_event_handler.cc | 67 ++++++++++++++++++++++ .../ui/ozone/platform/efl/efl_event_handler.h | 5 ++ 2 files changed, 72 insertions(+) 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 544c3ca..c07f30e 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 @@ -27,6 +27,10 @@ #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 +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, diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.h b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.h index 1ad3fac..cbeb94e 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.h +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.h @@ -81,6 +81,11 @@ class EflEventHandler { template bool GetTouchEventsEnabled(const EVT* evas_evt); +#if BUILDFLAG(IS_TIZEN_TV) + template + 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(); -- 2.7.4