Add deferring window creation feature 26/163526/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 11 Dec 2017 11:54:11 +0000 (20:54 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 12 Dec 2017 09:45:54 +0000 (18:45 +0900)
Change-Id: I236ddb2fe1f93d2843f32745688cbb23a9b61ad3

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

index 0a4f9c2..586ebde 100644 (file)
@@ -400,4 +400,11 @@ void CSCLCore::set_floating_drag_enabled(sclboolean enabled)
     if (m_impl) {
         m_impl->set_floating_drag_enabled(enabled);
     }
-}
\ No newline at end of file
+}
+
+void CSCLCore::set_window_creation_defer_flag(sclboolean flag)
+{
+    if (m_impl) {
+        m_impl->set_window_creation_defer_flag(flag);
+    }
+}
index f0bf947..23145a4 100644 (file)
@@ -420,6 +420,11 @@ public:
      * @brief Request to allow the user to move floating ISE.
      */
     void set_floating_drag_enabled(sclboolean enabled);
+
+    /**
+     * @brief Request to defer creating window until the window object gets accessed.
+     */
+    void set_window_creation_defer_flag(sclboolean flag);
 private:
     CSCLCoreImpl *m_impl;
 };
index c0e06b9..7a3a685 100644 (file)
@@ -26,6 +26,9 @@ CSCLCoreImpl::CSCLCoreImpl()
     m_event_callback = NULL;
     m_display = NULL;
     m_uuid = NULL;
+
+    m_window_created = FALSE;
+    m_window_creation_defer_flag = FALSE;
 }
 
 CSCLCoreImpl::~CSCLCoreImpl()
@@ -76,7 +79,11 @@ sclboolean CSCLCoreImpl::prepare()
         }
     }
 
-    ret = m_core_ui.create_main_window();
+    if (!m_window_creation_defer_flag) {
+        LOGD("defer_flag FALSE, creating main window");
+        m_window_created = m_core_ui.create_main_window();
+        ret = m_window_created;
+    }
     if (ret) {
         m_connection.open_connection(m_display);
     }
@@ -344,6 +351,11 @@ void CSCLCoreImpl::run()
 
 sclwindow CSCLCoreImpl::get_main_window()
 {
+    if (!m_window_created) {
+        LOGD("create main window\n");
+        m_window_created = m_core_ui.create_main_window();
+    }
+
     return m_core_ui.get_main_window();
 }
 
@@ -400,4 +412,10 @@ void CSCLCoreImpl::set_floating_mode(sclboolean floating_mode)
 void CSCLCoreImpl::set_floating_drag_enabled(sclboolean enabled)
 {
     m_core_ui.set_floating_drag_enabled(enabled);
-}
\ No newline at end of file
+}
+
+void CSCLCoreImpl::set_window_creation_defer_flag(sclboolean flag)
+{
+    LOGD("defer_flag %d", flag);
+    m_window_creation_defer_flag = flag;
+}
index 8ae5afd..8a9bac8 100644 (file)
@@ -110,12 +110,17 @@ public:
     void commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types);
     void set_floating_mode(sclboolean floating_mode);
     void set_floating_drag_enabled(sclboolean enabled);
+
+    void set_window_creation_defer_flag(sclboolean flag);
 private:
     ISCLCoreEventCallback *m_event_callback;
 
     CSCLConnection m_connection;
     CSCLCoreUI m_core_ui;
     sclchar *m_uuid;
+
+    sclboolean m_window_creation_defer_flag;
+    sclboolean m_window_created;
 };
 
 }
index c28d007..9510dcb 100644 (file)
@@ -25,6 +25,7 @@
 #include <vconf-keys.h>
 
 #include <glib.h>
+#include <malloc.h>
 #ifdef WAYLAND
 #include <Ecore_Wayland.h>
 #include <input-method-client-protocol.h>
@@ -428,6 +429,8 @@ sclboolean CSCLCoreUIEFL::create_main_window()
         &set, 1);
 
     ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF");
+#else
+    evas_object_show(main_window);
 #endif
 
     Evas_Coord win_w = 0, win_h = 0;
@@ -440,25 +443,26 @@ sclboolean CSCLCoreUIEFL::create_main_window()
     landscape.height = win_w / 3;
     set_keyboard_size_hints(portrait, landscape);
 
+#ifdef WAYLAND
+    evas_object_smart_callback_add(main_window, "wm,rotation,changed", win_rotation_changed_cb, NULL);
+    evas_object_show(main_window);
+#else
+    Ecore_Event_Handler *XClientMsgHandler =
+        ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this);
+#endif
     return TRUE;
 }
 
 int CSCLCoreUIEFL::create(void *data)
 {
-    Evas_Object *main_window = NULL;
+    LOGD("");
+
     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);
@@ -469,22 +473,11 @@ int CSCLCoreUIEFL::create(void *data)
     language_changed_cb(NULL, NULL);
     accessibility_changed_cb(NULL, NULL);
 
-#ifdef WAYLAND
-    evas_object_smart_callback_add(main_window, "wm,rotation,changed", win_rotation_changed_cb, NULL);
-#else
-    Ecore_Event_Handler *XClientMsgHandler =
-        ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this);
-#endif
-
     signal(SIGQUIT, signal_handler);
     signal(SIGTERM, signal_handler);
     signal(SIGINT,  signal_handler);
     signal(SIGHUP,  signal_handler);
 
-#ifdef WAYLAND
-    evas_object_show(main_window);
-#endif
-
     return 0;
 }
 
@@ -511,8 +504,12 @@ int CSCLCoreUIEFL::terminate(void *data)
 static int app_create_cb(void *data)
 {
     CSCLCoreUIEFL *sclui = static_cast<CSCLCoreUIEFL *>(data);
-    if (sclui)
-        return sclui->create(data);
+    if (sclui) {
+        int ret = sclui->create(data);
+        elm_cache_all_flush();
+        malloc_trim(0);
+        return ret;
+    }
 
     return -1;
 }