Add set/get window position api 18/286918/9
authorSukhyungKang <shine.kang@samsung.com>
Tue, 17 Jan 2023 01:10:54 +0000 (10:10 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Tue, 7 Feb 2023 03:07:19 +0000 (12:07 +0900)
Change-Id: I2b536f172bad64f276089a8cb84f8e2b59d1d176
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
include/app_control.h
src/app-control/app_control.cc
src/app-control/app_control.hh
src/app-control/stub.cc

index 751c50739d266cac42e452c4a51c1f1d5cab53e0..3135f76e6a88346b888bab604e48de6df7553c0a 100644 (file)
@@ -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);
+
 /**
  * @}
  */
index e5cceb64ce54dc6f493c18a4cf23d5af40afaad4..f03b7fe64d69271693af93e9a6ed72d28efcb386 100644 (file)
@@ -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<int, int, int, int> 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<int, int, int, int>(x, y, w, h);
+}
+
 }  // namespace app_control
index 4c068017e9b4f6c3aad2a4cb85451ad6c1d55a62..2aa4bc2cbf125fbc530c36a15442cc447e63f2f4 100644 (file)
@@ -90,6 +90,8 @@ class AppControl {
   bool IsExtraDataArray(const std::string& key) const;
   std::vector<std::string> GetExtraDataKeys();
   std::vector<std::string> GetMatchedAppIds();
+  void SetWindowPosition(int x, int y, int w, int h);
+  std::tuple<int, int, int, int> GetWindowPosition();
 
   bool IsReplyRequested() const;
   void EnableAppStartedResultEvent();
index e1ce2701a651bbe4fc28dd61277c437bf3f2d142..577a6c6d7fddf87f9d4c3368d22b758d482a3484 100644 (file)
@@ -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<AppControl*>(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<AppControl*>(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;
+}