[M120 Migration][VD] Fix some focus issues for offscreen mode 05/307505/3
authorfang fengrong <fr.fang@samsung.com>
Mon, 11 Mar 2024 09:21:44 +0000 (17:21 +0800)
committerYanqing Lu <yanqing.lu@samsung.com>
Wed, 13 Mar 2024 01:54:34 +0000 (01:54 +0000)
1.focus can't move to webview with arrow key.
  In WebBrowser, create two or more tab pages. When switch to another tab,
  the arrow key can't move to web-page. because focus isnot sync to efl window.
2.The webview focus should been controled by app through ewk_view_set focus api,
  chromium should not set default focus.
3.on hbbtv, press any key no response, because of webview on focus out status.
4.Keeps same with M94, register focusin/focusout for content_image_elm_host;
   when content_image_elm_host focusin/focusout, sync the focus to content_image.
5.Add some log for debug.

refer:
https://review.tizen.org/gerrit/#/c/297117/
https://review.tizen.org/gerrit/#/c/297301/

Change-Id: Ia2677e488c26ced5a81ae5973fc91e7789877cf2
Signed-off-by: fang fengrong <fr.fang@samsung.com>
content/browser/renderer_host/render_widget_host_view_aura.cc
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_window.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.h
ui/platform_window/platform_window.h

index d737845..2a443c9 100644 (file)
@@ -553,7 +553,8 @@ void RenderWidgetHostViewAura::Focus() {
     window_->Focus();
 
 #if BUILDFLAG(IS_EFL)
-  efl_helper_->Focus(true);
+  if (!efl_helper_->HasFocus())
+    efl_helper_->Focus(true);
 #endif
 }
 
index bfb1e76..6c498af 100644 (file)
@@ -181,6 +181,10 @@ RWHVAuraOffscreenHelperEfl::~RWHVAuraOffscreenHelperEfl() {
                                  OnFocusIn);
   evas_object_event_callback_del(content_image_, EVAS_CALLBACK_FOCUS_OUT,
                                  OnFocusOut);
+  evas_object_smart_callback_del(content_image_elm_host_, "focused",
+                                 OnHostFocusIn);
+  evas_object_smart_callback_del(content_image_elm_host_, "unfocused",
+                                 OnHostFocusOut);
   evas_event_callback_del_full(evas_, EVAS_CALLBACK_RENDER_FLUSH_PRE,
                                OnEvasRenderFlushPre, this);
   evas_object_del(content_image_);
@@ -559,8 +563,19 @@ void RWHVAuraOffscreenHelperEfl::NotifySwap(const size_t texture_id) {
 }
 
 void RWHVAuraOffscreenHelperEfl::Focus(bool focus) {
+  LOG(INFO) << "evas_object_focus_set:" << focus;
   elm_object_focus_set(content_image_elm_host_, focus);
   evas_object_focus_set(content_image_, focus);
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  // sync focus on efl window
+  aura::WindowTreeHost* window_host = rwhva()->window()->GetHost();
+  if (window_host) {
+    static_cast<aura::WindowTreeHostPlatform*>(window_host)
+        ->platform_window()
+        ->UpdateFocus(focus);
+  }
+#endif
 }
 
 bool RWHVAuraOffscreenHelperEfl::HasFocus() {
@@ -578,6 +593,7 @@ void RWHVAuraOffscreenHelperEfl::OnFocusIn(void* data,
                                            Evas* evas,
                                            Evas_Object* obj,
                                            void* event_info) {
+  LOG(INFO) << "OnFocusIn";
   RWHVAuraOffscreenHelperEfl* thiz =
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
   thiz->FocusRWHVA();
@@ -594,6 +610,7 @@ void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
                                             Evas* evas,
                                             Evas_Object* obj,
                                             void* event_info) {
+  LOG(INFO) << "OnFocusOut";
   RWHVAuraOffscreenHelperEfl* thiz =
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
   aura::WindowTreeHost* window_host = thiz->rwhva()->window()->GetHost();
@@ -624,6 +641,7 @@ void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
 void RWHVAuraOffscreenHelperEfl::OnHostFocusIn(void* data,
                                                Evas_Object*,
                                                void*) {
+  LOG(INFO) << "OnHostFocusIn";
   RWHVAuraOffscreenHelperEfl* thiz =
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
   thiz->Focus(true);
@@ -632,6 +650,7 @@ void RWHVAuraOffscreenHelperEfl::OnHostFocusIn(void* data,
 void RWHVAuraOffscreenHelperEfl::OnHostFocusOut(void* data,
                                                 Evas_Object*,
                                                 void*) {
+  LOG(INFO) << "OnHostFocusOut";
   RWHVAuraOffscreenHelperEfl* thiz =
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
   if (thiz && thiz->GetRenderWidgetHostImpl())
index d7e93d7..91ca651 100644 (file)
@@ -28,6 +28,8 @@
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)
+#include "base/base_switches.h"
+#include "base/command_line.h"
 #include "third_party/blink/public/platform/web_application_type.h"
 #endif
 
@@ -174,7 +176,11 @@ void EflEventHandler::RegisterCallbacks() {
   if (key_events_enabled_)
     AddKeyCallbacks();
 
-  evas_object_focus_set(events_overlay_, EINA_TRUE);
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering))
+#endif
+    evas_object_focus_set(events_overlay_, EINA_TRUE);
 
   if (touch_events_enabled_)
     AddTouchCallbacks();
index af45ee1..bd607d9 100644 (file)
@@ -307,6 +307,7 @@ void EflWindow::UpdateFocus(bool focused) {
   if (has_focus_ == focused)
     return;
 
+  LOG(INFO) << "EflWindow Focus:" << focused;
   has_focus_ = focused;
 
   if (events_overlay_) {
@@ -479,7 +480,11 @@ void EflWindow::InitializeEventHandler() {
 
   // Set focus active for a newly opened window.
 #if !defined(BUILD_CHROME)
-  UpdateFocus(true);
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering))
+#endif
+    UpdateFocus(true);
 #endif
   efl_event_handler_ = std::make_unique<EflEventHandler>(this);
   PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
@@ -495,7 +500,11 @@ void EflWindow::EnsureIMContextEfl() {
 
 void EflWindow::ResetEventHandler() {
   delegate_->OnActivationChanged(false /*active*/);
-  UpdateFocus(false);
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering))
+#endif
+    UpdateFocus(false);
   efl_event_handler_.reset();
   PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
 }
index 4da7edb..1e99f25 100644 (file)
@@ -76,7 +76,7 @@ class EflWindow : public PlatformWindow, public PlatformEventDispatcher {
   // Called only in case of offscreen rendering
   void SetEventsOverlayForOffscreen(Evas_Object* events_overlay) override;
 
-  void UpdateFocus(bool focused);
+  void UpdateFocus(bool focused) override;
   void SetFocus(bool focused) { has_focus_ = focused; }
 
   void OnWindowLostCapture();
index 7aac100..c9aab7f 100644 (file)
@@ -233,6 +233,7 @@ class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindow
 #if BUILDFLAG(IS_EFL)
   // Sets view created in RWHVAura as events overlay for offscreen rendering.
   virtual void SetEventsOverlayForOffscreen(Evas_Object* events_overlay) {}
+  virtual void UpdateFocus(bool focused) {}
 
   virtual EflEventHandler* GetEventHandler() { return nullptr; }
 #endif