e_pointer: do scale with same output resolution ratio of width and height 33/296933/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 7 Aug 2023 03:41:24 +0000 (12:41 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 7 Aug 2023 10:04:14 +0000 (19:04 +0900)
Change-Id: Iab23e011084c7d057b3a8bfafdbc51814ab32b28

src/bin/e_pointer.c

index 9f20946..12547db 100644 (file)
@@ -15,13 +15,15 @@ static Eina_Inlist *_e_pointer_hooks[] =
 };
 
 static void
-_e_pointer_configured_output_resolution_ratio_get(E_Client *ec, double *ratio_w, double *ratio_h)
+_e_pointer_configured_output_resolution_ratio_get(E_Client *ec, double *ratio)
 {
    E_Output *output;
    E_Zone *zone;
+   double cal_ratio_w, cal_ratio_h, cal_ratio;
 
-   if (ratio_w) *ratio_w = 1.0;
-   if (ratio_h) *ratio_h = 1.0;
+   if (!ratio) return;
+
+   *ratio = 1.0;
 
    if (!e_config->cursor_configured_output_resolution.use) return;
    if (e_config->cursor_configured_output_resolution.w == 0) return;
@@ -37,12 +39,15 @@ _e_pointer_configured_output_resolution_ratio_get(E_Client *ec, double *ratio_w,
    if (output->config.geom.w == 0) return;
    if (output->config.geom.h == 0) return;
 
-   if (ratio_w)
-      *ratio_w = (double)output->config.geom.w /
+   cal_ratio_w = (double)output->config.geom.w /
                  (double)e_config->cursor_configured_output_resolution.w;
-   if (ratio_h)
-      *ratio_h = (double)output->config.geom.h /
+
+   cal_ratio_h = (double)output->config.geom.h /
                  (double)e_config->cursor_configured_output_resolution.h;
+
+   cal_ratio = MIN(cal_ratio_w, cal_ratio_h);
+
+   *ratio = cal_ratio;
 }
 
 /* move the cursor image with the calcaultion of the hot spot */
@@ -53,7 +58,7 @@ _e_pointer_position_update(E_Pointer *ptr)
    int rotation;
    int cursor_w, cursor_h;
    E_Client *ec;
-   double ratio_w = 1.0, ratio_h = 1.0;
+   double ratio = 1.0;
    int hot_x = 0, hot_y = 0;
 
    if (!ptr->o_ptr) return;
@@ -64,12 +69,12 @@ _e_pointer_position_update(E_Pointer *ptr)
    rotation = ptr->rotation;
 
    evas_object_geometry_get(ec->frame, NULL, NULL, &cursor_w, &cursor_h);
-   _e_pointer_configured_output_resolution_ratio_get(ec, &ratio_w, &ratio_h);
+   _e_pointer_configured_output_resolution_ratio_get(ec, &ratio);
 
-   if ((ratio_w != 1.0) || (ratio_h != 1.0))
+   if (ratio != 1.0)
      {
-        hot_x = (int)((double)ptr->hot.x * ratio_w);
-        hot_y = (int)((double)ptr->hot.y * ratio_h);
+        hot_x = (int)((double)ptr->hot.x * ratio);
+        hot_y = (int)((double)ptr->hot.y * ratio);
      }
    else
      {
@@ -111,7 +116,7 @@ _e_pointer_map_apply(E_Pointer *ptr)
    int x, y, w, h;
    E_Client *ec;
    int rotation = 0;
-   double ratio_w = 1.0, ratio_h = 1.0;
+   double ratio = 1.0;
 
    EINA_SAFETY_ON_NULL_RETURN(ptr);
    if (!ptr->o_ptr) return;
@@ -119,10 +124,10 @@ _e_pointer_map_apply(E_Pointer *ptr)
    ec = e_comp_object_client_get(ptr->o_ptr);
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
-   _e_pointer_configured_output_resolution_ratio_get(ec, &ratio_w, &ratio_h);
+   _e_pointer_configured_output_resolution_ratio_get(ec, &ratio);
    rotation = ptr->rotation;
 
-   if (((ratio_w == 1.0) && (ratio_h == 1.0)) &&
+   if ((ratio == 1.0) &&
        ((rotation == 0) || (rotation % 90 != 0) || (rotation / 90 > 3)))
      {
         e_client_map_enable_set(ec, EINA_FALSE);
@@ -137,12 +142,12 @@ _e_pointer_map_apply(E_Pointer *ptr)
 
    e_map_util_points_populate_from_object_full(map, ec->frame, 0);
 
-   if ((ratio_w != 1.0) || (ratio_h != 1.0))
+   if (ratio != 1.0)
      {
-        e_map_point_coord_set(map, 1, x + (int)((double)w * ratio_w), y, 0);
-        e_map_point_coord_set(map, 2, x + (int)((double)w * ratio_w),
-                             y + (int)((double)h * ratio_h), 0);
-        e_map_point_coord_set(map, 3, x, y + (int)((double)h * ratio_h), 0);
+        e_map_point_coord_set(map, 1, x + (int)((double)w * ratio), y, 0);
+        e_map_point_coord_set(map, 2, x + (int)((double)w * ratio),
+                             y + (int)((double)h * ratio), 0);
+        e_map_point_coord_set(map, 3, x, y + (int)((double)h * ratio), 0);
      }
 
    if (rotation)