[M120 Migration][HBBTV] Dispatch key events through associated event dispatcher only 40/306440/4
authorNishitha S <n.saravanan@samsung.com>
Wed, 21 Feb 2024 10:21:18 +0000 (15:51 +0530)
committerBot Blink <blinkbot@samsung.com>
Mon, 26 Feb 2024 08:22:44 +0000 (08:22 +0000)
HBBTV app launches single ecore/elm window but two ewk_views within the
same window. The app can send key events through ewk api to any of the
ewk_view and they need to be dispatched irrespective of their focus state.
Currently the unfocused ewk_view is not dispatching event because of way
event forwarding logic is written in ozone layer.

This patch makes necessary changes to check the associated dispatcher handle
instead of CanDispatchEvent, also keeps both aura windows in focus parallely.
This change is only for HBBTV.

Reference: https://review.tizen.org/gerrit/299770

Change-Id: Iecb83a0f22665edd03795bd4745d69c88453395c
Signed-off-by: nishitha <n.saravanan@samsung.com>
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_event_handler.h
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.h
ui/events/event.h
ui/events/platform/platform_event_source.cc

index 0008ab5..0da202f 100644 (file)
@@ -583,7 +583,11 @@ void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
 
   aura::client::FocusClient* focus_client =
       aura::client::GetFocusClient(window_host->window());
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!blink::IsHbbTV() && focus_client) {
+#else
   if (focus_client) {
+#endif
     aura::Window* focused_window = focus_client->GetFocusedWindow();
 
     if (focused_window)
index d8a6b68..6a33c98 100644 (file)
@@ -636,6 +636,10 @@ void EflEventHandler::OnKeyDown(void* data,
 #endif
 
   KeyEvent event = MakeWebKeyEvent(true, key_down);
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Needed for HBBTV single window, multiwebview scenario.
+  event.SetDispatcher(thiz->window());
+#endif
   auto im_context_efl = thiz->GetIMContextEfl();
   if (!im_context_efl ||
       im_context_efl->ShouldHandleImmediately(key_down->key)) {
@@ -698,6 +702,10 @@ void EflEventHandler::OnKeyUp(void* data,
   }
 
   KeyEvent event = MakeWebKeyEvent(false, key_up);
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Needed for HBBTV single window, multiwebview scenario.
+  event.SetDispatcher(thiz->window());
+#endif
   auto im_context_efl = thiz->GetIMContextEfl();
   if (!im_context_efl || im_context_efl->ShouldHandleImmediately(key_up->key)) {
     EflPlatformEventSource::GetInstance()->DispatchEflEvent(&event);
index c615311..27d9e81 100644 (file)
@@ -63,6 +63,7 @@ class EflEventHandler {
 #if BUILDFLAG(IS_TIZEN_TV)
    void SetKeyEventChecker(
        const base::RepeatingCallback<bool(void*, bool)>& checker);
+   EflWindow* window() { return window_; }
 #endif
 
  private:
index d936bb1..2cc3995 100644 (file)
@@ -59,6 +59,7 @@ EflWindow::EflWindow(PlatformWindowDelegate* delegate,
                      PlatformWindowInitProperties properties,
                      EflWindowManager* manager)
     : delegate_(delegate), window_manager_(manager) {
+  LOG(INFO) << this;
   Initialize(properties);
 }
 
index 528c99d..c1236a6 100644 (file)
@@ -66,10 +66,11 @@ std::unique_ptr<IMContextEfl> IMContextEfl::Create(EflWindow* window) {
   if (!context)
     return nullptr;
 
-  return std::make_unique<IMContextEfl>(context);
+  return std::make_unique<IMContextEfl>(context, window);
 }
 
-IMContextEfl::IMContextEfl(Ecore_IMF_Context* context) : context_(context) {
+IMContextEfl::IMContextEfl(Ecore_IMF_Context* context, EflWindow* window)
+    : context_(context), window_(window) {
   IM_CTX_LOG;
   InitializeIMFContext();
 }
@@ -526,6 +527,10 @@ void IMContextEfl::SendFakeCompositionKeyEvent(const std::u16string& buf) {
 
   is_keyevent_processing_ = true;
   PushToKeyUpEventQueue(event.key_code());
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Needed for HBBTV single window, multiwebview scenario.
+  event.SetDispatcher(window_);
+#endif
   EflPlatformEventSource::GetInstance()->DispatchEflEvent(&event);
 }
 
@@ -893,6 +898,10 @@ void IMContextEfl::ProcessNextKeyDownEvent() {
 
   LOG(INFO) << "ProcessNextKeyDownEvent,key:"
             << keydown_event_queue_.front().key_code();
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Needed for HBBTV single window, multiwebview scenario.
+  keydown_event_queue_.front().SetDispatcher(window_);
+#endif
   EflPlatformEventSource::GetInstance()->DispatchEflEvent(
       &keydown_event_queue_.front());
   keydown_event_queue_.pop();
@@ -905,6 +914,10 @@ void IMContextEfl::ProcessNextKeyUpEvent() {
   LOG(INFO) << "ProcessNextKeyUpEvent,key:" << keyup_event_queue_.front();
   KeyEvent event(ET_KEY_RELEASED, keyup_event_queue_.front(), EF_NONE,
                  base::TimeTicks());
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Needed for HBBTV single window, multiwebview scenario.
+  event.SetDispatcher(window_);
+#endif
   EflPlatformEventSource::GetInstance()->DispatchEflEvent(&event);
   keyup_event_queue_.pop();
 }
index 2fb8f8e..ed593aa 100644 (file)
@@ -37,7 +37,7 @@ class IMContextEfl {
   // Returns nullptr if there is no available backend.
   static std::unique_ptr<IMContextEfl> Create(EflWindow*);
 
-  IMContextEfl(Ecore_IMF_Context*);
+  IMContextEfl(Ecore_IMF_Context*, EflWindow*);
   ~IMContextEfl();
 
   void HandleKeyDownEvent(const Evas_Event_Key_Down* event, bool* was_filtered);
@@ -213,6 +213,7 @@ class IMContextEfl {
   bool is_keyevent_processing_ = false;
   bool is_transaction_finished_ = true;
   InputMethodAuraLinux* im_aura_ = nullptr;
+  EflWindow* window_ = nullptr;
   content::RenderWidgetHostHelper* rwh_helper_ = nullptr;
 };
 
index 9ebf8ed..877f982 100644 (file)
 #include "ui/gfx/geometry/point_conversions.h"
 #include "ui/latency/latency_info.h"
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "ui/events/platform/platform_event_dispatcher.h"
+#endif
+
 namespace gfx {
 class Transform;
 }
@@ -299,6 +303,12 @@ class EVENTS_EXPORT Event {
   // Every concrete class transitively inheriting Event must implement this
   // method, even if any ancestors have provided an implementation.
   virtual std::unique_ptr<Event> Clone() const = 0;
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetDispatcher(PlatformEventDispatcher* dispatcher) {
+    dispatcher_ = dispatcher;
+  }
+  PlatformEventDispatcher* GetDispatcher() { return dispatcher_; }
+#endif
 
  protected:
   Event(EventType type, base::TimeTicks time_stamp, int flags);
@@ -331,6 +341,9 @@ class EVENTS_EXPORT Event {
   // The device id the event came from, or ED_UNKNOWN_DEVICE if the information
   // is not available.
   int source_device_id_ = ED_UNKNOWN_DEVICE;
+#if BUILDFLAG(IS_TIZEN_TV)
+  PlatformEventDispatcher* dispatcher_ = nullptr;
+#endif
 
   std::unique_ptr<Properties> properties_;
 };
index 87dc749..109786f 100644 (file)
 #include "ui/events/platform/platform_event_observer.h"
 #include "ui/events/platform/scoped_event_dispatcher.h"
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "base/logging.h"
+#include "tizen_src/ewk/efl_integration/common/application_type.h"
+#include "ui/events/event.h"
+#endif
+
 namespace ui {
 
 namespace {
@@ -90,6 +96,20 @@ uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) {
 
   if (action & POST_DISPATCH_PERFORM_DEFAULT) {
     for (PlatformEventDispatcher& dispatcher : dispatchers_) {
+#if BUILDFLAG(IS_TIZEN_TV)
+      if (content::IsHbbTV() && platform_event->IsKeyEvent()) {
+        if ((&dispatcher) == platform_event->GetDispatcher()) {
+          LOG(INFO) << "Dispatching event through dispatcher : "
+                    << (&dispatcher);
+          action = dispatcher.DispatchEvent(platform_event);
+          if (action & POST_DISPATCH_STOP_PROPAGATION) {
+            break;
+          }
+        } else {
+          continue;
+        }
+      }
+#endif
       if (dispatcher.CanDispatchEvent(platform_event))
         action = dispatcher.DispatchEvent(platform_event);
       if (action & POST_DISPATCH_STOP_PROPAGATION)