e_pointer: Support desk zoom 90/316990/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 2 Sep 2024 02:46:04 +0000 (11:46 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Mon, 2 Sep 2024 08:10:33 +0000 (17:10 +0900)
if e_pointer_desk_zoom_enable_set is set, hw cursor and evas compositing
cursor supports desk zoom.

Change-Id: Ib3578b3b61e1eb755aaf171f16b334d58220f193

src/bin/displaymgr/e_hwc_window.c
src/bin/windowmgr/e_pointer.c
src/include/e_pointer.h

index 540e9a3..edad9b7 100644 (file)
@@ -448,50 +448,57 @@ _e_hwc_window_cursor_image_update(E_Hwc_Window *hwc_window)
 }
 
 static void
-_e_hwc_window_cursor_position_get(E_Pointer *ptr, E_Output *output, int width, int height, unsigned int *x, unsigned int *y)
+_e_hwc_window_cursor_position_get(E_Pointer *ptr, E_Output *output, int width, int height,
+                                  double zx, double zy, unsigned int *x, unsigned int *y)
 {
    int rotation;
-   int hot_x, hot_y;
-   float ratio_w, ratio_h;
+   int ptr_x, ptr_y;
 
-   rotation = ptr->rotation;
+   if (!ptr->view_client)
+     {
+        if (x) *x = 0;
+        if (y) *y = 0;
+        return;
+     }
 
-   hot_x = ptr->hot.x;
-   hot_y = ptr->hot.y;
+   e_view_client_geometry_get(ptr->view_client, &ptr_x, &ptr_y, NULL, NULL);
+   rotation = ptr->rotation;
 
-   if (e_config->cursor_configured_output_resolution.use)
+   if ((zx != 1.0) || (zy != 1.0))
      {
-        ratio_w = (float)output->config.geom.w / (float)e_config->cursor_configured_output_resolution.w;
-        ratio_h = (float)output->config.geom.h / (float)e_config->cursor_configured_output_resolution.h;
-
-        if ((ratio_w > 1.0) && (ratio_h > 1.0))
+        if ((rotation == 90) || (rotation == 270))
           {
-             hot_x = (int)((float)hot_x * (float)ratio_w);
-             hot_y = (int)((float)hot_y * (float)ratio_h);
+             width = (int)((double)width * (double)zy);
+             height = (int)((double)height * (double)zx);
+          }
+        else
+          {
+             width = (int)((double)width * (double)zx);
+             height = (int)((double)height * (double)zy);
           }
      }
 
    switch (rotation)
      {
       case 0:
-        *x = ptr->x - hot_x;
-        *y = ptr->y - hot_y;
+        if (x) *x = ptr_x;
+        if (y) *y = ptr_y;
         break;
       case 90:
-        *x = ptr->x - hot_y;
-        *y = ptr->y + hot_x - width;
+        if (x) *x = ptr_x;
+        if (y) *y = ptr_y - width;
         break;
       case 180:
-        *x = ptr->x + hot_x - width;
-        *y = ptr->y + hot_y - height;
+        if (x) *x = ptr_x - width;
+        if (y) *y = ptr_y - height;
         break;
       case 270:
-        *x = ptr->x + hot_y - height;
-        *y = ptr->y - hot_x;
+        if (x) *x = ptr_x - height;
+        if (y) *y = ptr_y;
         break;
       default:
-        *x = ptr->x - hot_x;
-        *y = ptr->y - hot_y;
+        if (x) *x = ptr_x;
+        if (y) *y = ptr_y;
         break;
      }
 }
@@ -1632,6 +1639,8 @@ _e_hwc_window_cursor_info_get(E_Hwc_Window *hwc_window, tdm_hwc_window_info *hwc
    E_Pointer *pointer;
    E_Zone *zone;
    int rotation;
+   E_Desk *desk;
+   double zx = 1.0, zy = 1.0;
 
    if (!e_hwc_window_is_cursor(hwc_window)) return EINA_FALSE;
 
@@ -1651,6 +1660,13 @@ _e_hwc_window_cursor_info_get(E_Hwc_Window *hwc_window, tdm_hwc_window_info *hwc
    pointer = e_pointer_get(ec);
    if (!pointer) return EINA_TRUE;
 
+   if (e_pointer_desk_zoom_enable_get())
+     {
+        desk = e_desk_current_get(hwc_window->zone);
+        if (desk)
+          e_desk_zoom_get(desk, &zx, &zy, NULL, NULL);
+     }
+
    hwc_win_info->src_config.format = TBM_FORMAT_ARGB8888;
    hwc_win_info->src_config.pos.x = 0;
    hwc_win_info->src_config.pos.y = 0;
@@ -1664,6 +1680,7 @@ _e_hwc_window_cursor_info_get(E_Hwc_Window *hwc_window, tdm_hwc_window_info *hwc
    _e_hwc_window_cursor_position_get(pointer, output,
                                      hwc_win_info->src_config.pos.w,
                                      hwc_win_info->src_config.pos.h,
+                                     zx, zy,
                                      &hwc_win_info->dst_pos.x,
                                      &hwc_win_info->dst_pos.y);
 
@@ -1710,6 +1727,20 @@ _e_hwc_window_cursor_info_get(E_Hwc_Window *hwc_window, tdm_hwc_window_info *hwc
         break;
      }
 
+   if ((zx != 1.0) || (zy != 1.0))
+     {
+        if ((rotation == 90) || (rotation == 270))
+          {
+             hwc_win_info->dst_pos.w = (int)((double)hwc_win_info->dst_pos.w * zy);
+             hwc_win_info->dst_pos.h = (int)((double)hwc_win_info->dst_pos.h * zx);
+          }
+        else
+          {
+             hwc_win_info->dst_pos.w = (int)((double)hwc_win_info->dst_pos.w * zx);
+             hwc_win_info->dst_pos.h = (int)((double)hwc_win_info->dst_pos.h * zy);
+          }
+     }
+
    return EINA_TRUE;
 }
 
index 7a92ae9..d1813bb 100644 (file)
@@ -8,6 +8,8 @@
 /* local variables */
 static Eina_List *_ptrs = NULL;
 static Eina_Bool _initted = EINA_FALSE;
+static Eina_List *event_handlers = NULL;
+static Eina_Bool _desk_zoom_enable = EINA_FALSE;
 
 static int _e_pointer_hooks_delete = 0;
 static int _e_pointer_hooks_walking = 0;
@@ -55,6 +57,23 @@ _e_pointer_configured_output_resolution_ratio_get(E_Client *ec, double *ratio)
    *ratio = cal_ratio;
 }
 
+static void
+_e_pointer_desk_zoom_get(double *zx, double *zy)
+{
+   E_Zone *zone;
+   E_Desk *desk;
+
+   if (!_desk_zoom_enable) return;
+
+   zone = e_zone_current_get();
+   if (!zone) return;
+
+   desk = e_desk_current_get(zone);
+   if (!desk) return;
+
+   e_desk_zoom_get(desk, zx, zy, NULL, NULL);
+}
+
 /* move the cursor image with the calcaultion of the hot spot */
 static void
 _e_pointer_position_update(E_Pointer *ptr)
@@ -66,6 +85,7 @@ _e_pointer_position_update(E_Pointer *ptr)
    double ratio = 1.0;
    int hot_x = 0, hot_y = 0;
    E_View *view;
+   double zx = 1.0, zy = 1.0;
 
    if (!ptr->view_client) return;
    view = e_view_client_view_get(ptr->view_client);
@@ -78,16 +98,29 @@ _e_pointer_position_update(E_Pointer *ptr)
 
    e_view_client_geometry_get(ptr->view_client, NULL, NULL, &cursor_w, &cursor_h);
    _e_pointer_configured_output_resolution_ratio_get(ec, &ratio);
+   _e_pointer_desk_zoom_get(&zx, &zy);
+
+   hot_x = ptr->hot.x;
+   hot_y = ptr->hot.y;
 
    if (ratio != 1.0)
      {
-        hot_x = (int)((double)ptr->hot.x * ratio);
-        hot_y = (int)((double)ptr->hot.y * ratio);
+        hot_x = (int)((double)hot_x * ratio);
+        hot_y = (int)((double)hot_y * ratio);
      }
-   else
+
+   if ((zx != 1.0) || (zy != 1.0))
      {
-        hot_x = ptr->hot.x;
-        hot_y = ptr->hot.y;
+        if ((rotation == 90) || (rotation == 270))
+          {
+             hot_x = (int)((double)hot_x * zy);
+             hot_y = (int)((double)hot_y * zx);
+          }
+        else
+          {
+             hot_x = (int)((double)hot_x * zx);
+             hot_y = (int)((double)hot_y * zy);
+          }
      }
 
    switch (rotation)
@@ -126,6 +159,7 @@ _e_pointer_map_apply(E_Pointer *ptr)
    int rotation = 0;
    double ratio = 1.0;
    E_View *view;
+   double zx = 1.0, zy = 1.0;
 
    EINA_SAFETY_ON_NULL_RETURN(ptr);
    if (!ptr->view_client) return;
@@ -137,10 +171,12 @@ _e_pointer_map_apply(E_Pointer *ptr)
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
    _e_pointer_configured_output_resolution_ratio_get(ec, &ratio);
+   _e_pointer_desk_zoom_get(&zx, &zy);
    rotation = ptr->rotation;
 
    if ((ratio == 1.0) &&
-       ((rotation == 0) || (rotation % 90 != 0) || (rotation / 90 > 3)))
+       ((rotation == 0) || (rotation % 90 != 0) || (rotation / 90 > 3)) &&
+       ((zx == 1.0) && (zy == 1.0)))
      {
         e_client_map_enable_set(ec, EINA_FALSE);
         e_client_map_set(ec, NULL);
@@ -172,6 +208,9 @@ _e_pointer_map_apply(E_Pointer *ptr)
         e_map_util_rotate(map, rotation, x, y);
      }
 
+   if ((ratio != 1.0) || (zx != 1.0) || (zy != 1.0))
+     e_map_util_zoom(map, ratio * zx, ratio * zy, x, y);
+
    e_map_util_points_color_set(map, 255, 255, 255, 255);
    e_map_util_object_move_sync_set(map, EINA_TRUE);
 
@@ -270,9 +309,50 @@ _e_pointer_hook_call(E_Pointer_Hook_Point hookpoint, E_Pointer *ptr)
    return !!e_object_unref(E_OBJECT(ptr));
 }
 
+static Eina_Bool
+_e_pointer_cb_desk_zoom_set(void *data, int type, void *event)
+{
+   E_Pointer *ptr;
+   Eina_List *l;
+
+   if (!_desk_zoom_enable)
+     return ECORE_CALLBACK_PASS_ON;
+
+   EINA_LIST_FOREACH(_ptrs, l, ptr)
+     {
+        _e_pointer_map_apply(ptr);
+        _e_pointer_position_update(ptr);
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_e_pointer_cb_desk_zoom_unset(void *data, int type, void *event)
+{
+   E_Pointer *ptr;
+   Eina_List *l;
+
+   if (!_desk_zoom_enable)
+     return ECORE_CALLBACK_PASS_ON;
+
+   EINA_LIST_FOREACH(_ptrs, l, ptr)
+     {
+        _e_pointer_map_apply(ptr);
+        _e_pointer_position_update(ptr);
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 EINTERN int
 e_pointer_init(void)
 {
+   E_LIST_HANDLER_APPEND(event_handlers, E_EVENT_DESK_ZOOM_SET,
+                         _e_pointer_cb_desk_zoom_set, NULL);
+   E_LIST_HANDLER_APPEND(event_handlers, E_EVENT_DESK_ZOOM_UNSET,
+                         _e_pointer_cb_desk_zoom_unset, NULL);
+
    _initted = EINA_TRUE;
    return 1;
 }
@@ -280,6 +360,8 @@ e_pointer_init(void)
 EINTERN int
 e_pointer_shutdown(void)
 {
+   E_FREE_LIST(event_handlers, ecore_event_handler_del);
+
    _initted = EINA_FALSE;
    return 1;
 }
@@ -562,3 +644,31 @@ e_pointer_hook_del(E_Pointer_Hook *ph)
    else
      _e_pointer_hooks_delete++;
 }
+
+E_API Eina_Bool
+e_pointer_desk_zoom_enable_set(Eina_Bool set)
+{
+   E_Pointer *ptr;
+   Eina_List *l;
+
+   if (_desk_zoom_enable == set)
+     return EINA_TRUE;
+
+   _desk_zoom_enable = set;
+
+   EINA_LIST_FOREACH(_ptrs, l, ptr)
+     {
+        _e_pointer_map_apply(ptr);
+        _e_pointer_position_update(ptr);
+     }
+
+   ELOGF("POINTER", "desk_zoom_enable set:%d", NULL, set);
+
+   return EINA_TRUE;
+}
+
+E_API Eina_Bool
+e_pointer_desk_zoom_enable_get(void)
+{
+   return _desk_zoom_enable;
+}
index 89bd46c..5714f14 100644 (file)
@@ -86,4 +86,7 @@ E_API void       e_pointer_rotation_set(E_Pointer *ptr, int rotation);
 E_API E_Pointer_Hook *e_pointer_hook_add(E_Pointer_Hook_Point hookpoint, E_Pointer_Hook_Cb func, const void *data);
 E_API void            e_pointer_hook_del(E_Pointer_Hook *ch);
 
+E_API Eina_Bool e_pointer_desk_zoom_enable_set(Eina_Bool set);
+E_API Eina_Bool e_pointer_desk_zoom_enable_get(void);
+
 #endif