Change Tizen Nofification Protocol parameter in Wayland 82/40382/3
authorMun, Gwan-gyeong <kk.moon@samsung.com>
Wed, 3 Jun 2015 05:57:14 +0000 (14:57 +0900)
committerMun, Gwan-gyeong <kk.moon@samsung.com>
Wed, 3 Jun 2015 10:51:30 +0000 (19:51 +0900)
Change-Id: Ib307814a2d533e4d0bed3fa64e0daf41f28ae03d

include/efl_util.h
src/efl_util.c
src/tizen_notification-client-protocol.h
src/tizen_notification-protocol.c

index 1d4e244..4934ffa 100644 (file)
@@ -52,9 +52,14 @@ typedef enum
  */
 typedef enum
 {
-   EFL_UTIL_NOTIFICATION_LEVEL_1, /**< Default notification level */
-   EFL_UTIL_NOTIFICATION_LEVEL_2, /**< Higher notification level than default */
-   EFL_UTIL_NOTIFICATION_LEVEL_3, /**< The highest notification level */
+   EFL_UTIL_NOTIFICATION_LEVEL_1, /**< Default notification level. (Deprecated since 2.4. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.) */
+   EFL_UTIL_NOTIFICATION_LEVEL_2, /**< Higher notification level than default. (Deprecated since 2.4. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.) */
+   EFL_UTIL_NOTIFICATION_LEVEL_3, /**< The highest notification level. (Deprecated since 2.4. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.) */
+   EFL_UTIL_NOTIFICATION_LEVEL_NONE    = -1, /**< No (reset) notification level. This value makes the window place in normal layer. (@b Since: 2.4) */
+   EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT = 10, /**< Default notification level. (@b Since: 2.4) */
+   EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM  = 20, /**< Higher notification level than default. (@b Since: 2.4) */
+   EFL_UTIL_NOTIFICATION_LEVEL_HIGH    = 30, /**< Higher notification level than medium. (@b Since: 2.4) */
+   EFL_UTIL_NOTIFICATION_LEVEL_TOP     = 40  /**< The highest notification level. (@b Since: 2.4) */
 } efl_util_notification_level_e; 
 
 /**
index f472db4..e105989 100644 (file)
@@ -60,12 +60,13 @@ static notification_error_cb_info *_notification_error_cb_info_find_by_xwin(unsi
 typedef struct _Surface_Level
 {
    struct wl_surface *surface;
-   uint32_t level;
+   int32_t level;
+   Eina_Bool wait_set_level_done;
 } Surface_Level;
 
 static void _cb_handle_registry_global(void *data, struct wl_registry *registry, unsigned int name, const char *interface, unsigned int version);
 static void _cb_handle_registry_global_remove(void *data, struct wl_registry *registry, unsigned int name);
-static void _notification_set_level_done(void *data, struct tizen_notification *tizen_notification, struct wl_surface *surface, uint32_t level, uint32_t error_state);
+static void _notification_set_level_done(void *data, struct tizen_notification *tizen_notification, struct wl_surface *surface, int32_t level, uint32_t error_state);
 static notification_error_cb_info *_notification_error_cb_info_find_by_wl_surface(struct wl_surface *surface);
 
 static const struct wl_registry_listener _registry_listener =
@@ -110,32 +111,20 @@ static void
 _notification_set_level_done(void *data,
                              struct tizen_notification *tizen_notification,
                              struct wl_surface *surface,
-                             uint32_t level,
+                             int32_t level,
                              uint32_t error_state)
 {
    Surface_Level *sl;
    notification_error_cb_info *cb_info = NULL;
    efl_util_error_e error_cb_state = EFL_UTIL_ERROR_NONE;
 
-   if (error_state == TIZEN_NOTIFICATION_ERROR_STATE_NONE)
+   if (hash_surface_levels)
      {
-        if (hash_surface_levels)
+        sl = eina_hash_find(hash_surface_levels, &surface);
+        if (sl)
           {
-             sl = eina_hash_find(hash_surface_levels, &surface);
-             if (!sl)
-               {
-                  sl = calloc(1, sizeof(Surface_Level));
-                  if (sl)
-                    {
-                       sl->surface = surface;
-                       sl->level = level;
-                       eina_hash_add(hash_surface_levels, &surface, sl);
-                    }
-               }
-             else
-               {
-                  sl->level = level;
-               }
+             sl->level = level;
+             sl->wait_set_level_done = EINA_FALSE;
           }
      }
 
@@ -147,18 +136,9 @@ _notification_set_level_done(void *data,
              case TIZEN_NOTIFICATION_ERROR_STATE_NONE:
                 error_cb_state = EFL_UTIL_ERROR_NONE;
                 break;
-             case TIZEN_NOTIFICATION_ERROR_STATE_INVALID_PARAMETER:
-                error_cb_state = EFL_UTIL_ERROR_INVALID_PARAMETER;
-                break;
-             case TIZEN_NOTIFICATION_ERROR_STATE_OUT_OF_MEMORY:
-                error_cb_state = EFL_UTIL_ERROR_OUT_OF_MEMORY;
-                break;
              case TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED:
-                error_cb_state = EFL_UTIL_ERROR_PERMISSION_DENIED;
-                break;
-             case EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE:
              default:
-                error_cb_state = TIZEN_NOTIFICATION_ERROR_STATE_NOT_SUPPORTED_WINDOW_TYPE;
+                error_cb_state = EFL_UTIL_ERROR_PERMISSION_DENIED;
                 break;
           }
         if (cb_info->err_cb)
@@ -217,6 +197,29 @@ efl_util_set_notification_window_level(Evas_Object *window, efl_util_notificatio
    if (wl_win)
      {
         _efl_util_wl_init();
+
+        if (hash_surface_levels)
+          {
+             Surface_Level *sl;
+             struct wl_surface *surface = ecore_wl_window_surface_get(wl_win);
+             sl = eina_hash_find(hash_surface_levels, &surface);
+             if (!sl)
+               {
+                  sl = calloc(1, sizeof(Surface_Level));
+                  if (sl)
+                    {
+                       sl->surface = surface;
+                       sl->level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
+                       sl->wait_set_level_done = EINA_TRUE;
+                       eina_hash_add(hash_surface_levels, &surface, sl);
+                    }
+               }
+             else
+               {
+                  sl->wait_set_level_done = EINA_TRUE;
+               }
+          }
+
         //Add notification window type check
         tizen_notification_set_level(_tizen_notification,
                                      ecore_wl_window_surface_get(wl_win),
@@ -286,9 +289,28 @@ efl_util_get_notification_window_level(Evas_Object *window, efl_util_notificatio
      {
         Surface_Level *sl;
         struct wl_surface *surface = ecore_wl_window_surface_get(wl_win);
+
         sl = eina_hash_find(hash_surface_levels, &surface);
         if (sl)
           {
+            if (sl->wait_set_level_done)
+              {
+                  if (ecore_wl_window_shell_surface_get(wl_win) ||
+                      ecore_wl_window_xdg_surface_get(wl_win))
+                    {
+                       while (sl->wait_set_level_done)
+                         {
+                            ecore_wl_flush();
+                            wl_display_dispatch(ecore_wl_display_get());
+                         }
+                    }
+                  else
+                    {
+                       *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
+                       return EFL_UTIL_ERROR_INVALID_PARAMETER;
+                    }
+              }
+
             switch (sl->level)
               {
                  case TIZEN_NOTIFICATION_LEVEL_1:
@@ -300,11 +322,30 @@ efl_util_get_notification_window_level(Evas_Object *window, efl_util_notificatio
                  case TIZEN_NOTIFICATION_LEVEL_3:
                    *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
                    break;
+                 case TIZEN_NOTIFICATION_LEVEL_NONE:
+                   *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE;
+                   break;
+                 case TIZEN_NOTIFICATION_LEVEL_DEFAULT:
+                   *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
+                   break;
+                 case TIZEN_NOTIFICATION_LEVEL_MEDIUM:
+                   *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM;
+                   break;
+                 case TIZEN_NOTIFICATION_LEVEL_HIGH:
+                   *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH;
+                   break;
+                 case TIZEN_NOTIFICATION_LEVEL_TOP:
+                   *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP;
                  default:
+                   *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
                    return EFL_UTIL_ERROR_INVALID_PARAMETER;
               }
             return EFL_UTIL_ERROR_NONE;
           }
+        else
+          {
+             *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
+          }
      }
 #endif
    return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
index cfe16e8..a285045 100644 (file)
@@ -22,6 +22,11 @@ enum tizen_notification_level {
        TIZEN_NOTIFICATION_LEVEL_1 = 0,
        TIZEN_NOTIFICATION_LEVEL_2 = 1,
        TIZEN_NOTIFICATION_LEVEL_3 = 2,
+       TIZEN_NOTIFICATION_LEVEL_NONE = -1,
+       TIZEN_NOTIFICATION_LEVEL_DEFAULT = 10,
+       TIZEN_NOTIFICATION_LEVEL_MEDIUM = 20,
+       TIZEN_NOTIFICATION_LEVEL_HIGH = 30,
+       TIZEN_NOTIFICATION_LEVEL_TOP = 40,
 };
 #endif /* TIZEN_NOTIFICATION_LEVEL_ENUM */
 
@@ -29,10 +34,7 @@ enum tizen_notification_level {
 #define TIZEN_NOTIFICATION_ERROR_STATE_ENUM
 enum tizen_notification_error_state {
        TIZEN_NOTIFICATION_ERROR_STATE_NONE = 0,
-       TIZEN_NOTIFICATION_ERROR_STATE_INVALID_PARAMETER = 1,
-       TIZEN_NOTIFICATION_ERROR_STATE_OUT_OF_MEMORY = 2,
-       TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED = 3,
-       TIZEN_NOTIFICATION_ERROR_STATE_NOT_SUPPORTED_WINDOW_TYPE = 4,
+       TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED = 1,
 };
 #endif /* TIZEN_NOTIFICATION_ERROR_STATE_ENUM */
 
@@ -46,7 +48,7 @@ struct tizen_notification_listener {
        void (*done)(void *data,
                     struct tizen_notification *tizen_notification,
                     struct wl_surface *surface,
-                    uint32_t level,
+                    int32_t level,
                     uint32_t error_state);
 };
 
@@ -79,7 +81,7 @@ tizen_notification_destroy(struct tizen_notification *tizen_notification)
 }
 
 static inline void
-tizen_notification_set_level(struct tizen_notification *tizen_notification, struct wl_surface *surface, uint32_t level)
+tizen_notification_set_level(struct tizen_notification *tizen_notification, struct wl_surface *surface, int32_t level)
 {
        wl_proxy_marshal((struct wl_proxy *) tizen_notification,
                         TIZEN_NOTIFICATION_SET_LEVEL, surface, level);
index 36c4475..1138b56 100644 (file)
@@ -13,11 +13,11 @@ static const struct wl_interface *types[] = {
 };
 
 static const struct wl_message tizen_notification_requests[] = {
-       { "set_level", "ou", types + 0 },
+       { "set_level", "oi", types + 0 },
 };
 
 static const struct wl_message tizen_notification_events[] = {
-       { "done", "ouu", types + 2 },
+       { "done", "oiu", types + 2 },
 };
 
 WL_EXPORT const struct wl_interface tizen_notification_interface = {