e_zone: functionization the generic event emit 51/321951/1
authorJunseok Kim <juns.kim@samsung.com>
Thu, 20 Mar 2025 02:15:15 +0000 (11:15 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 1 Apr 2025 09:18:24 +0000 (18:18 +0900)
Change-Id: I8f61f264c703d1ac91b3cc5d96e7e86aacf2101f

src/bin/core/e_zone.c
src/bin/core/e_zone_intern.h

index 7cbbc66744f14fca12ff5ab3db82ccbc364d74d5..6cdc1a300dc8d586e5a26c93dff2ba7fde1fa788 100644 (file)
@@ -183,7 +183,6 @@ EINTERN E_Zone *
 e_zone_new(int num, int id, int x, int y, int w, int h)
 {
    E_Zone *zone;
-   E_Event_Zone_Add *ev;
    E_Zone_Private *zone_priv;
    E_View_Tree *layer_tree;
    E_View_Rect *rect;
@@ -246,13 +245,8 @@ e_zone_new(int num, int id, int x, int y, int w, int h)
 
    if (starting) return zone;
 
-   ev = E_NEW(E_Event_Zone_Add, 1);
-   if (ev)
-     {
-        ev->zone = zone;
-        e_object_ref(E_OBJECT(ev->zone));
-        ecore_event_add(E_EVENT_ZONE_ADD, ev, _e_zone_event_generic_free, NULL);
-     }
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_ADD))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 
    return zone;
 }
@@ -282,7 +276,6 @@ e_zone_move(E_Zone *zone,
             int x,
             int y)
 {
-   E_Event_Zone_Move_Resize *ev;
    int dx, dy;
    E_View_Rect *bg_event_view_rect, *bg_clip_view_rect;
 
@@ -302,13 +295,8 @@ e_zone_move(E_Zone *zone,
    e_view_position_set(e_view_rect_view_get(bg_event_view_rect), x, y);
    e_view_position_set(e_view_rect_view_get(bg_clip_view_rect), x, y);
 
-   ev = E_NEW(E_Event_Zone_Move_Resize, 1);
-   if (ev)
-     {
-        ev->zone = zone;
-        e_object_ref(E_OBJECT(ev->zone));
-        ecore_event_add(E_EVENT_ZONE_MOVE_RESIZE, ev, _e_zone_event_generic_free, NULL);
-     }
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_MOVE_RESIZE))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 
    E_Zone_Data_Move_Resize move_resize_data = {0,};
    move_resize_data.dx = dx;
@@ -321,7 +309,6 @@ e_zone_resize(E_Zone *zone,
               int w,
               int h)
 {
-   E_Event_Zone_Move_Resize *ev;
    int dw, dh;
 
    E_OBJECT_CHECK(zone);
@@ -337,14 +324,8 @@ e_zone_resize(E_Zone *zone,
    e_view_rect_size_set(PRI(zone)->bg_event_view_rect, w, h);
    e_view_rect_size_set(PRI(zone)->bg_clip_view_rect, w, h);
 
-   ev = E_NEW(E_Event_Zone_Move_Resize, 1);
-   if (ev)
-     {
-        ev->zone = zone;
-        e_object_ref(E_OBJECT(ev->zone));
-        ecore_event_add(E_EVENT_ZONE_MOVE_RESIZE, ev,
-                        _e_zone_event_generic_free, NULL);
-     }
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_MOVE_RESIZE))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 
    E_Zone_Data_Move_Resize move_resize_data = {0,};
    move_resize_data.dw = dw;
@@ -359,7 +340,6 @@ e_zone_move_resize(E_Zone *zone,
                    int w,
                    int h)
 {
-   E_Event_Zone_Move_Resize *ev;
    int dx, dy, dw, dh;
    E_View_Rect *bg_event_view_rect, *bg_clip_view_rect;
 
@@ -386,14 +366,8 @@ e_zone_move_resize(E_Zone *zone,
    e_view_position_set(e_view_rect_view_get(bg_event_view_rect), x, y);
    e_view_position_set(e_view_rect_view_get(bg_clip_view_rect), x, y);
 
-   ev = E_NEW(E_Event_Zone_Move_Resize, 1);
-   if (ev)
-     {
-        ev->zone = zone;
-        e_object_ref(E_OBJECT(ev->zone));
-        ecore_event_add(E_EVENT_ZONE_MOVE_RESIZE, ev,
-                        _e_zone_event_generic_free, NULL);
-     }
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_MOVE_RESIZE))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 
    E_Zone_Data_Move_Resize move_resize_data = {0,};
    move_resize_data.dx = dx;
@@ -478,7 +452,6 @@ e_zone_desk_count_set(E_Zone *zone,
                       int x_count,
                       int y_count)
 {
-   E_Event_Zone_Desk_Count_Set *ev;
    E_Zone_Data_Desk_Count_Set desk_count_data = {0,};
 
    desk_count_data.x_count = x_count;
@@ -486,12 +459,8 @@ e_zone_desk_count_set(E_Zone *zone,
 
    wl_signal_emit(&PRI(zone)->events.desk_count_set, &desk_count_data);
 
-   ev = E_NEW(E_Event_Zone_Desk_Count_Set, 1);
-   if (!ev) return;
-   ev->zone = zone;
-   e_object_ref(E_OBJECT(ev->zone));
-   ecore_event_add(E_EVENT_ZONE_DESK_COUNT_SET, ev,
-                   _e_zone_event_generic_free, NULL);
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_DESK_COUNT_SET))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 }
 
 EINTERN Eina_Bool
@@ -585,23 +554,16 @@ e_zone_desk_useful_geometry_get(E_Zone *zone, E_Desk *desk, int *x, int *y, int
 EINTERN void
 e_zone_useful_geometry_dirty(E_Zone *zone)
 {
-   E_Event_Zone_Useful_Geometry_Change *ev;
-
    E_OBJECT_CHECK(zone);
    E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
 
-   ev = E_NEW(E_Event_Zone_Useful_Geometry_Change, 1);
-   if (!ev) return;
-   ev->zone = zone;
-   e_object_ref(E_OBJECT(ev->zone));
-   ecore_event_add(E_EVENT_ZONE_USEFUL_GEOMETRY_CHANGE, ev, _e_zone_event_generic_free, NULL);
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_USEFUL_GEOMETRY_CHANGE))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 }
 
 E_API void
 e_zone_display_state_set(E_Zone *zone, E_Zone_Display_State state)
 {
-   E_Event_Zone_Display_State_Change *ev;
-
    E_OBJECT_CHECK(zone);
    E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
 
@@ -609,11 +571,8 @@ e_zone_display_state_set(E_Zone *zone, E_Zone_Display_State state)
 
    _e_zone_hook_call(E_ZONE_HOOK_DISPLAY_STATE_CHANGE, zone);
 
-   ev = E_NEW(E_Event_Zone_Display_State_Change, 1);
-   if (!ev) return;
-   ev->zone = zone;
-   e_object_ref(E_OBJECT(ev->zone));
-   ecore_event_add(E_EVENT_ZONE_DISPLAY_STATE_CHANGE, ev, _e_zone_event_generic_free, NULL);
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_DISPLAY_STATE_CHANGE))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 }
 
 E_API E_Zone_Display_State
@@ -725,15 +684,12 @@ static void
 _e_zone_object_del_attach(void *o)
 {
    E_Zone *zone;
-   E_Event_Zone_Del *ev;
 
    zone = o;
    if (stopping) return;
-   ev = E_NEW(E_Event_Zone_Del, 1);
-   if (!ev) return;
-   ev->zone = zone;
-   e_object_ref(E_OBJECT(ev->zone));
-   ecore_event_add(E_EVENT_ZONE_DEL, ev, _e_zone_event_generic_free, NULL);
+
+   if (!e_zone_generic_event_emit(zone, E_EVENT_ZONE_DEL))
+     ELOGF("ZONE", "Failed to add zone event, zone:%p", NULL, zone);
 }
 
 static void
@@ -1104,6 +1060,31 @@ e_zone_client_set_event_emit(E_Zone *zone, E_Client *ec)
    ecore_event_add(E_EVENT_CLIENT_ZONE_SET, ev, (Ecore_End_Cb)_e_client_event_zone_set_free, NULL);
 }
 
+EINTERN Eina_Bool
+e_zone_generic_event_emit(E_Zone *zone, int event)
+{
+   struct _E_Event_Zone_Generic *ev;
+
+   if ((event != E_EVENT_ZONE_ADD) &&
+       (event != E_EVENT_ZONE_MOVE_RESIZE) &&
+       (event != E_EVENT_ZONE_DESK_COUNT_SET) &&
+       (event != E_EVENT_ZONE_USEFUL_GEOMETRY_CHANGE) &&
+       (event != E_EVENT_ZONE_DISPLAY_STATE_CHANGE) &&
+       (event != E_EVENT_ZONE_DEL))
+     {
+        ERR("not supported event: %d", event);
+        return EINA_FALSE;
+     }
+
+   ev = E_NEW(struct _E_Event_Zone_Generic, 1);
+   if (!ev) return EINA_FALSE;
+
+   ev->zone = zone;
+   e_object_ref(E_OBJECT(ev->zone));
+   ecore_event_add(event, ev, _e_zone_event_generic_free, NULL);
+   return EINA_TRUE;
+}
+
 EINTERN E_Client *
 e_zone_client_top_get(E_Zone *zone)
 {
index 1834ba425bdc9bef09537f170a2a7933cdea2941..04af1fe0152ae8f9ef10eb56c63c84e7ea188df3 100644 (file)
@@ -124,6 +124,7 @@ EINTERN Eina_Bool e_zone_obstacle_update(E_Zone *zone, E_Client *ec, Eina_Rectan
 EINTERN void      e_zone_obstacle_remove(E_Zone *zone, E_Client *ec);
 
 EINTERN void      e_zone_client_set_event_emit(E_Zone *zone, E_Client *ec);
+EINTERN Eina_Bool e_zone_generic_event_emit(E_Zone *zone, int event);
 
 EINTERN E_Client *e_zone_client_top_get(E_Zone *zone);
 EINTERN E_Client *e_zone_client_bottom_get(E_Zone *zone);