Use Idler to register vconf callback 90/318590/2
authorInhong Han <inhong1.han@samsung.com>
Tue, 21 Jan 2025 02:25:06 +0000 (11:25 +0900)
committerInhong Han <inhong1.han@samsung.com>
Tue, 21 Jan 2025 03:02:22 +0000 (12:02 +0900)
Change-Id: If8f84b59645abf91f8b013c35cfaa2cc12a7e978

src/e_mod_main.c

index 992f59e58fb53604e04bc3bc4743f5f9e6e62561..1648c886cf80b0b2a261082c8b248de0c2429844 100644 (file)
@@ -145,6 +145,7 @@ 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 Eina_Bool g_fullscreen_mode = 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;
@@ -2376,6 +2377,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)
 {
@@ -2399,8 +2413,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);
 
@@ -2431,6 +2444,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();