Add internal method to set window position
[platform/core/appfw/app-core.git] / tizen-cpp / app-core-ui-cpp / app_core_ui_base.cc
index 014e83a..cfc6e6c 100644 (file)
@@ -142,6 +142,7 @@ class AppCoreUiBase::Impl {
   int FiniWl();
   void PluginInit(int argc, char** argv);
   void PluginFini();
+  void SetWindowPosition(const tizen_base::Bundle& b);
   void Run(int argc, char** argv);
   void Exit();
 
@@ -415,6 +416,27 @@ void AppCoreUiBase::Impl::PluginFini() {
   plugin_->Fini(parent_);
 }
 
+void AppCoreUiBase::Impl::SetWindowPosition(const tizen_base::Bundle& b) {
+  std::string x_str = b.GetString(AUL_K_HINT_SCREEN_POS_X);
+  if (x_str.empty())
+    return;
+
+  std::string y_str = b.GetString(AUL_K_HINT_SCREEN_POS_Y);
+  if (y_str.empty())
+    return;
+
+  std::string w_str = b.GetString(AUL_K_HINT_SCREEN_WIDTH);
+  if (w_str.empty())
+    return;
+
+  std::string h_str = b.GetString(AUL_K_HINT_SCREEN_HEIGHT);
+  if (h_str.empty())
+    return;
+
+  position_ = std::make_unique<AppCoreUiBase::Impl::WindowPosition>(
+      std::stoi(x_str), std::stoi(y_str), std::stoi(w_str), std::stoi(h_str));
+}
+
 void AppCoreUiBase::DoRun(int argc, char** argv) {
   SetCoreDelegator(nullptr);
   SetLoopDelegator(nullptr);
@@ -443,21 +465,7 @@ void AppCoreUiBase::DoRun(int argc, char** argv) {
         impl_->ApplyBgState(true);
     }
 
-    std::string x_str = b.GetString(AUL_K_HINT_SCREEN_POS_X);
-    if (!x_str.empty()) {
-      std::string y_str = b.GetString(AUL_K_HINT_SCREEN_POS_Y);
-      std::string w_str = b.GetString(AUL_K_HINT_SCREEN_WIDTH);
-      std::string h_str = b.GetString(AUL_K_HINT_SCREEN_HEIGHT);
-      if (!y_str.empty() && !w_str.empty() && !h_str.empty()) {
-        int x = atoi(x_str.c_str());
-        int y = atoi(y_str.c_str());
-        int w = atoi(w_str.c_str());
-        int h = atoi(h_str.c_str());
-
-        impl_->position_ =
-          std::make_unique<AppCoreUiBase::Impl::WindowPosition>(x, y, w, h);
-      }
-    }
+    impl_->SetWindowPosition(b);
   }
 
   if (impl_->hint_ & HINT_WINDOW_ID_CONTROL)