Add window position 21/286921/7
authorSukhyungKang <shine.kang@samsung.com>
Tue, 17 Jan 2023 01:28:39 +0000 (10:28 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Wed, 8 Feb 2023 08:15:38 +0000 (17:15 +0900)
Change-Id: I0cd675d522164242fa28b8b5590be4fcb76ed011
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc
tizen-cpp/app-core-ui-cpp/app_core_ui_base.hh

index dd2c2dc..014e83a 100644 (file)
@@ -105,6 +105,24 @@ class AppCoreUiBase::Impl {
     }
   };
 
+  class WindowPosition {
+   public:
+    WindowPosition(int x, int y, int w, int h)
+      : x_(x), y_(y), w_(w), h_(h){
+    }
+
+    int GetPositionX() const { return x_; }
+    int GetPositionY() const { return y_; }
+    int GetScreenWidth() const { return w_; }
+    int GetScreenHeight() const { return h_; }
+
+   private:
+    int x_;
+    int y_;
+    int w_;
+    int h_;
+  };
+
   void ExitFromSuspend();
   void PrepareToSuspend();
   void DoStart(tizen_base::Bundle b);
@@ -144,6 +162,7 @@ class AppCoreUiBase::Impl {
   std::unique_ptr<AppCoreTaskBase> service_;
   GMainContext* context_ = nullptr;
   std::thread thread_;
+  std::unique_ptr<WindowPosition> position_;
 };
 
 AppCoreUiBase::AppCoreUiBase(unsigned int hint)
@@ -415,13 +434,30 @@ void AppCoreUiBase::DoRun(int argc, char** argv) {
   impl_->w_status_ = Impl::WS_NONE;
   impl_->appid_ = std::string(appid);
   LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", appid);
-  if (impl_->hint_ & HINT_BG_LAUNCH_CONTROL) {
-    tizen_base::Bundle b(bundle_import_from_argv(argc, argv), false, true);
-    if (!b.IsEmpty()) {
+
+  tizen_base::Bundle b(bundle_import_from_argv(argc, argv), false, true);
+  if (!b.IsEmpty()) {
+    if (impl_->hint_ & HINT_BG_LAUNCH_CONTROL) {
       std::string bg_launch = b.GetString(AUL_SVC_K_BG_LAUNCH);
       if (bg_launch.compare("enable") == 0)
         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);
+      }
+    }
   }
 
   if (impl_->hint_ & HINT_WINDOW_ID_CONTROL)
@@ -898,4 +934,20 @@ void AppCoreUiBase::SetSystemResourceReclaiming(bool enable) {
   impl_->resource_reclaiming_ = enable;
 }
 
+int AppCoreUiBase::GetWindowPosition(int* x, int* y, int* w, int* h) {
+  if (!impl_->position_ ||
+      x == nullptr ||
+      y == nullptr ||
+      w == nullptr ||
+      h == nullptr)
+    return -1;
+
+  *x = impl_->position_->GetPositionX();
+  *y = impl_->position_->GetPositionY();
+  *w = impl_->position_->GetScreenWidth();
+  *h = impl_->position_->GetScreenHeight();
+
+  return 0;
+}
+
 }  // namespace tizen_cpp
index ce9ff03..0c4acac 100644 (file)
@@ -73,6 +73,7 @@ class EXPORT_API AppCoreUiBase : public AppCoreBase,
   void Dispose() override;
   virtual std::unique_ptr<AppCoreTaskBase> CreateTask();
   void Exit() override;
+  int GetWindowPosition(int* x, int* y, int* w, int* h);
 
  protected:
   void SetCoreUiDelegator(IAppCoreUi* delegator);