policy: added code to handle indicator information 94/82194/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Mon, 1 Aug 2016 13:15:01 +0000 (22:15 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Mon, 1 Aug 2016 13:15:01 +0000 (22:15 +0900)
Change-Id: Ibf7f5439346a1bf63299c4cb6bb5c2c3e8ce2280

src/bin/e_policy_wl.c
src/bin/e_policy_wl.h
src/bin/services/e_service_gesture.c
src/bin/services/e_service_gesture.h
src/bin/services/e_service_quickpanel.c
src/bin/services/e_service_region.c

index b9673a210097d8c223086a0b3e46f497bd2396a3..ea1646389ee0362dd76baa9a2401617737ecaeaf 100644 (file)
@@ -136,6 +136,12 @@ typedef struct _E_Policy_Wl_Tzlaunch_Img
    Eina_Bool           valid;
 } E_Policy_Wl_Tzlaunch_Img;
 
+typedef struct _E_Policy_Wl_Tz_Indicator
+{
+   struct wl_resource *res_tz_indicator;
+   E_Client           *ec;
+} E_Policy_Wl_Tz_Indicator;
+
 typedef enum _E_Launch_Img_File_type
 {
    E_LAUNCH_FILE_TYPE_ERROR = -1,
@@ -157,6 +163,7 @@ typedef struct _E_Policy_Wl
    Eina_List       *tzsh_clients;            /* list of E_Policy_Wl_Tzsh_Client */
    E_Policy_Wl_Tzsh_Srv *srvs[TZSH_SRV_ROLE_MAX]; /* list of registered E_Policy_Wl_Tzsh_Srv */
    Eina_List       *tvsrv_bind_list;         /* list of activated E_Policy_Wl_Tzsh_Client */
+   Eina_List       *tz_indicators;
 
    /* tizen_launchscreen_interface */
    Eina_List       *tzlaunchs;                   /* list of E_Policy_Wl_Tzlaunch */
@@ -4243,6 +4250,221 @@ _e_policy_wl_cb_scrsaver_off(void *data EINA_UNUSED, int type EINA_UNUSED, void
    return ECORE_CALLBACK_PASS_ON;
 }
 
+// --------------------------------------------------------
+// E_Policy_Wl_Tz_Indicator
+// --------------------------------------------------------
+static E_Policy_Wl_Tz_Indicator *
+_e_policy_wl_tz_indicator_add(struct wl_resource *res_tz_indicator)
+{
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
+
+   tz_indicator = E_NEW(E_Policy_Wl_Tz_Indicator, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, NULL);
+
+   tz_indicator->res_tz_indicator = res_tz_indicator;
+
+   polwl->tz_indicators = eina_list_append(polwl->tz_indicators, tz_indicator);
+
+   return tz_indicator;
+}
+
+static void
+_e_policy_wl_tz_indicator_del(E_Policy_Wl_Tz_Indicator *tz_indicator)
+{
+   EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
+
+   polwl->tz_indicators = eina_list_remove(polwl->tz_indicators, tz_indicator);
+   E_FREE(tz_indicator);
+}
+
+static E_Policy_Wl_Tz_Indicator *
+_e_policy_wl_tz_indicator_get(struct wl_resource *res_tz_indicator)
+{
+   Eina_List *l;
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
+
+   EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
+     {
+        if (tz_indicator->res_tz_indicator == res_tz_indicator)
+          return tz_indicator;
+     }
+   return NULL;
+}
+
+static E_Policy_Wl_Tz_Indicator *
+_e_policy_wl_tz_indicator_get_from_client(E_Client *ec)
+{
+   Eina_List *l;
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
+
+   EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
+     {
+        if (tz_indicator->ec == ec)
+          {
+             return tz_indicator;
+          }
+     }
+
+   return NULL;
+}
+
+static Eina_Bool
+_e_policy_wl_tz_indicator_set_client(struct wl_resource *res_tz_indicator, E_Client *ec)
+{
+   E_Policy_Wl_Tz_Indicator *tz_indicator = NULL;
+
+   tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tz_indicator, EINA_FALSE);
+
+   if (!tz_indicator->ec)
+     {
+        tz_indicator->ec = ec;
+        return EINA_TRUE;
+     }
+   else
+     {
+        if (tz_indicator->ec == ec)
+          {
+             return EINA_TRUE;
+          }
+        else
+          {
+             return EINA_FALSE;
+          }
+     }
+}
+
+static void
+_e_policy_wl_tz_indicator_unset_client(E_Client *ec)
+{
+   Eina_List *l;
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
+
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   EINA_LIST_FOREACH(polwl->tz_indicators, l, tz_indicator)
+     {
+        if (tz_indicator->ec == ec)
+          tz_indicator->ec = NULL;
+     }
+}
+
+static void
+_tz_indicator_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator)
+{
+   wl_resource_destroy(res_tz_indicator);
+}
+
+static void
+_tz_indicator_cb_state_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t state)
+{
+   E_Client *ec;
+
+   ec = wl_resource_get_user_data(surf);
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->frame);
+
+   ELOGF("TZ_IND", "STATE:%d", ec->pixmap, ec, state);
+   _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
+   ec->indicator.state = state;
+}
+
+static void
+_tz_indicator_cb_opacity_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t mode)
+{
+   E_Client *ec;
+
+   ec = wl_resource_get_user_data(surf);
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->frame);
+
+   ELOGF("TZ_IND", "OPACITY_MODE:%d", ec->pixmap, ec, mode);
+   _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
+   ec->indicator.opacity_mode = mode;
+}
+
+static void
+_tz_indicator_cb_visible_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tz_indicator, struct wl_resource *surf, int32_t vtype)
+{
+   E_Client *ec;
+
+   ec = wl_resource_get_user_data(surf);
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->frame);
+
+   ELOGF("TZ_IND", "VIS_TYPE:%d", ec->pixmap, ec, vtype);
+   _e_policy_wl_tz_indicator_set_client(res_tz_indicator, ec);
+   ec->indicator.visible_type = vtype;
+}
+
+// --------------------------------------------------------
+// tizen_indicator_interface
+// --------------------------------------------------------
+static const struct tizen_indicator_interface _tz_indicator_iface =
+{
+   _tz_indicator_cb_destroy,
+   _tz_indicator_cb_state_set,
+   _tz_indicator_cb_opacity_mode_set,
+   _tz_indicator_cb_visible_type_set,
+};
+
+static void
+_tz_indicator_cb_unbind(struct wl_resource *res_tz_indicator)
+{
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
+
+   tz_indicator = _e_policy_wl_tz_indicator_get(res_tz_indicator);
+   EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
+
+   _e_policy_wl_tz_indicator_del(tz_indicator);
+}
+
+static void
+_tz_indicator_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
+{
+   E_Policy_Wl_Tz_Indicator *tz_indicator_pol;
+   struct wl_resource *res_tz_indicator;
+
+   EINA_SAFETY_ON_NULL_GOTO(polwl, err);
+
+   res_tz_indicator = wl_resource_create(client,
+                                         &tizen_indicator_interface,
+                                         ver,
+                                         id);
+   EINA_SAFETY_ON_NULL_GOTO(res_tz_indicator, err);
+
+   tz_indicator_pol = _e_policy_wl_tz_indicator_add(res_tz_indicator);
+   EINA_SAFETY_ON_NULL_GOTO(tz_indicator_pol, err);
+
+   wl_resource_set_implementation(res_tz_indicator,
+                                  &_tz_indicator_iface,
+                                  NULL,
+                                  _tz_indicator_cb_unbind);
+   return;
+
+err:
+   ERR("Could not create tizen_indicator_interface res: %m");
+   wl_client_post_no_memory(client);
+}
+
+void
+e_policy_wl_indicator_flick_send(E_Client *ec)
+{
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
+   struct wl_resource *surf;
+
+   tz_indicator = _e_policy_wl_tz_indicator_get_from_client(ec);
+   EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
+
+   if (ec->comp_data)
+     surf = ec->comp_data->surface;
+   else
+     surf = NULL;
+
+   ELOGF("TZ_IND", "SEND FLICK EVENT", ec->pixmap, ec);
+   tizen_indicator_send_flick(tz_indicator->res_tz_indicator, surf, 0);
+}
+
 static void
 _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
 {
@@ -4288,6 +4510,7 @@ e_policy_wl_client_del(E_Client *ec)
    e_policy_wl_pixmap_del(ec->pixmap);
    _e_policy_wl_tzsh_client_unset(ec);
    _e_policy_wl_dpy_surf_del(ec);
+   _e_policy_wl_tz_indicator_unset_client(ec);
 
    polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
 }
@@ -4392,6 +4615,14 @@ e_policy_wl_init(void)
    EINA_SAFETY_ON_NULL_GOTO(global, err);
    polwl->globals = eina_list_append(polwl->globals, global);
 
+   global = wl_global_create(e_comp_wl->wl.disp,
+                             &tizen_indicator_interface,
+                             1,
+                             NULL,
+                             _tz_indicator_cb_bind);
+   EINA_SAFETY_ON_NULL_GOTO(global, err);
+   polwl->globals = eina_list_append(polwl->globals, global);
+
    polwl->tzpols = eina_hash_pointer_new(_e_policy_wl_tzpol_del);
 
 #ifdef HAVE_CYNARA
@@ -4426,6 +4657,7 @@ e_policy_wl_shutdown(void)
    E_Policy_Wl_Tzsh_Srv *tzsh_srv;
    E_Policy_Wl_Tzlaunch *tzlaunch;
    E_Policy_Wl_Tz_Dpy_Pol *tz_dpy_pol;
+   E_Policy_Wl_Tz_Indicator *tz_indicator;
    struct wl_global *global;
    int i;
 
@@ -4463,6 +4695,9 @@ e_policy_wl_shutdown(void)
    EINA_LIST_FREE(polwl->tzlaunchs, tzlaunch)
      wl_resource_destroy(tzlaunch->res_tzlaunch);
 
+   EINA_LIST_FREE(polwl->tz_indicators, tz_indicator)
+     wl_resource_destroy(tz_indicator->res_tz_indicator);
+
    EINA_LIST_FREE(polwl->globals, global)
      wl_global_destroy(global);
 
index e1aa290b89095744ea348ff6e86bad505393a2d6..d8a2471b4524dfd0fbb259acb36ce7398779f5a7 100644 (file)
@@ -39,5 +39,8 @@ EINTERN void e_tzsh_qp_state_visible_update(E_Client *ec, Eina_Bool vis);
 EINTERN void e_tzsh_qp_state_orientation_update(E_Client *ec, int ridx);
 EINTERN void e_tzsh_qp_state_scrollable_update(E_Client *ec, Eina_Bool scrollable);
 
+/* indicator */
+void         e_policy_wl_indicator_flick_send(E_Client *ec);
+
 #endif /* HAVE_WAYLAND_ONLY */
 #endif /* E_MOD_WL_H */
index 174f307cc23aa7ac02653d6c6af476882ea0e676..b793c786f85003200dc0cc6444b5eaad813e604f 100644 (file)
@@ -7,6 +7,7 @@ struct _E_Policy_Gesture
    E_Policy_Gesture_Type type;
 
    Eina_Bool active;
+   int angle;
 
    struct
    {
@@ -50,9 +51,23 @@ _gesture_line_check(E_Policy_Gesture *gesture, int x, int y)
 
    dx = x - gesture->mouse_info.x;
    dy = y - gesture->mouse_info.y;
-   if ((abs(dy) < sensitivity) &&
-       (abs(dx) < sensitivity))
-     return EINA_FALSE;
+
+   if (gesture->angle == 0 || gesture->angle == 180)
+     {
+        if (abs(dy) < sensitivity)
+          return EINA_FALSE;
+     }
+   else if (gesture->angle == 90 || gesture->angle == 270)
+     {
+        if (abs(dx) < sensitivity)
+          return EINA_FALSE;
+     }
+   else
+     {
+        if ((abs(dy) < sensitivity) &&
+            (abs(dx) < sensitivity))
+          return EINA_FALSE;
+     }
 
    return EINA_TRUE;
 }
@@ -215,3 +230,10 @@ e_service_gesture_cb_set(E_Policy_Gesture *gesture, E_Policy_Gesture_Start_Cb cb
    gesture->cb.end = cb_end;
    gesture->cb.data = data;
 }
+
+EINTERN void
+e_service_gesture_angle_set(E_Policy_Gesture *gesture, int angle)
+{
+   EINA_SAFETY_ON_NULL_RETURN(gesture);
+   gesture->angle = angle;
+}
\ No newline at end of file
index 836bf05a743fd642a35172f2e951d13c96a9cdf4..4326f8750ca0249cb6d3899eb6b6eaceb352bc72 100644 (file)
@@ -19,5 +19,6 @@ typedef void (*E_Policy_Gesture_End_Cb)(void *data, Evas_Object *obj, int x, int
 EINTERN E_Policy_Gesture  *e_service_gesture_add(Evas_Object *obj, E_Policy_Gesture_Type type);
 EINTERN void          e_service_gesture_del(E_Policy_Gesture *gesture);
 EINTERN void          e_service_gesture_cb_set(E_Policy_Gesture *gesture, E_Policy_Gesture_Start_Cb cb_start, E_Policy_Gesture_Move_Cb cb_move, E_Policy_Gesture_End_Cb cb_end, void *data);
+EINTERN void          e_service_gesture_angle_set(E_Policy_Gesture *gesture, int angle);
 
 #endif /* E_SERVICE_GESTURE */
index eec0408c81354f472b220b16fe93bb70174e1d21..7e9acdc2e42beac38165ebd8a6e96182690ae140 100644 (file)
@@ -677,6 +677,33 @@ _mover_obj_effect_visible_get(Evas_Object *mover)
    return md->effect_info.visible;
 }
 
+static Eina_Bool
+_quickpanel_send_gesture_to_indicator(void)
+{
+   E_Client *focused;
+   focused = e_client_focused_get();
+   if (focused)
+     {
+        ELOGF("TZ_IND", "INDICATOR state:%d, opacity:%d, vtype:%d",
+              focused->pixmap, focused, focused->indicator.state, focused->indicator.opacity_mode, focused->indicator.visible_type);
+
+        if (focused->indicator.state == 2) // state: on
+          {
+             if (focused->indicator.visible_type == 0) // visible: hidden
+               {
+                  e_policy_wl_indicator_flick_send(focused);
+                  return EINA_TRUE;
+               }
+          }
+        else if (focused->indicator.state == 1) // state: off
+          {
+             return EINA_TRUE;
+          }
+     }
+
+   return EINA_FALSE;
+}
+
 static void
 _region_obj_cb_gesture_start(void *data, Evas_Object *handler, int x, int y, unsigned int timestamp)
 {
@@ -692,6 +719,9 @@ _region_obj_cb_gesture_start(void *data, Evas_Object *handler, int x, int y, uns
    if (e_object_is_del(E_OBJECT(qp->ec)))
      return;
 
+   if (_quickpanel_send_gesture_to_indicator())
+     return;
+
    if (qp->mover)
      {
         if (_mover_obj_is_animating(qp->mover))
index 331d23fc6072924c589b6c7a78b4ff8e3baafdd9..f59f53bbbc2b73b59e892f5ba1101f7d617f011a 100644 (file)
@@ -36,6 +36,7 @@ _region_rotation_set(E_Policy_Region *region, int angle)
      return;
 
    region->rotation = e_policy_angle_map(angle);
+   e_service_gesture_angle_set(region->gesture, angle);
 }
 
 static void