From 7cc6a8b0781252f5f62580b14c33e979ae00d945 Mon Sep 17 00:00:00 2001 From: Seungjin Park Date: Thu, 2 Feb 2017 18:44:14 +0900 Subject: [PATCH] e_policy: Add a function to call aux_message_send with variable arguments Signed-off-by: Seungjin Park Change-Id: I48d27a34aab0af73b41a026357c1ac7607884097 --- src/bin/e_policy.c | 44 +++++++++++++++++++++++++++++-------------- src/bin/e_policy.h | 1 + src/bin/e_policy_wl.c | 11 +---------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/bin/e_policy.c b/src/bin/e_policy.c index 3739794c2d..8c949ccddf 100644 --- a/src/bin/e_policy.c +++ b/src/bin/e_policy.c @@ -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) { diff --git a/src/bin/e_policy.h b/src/bin/e_policy.h index 084e894cdd..7506b2b707 100644 --- a/src/bin/e_policy.h +++ b/src/bin/e_policy.h @@ -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); diff --git a/src/bin/e_policy_wl.c b/src/bin/e_policy_wl.c index 349506f529..a4c62d2fb9 100644 --- a/src/bin/e_policy_wl.c +++ b/src/bin/e_policy_wl.c @@ -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 -- 2.34.1