display: Add init direction in rotation angle API 10/286310/5 accepted/tizen/unified/20230110.164121
authorTaeminYeom <taemin.yeom@samsung.com>
Tue, 3 Jan 2023 07:51:59 +0000 (16:51 +0900)
committerTaeminYeom <taemin.yeom@samsung.com>
Mon, 9 Jan 2023 06:52:39 +0000 (15:52 +0900)
init direction means the display direction of degree 0.
It is needed to know physical display state by app.

Enumeration
-device_display_init_direction_e
DEVICE_DISPLAY_INIT_DIRECTION_HORIZONTAL : Display initial direction is horizontal
DEVICE_DISPLAY_INIT_DIRECTION_VERTICAL : Display initial direction is vertical

Change-Id: Ic9092286e17d05cdd11e4c0190b301eaa8dfc263
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
include/display-internal.h
src/display.c

index e6ef10c..58334ed 100644 (file)
@@ -71,6 +71,19 @@ typedef enum
        DEVICE_DISPLAY_ROTATION_DIRECTION_COUNTER_CLOCKWISE,    /**< Rotate with counter clockwise direction */
 } device_display_rotation_direction_e;
 
+
+/**
+ * @brief Enumeration for the display initial direction.
+ * Initial direction means the display direction of degree 0.
+ * @since_tizen 7.0
+ */
+typedef enum
+{
+       DEVICE_DISPLAY_INIT_DIRECTION_HORIZONTAL,       /**< Display initial direction is horizontal */
+       DEVICE_DISPLAY_INIT_DIRECTION_VERTICAL,         /**< Display initial direction is vertical */
+} device_display_init_direction_e;
+
+
 /**
  * @brief Gets the display brightness value.
  * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif
@@ -185,6 +198,10 @@ int is_feature_display_supported(void);
  *                 DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_90\n
  *                 DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_180\n
  *                 DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_270\n
+ * @param[out] init_direction The type is display initial direction
+ *                 When the rotation angle is 0 degree, initial direction means the display is a horizontal or vertical.\n
+ *                 DEVICE_DISPLAY_INIT_DIRECTION_HORIZONTAL\n
+ *                 DEVICE_DISPLAY_INIT_DIRECTION_VERTICAL\n
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
@@ -192,7 +209,9 @@ int is_feature_display_supported(void);
  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  */
-int device_display_get_rotation_angle(int display_index, device_display_rotation_angle_e *angle);
+int device_display_get_rotation_angle(int display_index,
+                               device_display_rotation_angle_e *angle,
+                               device_display_init_direction_e *init_direction);
 
 /**
  * @brief Set display rotation angle
@@ -209,7 +228,7 @@ int device_display_get_rotation_angle(int display_index, device_display_rotation
  *                 DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_90\n
  *                 DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_180\n
  *                 DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_270\n
- * @param[in] direction The type is display rotation direction\n
+ * @param[in] rotation_direction The type is display rotation direction\n
  *                    DEVICE_DISPLAY_ROTATION_DIRECTION_CLOCKWISE\n
  *                    DEVICE_DISPLAY_ROTATION_DIRECTION_COUNTER_CLOCKWISE\n
  * @return @c 0 on success,
@@ -219,7 +238,9 @@ int device_display_get_rotation_angle(int display_index, device_display_rotation
  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  */
-int device_display_set_rotation_angle(int display_index, device_display_rotation_angle_e angle, device_display_rotation_direction_e direction);
+int device_display_set_rotation_angle(int display_index,
+                               device_display_rotation_angle_e angle,
+                               device_display_rotation_direction_e rotation_direction);
 
 /**
  * @platform
index 7dc7161..92131ea 100644 (file)
@@ -570,9 +570,11 @@ static int sensor_get_rotation_angle(device_display_rotation_angle_e *angle)
        return display_sensor_listener_stop();
 }
 
-int device_display_get_rotation_angle(int display_index, int *angle)
+int device_display_get_rotation_angle(int display_index,
+                               device_display_rotation_angle_e *angle,
+                               device_display_init_direction_e *init_direction)
 {
-       int ret = 0, reply_val = 0;
+       int ret = 0, reply_angle, reply_init_direction;
        GVariant *reply;
 
        ret = is_feature_display_supported();
@@ -585,7 +587,7 @@ int device_display_get_rotation_angle(int display_index, int *angle)
                        return ret;
        }
 
-       if (display_index < 0 || display_index >= display_cnt || !angle)
+       if (display_index < 0 || display_index >= display_cnt || !angle || !init_direction)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
        /* Get the display rotation angle from deviced */
@@ -601,13 +603,14 @@ int device_display_get_rotation_angle(int display_index, int *angle)
                return ret;
        }
 
-       g_variant_get(reply, "(ii)", &ret, &reply_val);
+       g_variant_get(reply, "(iii)", &ret, &reply_angle, &reply_init_direction);
        g_variant_unref(reply);
        if (ret < 0 && ret != -ENODEV) {
                _E("Failed to get display rotation angle");
                return ret;
        } else if (ret >= 0) {
-               *angle = reply_val;
+               *angle = reply_angle;
+               *init_direction = reply_init_direction;
                return DEVICE_ERROR_NONE;
        }
 
@@ -615,12 +618,13 @@ int device_display_get_rotation_angle(int display_index, int *angle)
         * If the device don't support display rotation,
         * get the display rotation angle using capi-system-sensor.
         */
+       *init_direction = DEVICE_DISPLAY_INIT_DIRECTION_VERTICAL;
        return sensor_get_rotation_angle(angle);
 }
 
 int device_display_set_rotation_angle(int display_index,
                                device_display_rotation_angle_e angle,
-                               device_display_rotation_direction_e direction)
+                               device_display_rotation_direction_e rotation_direction)
 {
        int ret, reply;
 
@@ -641,7 +645,7 @@ int device_display_set_rotation_angle(int display_index,
                || angle > ROTATION_ANGLE_DEGREE_MAX)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
-       switch (direction) {
+       switch (rotation_direction) {
        case DEVICE_DISPLAY_ROTATION_DIRECTION_CLOCKWISE:
        case DEVICE_DISPLAY_ROTATION_DIRECTION_COUNTER_CLOCKWISE:
                break;
@@ -653,7 +657,7 @@ int device_display_set_rotation_angle(int display_index,
                                        DEVICED_PATH_DISPLAY,
                                        DEVICED_INTERFACE_DISPLAY,
                                        METHOD_SET_ROTATION_ANGLE,
-                                       g_variant_new("(iii)", display_index, angle, direction),
+                                       g_variant_new("(iii)", display_index, angle, rotation_direction),
                                        &reply);
 
        if (ret < 0) {