Use Idler to register vconf callback 88/318588/3
authorInhong Han <inhong1.han@samsung.com>
Tue, 21 Jan 2025 02:13:56 +0000 (11:13 +0900)
committerInhong Han <inhong1.han@samsung.com>
Tue, 21 Jan 2025 03:00:28 +0000 (12:00 +0900)
Change-Id: I49d66b2b4608a42c8ae609d283a599cafe2020c4

src/e_mod_main.c

index bd76073fe2a18a2c0f7b045bc3b9067acf482f0e..c4ca9a3220102195f28b541a21030b9039fcb120 100644 (file)
@@ -145,6 +145,7 @@ static E_Client *client_surface_ec = NULL;
 static E_Text_Input *g_show_text_input = NULL;
 static struct wl_client *g_show_client = NULL;
 static Eina_Bool g_updated_geometry = EINA_FALSE;
+static Ecore_Idler *g_vconf_idler = NULL;
 
 /* The candidate's show state that was requested by the application or IME */
 static Eina_Bool g_show_state_candidate = EINA_FALSE;
@@ -2368,6 +2369,19 @@ e_input_panel_show_request_flag_get()
    return g_text_input->input_panel_show_requested;
 }
 
+static Eina_Bool
+_vconf_idler_cb(void *user_data)
+{
+   LOGD("");
+
+   if (vconf_notify_key_changed(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, _keyboard_mode_changed_cb, NULL) != 0)
+     LOGW ("Failed to register callback function for H/W keyboard input detection.");
+
+   g_vconf_idler = NULL;
+
+   return ECORE_CALLBACK_CANCEL;
+}
+
 E_API void *
 e_modapi_init(E_Module *m)
 {
@@ -2391,8 +2405,7 @@ e_modapi_init(E_Module *m)
 
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_RESIZE, _e_text_input_method_context_cb_client_resize, NULL);
 
-   if (vconf_notify_key_changed(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, _keyboard_mode_changed_cb, NULL) != 0)
-     LOGW ("Failed to register callback function for H/W keyboard input detection.");
+   g_vconf_idler = ecore_idler_add(_vconf_idler_cb, NULL);
 
    ecore_device_del_handler = ecore_event_handler_add(ECORE_EVENT_DEVICE_DEL, _e_mod_device_removed_cb, NULL);
 
@@ -2423,6 +2436,12 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
         ecore_device_del_handler = NULL;
      }
 
+   if (g_vconf_idler)
+     {
+        ecore_idler_del(g_vconf_idler);
+        g_vconf_idler = NULL;
+     }
+
    _e_mod_text_input_shutdown();
 
    e_input_panel_shutdown();