added code to handle indicator information
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 2 Aug 2016 04:09:37 +0000 (13:09 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Wed, 3 Aug 2016 11:41:12 +0000 (20:41 +0900)
Change-Id: I04dffae9153b98bed9fc8b02da81c168be3cdb9e

src/e_mod_wl.c
src/e_mod_wl.h
src/services/e_mod_gesture.c
src/services/e_mod_gesture.h
src/services/e_mod_quickpanel.c
src/services/e_mod_region.c

index 7982476..cce64f7 100644 (file)
@@ -136,6 +136,12 @@ typedef struct _Pol_Wl_Tzlaunch_Img
    Eina_Bool           valid;
 } Pol_Wl_Tzlaunch_Img;
 
+typedef struct _Pol_Wl_Tz_Indicator
+{
+   struct wl_resource *res_tz_indicator;
+   E_Client           *ec;
+} Pol_Wl_Tz_Indicator;
+
 typedef enum _E_Launch_Img_File_type
 {
    E_LAUNCH_FILE_TYPE_ERROR = -1,
@@ -157,6 +163,7 @@ typedef struct _Pol_Wl
    Eina_List       *tzsh_clients;            /* list of Pol_Wl_Tzsh_Client */
    Pol_Wl_Tzsh_Srv *srvs[TZSH_SRV_ROLE_MAX]; /* list of registered Pol_Wl_Tzsh_Srv */
    Eina_List       *tvsrv_bind_list;         /* list of activated Pol_Wl_Tzsh_Client */
+   Eina_List       *tz_indicators;
 
    /* tizen_launchscreen_interface */
    Eina_List       *tzlaunchs;                   /* list of Pol_Wl_Tzlaunch */
@@ -4242,6 +4249,221 @@ _pol_wl_cb_scrsaver_off(void *data EINA_UNUSED, int type EINA_UNUSED, void *even
    return ECORE_CALLBACK_PASS_ON;
 }
 
+// --------------------------------------------------------
+// Pol_Wl_Tz_Indicator
+// --------------------------------------------------------
+static Pol_Wl_Tz_Indicator *
+_pol_wl_tz_indicator_add(struct wl_resource *res_tz_indicator)
+{
+   Pol_Wl_Tz_Indicator *tz_indicator;
+
+   tz_indicator = E_NEW(Pol_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
+_pol_wl_tz_indicator_del(Pol_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 Pol_Wl_Tz_Indicator *
+_pol_wl_tz_indicator_get(struct wl_resource *res_tz_indicator)
+{
+   Eina_List *l;
+   Pol_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 Pol_Wl_Tz_Indicator *
+_pol_wl_tz_indicator_get_from_client(E_Client *ec)
+{
+   Eina_List *l;
+   Pol_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
+_pol_wl_tz_indicator_set_client(struct wl_resource *res_tz_indicator, E_Client *ec)
+{
+   Pol_Wl_Tz_Indicator *tz_indicator = NULL;
+
+   tz_indicator = _pol_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
+_pol_wl_tz_indicator_unset_client(E_Client *ec)
+{
+   Eina_List *l;
+   Pol_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);
+   _pol_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);
+   _pol_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);
+   _pol_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)
+{
+   Pol_Wl_Tz_Indicator *tz_indicator;
+
+   tz_indicator = _pol_wl_tz_indicator_get(res_tz_indicator);
+   EINA_SAFETY_ON_NULL_RETURN(tz_indicator);
+
+   _pol_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)
+{
+   Pol_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 = _pol_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_mod_pol_wl_indicator_flick_send(E_Client *ec)
+{
+   Pol_Wl_Tz_Indicator *tz_indicator;
+   struct wl_resource *surf;
+
+   tz_indicator = _pol_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
 _pol_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
 {
@@ -4287,6 +4509,7 @@ e_mod_pol_wl_client_del(E_Client *ec)
    e_mod_pol_wl_pixmap_del(ec->pixmap);
    _pol_wl_tzsh_client_unset(ec);
    _pol_wl_dpy_surf_del(ec);
+   _pol_wl_tz_indicator_unset_client(ec);
 
    polwl->pending_vis = eina_list_remove(polwl->pending_vis, ec);
 }
@@ -4391,6 +4614,14 @@ e_mod_pol_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(_pol_wl_tzpol_del);
 
 #ifdef ENABLE_CYNARA
@@ -4425,6 +4656,7 @@ e_mod_pol_wl_shutdown(void)
    Pol_Wl_Tzsh_Srv *tzsh_srv;
    Pol_Wl_Tzlaunch *tzlaunch;
    Pol_Wl_Tz_Dpy_Pol *tz_dpy_pol;
+   Pol_Wl_Tz_Indicator *tz_indicator;
    struct wl_global *global;
    int i;
 
@@ -4462,6 +4694,9 @@ e_mod_pol_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 29d976f..689bd4a 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_mod_pol_wl_indicator_flick_send(E_Client *ec);
+
 #endif /* HAVE_WAYLAND_ONLY */
 #endif /* E_MOD_WL_H */
index 30bda2f..41159bf 100644 (file)
@@ -7,6 +7,7 @@ struct _Pol_Gesture
    Pol_Gesture_Type type;
 
    Eina_Bool active;
+   int angle;
 
    struct
    {
@@ -50,9 +51,23 @@ _gesture_line_check(Pol_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_mod_gesture_cb_set(Pol_Gesture *gesture, Pol_Gesture_Start_Cb cb_start, Pol_Ge
    gesture->cb.end = cb_end;
    gesture->cb.data = data;
 }
+
+EINTERN void
+e_mod_gesture_angle_set(Pol_Gesture *gesture, int angle)
+{
+   EINA_SAFETY_ON_NULL_RETURN(gesture);
+   gesture->angle = angle;
+}
index 89c5c83..033cb32 100644 (file)
@@ -17,5 +17,7 @@ typedef void (*Pol_Gesture_End_Cb)(void *data, Evas_Object *obj, int x, int y, u
 EINTERN Pol_Gesture  *e_mod_gesture_add(Evas_Object *obj, Pol_Gesture_Type type);
 EINTERN void          e_mod_gesture_del(Pol_Gesture *gesture);
 EINTERN void          e_mod_gesture_cb_set(Pol_Gesture *gesture, Pol_Gesture_Start_Cb cb_start, Pol_Gesture_Move_Cb cb_move, Pol_Gesture_End_Cb cb_end, void *data);
+EINTERN void          e_mod_gesture_angle_set(Pol_Gesture *gesture, int angle);
+
 
 #endif /* E_MOD_GESTURE */
index 8b62d83..e7b518d 100644 (file)
@@ -679,6 +679,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_mod_pol_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)
 {
@@ -694,6 +721,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 e8ee21c..69ff9cc 100644 (file)
@@ -38,6 +38,7 @@ _region_rotation_set(Pol_Region *region, int angle)
      return;
 
    region->rotation = e_mod_rotation_angle_to_idx(angle);
+   e_mod_gesture_angle_set(region->gesture, angle);
 }
 
 static void