e_pointer: refactoring e_pointer_object_set() 58/292858/1
authorduna.oh <duna.oh@samsung.com>
Wed, 10 May 2023 07:00:15 +0000 (16:00 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 16 May 2023 04:39:39 +0000 (13:39 +0900)
Change-Id: Ic5c9e2a6c50e30e9a6d12e6d9b8b1f38ee0cd095

src/bin/e_pointer.c

index 17759ea..e084db6 100644 (file)
@@ -241,10 +241,72 @@ e_pointer_canvas_new(Ecore_Evas *ee, Eina_Bool filled)
    return ptr;
 }
 
+static Eina_Bool
+_e_pointer_object_hide(E_Pointer *ptr, Evas_Object *obj)
+{
+   E_Client *ec;
+   Eina_Bool res = EINA_FALSE;
+
+   ec = e_comp_object_client_get(obj);
+   if ((ec) && (!e_object_is_del(E_OBJECT(ec))))
+     {
+        ec->hidden = 1;
+        ec->visible = EINA_FALSE;
+        ec->visibility.obscured = E_VISIBILITY_FULLY_OBSCURED;
+        ec->comp_data->mapped = EINA_FALSE;
+        ec->override = 1; /* ignore the previous cursor_ec */
+     }
+
+   ptr->hwc = EINA_FALSE;
+
+   /* hide cursor object */
+   if (evas_object_visible_get(obj))
+     {
+        res = EINA_TRUE;
+        evas_object_hide(obj);
+     }
+
+   _e_pointer_object_set(ptr, NULL);
+   ptr->device = E_POINTER_NONE;
+
+   return res;
+}
+
+static Eina_Bool
+_e_pointer_object_show(E_Pointer *ptr, Evas_Object *obj)
+{
+   E_Client *ec;
+   Eina_Bool res = EINA_FALSE;
+
+   ec = e_comp_object_client_get(obj);
+   if (ec && e_pixmap_usable_get(ec->pixmap))
+     {
+        ec->hidden = 0;
+        ec->visible = EINA_TRUE;
+        ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
+        evas_object_geometry_set(ec->frame, ec->x, ec->y, ec->w, ec->h);
+        ec->comp_data->mapped = EINA_TRUE;
+        ec->override = 0; /* do not ignore the cursor_ec to set the image object */
+
+        if (e_comp_is_on_overlay(ec))
+          ptr->hwc = EINA_TRUE;
+     }
+
+   /* show cursor object */
+   if (!evas_object_visible_get(obj))
+     {
+        res = EINA_TRUE;
+        evas_object_show(obj);
+     }
+
+   _e_pointer_object_set(ptr, obj);
+
+   return res;
+}
+
 EINTERN void
 e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
 {
-   E_Client *ec;
    Eina_Bool need_call_hide = EINA_FALSE;
 
    EINA_SAFETY_ON_NULL_RETURN(ptr);
@@ -252,39 +314,17 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
    /* don't show cursor if in hidden mode */
    if ((!e_config->show_cursor) || (!e_comp_wl->ptr.enabled))
      {
-        if (ptr->o_ptr && evas_object_visible_get(ptr->o_ptr))
-          {
-             _e_pointer_hook_call(E_POINTER_HOOK_HIDE, ptr);
-             e_pointer_hide(ptr);
-          }
-        _e_pointer_object_set(ptr, NULL);
-        ptr->device = E_POINTER_NONE;
+        if (_e_pointer_object_hide(ptr, ptr->o_ptr))
+          _e_pointer_hook_call(E_POINTER_HOOK_HIDE, ptr);
+
         return;
      }
 
    /* hide and unset the existed ptr->o_ptr */
    if (ptr->o_ptr && (ptr->o_ptr != obj))
      {
-        ec = e_comp_object_client_get(ptr->o_ptr);
-        if ((ec) && (!e_object_is_del(E_OBJECT(ec))))
-          {
-             ec->hidden = 1;
-             ec->visible = EINA_FALSE;
-             ec->visibility.obscured = E_VISIBILITY_FULLY_OBSCURED;
-             ec->comp_data->mapped = EINA_FALSE;
-             ec->override = 1; /* ignore the previous cursor_ec */
-          }
-
-        ptr->hwc = EINA_FALSE;
-
-        /* hide cursor object */
-        if (evas_object_visible_get(ptr->o_ptr))
-          {
-             need_call_hide = EINA_TRUE;
-             e_pointer_hide(ptr);
-          }
-        _e_pointer_object_set(ptr, NULL);
-        ptr->device = E_POINTER_NONE;
+        if (_e_pointer_object_hide(ptr, ptr->o_ptr))
+          need_call_hide = EINA_TRUE;
      }
 
    /* update the hot spot of the cursor */
@@ -294,36 +334,19 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
    /* if obj is not null, set the obj to ptr->o_ptr */
    if (obj && (ptr->o_ptr != obj))
      {
-        ec = e_comp_object_client_get(obj);
-        if (ec && e_pixmap_usable_get(ec->pixmap))
+        if (_e_pointer_object_show(ptr, obj))
           {
-             ec->hidden = 0;
-             ec->visible = EINA_TRUE;
-             ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
-             evas_object_geometry_set(ec->frame, ec->x, ec->y, ec->w, ec->h);
-             ec->comp_data->mapped = EINA_TRUE;
-             ec->override = 0; /* do not ignore the cursor_ec to set the image object */
-
-             if (e_comp_is_on_overlay(ec))
-               ptr->hwc = EINA_TRUE;
+             need_call_hide = EINA_FALSE;
+             _e_pointer_hook_call(E_POINTER_HOOK_SHOW, ptr);
           }
 
-        _e_pointer_object_set(ptr, obj);
-
         /* move the pointer to the current position */
         _e_pointer_position_update(ptr);
 
         /* apply the cursor obj rotation */
         _e_pointer_rotation_apply(ptr);
-
-        /* show cursor object */
-        if (!evas_object_visible_get(ptr->o_ptr))
-          {
-             need_call_hide = EINA_FALSE;
-             _e_pointer_hook_call(E_POINTER_HOOK_SHOW, ptr);
-             evas_object_show(ptr->o_ptr);
-          }
      }
+
    if (need_call_hide)
      _e_pointer_hook_call(E_POINTER_HOOK_HIDE, ptr);
 }