Add code to connect to wl display 48/173048/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 11 Jan 2018 00:23:17 +0000 (09:23 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 19 Mar 2018 08:50:16 +0000 (17:50 +0900)
Change-Id: I53ecc97b94f2a061f6cd652a4ac9ecc5ed269dfb
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/extras/wayland_immodule/wayland_module.c
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp

index 72cfacf..8af86b6 100644 (file)
 #define EFL_BETA_API_SUPPORT
 #include <Ecore_Wl2.h>
 #include <stdio.h>
+#include <dlog.h>
 
 #include "wayland_imcontext.h"
 #include <text-client-protocol.h>
 
+#ifdef LOG_TAG
+# undef LOG_TAG
+#endif
+#define LOG_TAG "IMMODULE"
+
 int _ecore_imf_wayland_log_dom = -1;
 static int ecore_wl2_init_count = 0;
+static Ecore_Wl2_Display *ewd = NULL;
 
 static const Ecore_IMF_Context_Info wayland_im_info =
 {
@@ -106,17 +113,21 @@ im_module_create()
        Eina_Iterator *globals;
 
        ecore_wl2_init_count = ecore_wl2_init();
-       if (!ecore_wl2_init_count)
+       if (!ecore_wl2_init_count) {
+           LOGE("Could not initialize ecore_wl2");
            return NULL;
+       }
 
-       Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
-       if (!wl2_display)
+       ewd = ecore_wl2_display_connect(NULL);
+       if (!ewd) {
+           LOGE("Could not connect to Wayland Display");
            goto err;
+       }
 
-       if (!(registry = ecore_wl2_display_registry_get(wl2_display)))
+       if (!(registry = ecore_wl2_display_registry_get(ewd)))
            goto err;
 
-       if (!(globals = ecore_wl2_display_globals_get(wl2_display)))
+       if (!(globals = ecore_wl2_display_globals_get(ewd)))
            goto err;
 
        EINA_ITERATOR_FOREACH(globals, global)
@@ -151,6 +162,11 @@ im_module_create()
 
 err:
     ecore_wl2_init_count = 0;
+    if (ewd) {
+        ecore_wl2_display_disconnect(ewd);
+        ewd = NULL;
+    }
+
     ecore_wl2_shutdown();
     return NULL;
 }
@@ -187,6 +203,9 @@ im_module_shutdown(void)
    //
    EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "im module shutdown");
 
+   if (ewd)
+       ecore_wl2_display_disconnect(ewd);
+
    if (ecore_wl2_init_count > 0)
        ecore_wl2_shutdown();
 }
index f79c469..612ecab 100644 (file)
@@ -78,7 +78,7 @@ using namespace scim;
 
 struct _WSCContextISFImpl {
     WSCContextISF           *parent;
-    Ecore_Wl2_Window         *client_window;
+    Ecore_Wl2_Window        *client_window;
     Ecore_IMF_Input_Mode     input_mode;
     WideString               surrounding_text;
     WideString               preedit_string;
@@ -209,7 +209,7 @@ static Ecore_Timer                                     *_resource_check_timer
 
 static bool                                             _need_wl_im_init           = false;
 static struct _wl_im                                    *_wl_im_ctx                = NULL;
-static int                                              _ecore_wl2_init_count       = 0;
+static int                                              _ecore_wl2_init_count      = 0;
 
 #define WAYLAND_MODULE_CLIENT_ID (0)
 #define MAX_PREEDIT_BUFSIZE 4000
@@ -905,15 +905,10 @@ _wsc_setup (struct weescim *wsc)
 
     if (!wsc) return false;
 
-    Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get (NULL);
+    Ecore_Wl2_Display *wl2_display = ecore_wl2_display_connect (NULL);
     if (!wl2_display) {
-        LOGW ("failed to get wl2_display, try connecting");
-        wl2_display = ecore_wl2_display_connect (NULL);
-
-        if (!wl2_display) {
-            LOGW ("failed to connect");
-            return false;
-        }
+        LOGW ("failed to connect");
+        return false;
     }
 
     if (!(registry = ecore_wl2_display_registry_get (wl2_display))) {