#include "runtime/browser/native_window.h"
-#if defined(HAVE_X11)
-#include <Ecore_X.h>
-#elif defined(HAVE_WAYLAND)
#include <Ecore_Wayland.h>
-#endif
-
+#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
NativeWindow::NativeWindow()
- : initialized_(false),
- window_(NULL),
+ : window_(NULL),
+ window_type_(Type::NORMAL),
+ initialized_(false),
focus_(NULL),
content_(NULL),
rotation_(0),
}
NativeWindow::~NativeWindow() {
+ if (window_)
+ evas_object_del(window_);
}
void NativeWindow::Initialize() {
+ if (initialized_) {
+ LOGGER(DEBUG) << "already initialized";
+ return;
+ }
// window
window_ = CreateWindowInternal();
elm_win_conformant_set(window_, EINA_TRUE);
int w, h;
-#if defined(HAVE_X11)
- uint16_t pid = getpid();
- ecore_x_window_prop_property_set(
- elm_win_xwindow_get(window_),
- ECORE_X_ATOM_NET_WM_PID,
- ECORE_X_ATOM_CARDINAL, 32, &pid, 1);
- ecore_x_vsync_animator_tick_source_set(elm_win_xwindow_get(window_));
- ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
-#elif defined(HAVE_WAYLAND)
ecore_wl_screen_size_get(&w, &h);
-#endif
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);
evas_object_show(top_layout);
// focus
- Evas_Object* focus = elm_button_add(top_layout);
- elm_theme_extension_add(NULL, kEdjePath);
- elm_object_style_set(focus, "wrt");
+ 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);
+ elm_atspi_accessible_role_set(focus, ELM_ATSPI_ROLE_FILLER);
evas_object_show(focus);
focus_ = focus;
natural_orientation_ = ScreenOrientation::PORTRAIT_PRIMARY;
}
+ elm_win_indicator_mode_set(window_, ELM_WIN_INDICATOR_SHOW);
+
initialized_ = true;
}
// If the content is NULL, this call will just delete the previous object.
// If the If you wish to preserve it,
// issue elm_object_part_content_unset() on it first.
+
evas_object_show(content);
- elm_object_part_content_unset(focus_, "elm.swallow.content");
+ evas_object_hide(
+ 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
+ evas_norender(evas_object_evas_get(window_));
}
void NativeWindow::DidRotation(int degree) {
void NativeWindow::DidFocusChanged(bool got) {
if (content_ != NULL) {
- elm_object_focus_set(content_, got ? EINA_TRUE : EINA_FALSE);
+ ewk_view_focus_set(content_, got ? EINA_TRUE : EINA_FALSE);
}
}
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;
}
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)]);
}
enable ? ELM_WIN_INDICATOR_TRANSPARENT : ELM_WIN_INDICATOR_OPAQUE);
}
+#ifdef MANUAL_ROTATE_FEATURE_SUPPORT
+void NativeWindow::EnableManualRotation(bool enable) {
+ LOGGER(DEBUG) << "set manual rotation : " << (enable ? "enabled" : "disabled");
+ elm_win_wm_rotation_manual_rotation_done_set(window_, enable ? EINA_TRUE : EINA_FALSE);
+}
+
+void NativeWindow::ManualRotationDone() {
+ if (EINA_TRUE == elm_win_wm_rotation_manual_rotation_done_get(window_)) {
+ elm_win_wm_rotation_manual_rotation_done(window_);
+ }
+}
+#endif // MANUAL_ROTATE_FEATURE_SUPPORT
+
} // namespace runtime