From b44d445d9207cbb4c48a39ca21dcc9e832bdf60e Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 11 Mar 2017 20:16:53 +0900 Subject: [PATCH] Reduce the duplicate code Change-Id: I5b71ef1712baf8f35cc660196b95e69ecb110d2d Signed-off-by: Jihoon Kim --- ism/extras/wayland_immodule/wayland_imcontext.c | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index 7478912..869b2ad 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -893,6 +893,18 @@ static void _conformant_area_free (void *data EINA_UNUSED, void *ev) e = NULL; } +static void add_conformant_change_event(Ecore_Wl_Window *window) +{ + Ecore_Wl_Event_Conformant_Change *ev; + ev = calloc(1, sizeof(Ecore_Wl_Event_Conformant_Change)); + if (ev) { + ev->win = ecore_wl_window_id_get(window); + ev->part_type = 1; + ev->state = 0; + ecore_event_add(ECORE_WL_EVENT_CONFORMANT_CHANGE, ev, _conformant_area_free, NULL); + } +} + static Eina_Rectangle _conformant_area_backup = { 0, 0, 0, 0 }; static Eina_Bool reset_conformant_area(Ecore_IMF_Context *ctx) { @@ -926,14 +938,7 @@ static Eina_Bool reset_conformant_area(Ecore_IMF_Context *ctx) if (reset) { ecore_wl_window_keyboard_geometry_set(window, 0, 0, 0, 0); - Ecore_Wl_Event_Conformant_Change *ev; - ev = calloc(1, sizeof(Ecore_Wl_Event_Conformant_Change)); - if (ev) { - ev->win = ecore_wl_window_id_get(window); - ev->part_type = 1; - ev->state = 0; - ecore_event_add(ECORE_WL_EVENT_CONFORMANT_CHANGE, ev, _conformant_area_free, NULL); - } + add_conformant_change_event(window); _conformant_reset_started = EINA_TRUE; } @@ -971,15 +976,9 @@ static void restore_conformant_area(Ecore_IMF_Context *ctx) _conformant_area_backup.x, _conformant_area_backup.y, _conformant_area_backup.w, _conformant_area_backup.h); - Ecore_Wl_Event_Conformant_Change *ev; - ev = calloc(1, sizeof(Ecore_Wl_Event_Conformant_Change)); - if (ev) { - ev->win = ecore_wl_window_id_get(window); - ev->part_type = 1; - ev->state = 0; - ecore_event_add(ECORE_WL_EVENT_CONFORMANT_CHANGE, ev, _conformant_area_free, NULL); - } - _conformant_reset_started = EINA_FALSE; + add_conformant_change_event(window); + + _conformant_reset_started = EINA_FALSE; } } -- 2.7.4