From: SukhyungKang Date: Tue, 17 Jan 2023 01:10:54 +0000 (+0900) Subject: Add set/get window position api X-Git-Tag: accepted/tizen/unified/20230302.131113~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F286918%2F9;p=platform%2Fcore%2Fapi%2Fapp-control.git Add set/get window position api Change-Id: I2b536f172bad64f276089a8cb84f8e2b59d1d176 Signed-off-by: SukhyungKang --- diff --git a/include/app_control.h b/include/app_control.h index 751c507..3135f76 100644 --- a/include/app_control.h +++ b/include/app_control.h @@ -1555,6 +1555,42 @@ int app_control_set_component_id(app_control_h app_control, int app_control_get_component_id(app_control_h app_control, char **component_id); +/** + * @brief Sets the window position of application. + * @since_tizen 7.5 + * + * @param[in] app_control The app_control handle + * @param[in] x x position of application's left top + * @param[in] y y position of application's left top + * @param[in] w width of application + * @param[in] h height of application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_CONTROL_ERROR_NONE Successful + * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_CONTROL_ERROR_IO_ERROR IO error + */ +int app_control_set_window_position(app_control_h app_control, + int x, int y, int w, int h); + +/** + * @brief Gets the window position of application. + * @since_tizen 7.5 + * + * @param[in] app_control The app_control handle + * @param[out] x x position of application's left top + * @param[out] y y position of application's left top + * @param[out] w width of application + * @param[out] h height of application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_CONTROL_ERROR_NONE Successful + * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_CONTROL_ERROR_IO_ERROR IO error + */ +int app_control_get_window_position(app_control_h app_control, + int *x, int *y, int *w, int *h); + /** * @} */ diff --git a/src/app-control/app_control.cc b/src/app-control/app_control.cc index e5cceb6..f03b7fe 100644 --- a/src/app-control/app_control.cc +++ b/src/app-control/app_control.cc @@ -460,4 +460,20 @@ bool AppControl::ValidateInternalKey(const std::string& key) { return true; } +void AppControl::SetWindowPosition(int x, int y, int w, int h) { + int ret = aul_svc_set_window_position(data_.GetHandle(), x, y, w, h); + if (ret != AUL_SVC_RET_OK) + THROW(Util::AulSvcErrorConvert(ret)); +} + +std::tuple AppControl::GetWindowPosition() { + int x, y, w, h; + + int ret = aul_svc_get_window_position(data_.GetHandle(), &x, &y, &w, &h); + if (ret != AUL_SVC_RET_OK) + THROW(Util::AulSvcErrorConvert(ret)); + + return std::tuple(x, y, w, h); +} + } // namespace app_control diff --git a/src/app-control/app_control.hh b/src/app-control/app_control.hh index 4c06801..2aa4bc2 100644 --- a/src/app-control/app_control.hh +++ b/src/app-control/app_control.hh @@ -90,6 +90,8 @@ class AppControl { bool IsExtraDataArray(const std::string& key) const; std::vector GetExtraDataKeys(); std::vector GetMatchedAppIds(); + void SetWindowPosition(int x, int y, int w, int h); + std::tuple GetWindowPosition(); bool IsReplyRequested() const; void EnableAppStartedResultEvent(); diff --git a/src/app-control/stub.cc b/src/app-control/stub.cc index e1ce270..577a6c6 100644 --- a/src/app-control/stub.cc +++ b/src/app-control/stub.cc @@ -1308,3 +1308,43 @@ EXPORT int app_control_foreach_default_application( return APP_CONTROL_ERROR_NONE; } + +EXPORT int app_control_set_window_position(app_control_h app_control, + int x, int y, int w, int h) { + if (app_control == nullptr) { + _E("Invalid parameter"); + return APP_CONTROL_ERROR_INVALID_PARAMETER; + } + + auto* handle = reinterpret_cast(app_control); + try { + handle->SetWindowPosition(x, y, w, h); + } catch (Exception& e) { + _E("Failed to set window position"); + return APP_CONTROL_ERROR_IO_ERROR; + } + + return APP_CONTROL_ERROR_NONE; +} + +EXPORT int app_control_get_window_position(app_control_h app_control, + int *x, int *y, int *w, int *h) { + if (app_control == nullptr || + x == nullptr || + y == nullptr || + w == nullptr || + h == nullptr) { + _E("Invalid parameter"); + return APP_CONTROL_ERROR_INVALID_PARAMETER; + } + + auto* handle = reinterpret_cast(app_control); + try { + std::tie(*x, *y, *w, *h) = handle->GetWindowPosition(); + } catch (Exception& e) { + _E("Failed to get window position"); + return APP_CONTROL_ERROR_IO_ERROR; + } + + return APP_CONTROL_ERROR_NONE; +}