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 45812c684e1310ad5abc2283275b255c42fb0efd..525a4b32a2a616a6fc431611520505cbad09fff0 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 29d04d025c010a4570da05cc5d07d554afb3babb..019ea73088cb1304c9903177e9fbce03227909d0 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 1ab472341d8f1042ed90c2ae6e31c8b147d1e0d8..fa16a7cb7fa0537ada32490f1c6dd7ad507ef981 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 554bdb732e69056c63b0286271b9bd68b461b726..59c2af3bafe0404687a77de196b6df749e41bc5d 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 34c5d1d205637fe9de2395ebbf110c837969b059..e0ce5134b3b531ecb75f3c4e860656b76397d3fb 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 9b8ae23403bdf6172c87b34c70a93416ab890239..0c4cfbcf4595940e7ece6be35b501027facea3ee 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 145229048d7eb7eb8d45d050f382e7651be04dca..817f5aa17b1f491b4170269a03b660381c8ec292 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 c35b8e275d63dfbbdbc246ebcc455d2a4587fb97..04f48da088562a293d1f053b006871de158aef6e 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 287574652c919ace22a58181cbac1d562f27f383..4c16fca0dc3ea7461c1d21d51484a843f3e3de8f 100644 (file)
@@ -51,6 +51,8 @@ public:
     virtual sclboolean init();
     virtual void fini();
 
+    virtual sclboolean create_main_window();
+
     virtual void run(const sclchar *display);
 
     /**