Add support for uix-inputmethod apis 13/135713/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 26 Jun 2017 04:40:03 +0000 (13:40 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 26 Jun 2017 04:52:03 +0000 (13:52 +0900)
Since the current window manager does not support converting
a normal application window into an IME window, the previous
attempt to convert an window that was created inside the
FormsApplication class into an IME window, turned out to be
an inappropriate approach.
Thus reverted "Add init interface with main_window as a parameter"
and added some interfaces to initialize and create IME window
without using ime_run main loop, and we are going to assign this
IME window as a MainWindow member variable of IMEApplication
class which is a child of FormsApplication.

Change-Id: I9d318d6ae16ba88ca808784cdddfac5f2c8043ab

src/sclconnection-isf.cpp
src/sclcore.cpp
src/sclcore.h
src/sclcoreimpl.cpp
src/sclcoreimpl.h
src/sclcoreui-efl.cpp
src/sclcoreui-efl.h
src/sclcoreui.cpp
src/sclcoreui.h

index 45812c6..525a4b3 100644 (file)
@@ -652,14 +652,6 @@ sclboolean CSCLConnectionISF::init()
 {
     LOGD("Enter\n");
 
-    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
-    if (impl) {
-        sclchar *uuid = impl->get_uuid();
-        if (uuid) {
-            m_helper_info.uuid = uuid;
-        }
-    }
-
     if (!m_initialized) {
         m_helper_agent.signal_connect_exit(scim::slot(slot_exit));
         m_helper_agent.signal_connect_attach_input_context(scim::slot(slot_attach_input_context));
@@ -741,6 +733,14 @@ void CSCLConnectionISF::fini()
 void CSCLConnectionISF::open_connection(const sclchar *display)
 {
     if (m_initialized) {
+        CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+        if (impl) {
+            sclchar *uuid = impl->get_uuid();
+            if (uuid) {
+                m_helper_info.uuid = uuid;
+            }
+        }
+
         m_helper_agent.open_connection(m_helper_info, display);
         int fd = m_helper_agent.get_connection_number();
 
@@ -765,6 +765,7 @@ void CSCLConnectionISF::open_connection(const sclchar *display)
         }
     }
 }
+
 void CSCLConnectionISF::close_connection()
 {
     if (m_initialized) {
index 29d04d0..019ea73 100644 (file)
@@ -34,6 +34,27 @@ CSCLCore::~CSCLCore()
     m_impl = NULL;
 }
 
+void CSCLCore::init()
+{
+    if (m_impl) {
+        m_impl->init();
+    }
+}
+
+void CSCLCore::prepare()
+{
+    if (m_impl) {
+        m_impl->prepare();
+    }
+}
+
+void CSCLCore::fini()
+{
+    if (m_impl) {
+        m_impl->fini();
+    }
+}
+
 void CSCLCore::run()
 {
     if (m_impl) {
index 1ab4723..fa16a7c 100644 (file)
@@ -45,6 +45,29 @@ public:
     CSCLCore(ISCLCoreEventCallback *callback);
     ~CSCLCore();
 
+    /**
+     * @brief Request SCLCore to initialize its components.
+     *
+     * Note that the init() / prepare() / fini() functions are not expected to be called
+     * when using run() function, since they are called automatically inside run().
+     */
+    void init();
+
+    /**
+    * @brief Request SCLCore to prepare necessary resources.
+    */
+    void prepare();
+
+    /**
+    * @brief Request SCLCore to finalize its components.
+    */
+    void fini();
+
+    /**
+     * @brief Request SCLCore to start its main loop.
+     *
+     * As described above, init() / prepare() / fini() functions are called automatically when necessary
+     */
     void run();
 
     /**
index 554bdb7..59c2af3 100644 (file)
@@ -47,20 +47,50 @@ CSCLCoreImpl::get_instance()
     return &instance;
 }
 
-void CSCLCoreImpl::init(const sclchar *display)
+void CSCLCoreImpl::init()
 {
-    m_connection.init();
+    LOGD("");
     m_core_ui.init();
+    m_connection.init();
+}
 
-    m_connection.open_connection(display);
+sclboolean CSCLCoreImpl::prepare()
+{
+    sclboolean ret = TRUE;
+
+    if (!m_display) {
+        const char *display = getenv("DISPLAY");
+        LOGD("display env : '%s'\n", display);
+        m_display = display ? strdup(display) : strdup(":0");
+    }
+
+    if (!m_uuid) {
+        char *appid = NULL;
+        app_get_id(&appid);
+
+        LOGD("appid : '%s'\n", appid);
+
+        if (appid) {
+            m_uuid = strdup(appid);
+            free(appid);
+        }
+    }
+
+    ret = m_core_ui.create_main_window();
+    if (ret) {
+        m_connection.open_connection(m_display);
+    }
 
     if (m_event_callback) {
         m_event_callback->on_init();
     }
+
+    return ret;
 }
 
 void CSCLCoreImpl::fini()
 {
+    LOGD("");
     if (m_event_callback) {
         m_event_callback->on_exit();
     }
@@ -274,9 +304,6 @@ void CSCLCoreImpl::get_keyboard_ise(const sclchar *uuid)
 
 void CSCLCoreImpl::on_run(const sclchar *uuid, const sclchar *display)
 {
-    m_core_ui.init();
-    m_connection.init();
-
     LOGD("uuid : '%s', display : '%s'\n", uuid, display);
 
     if (uuid && strlen(uuid) > 0) {
@@ -302,20 +329,7 @@ void CSCLCoreImpl::on_run(const sclchar *uuid, const sclchar *display)
 
 void CSCLCoreImpl::run()
 {
-    m_core_ui.init();
-    m_connection.init();
-
-    if (!m_uuid) {
-        char *appid = NULL;
-        app_get_id(&appid);
-
-        LOGD("appid : '%s'\n", appid);
-
-        if (appid) {
-            m_uuid = strdup(appid);
-            free(appid);
-        }
-    }
+    init();
 
     if (!m_display) {
         const char *display = getenv("DISPLAY");
@@ -325,8 +339,7 @@ void CSCLCoreImpl::run()
 
     m_core_ui.run(m_display);
 
-    m_connection.fini();
-    m_core_ui.fini();
+    fini();
 }
 
 sclwindow CSCLCoreImpl::get_main_window()
index 34c5d1d..e0ce513 100644 (file)
@@ -39,7 +39,8 @@ public:
     ~CSCLCoreImpl();
     static CSCLCoreImpl* get_instance();
 
-    void init(const sclchar *display);
+    void init();
+    sclboolean prepare();
     void fini();
 
     void on_run(const sclchar *uuid, const sclchar *display);
index 9b8ae23..0c4cfbc 100644 (file)
@@ -413,12 +413,12 @@ err:
 }
 #endif
 
-int CSCLCoreUIEFL::create(void *data)
+sclboolean CSCLCoreUIEFL::create_main_window()
 {
 #ifdef WAYLAND
     if (!check_evas_engine(&wlkb)) {
         LOGW("_wlkb_check_evas_engine error!\n");
-        return -1;
+        return FALSE;
     }
     LOGD("Selected engine: '%s'\n", wlkb.ee_engine);
 #endif
@@ -429,7 +429,7 @@ int CSCLCoreUIEFL::create(void *data)
     Evas_Object *main_window = elm_win_add(NULL, m_appid, ELM_WIN_UTILITY);
     if (!main_window) {
         LOGE("Failed to create main window\n");
-        return -1;
+        return FALSE;
     }
 
     m_main_window = SCL_WINDOW_CAST(main_window);
@@ -437,8 +437,7 @@ int CSCLCoreUIEFL::create(void *data)
 #ifdef WAYLAND
     if (!_wayland_setup(&wlkb, main_window)) {
         LOGW("ERROR: Unable to setup input panel.\n");
-        appcore_efl_fini();
-        return -1;
+        return FALSE;
     }
 #endif
 
@@ -459,6 +458,27 @@ int CSCLCoreUIEFL::create(void *data)
     ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF");
 #endif
 
+    return TRUE;
+}
+
+int CSCLCoreUIEFL::create(void *data)
+{
+    Evas_Object *main_window = NULL;
+    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+    if (impl) {
+        if (!impl->prepare()) {
+            appcore_efl_fini();
+            return -1;
+        }
+
+        main_window = NATIVE_WINDOW_CAST(impl->get_main_window());
+        if (!main_window) {
+            LOGW("Main window does not exist!");
+            appcore_efl_fini();
+            return -1;
+        }
+    }
+
     appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, language_changed_cb, NULL);
 
     vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL);
@@ -467,10 +487,6 @@ int CSCLCoreUIEFL::create(void *data)
     language_changed_cb(NULL, NULL);
     accessibility_changed_cb(NULL, NULL);
 
-    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
-    if (impl)
-        impl->init(m_display);
-
 #ifdef WAYLAND
     evas_object_smart_callback_add(main_window, "wm,rotation,changed", win_rotation_changed_cb, NULL);
 #else
index 1452290..817f5aa 100644 (file)
@@ -48,6 +48,8 @@ public:
     virtual void fini();
 
     virtual void run(const sclchar *display);
+
+    virtual sclboolean create_main_window();
     virtual sclwindow get_main_window();
     virtual void set_keyboard_size_hints(SclSize portrait, SclSize landscape);
     virtual int get_screen_rotation_degree();
index c35b8e2..04f48da 100644 (file)
@@ -60,6 +60,15 @@ void CSCLCoreUI::fini()
     }
 }
 
+sclboolean CSCLCoreUI::create_main_window()
+{
+    sclboolean ret = FALSE;
+    if (m_impl) {
+        ret = m_impl->create_main_window();
+    }
+    return ret;
+}
+
 void CSCLCoreUI::run(const sclchar *display)
 {
     if (m_impl) {
index 2875746..4c16fca 100644 (file)
@@ -51,6 +51,8 @@ public:
     virtual sclboolean init();
     virtual void fini();
 
+    virtual sclboolean create_main_window();
+
     virtual void run(const sclchar *display);
 
     /**