#include "sclcoreimpl.h"
#include <Elementary.h>
#include <dlog.h>
+#include <appcore-efl.h>
#include <vconf.h>
#include <vconf-keys.h>
CWebHelperAgentWebSocket g_websocket;
#endif
+static struct appcore_ops ops;
+
#ifdef WAYLAND
struct WaylandKeyboard
{
m_rotation_degree = 0;
m_main_window = SCLWINDOW_INVALID;
+ m_uuid = NULL;
+ m_display = NULL;
}
CSCLCoreUIEFL::~CSCLCoreUIEFL()
}
#endif
-void CSCLCoreUIEFL::run(const sclchar *display)
+int CSCLCoreUIEFL::create(void *data)
{
- char *argv[4];
- int argc = 3;
-
- CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
- if (impl) {
- const sclchar *uuid = impl->get_uuid();
- if (!uuid)
- uuid = "";
-
- argv[0] = const_cast<char *> (uuid);
- argv[1] = (char *)"--display";
- argv[2] = const_cast<char *> (display);
- argv[3] = 0;
-
- elm_init(argc, argv);
-
#ifdef WAYLAND
- if (!check_evas_engine(&wlkb)) {
- LOGW("_wlkb_check_evas_engine error!\n");
- elm_shutdown();
- return;
- }
- LOGD("Selected engine: '%s'\n", wlkb.ee_engine);
+ if (!check_evas_engine(&wlkb)) {
+ LOGW("_wlkb_check_evas_engine error!\n");
+ elm_shutdown();
+ return -1;
+ }
+ LOGD("Selected engine: '%s'\n", wlkb.ee_engine);
#endif
- elm_config_accel_preference_set("3d");
- elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER);
+ elm_config_accel_preference_set("3d");
+ elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER);
- Evas_Object *main_window = elm_win_add(NULL, uuid, ELM_WIN_UTILITY);
- if (!main_window) {
- LOGE("Failed to create main window\n");
- return;
- }
+ Evas_Object *main_window = elm_win_add(NULL, m_uuid, ELM_WIN_UTILITY);
+ if (!main_window) {
+ LOGE("Failed to create main window\n");
+ return -1;
+ }
- m_main_window = SCL_WINDOW_CAST(main_window);
+ m_main_window = SCL_WINDOW_CAST(main_window);
#ifdef WAYLAND
- if (!_wayland_setup(&wlkb, main_window)) {
- LOGW("ERROR: Unable to setup input panel.\n");
- elm_shutdown();
- return;
- }
+ if (!_wayland_setup(&wlkb, main_window)) {
+ LOGW("ERROR: Unable to setup input panel.\n");
+ appcore_efl_fini();
+ return -1;
+ }
#endif
- elm_win_borderless_set(main_window, EINA_TRUE);
- elm_win_keyboard_win_set(main_window, EINA_TRUE);
- elm_win_autodel_set(main_window, EINA_TRUE);
- elm_win_title_set(main_window, uuid);
- elm_win_prop_focus_skip_set(main_window, EINA_TRUE);
- int rots[] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(main_window, rots, (sizeof(rots) / sizeof(int)));
+ elm_win_borderless_set(main_window, EINA_TRUE);
+ elm_win_keyboard_win_set(main_window, EINA_TRUE);
+ elm_win_autodel_set(main_window, EINA_TRUE);
+ elm_win_title_set(main_window, m_uuid);
+ elm_win_prop_focus_skip_set(main_window, EINA_TRUE);
+ int rots[] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(main_window, rots, (sizeof(rots) / sizeof(int)));
#ifndef WAYLAND
- unsigned int set = 1;
- ecore_x_window_prop_card32_set(elm_win_xwindow_get(main_window),
- ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED,
- &set, 1);
+ unsigned int set = 1;
+ ecore_x_window_prop_card32_set(elm_win_xwindow_get(main_window),
+ ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED,
+ &set, 1);
- ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF");
+ ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF");
#endif
- vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL);
- vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL);
- /* Should we call these callback functions here? */
- language_changed_cb(NULL, NULL);
- accessibility_changed_cb(NULL, NULL);
+ /* Should we call these callback functions here? */
+ language_changed_cb(NULL, NULL);
+ accessibility_changed_cb(NULL, NULL);
- impl->init(display);
+ 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, this);
+ 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);
+ 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);
+ signal(SIGQUIT, signal_handler);
+ signal(SIGTERM, signal_handler);
+ signal(SIGINT, signal_handler);
+ signal(SIGHUP, signal_handler);
#ifdef WAYLAND
- evas_object_show(main_window);
+ evas_object_show(main_window);
#endif
- elm_run();
+ return 0;
+}
+int CSCLCoreUIEFL::terminate(void *data)
+{
+ CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+ if (impl)
impl->fini();
- vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb);
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb);
+ vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb);
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb);
#ifndef WAYLAND
- if (XClientMsgHandler) {
- ecore_event_handler_del(XClientMsgHandler);
- XClientMsgHandler = NULL;
- }
+ if (XClientMsgHandler) {
+ ecore_event_handler_del(XClientMsgHandler);
+ XClientMsgHandler = NULL;
+ }
#endif
- elm_shutdown();
+ return 0;
+}
+
+static int app_create_cb(void *data)
+{
+ CSCLCoreUIEFL *sclui = static_cast<CSCLCoreUIEFL *>(data);
+ if (sclui)
+ return sclui->create(data);
+
+ return -1;
+}
+
+static int app_terminate_cb(void *data)
+{
+ CSCLCoreUIEFL *sclui = static_cast<CSCLCoreUIEFL *>(data);
+ if (sclui)
+ return sclui->terminate(data);
+
+ return -1;
+}
+
+void CSCLCoreUIEFL::run(const sclchar *display)
+{
+ char **argv = new char*[4];
+ int argc = 3;
+ const sclchar *uuid = NULL;
+
+ ops.create = app_create_cb;
+ ops.terminate = app_terminate_cb;
+ ops.resume = NULL;
+ ops.pause = NULL;
+ ops.reset = NULL;
+ ops.data = this;
+
+ CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+ if (impl) {
+ uuid = impl->get_uuid();
}
+
+ if (!uuid)
+ uuid = "";
+
+ m_uuid = uuid;
+ m_display = display;
+
+ argv[0] = const_cast<char *> (uuid);
+ argv[1] = (char *)"--display";
+ argv[2] = const_cast<char *> (display);
+ argv[3] = 0;
+
+ LOGD("name : %s\n", uuid);
+
+ int ret = appcore_efl_main(uuid, &argc, (char ***)&argv, &ops);
+
+ delete [] argv;
}
static void focus_out_cb(void *data, Evas *e, void *event)