Revert "Remove dummy object which is used for focus issue."
authorJongHeon Choi <j-h.choi@samsung.com>
Thu, 29 Sep 2016 06:44:48 +0000 (15:44 +0900)
committerJongHeon Choi <j-h.choi@samsung.com>
Thu, 29 Sep 2016 06:44:48 +0000 (15:44 +0900)
This reverts commit 8f5bfb51d878fe37159235e6941207078921b5f1.

runtime/browser/native_window.cc
runtime/browser/native_window.h
runtime/browser/web_application.cc
runtime/browser/web_view.cc
runtime/browser/web_view.h
runtime/browser/web_view_impl.cc
runtime/browser/web_view_impl.h

index 53ea275067c90ebd8da0e41a14fcfc3b30905817..8709672ed847531013e3770ca48295d78affd180 100755 (executable)
@@ -17,6 +17,7 @@
 #include "runtime/browser/native_window.h"
 
 #include <Ecore_Wayland.h>
+#include <ewk_chromium.h>
 #include <cstdint>
 
 #include "common/arraysize.h"
@@ -27,6 +28,8 @@ namespace runtime {
 namespace {
 const char* kEdjePath = "/usr/share/edje/xwalk/xwalk_tizen.edj";
 const char* kWinowRotationEventKey = "wm,rotation,changed";
+const char* kWinowFocusedEventKey = "focused";
+const char* kWinowUnfocusedEventKey = "unfocused";
 
 const int kPortraitNaturalAngle[] = {
   0,  // PORTRAIT_PRIMARY
@@ -68,7 +71,7 @@ NativeWindow::NativeWindow()
     : window_(NULL),
       window_type_(Type::NORMAL),
       initialized_(false),
-      layout_(NULL),
+      focus_(NULL),
       content_(NULL),
       rotation_(0),
       handler_id_(0) {
@@ -121,7 +124,40 @@ void NativeWindow::Initialize() {
   EVAS_SIZE_EXPAND_FILL(top_layout);
   elm_object_content_set(conformant, top_layout);
   evas_object_show(top_layout);
-  layout_ = top_layout;
+
+  // focus
+  Evas_Object* focus = elm_bg_add(top_layout);
+  evas_object_size_hint_align_set(focus, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  evas_object_size_hint_weight_set(focus, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  elm_object_focus_allow_set(focus, EINA_TRUE);
+  elm_object_part_content_set(top_layout, "elm.swallow.content", focus);
+  EVAS_SIZE_EXPAND_FILL(focus);
+  elm_access_object_unregister(focus);
+  evas_object_show(focus);
+  focus_ = focus;
+
+  // focus callback
+  auto focus_callback = [](void* user_data,
+                           Evas_Object*,
+                           void*) -> void {
+    NativeWindow* window = static_cast<NativeWindow*>(user_data);
+    window->DidFocusChanged(true);
+  };
+  auto unfocus_callback = [](void* user_data,
+                             Evas_Object*,
+                             void*) -> void {
+    NativeWindow* window = static_cast<NativeWindow*>(user_data);
+    window->DidFocusChanged(false);
+  };
+
+  evas_object_smart_callback_add(focus,
+                                 kWinowFocusedEventKey,
+                                 focus_callback,
+                                 this);
+  evas_object_smart_callback_add(focus,
+                                 kWinowUnfocusedEventKey,
+                                 unfocus_callback,
+                                 this);
 
   // Rotation
   auto rotation_callback = [](void* user_data,
@@ -169,11 +205,10 @@ void NativeWindow::SetContent(Evas_Object* content) {
   // issue elm_object_part_content_unset() on it first.
 
   evas_object_show(content);
-
-  // Hide unseted evas object to avoid focus and event callback problem.
   evas_object_hide(
-    elm_object_part_content_unset(layout_, "elm.swallow.content"));
-  elm_object_part_content_set(layout_, "elm.swallow.content", content);
+    elm_object_part_content_unset(focus_, "elm.swallow.content"));
+  elm_object_part_content_set(focus_, "elm.swallow.content", content);
+  elm_object_focus_set(focus_, EINA_TRUE);
   content_ = content;
 
   // attached webview was resized by evas_norender API
@@ -188,6 +223,12 @@ void NativeWindow::DidRotation(int degree) {
   }
 }
 
+void NativeWindow::DidFocusChanged(bool got) {
+  if (content_ != NULL) {
+    ewk_view_focus_set(content_, got ? EINA_TRUE : EINA_FALSE);
+  }
+}
+
 int NativeWindow::AddRotationHandler(RotationHandler handler) {
   int id = handler_id_++;
   handler_table_[id] = handler;
index 5fb4e1d40056a2d1cd954c1312b688e87d051014..e939a017ce600b899c908ae697ca040b4a654a02 100755 (executable)
@@ -75,9 +75,10 @@ class NativeWindow {
                                  void* event_info);
   static void DidProfileChanged(void* data, Evas_Object* obj, void* event_info);
   void DidRotation(int degree);
+  void DidFocusChanged(bool got);
 
   bool initialized_;
-  Evas_Object* layout_;
+  Evas_Object* focus_;
   Evas_Object* content_;
   int rotation_;
   int handler_id_;
index 8600bbd08591e9824f1f457797abe4f381bad68b..89483e1af24ae54beac964e0092a8628b4aa9374 100644 (file)
@@ -405,7 +405,7 @@ void WebApplication::Launch(std::unique_ptr<common::AppControl> appcontrol) {
   STEP_PROFILE_END("OnCreate -> URL Set");
   STEP_PROFILE_START("URL Set -> Rendered");
 
-  window_->SetContent(view->native_view());
+  window_->SetContent(view->evas_object());
 
   // rotate and resize window forcibily for landscape mode.
   // window rotate event is generated after window show. so
@@ -463,7 +463,7 @@ void WebApplication::AppControl(
     SetupWebView(view);
     view->SetDefaultEncoding(res->encoding());
     view->LoadUrl(res->uri(), res->mime());
-    window_->SetContent(view->native_view());
+    window_->SetContent(view->evas_object());
   }
 
   if (!debug_mode_ && appcontrol->data(AUL_K_DEBUG) == "1") {
@@ -542,7 +542,7 @@ void WebApplication::OnCreatedNewWebView(WebView* /*view*/, WebView* new_view) {
 
   SetupWebView(new_view);
   view_stack_.push_front(new_view);
-  window_->SetContent(new_view->native_view());
+  window_->SetContent(new_view->evas_object());
 }
 
 void WebApplication::RemoveWebViewFromStack(WebView* view) {
@@ -562,7 +562,7 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) {
     Terminate();
   } else if (current != view_stack_.front()) {
     view_stack_.front()->SetVisibility(true);
-    window_->SetContent(view_stack_.front()->native_view());
+    window_->SetContent(view_stack_.front()->evas_object());
   }
 
   // Delete after the callback context(for ewk view) was not used
index 8b35e410aed806b4763e1fd1f5e074ab7b57319d..a8add92445ac5277984d6e239089517bb50043ad 100644 (file)
@@ -73,10 +73,6 @@ Evas_Object* WebView::evas_object() const {
   return impl_->evas_object();
 }
 
-Evas_Object* WebView::native_view() const {
-  return impl_->native_view();
-}
-
 void WebView::SetAppInfo(const std::string& app_name,
                          const std::string& version) {
   impl_->SetAppInfo(app_name, version);
index 5ca952f36b554aa6b9717a35af67b667204ea63f..bb19e5449f4eb51b7f828cc68cf4a55e8c368641 100644 (file)
@@ -134,7 +134,6 @@ class WebView {
 
   void SetEventListener(EventListener* listener);
   Evas_Object* evas_object() const;
-  Evas_Object* native_view() const;
 
  private:
   WebViewImpl* impl_;
index 7cbe961a6794e34dff5e3ff9f9b869122dd42e29..7683c305b464950cc31b6f9e92b83a20558c8cbc 100644 (file)
@@ -75,7 +75,6 @@ WebViewImpl::WebViewImpl(WebView* view,
     : window_(window),
       context_(context),
       ewk_view_(NULL),
-      native_view_(NULL),
       listener_(NULL),
       rotation_handler_id_(0),
       view_(view),
@@ -196,7 +195,6 @@ void WebViewImpl::Initialize() {
                                  evas_smart_class_,
                                  context_,
                                  page_group);
-  native_view_ = ewk_view_widget_get(ewk_view_);
   evas_object_data_set(ewk_view_, kSmartClassUserDataKey, this);
 
   InitKeyCallback();
@@ -952,10 +950,6 @@ Evas_Object* WebViewImpl::evas_object() const {
   return ewk_view_;
 }
 
-Evas_Object* WebViewImpl::native_view() const {
-  return native_view_;
-}
-
 void WebViewImpl::OnRotation(int degree) {
   ewk_view_orientation_send(ewk_view_, ToWebRotation(degree));
 }
index 5d1b3d2a34346607526956ab2864e307f2cb910d..f5c5f6dad04afa30dfa830a58a28e13d75c4551c 100644 (file)
@@ -54,7 +54,6 @@ class WebViewImpl {
 
   void SetEventListener(WebView::EventListener* listener);
   Evas_Object* evas_object() const;
-  Evas_Object* native_view() const;
 
  private:
   void OnKeyEvent(Eext_Callback_Type key_type);
@@ -88,7 +87,6 @@ class WebViewImpl {
   NativeWindow* window_;
   Ewk_Context* context_;
   Evas_Object* ewk_view_;
-  Evas_Object* native_view_;
   WebView::EventListener* listener_;
   int rotation_handler_id_;
   WebView* view_;