From 6bc2d0eae3d8071fc6c624e1a9dec0664acd3848 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Tue, 30 Dec 2014 21:00:33 +0900 Subject: [PATCH] Modify system event callback appcore passes system event information to application. Change-Id: Iad10469457c96c331dd260415f5238e6978419ba Signed-off-by: Jiwoong Im --- include/appcore-common.h | 4 ++-- include/appcore-internal.h | 4 ++-- src/appcore-efl.c | 6 +++--- src/appcore-rotation.c | 12 ++++++------ src/appcore.c | 27 ++++++++++++++++++++------- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/include/appcore-common.h b/include/appcore-common.h index cd61e01..1201b6d 100755 --- a/include/appcore-common.h +++ b/include/appcore-common.h @@ -201,7 +201,7 @@ int add_callbacks(struct appdata *data) * */ int appcore_set_event_callback(enum appcore_event event, - int (*cb)(void *), void *data); + int (*cb)(void *, void *), void *data); /** * @par Description: @@ -255,7 +255,7 @@ static int _rot_cb(enum appcore_rm, void *); * @endcode * */ -int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *), +int appcore_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data); /** diff --git a/include/appcore-internal.h b/include/appcore-internal.h index 038e2dc..1d88353 100755 --- a/include/appcore-internal.h +++ b/include/appcore-internal.h @@ -132,7 +132,7 @@ enum sys_event { * Appcore system event operation */ struct sys_op { - int (*func) (void *); + int (*func) (void *, void *); void *data; }; @@ -170,7 +170,7 @@ int appcore_pause_rotation_cb(void); int appcore_resume_rotation_cb(void); struct ui_wm_rotate { - int (*set_rotation_cb) (int (*cb) (enum appcore_rm, void *), void *data); + int (*set_rotation_cb) (int (*cb) (void *event_info, enum appcore_rm, void *), void *data); int (*unset_rotation_cb) (void); int (*get_rotation_state) (enum appcore_rm *curr); int (*pause_rotation_cb) (void); diff --git a/src/appcore-efl.c b/src/appcore-efl.c index 9ef5f96..969fe3c 100644 --- a/src/appcore-efl.c +++ b/src/appcore-efl.c @@ -96,7 +96,7 @@ struct ui_priv { /* WM_ROTATE */ int wm_rot_supported; int rot_started; - int (*rot_cb) (enum appcore_rm, void *); + int (*rot_cb) (void *event_info, enum appcore_rm, void *); void *rot_cb_data; enum appcore_rm rot_mode; }; @@ -765,7 +765,7 @@ static Eina_Bool __cmsg_cb(void *data, int type, void *event) ui->rot_mode = rm; if (APPCORE_RM_UNKNOWN != rm) { - ui->rot_cb(rm, ui->rot_cb_data); + ui->rot_cb((void *)&rm, rm, ui->rot_cb_data); } } @@ -936,7 +936,7 @@ static void __unset_data(struct ui_priv *ui) } /* WM_ROTATE */ -static int __wm_set_rotation_cb(int (*cb) (enum appcore_rm, void *), void *data) +static int __wm_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data) { if (cb == NULL) { errno = EINVAL; diff --git a/src/appcore-rotation.c b/src/appcore-rotation.c index bfb33af..46138b6 100644 --- a/src/appcore-rotation.c +++ b/src/appcore-rotation.c @@ -49,7 +49,7 @@ static Ecore_X_Window root; struct rot_s { int handle; - int (*callback) (enum appcore_rm, void *); + int (*callback) (void *event_info, enum appcore_rm, void *); enum appcore_rm mode; int lock; void *cbdata; @@ -125,7 +125,7 @@ static void __changed_cb(unsigned int event_type, sensor_event_data_t *event, if (rot.callback) { if (rot.cb_set && rot.mode != m) { _DBG("[APP %d] Rotation: %d -> %d", getpid(), rot.mode, m); - rot.callback(m, data); + rot.callback((void *)&m, m, data); rot.mode = m; } } @@ -142,7 +142,7 @@ static void __lock_cb(keynode_t *node, void *data) if (rot.lock) { m = APPCORE_RM_PORTRAIT_NORMAL; if (rot.mode != m) { - rot.callback(m, data); + rot.callback((void *)&m, m, data); rot.mode = m; } _DBG("[APP %d] Rotation locked", getpid()); @@ -156,7 +156,7 @@ static void __lock_cb(keynode_t *node, void *data) _DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(), rot.mode, m); if (!r && rot.mode != m) { - rot.callback(m, data); + rot.callback((void *)&m, m, data); rot.mode = m; } } @@ -186,7 +186,7 @@ static void __del_rotlock(void) rot.lock = 0; } -EXPORT_API int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *), +EXPORT_API int appcore_set_rotation_cb(int (*cb) (void *evnet_info, enum appcore_rm, void *), void *data) { if (rot.wm_rotate) { @@ -401,7 +401,7 @@ EXPORT_API int appcore_resume_rotation_cb(void) r = appcore_get_rotation_state(&m); _DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(), rot.mode, m); if (!r && rot.mode != m && rot.lock == 0) { - rot.callback(m, rot.cbdata); + rot.callback((void *)&m, m, rot.cbdata); rot.mode = m; } } diff --git a/src/appcore.c b/src/appcore.c index 841eb08..305f451 100644 --- a/src/appcore.c +++ b/src/appcore.c @@ -229,7 +229,7 @@ static int __sys_do_default(struct appcore *ac, enum sys_event event) return r; } -static int __sys_do(struct appcore *ac, enum sys_event event) +static int __sys_do(struct appcore *ac, void *event_info, enum sys_event event) { struct sys_op *op; @@ -240,7 +240,7 @@ static int __sys_do(struct appcore *ac, enum sys_event event) if (op->func == NULL) return __sys_do_default(ac, event); - return op->func(op->data); + return op->func(event_info, op->data); } static int __sys_lowmem_post(void *data, void *evt) @@ -269,7 +269,7 @@ static int __sys_lowmem(void *data, void *evt) val = vconf_keynode_get_int(key); if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) - return __sys_do(data, SE_LOWMEM); + return __sys_do(data, (void *)&val, SE_LOWMEM); return 0; } @@ -283,7 +283,7 @@ static int __sys_lowbatt(void *data, void *evt) /* VCONFKEY_SYSMAN_BAT_CRITICAL_LOW or VCONFKEY_SYSMAN_POWER_OFF */ if (val <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) - return __sys_do(data, SE_LOWBAT); + return __sys_do(data, (void *)&val, SE_LOWBAT); return 0; } @@ -296,7 +296,12 @@ static int __sys_langchg_pre(void *data, void *evt) static int __sys_langchg(void *data, void *evt) { - return __sys_do(data, SE_LANGCHG); + keynode_t *key = evt; + char *val; + + val = vconf_keynode_get_str(key); + + return __sys_do(data, (void *)val, SE_LANGCHG); } static int __sys_regionchg_pre(void *data, void *evt) @@ -307,7 +312,15 @@ static int __sys_regionchg_pre(void *data, void *evt) static int __sys_regionchg(void *data, void *evt) { - return __sys_do(data, SE_REGIONCHG); + keynode_t *key = evt; + char *val = NULL; + const char *name; + + name = vconf_keynode_get_name(key); + if (!strcmp(name, VCONFKEY_REGIONFORMAT)) + val = vconf_keynode_get_str(key); + + return __sys_do(data, (void *)val, SE_REGIONCHG); } static void __vconf_do(struct evt_ops *eo, keynode_t * key, void *data) @@ -440,7 +453,7 @@ EXPORT_API int appcore_set_open_cb(int (*cb) (void *), } EXPORT_API int appcore_set_event_callback(enum appcore_event event, - int (*cb) (void *), void *data) + int (*cb) (void *, void *), void *data) { struct appcore *ac = &core; struct sys_op *op; -- 2.7.4