From 5ebd81634b5b5b23a8469b26d8e548a3fa4a21fa Mon Sep 17 00:00:00 2001 From: SukhyungKang Date: Tue, 17 Jan 2023 10:28:39 +0900 Subject: [PATCH] Add window position Change-Id: I0cd675d522164242fa28b8b5590be4fcb76ed011 Signed-off-by: SukhyungKang --- tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc | 58 +++++++++++++++++++++++++-- tizen-cpp/app-core-ui-cpp/app_core_ui_base.hh | 1 + 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc b/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc index dd2c2dc..014e83a 100644 --- a/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc +++ b/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc @@ -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 service_; GMainContext* context_ = nullptr; std::thread thread_; + std::unique_ptr 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(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 diff --git a/tizen-cpp/app-core-ui-cpp/app_core_ui_base.hh b/tizen-cpp/app-core-ui-cpp/app_core_ui_base.hh index ce9ff03..0c4acac 100644 --- a/tizen-cpp/app-core-ui-cpp/app_core_ui_base.hh +++ b/tizen-cpp/app-core-ui-cpp/app_core_ui_base.hh @@ -73,6 +73,7 @@ class EXPORT_API AppCoreUiBase : public AppCoreBase, void Dispose() override; virtual std::unique_ptr CreateTask(); void Exit() override; + int GetWindowPosition(int* x, int* y, int* w, int* h); protected: void SetCoreUiDelegator(IAppCoreUi* delegator); -- 2.7.4