e_policy: Add a function to call aux_message_send with variable arguments 13/112713/3
authorSeungjin Park <sj8808.park@samsung.com>
Thu, 2 Feb 2017 09:44:14 +0000 (18:44 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Mon, 6 Feb 2017 23:20:37 +0000 (15:20 -0800)
Signed-off-by: Seungjin Park <sj8808.park@samsung.com>
Change-Id: I48d27a34aab0af73b41a026357c1ac7607884097

src/bin/e_policy.c
src/bin/e_policy.h
src/bin/e_policy_wl.c

index 3739794c2d041abf2b4dc3ac712fe0027c2d2929..8c949ccddf416f936377406e1619b460c593c4f3 100644 (file)
@@ -1290,8 +1290,6 @@ _e_policy_client_stack_change_send(E_Client *ec)
    E_Client *below = NULL;
    int above_pid = -1;
    int below_pid = -1;
-   char above_pid_s[4096] = {0,};
-   char below_pid_s[4096] = {0,};
 
    above = _e_policy_client_find_above(ec);
    below = _e_policy_client_find_below(ec);
@@ -1299,19 +1297,10 @@ _e_policy_client_stack_change_send(E_Client *ec)
    if (above) above_pid = above->netwm.pid;
    if (below) below_pid = below->netwm.pid;
 
-   eina_convert_itoa(above_pid, above_pid_s);
-   eina_convert_itoa(below_pid, below_pid_s);
-   ELOGF("TZPOL", "Send stack change.  above(win:%x, pid:%s), below(win:%x, pid:%s)",
-         ec->pixmap, ec, e_client_util_win_get(above), above_pid_s, e_client_util_win_get(below), below_pid_s);
+   ELOGF("TZPOL", "Send stack change.  above(win:%x, pid:%d), below(win:%x, pid:%d)",
+         ec->pixmap, ec, e_client_util_win_get(above), above_pid, e_client_util_win_get(below), below_pid);
 
-   Eina_List *options = NULL;
-
-   options = eina_list_append(options, above_pid_s);
-   options = eina_list_append(options, below_pid_s);
-
-   e_policy_aux_message_send(ec, "stack_changed", "pid", options);
-
-   eina_list_free(options);
+   e_policy_aux_message_send_from_int(ec, "stack_changed", "pid", 2, above_pid, below_pid);
 }
 
 static Eina_Bool
@@ -1962,6 +1951,33 @@ e_policy_aux_message_use_get(E_Client *ec)
    return EINA_FALSE;
 }
 
+E_API void
+e_policy_aux_message_send_from_int(E_Client *ec, const char *key, const char *val, int count, ...)
+{
+   char option[4096];
+   char *str_itor;
+   Eina_List *options_list = NULL;
+   va_list opt_args;
+   int opt;
+   int itor;
+
+   va_start(opt_args, count);
+   for(itor = 0; itor < count; itor ++)
+    {
+       opt = va_arg(opt_args, int);
+       eina_convert_itoa(opt, option);
+       options_list = eina_list_append(options_list, eina_stringshare_add(option));
+    }
+   va_end(opt_args);
+
+   e_policy_aux_message_send(ec, key, val, options_list);
+
+   EINA_LIST_FREE(options_list, str_itor)
+    {
+       eina_stringshare_del(str_itor);
+    }
+}
+
 E_API void
 e_policy_aux_message_send(E_Client *ec, const char *key, const char *val, Eina_List *options)
 {
index 084e894cdda891ab75d89678c51d9c6a5bded381..7506b2b707621ea1296549c82ce48fa15078cad8 100644 (file)
@@ -171,6 +171,7 @@ EINTERN void             e_policy_event_simple(E_Client *ec, int type);
 
 E_API Eina_Bool e_policy_aux_message_use_get(E_Client *ec);
 E_API void      e_policy_aux_message_send(E_Client *ec, const char *key, const char *val, Eina_List *options);
+E_API void      e_policy_aux_message_send_from_int(E_Client *ec, const char *key, const char *val, int count, ...);
 
 E_API E_Policy_Interceptor *e_policy_interceptor_add(E_Policy_Intercept_Point ipoint, E_Policy_Intercept_Cb func, const void *data);
 E_API void                  e_policy_interceptor_del(E_Policy_Interceptor *pi);
index 349506f529581b22bc1670d8d9f0b38875b95bf0..a4c62d2fb9f944353d848ebcc96f25419605fdb3 100644 (file)
@@ -1297,9 +1297,6 @@ e_policy_wl_stack_changed_send(E_Client *ec)
    E_Client *below = NULL;
    int above_pid = -1;
    int below_pid = -1;
-   char above_pid_s[4096] = {0,};
-   char below_pid_s[4096] = {0,};
-   Eina_List *options = NULL;
 
    above = e_client_above_get(ec);
    while (above)
@@ -1328,18 +1325,12 @@ e_policy_wl_stack_changed_send(E_Client *ec)
    if (above) above_pid = above->netwm.pid;
    if (below) below_pid = below->netwm.pid;
 
-   eina_convert_itoa(above_pid, above_pid_s);
-   eina_convert_itoa(below_pid, below_pid_s);
-
    ELOGF("TZPOL", "Send stack_changed by activate_below. above(win:%x, pid:%d), below(win:%x, pid:%d)",
          ec->pixmap, ec, e_client_util_win_get(above), above_pid, e_client_util_win_get(below), below_pid);
 
-   options = eina_list_append(options, above_pid_s);
-   options = eina_list_append(options, below_pid_s);
 
-   e_policy_aux_message_send(ec, "stack_changed", "activate_below", options);
+   e_policy_aux_message_send_from_int(ec, "stack_changed", "activate_below", 2, above_pid, below_pid);
 
-   eina_list_free(options);
 }
 
 static void