Change dummy object atspi role
[platform/framework/web/crosswalk-tizen.git] / runtime / browser / native_window.cc
index d332dd8..5712dff 100755 (executable)
 #include "runtime/browser/native_window.h"
 
 #include <Ecore_Wayland.h>
-#include <ewk_chromium.h>
+#include <EWebKit.h>
+#include <EWebKit_internal.h>
 #include <cstdint>
 
+#include "common/arraysize.h"
 #include "common/logger.h"
 
 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 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
+  180,  // PORTRAIT_SECONDARY
+  270,  // LANDSCAPE_PRIMARY
+  90,  // LANDSCAPE_SECONDARY
+  0,  // NATURAL
+  -1  // ANY
+};
+const int kLandscapeNaturalAngle[] = {
+  270,  // PORTRAIT_PRIMARY
+  90,  // PORTRAIT_SECONDARY
+  0,  // LANDSCAPE_PRIMARY
+  180,  // LANDSCAPE_SECONDARY
+  0,  // NATURAL
+  -1,  // ANY
+};
+
+NativeWindow::ScreenOrientation NativeAngleToOrientation(
+    int angle, NativeWindow::ScreenOrientation natural_orientation) {
+  auto& convert_table =
+      natural_orientation == NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY ?
+          kPortraitNaturalAngle :
+          kLandscapeNaturalAngle;
+  unsigned index = ARRAYSIZE(convert_table) - 1;
+  for (unsigned i = 0; i < ARRAYSIZE(convert_table); ++i) {
+    if (convert_table[i] == angle) {
+      index = i;
+      break;
+    }
+  }
+  return static_cast<NativeWindow::ScreenOrientation>(index);
+}
+
 }  // namespace
 
 
@@ -58,6 +94,7 @@ void NativeWindow::Initialize() {
   int w, h;
   ecore_wl_screen_size_get(&w, &h);
   evas_object_resize(window_, w, h);
+  elm_win_size_base_set(window_, w, h);
   elm_win_autodel_set(window_, EINA_TRUE);
   evas_object_smart_callback_add(window_, "delete,request",
                                  DidDeleteRequested, this);
@@ -97,6 +134,7 @@ void NativeWindow::Initialize() {
   elm_object_part_content_set(top_layout, "elm.swallow.content", focus);
   EVAS_SIZE_EXPAND_FILL(focus);
   elm_access_object_unregister(focus);
+  elm_atspi_accessible_role_set(focus, ELM_ATSPI_ROLE_FILLER);
   evas_object_show(focus);
   focus_ = focus;
 
@@ -142,6 +180,8 @@ void NativeWindow::Initialize() {
     natural_orientation_ = ScreenOrientation::PORTRAIT_PRIMARY;
   }
 
+  elm_win_indicator_mode_set(window_, ELM_WIN_INDICATOR_SHOW);
+
   initialized_ = true;
 }
 
@@ -203,6 +243,10 @@ void NativeWindow::RemoveRotationHandler(int id) {
   handler_table_.erase(id);
 }
 
+NativeWindow::ScreenOrientation NativeWindow::orientation() const {
+  return NativeAngleToOrientation(rotation_, natural_orientation_);
+}
+
 void NativeWindow::SetRotationLock(int degree) {
   if (degree != -1)
     rotation_ = degree % 360;
@@ -210,26 +254,10 @@ void NativeWindow::SetRotationLock(int degree) {
 }
 
 void NativeWindow::SetRotationLock(ScreenOrientation orientation) {
-  int portrait_natural_angle[] = {
-    0,  // PORTRAIT_PRIMARY
-    180,  // PORTRAIT_SECONDARY
-    270,  // LANDSCAPE_PRIMARY
-    90,  // LANDSCAPE_SECONDARY
-    0,  // NATURAL
-    -1  // ANY
-  };
-  int landscape_natural_angle[] = {
-    270,  // PORTRAIT_PRIMARY
-    90,  // PORTRAIT_SECONDARY
-    0,  // LANDSCAPE_PRIMARY
-    180,  // LANDSCAPE_SECONDARY
-    0,  // NATURAL
-    -1,  // ANY
-  };
   auto& convert_table =
       natural_orientation_ == ScreenOrientation::PORTRAIT_PRIMARY ?
-          portrait_natural_angle :
-          landscape_natural_angle;
+          kPortraitNaturalAngle :
+          kLandscapeNaturalAngle;
   SetRotationLock(convert_table[static_cast<int>(orientation)]);
 }