Add get/set window position api 20/286920/8
authorSukhyungKang <shine.kang@samsung.com>
Tue, 17 Jan 2023 01:27:08 +0000 (10:27 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Fri, 3 Feb 2023 07:46:30 +0000 (16:46 +0900)
Change-Id: I34623f70a1c92f498b8e5674d074ed90182d409a
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
include/aul_key.h
include/aul_svc.h
src/aul_svc.cc

index 9a7687b..23760bc 100644 (file)
  * @since_tizen 7.5
  */
 #define AUL_K_MOUNT_RES_PKGIDS          "__AUL_MOUNT_RES_PKGIDS__"
+
+/**
+ * @brief Definition for AUL: X position of the window.
+ * @since_tizen 7.5
+ */
+#define AUL_K_HINT_SCREEN_POS_X         "__K_HINT_SCREEN_POS_X"
+
+/**
+ * @brief Definition for AUL: Y position of the window.
+ * @since_tizen 7.5
+ */
+#define AUL_K_HINT_SCREEN_POS_Y         "__K_HINT_SCREEN_POS_Y"
+
+/**
+ * @brief Definition for AUL: Width of the window.
+ * @since_tizen 7.5
+ */
+#define AUL_K_HINT_SCREEN_WIDTH         "__K_HINT_SCREEN_WIDTH"
+
+/**
+ * @brief Definition for AUL: Height of the window.
+ * @since_tizen 7.5
+ */
+#define AUL_K_HINT_SCREEN_HEIGHT        "__K_HINT_SCREEN_HEIGHT"
index af8f290..553ae7a 100644 (file)
@@ -1181,6 +1181,38 @@ int aul_svc_send_resume_request_for_uid(bundle *b, int request_code,
                aul_svc_err_cb err_cb, void *user_data, uid_t uid);
 
 /**
+ * @par Description:
+ * This function sets window position into bundle.
+ *
+ * @param[in] b Bundle object
+ * @param[in] x x position of window
+ * @param[in] y y position of window
+ * @param[in] w width of window
+ * @param[in] h height of window
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @see aul_svc_get_window_position
+ * @remarks This API is only for Appfw internally.
+ */
+int aul_svc_set_window_position(bundle *b, int x, int y, int w, int h);
+
+/**
+ * @par Description:
+ * This function gets window position into bundle.
+ *
+ * @param[in] b Bundle object
+ * @param[out] x x position of window
+ * @param[out] y y position of window
+ * @param[out] w width of window
+ * @param[out] h height of window
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @see aul_svc_set_window_position
+ * @remarks This API is only for Appfw internally.
+ */
+int aul_svc_get_window_position(bundle* b, int *x, int *y, int *w, int *h);
+
+/**
  * @deprecated Deprecated since 6.5.
  */
 int aul_svc_set_defapp(const char *op, const char *mime_type,
index 72b9673..389dc50 100644 (file)
@@ -1233,6 +1233,58 @@ extern "C" API void aul_svc_free_appid_array(char** appid_array,
   free(appid_array);
 }
 
+extern "C" API int aul_svc_set_window_position(bundle* b,
+    int x, int y, int w, int h) {
+  if (b == nullptr) {
+    _E("Invalid parameter");
+    return AUL_SVC_RET_EINVAL;
+  }
+
+  ::SetBundle(b, AUL_K_HINT_SCREEN_POS_X, std::to_string(x).c_str());
+  ::SetBundle(b, AUL_K_HINT_SCREEN_POS_Y, std::to_string(y).c_str());
+  ::SetBundle(b, AUL_K_HINT_SCREEN_WIDTH, std::to_string(w).c_str());
+  ::SetBundle(b, AUL_K_HINT_SCREEN_HEIGHT, std::to_string(h).c_str());
+
+  return AUL_SVC_RET_OK;
+}
+
+extern "C" API int aul_svc_get_window_position(bundle* b,
+    int* x, int* y, int* w, int* h) {
+  if (b == nullptr ||
+      x == nullptr ||
+      y == nullptr ||
+      w == nullptr ||
+      h == nullptr) {
+    _E("Invalid parameter");
+    return AUL_SVC_RET_EINVAL;
+  }
+
+  char* x_str = nullptr;
+  char* y_str = nullptr;
+  char* w_str = nullptr;
+  char* h_str = nullptr;
+
+  bundle_get_str(b , AUL_K_HINT_SCREEN_POS_X, &x_str);
+  bundle_get_str(b , AUL_K_HINT_SCREEN_POS_Y, &y_str);
+  bundle_get_str(b , AUL_K_HINT_SCREEN_WIDTH, &w_str);
+  bundle_get_str(b , AUL_K_HINT_SCREEN_HEIGHT, &h_str);
+
+  if (x_str == nullptr ||
+      y_str == nullptr ||
+      w_str == nullptr ||
+      h_str == nullptr) {
+    _E("failed to get position");
+    return AUL_SVC_RET_ERROR;
+  }
+
+  *x = atoi(x_str);
+  *y = atoi(y_str);
+  *w = atoi(w_str);
+  *h = atoi(h_str);
+
+  return AUL_SVC_RET_OK;
+}
+
 extern "C" API int aul_svc_set_defapp(const char* op, const char* mime_type,
     const char* uri, const char* defapp) {
   DEPRECATION_WARNING();