Add dummy button to solve focus issue
authorJongHeon Choi <j-h.choi@samsung.com>
Fri, 24 Jun 2016 04:55:10 +0000 (13:55 +0900)
committerJongHeon Choi <j-h.choi@samsung.com>
Fri, 24 Jun 2016 04:55:10 +0000 (13:55 +0900)
runtime/browser/native_window.cc
runtime/browser/native_window.h
runtime/resources/xwalk_tizen.edc

index c201a6afaf67817df556e67f7e2861333d210b4f..0caf58a2290e942dc93c8eb6149fd19b2aa28382 100755 (executable)
@@ -17,6 +17,7 @@
 #include "runtime/browser/native_window.h"
 
 #include <Ecore_Wayland.h>
+#include <ewk_chromium.h>
 #include <cstdint>
 
 #include "common/logger.h"
@@ -26,6 +27,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";
 }  // namespace
 
 
@@ -33,7 +36,7 @@ NativeWindow::NativeWindow()
     : window_(NULL),
       window_type_(Type::NORMAL),
       initialized_(false),
-      layout_(NULL),
+      focus_(NULL),
       content_(NULL),
       rotation_(0),
       handler_id_(0) {
@@ -85,7 +88,39 @@ 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_button_add(top_layout);
+  elm_theme_extension_add(NULL, kEdjePath);
+  elm_object_style_set(focus, "wrt");
+  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,
@@ -133,11 +168,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);
+  ewk_view_focus_set(focus_, EINA_TRUE);
   content_ = content;
 
   // attached webview was resized by evas_norender API
@@ -152,6 +186,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 a2f396d16bcb269abca0525396bb4441a2840c19..279ac2caa7b7f8d649ab3c7cc0cc68ac27a38e33 100755 (executable)
@@ -70,9 +70,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 cc3c65c04aafb7f738e27217dc458a849c6a7d53..0ad09ec10432e84e07096609b67a26dc7404eb4c 100755 (executable)
@@ -94,6 +94,56 @@ collections {
         }//end of programs
     }//end of group
 
+    group { name: "elm/button/base/wrt";
+     #define BUTTON_HEIGHT 78.0
+     parts {
+        part { name: "bg";
+           type: RECT;
+           scale: 1;
+           description { state: "default" 0.0;
+              color: 0 0 0 0;
+              min: 0 BUTTON_HEIGHT;
+           }
+        }
+        part { name: "elm.text";
+           type: TEXTBLOCK;
+           mouse_events: 0;
+           scale: 1;
+           description { state: "default" 0.0;
+              text {
+                 min: 0 1;
+                 style: "button_general_text_normal";
+              }
+           }
+           description { state: "disabled" 0.0;
+              inherit: "default" 0.0;
+              text.style: "button_general_text_dim";
+           }
+           description { state: "pressed" 0.0;
+              inherit: "default" 0.0;
+              text.style: "button_general_text_press";
+           }
+        }
+        part { name: "elm.swallow.content";
+           clip_to: "elm.swallow.content.clip";
+           type: SWALLOW;
+           scale: 1;
+           description { state: "default" 0.0; }
+        }
+        part { name: "elm.swallow.content.clip";
+           type: RECT;
+           scale: 1;
+           description { state: "default" 0.0;
+              color_class: "F022L1i";
+           }
+           description { state: "disabled" 0.0;
+              inherit: "default" 0.0;
+              color_class: "F022L1iD";
+           }
+        }
+     }//end of part
+    }//end of group
+
     group {
         name: "PopupTextEntrySet";
         parts{