e_policy_wl: support interactive_move/resize_done event of tizen_policy 73/282273/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Sat, 24 Sep 2022 04:06:33 +0000 (13:06 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 29 Sep 2022 08:48:15 +0000 (17:48 +0900)
Change-Id: Iff61f5cee2b2e214188780112587822a3264c7a5

src/bin/e_policy_wl.c

index 67c9b09..11b92e5 100644 (file)
@@ -241,6 +241,7 @@ typedef struct _E_Tzsh_QP_Event
 static E_Policy_Wl *polwl = NULL;
 
 static Eina_List *handlers = NULL;
+static Eina_List *polwl_hooks_ec = NULL;
 static Eina_List *hooks_cw = NULL;
 static Eina_List *hooks_co = NULL;
 static struct wl_resource *_scrsaver_mng_res = NULL; // TODO
@@ -7838,6 +7839,102 @@ _e_policy_wl_cb_hook_alpha_change(void *data, E_Client *ec)
      }
 }
 
+static void
+_e_policy_wl_client_cb_resize_end(void *data EINA_UNUSED, E_Client *ec)
+{
+   int x, y, w, h;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
+
+   if (ec->manage_resize.resize_obj)
+     {
+        x = ec->manage_resize.x;
+        y = ec->manage_resize.y;
+        w = ec->manage_resize.w;
+        h = ec->manage_resize.h;
+     }
+   else
+     {
+        x = ec->x;
+        y = ec->y;
+        w = ec->w;
+        h = ec->h;
+        e_client_geometry_get(ec, &x, &y, &w, &h);
+     }
+
+   E_Policy_Wl_Tzpol *tzpol;
+   E_Policy_Wl_Surface *psurf;
+   Eina_List *l;
+   Eina_Iterator *it;
+   int ver = -1;
+
+   it = eina_hash_iterator_data_new(polwl->tzpols);
+   EINA_ITERATOR_FOREACH(it, tzpol)
+     {
+        EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
+          {
+             if (e_pixmap_client_get(psurf->cp) != ec) continue;
+             if (!psurf->surf) continue;
+
+             ver = wl_resource_get_version(tzpol->res_tzpol);
+             if (ver < 10)
+               {
+                  // interactive_resize_done event is supported since ver 10
+                  continue;
+               }
+
+             tizen_policy_send_interactive_resize_done(tzpol->res_tzpol,
+                                                       psurf->surf, x, y, w, h,
+                                                       ec->e.state.rot.ang.curr);
+          }
+     }
+   eina_iterator_free(it);
+}
+
+static void
+_e_policy_wl_client_cb_move_end(void *data EINA_UNUSED, E_Client *ec)
+{
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
+
+   int x, y, w, h;
+   x = ec->x;
+   y = ec->y;
+   w = ec->w;
+   h = ec->h;
+   e_client_geometry_get(ec, &x, &y, &w, &h);
+
+   E_Policy_Wl_Tzpol *tzpol;
+   E_Policy_Wl_Surface *psurf;
+   Eina_List *l;
+   Eina_Iterator *it;
+   int ver = -1;
+
+   it = eina_hash_iterator_data_new(polwl->tzpols);
+   EINA_ITERATOR_FOREACH(it, tzpol)
+     {
+        EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
+          {
+             if (e_pixmap_client_get(psurf->cp) != ec) continue;
+             if (!psurf->surf) continue;
+
+             ver = wl_resource_get_version(tzpol->res_tzpol);
+             if (ver < 10)
+               {
+                  // interactive_move_done event is supported since ver 10
+                  continue;
+               }
+
+             tizen_policy_send_interactive_move_done(tzpol->res_tzpol,
+                                                     psurf->surf,
+                                                     x, y, w, h,
+                                                     ec->e.state.rot.ang.curr);
+          }
+     }
+   eina_iterator_free(it);
+}
+
 void
 e_policy_wl_generate_request(E_Client *ec, E_Policy_Wl_Gen_Request type)
 {
@@ -8059,7 +8156,7 @@ e_policy_wl_init(void)
    /* create globals */
    global = wl_global_create(e_comp_wl->wl.disp,
                              &tizen_policy_interface,
-                             9,
+                             10,
                              NULL,
                              _tzpol_cb_bind);
    EINA_SAFETY_ON_NULL_GOTO(global, err);
@@ -8108,6 +8205,9 @@ e_policy_wl_init(void)
    E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_policy_wl_cb_hook_shell_surface_ready, NULL);
    E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, _e_policy_wl_cb_hook_alpha_change, NULL);
 
+   E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_RESIZE_END, _e_policy_wl_client_cb_resize_end, NULL);
+   E_LIST_HOOK_APPEND(polwl_hooks_ec, E_CLIENT_HOOK_MOVE_END, _e_policy_wl_client_cb_move_end, NULL);
+
    E_EVENT_POLICY_INDICATOR_STATE_CHANGE = ecore_event_type_new();
    E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = ecore_event_type_new();
    E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = ecore_event_type_new();
@@ -8145,6 +8245,7 @@ e_policy_wl_shutdown(void)
 
    EINA_SAFETY_ON_NULL_RETURN(polwl);
 
+   E_FREE_LIST(polwl_hooks_ec, e_client_hook_del);
    E_FREE_LIST(hooks_cw, e_comp_wl_hook_del);
    E_FREE_LIST(hooks_co, e_comp_object_intercept_hook_del);
    E_FREE_LIST(handlers, ecore_event_handler_del);