#include <cynara-client.h>
#include <cynara-error.h>
#include <cynara-session.h>
+#include <Ecore_Wayland.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
static Ecore_Timer* g_connect_timer = NULL;
+static Ecore_Event_Handler* g_focus_in_handler = NULL;
+static Ecore_Event_Handler* g_focus_out_handler = NULL;
+
static vc_h g_vc = NULL;
static int g_daemon_pid = 0;
return EINA_FALSE;
}
-static int __vc_app_state_changed_cb(int app_state, void *data)
+static Eina_Bool __focus_changed_cb(void *data, int type, void *event)
{
- int ret = -1;
- SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] app state changed");
+ SLOG(LOG_DEBUG, TAG_VCC, "===== Focus changed");
- /* Set current pid */
- if (STATUS_VISIBLE == app_state) {
+ int ret;
+ if (ECORE_WL_EVENT_FOCUS_IN == type) {
SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground");
ret = vc_dbus_set_foreground(getpid(), true);
if (0 != ret) {
/* notify auth changed cb */
ecore_timer_add(0, __notify_auth_changed_cb, NULL);
}
- } else if (STATUS_BG == app_state) {
- SLOG(LOG_DEBUG, TAG_VCC, "===== Set background");
+ } else if (ECORE_WL_EVENT_FOCUS_OUT == type) {
+ SLOG(LOG_DEBUG, TAG_VCW, "===== Set background");
ret = vc_dbus_set_foreground(getpid(), false);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (false) : %d", ret);
ecore_timer_add(0, __notify_auth_changed_cb, NULL);
}
} else {
- SLOG(LOG_DEBUG, TAG_VCC, "===== App state is NOT valid");
+ SLOG(LOG_DEBUG, TAG_VCC, "===== type(%d) is NOT valid", type);
}
SLOG(LOG_DEBUG, TAG_VCC, "=====");
- SLOG(LOG_DEBUG, TAG_VCC, " ");
+ SLOG(LOG_DEBUG, TAG_VCC, "");
- return 0;
+ return ECORE_CALLBACK_RENEW;
}
int vc_initialize(void)
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret));
}
+ if (NULL != g_focus_in_handler) {
+ ecore_event_handler_del(g_focus_in_handler);
+ g_focus_in_handler = NULL;
+ }
+ if (NULL != g_focus_out_handler) {
+ ecore_event_handler_del(g_focus_out_handler);
+ g_focus_out_handler = NULL;
+ }
ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND);
if (0 != ret)
g_connect_timer = NULL;
- ret = aul_add_status_local_cb(__vc_app_state_changed_cb, NULL);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set app stae changed callback");
- }
+ g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL);
+ g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL);
+
+ char appid[255] = {'\0',};
+ aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
- int status = aul_app_get_status_bypid(getpid());
- if (STATUS_FOCUS == status || STATUS_VISIBLE == status) {
+ int status = aul_app_get_status(appid);
+ if (STATUS_FOCUS == status) {
SLOG(LOG_DEBUG, TAG_VCC, "===== Set foreground");
ret = vc_dbus_set_foreground(getpid(), true);
if (0 != ret) {
static Ecore_Timer* g_w_connect_timer = NULL;
+static Ecore_Event_Handler* g_focus_in_handler = NULL;
+static Ecore_Event_Handler* g_focus_out_handler = NULL;
+
static Ecore_Timer* g_w_start_timer = NULL;
static Ecore_Timer* g_w_tooltip_timer = NULL;
SLOG(LOG_WARN, TAG_VCW, "[ERROR] Fail to request finalize : %s", __vc_widget_get_error_code(ret));
}
+ if (NULL != g_focus_in_handler) {
+ ecore_event_handler_del(g_focus_in_handler);
+ g_focus_in_handler = NULL;
+ }
+ if (NULL != g_focus_out_handler) {
+ ecore_event_handler_del(g_focus_out_handler);
+ g_focus_out_handler = NULL;
+ }
+
ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_WIDGET);
if (0 != ret)
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_WIDGET, ret);
vc_widget_client_set_service_state(g_vc_w, (vc_service_state_e)service_state);
- ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL);
- ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL);
+ g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL);
+ g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL);
char appid[255] = {'\0',};
aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));