EVENT_STATE_ERROR
};
+enum event_handler_activate_type {
+ EVENT_HANDLER_DEACTIVATED = 0x00,
+ EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET = 0x01,
+ EVENT_HANDLER_ACTIVATED_BY_SHOW = 0x02,
+ EVENT_HANDLER_UNKNOWN = 0x04
+};
+
extern int event_init(void);
extern int event_fini(void);
extern int event_input_fd(void);
extern int event_is_activated(void);
extern int event_reset_cbdata(int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data, void *new_data);
+extern int event_deactivate_thread(enum event_handler_activate_type activate_type);
+extern int event_activate_thread(enum event_handler_activate_type activate_type);
+
/* End of a file */
Eina_List *event_listener_list;
Eina_List *reactivate_list;
- int event_handler_activated;
+ enum event_handler_activate_type event_handler_activated;
int timestamp_updated;
} s_info = {
- .event_handler_activated = 0,
+ .event_handler_activated = EVENT_HANDLER_DEACTIVATED,
.event_list = NULL,
.handle = -1,
.event_handler = NULL,
int y; /* RelY */
};
-static int activate_thread(void);
-static int deactivate_thread(void);
static int event_control_fini(void);
HAPI int event_init(void)
DbgPrint("Reactivate: %p\n", s_info.event_listener_list);
if (s_info.event_listener_list) {
- if (activate_thread() < 0) {
+ if (event_activate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET) < 0) {
EINA_LIST_FREE(s_info.event_listener_list, listener) {
(void)listener->event_cb(EVENT_STATE_ERROR, NULL, listener->cbdata);
}
return DBOX_STATUS_ERROR_NONE;
}
-static int activate_thread(void)
+int event_activate_thread(enum event_handler_activate_type activate_type)
{
int ret;
return ret;
}
- if (s_info.event_handler_activated) {
- ErrPrint("Event handler is already activated\n");
- return DBOX_STATUS_ERROR_ALREADY;
- }
-
if (s_info.event_handler) {
ErrPrint("Event handler is already registered\n");
return DBOX_STATUS_ERROR_ALREADY;
}
DbgPrint("Event handler activated\n");
- s_info.event_handler_activated = 1;
+ s_info.event_handler_activated = activate_type;
return DBOX_STATUS_ERROR_NONE;
}
-static int deactivate_thread(void)
+int event_deactivate_thread(enum event_handler_activate_type activate_type)
{
int status;
void *ret;
char event_ch = EVENT_CH;
+ if (s_info.event_handler_activated != activate_type) {
+ ErrPrint("Event handler activate type is mismatched\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
/* Terminating thread */
if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
ErrPrint("Unable to write tcb_pipe: %s\n", strerror(errno));
DbgPrint("Thread returns: %p\n", ret);
}
- s_info.event_handler_activated = 0;
+ s_info.event_handler_activated = EVENT_HANDLER_DEACTIVATED;
return DBOX_STATUS_ERROR_NONE;
}
listener->x = x;
listener->y = y;
- if (!s_info.event_handler_activated) {
+ if (s_info.event_handler_activated == EVENT_HANDLER_DEACTIVATED) {
/*!
* \note
* We don't need to lock to access event_list here.
} else {
s_info.event_listener_list = eina_list_append(s_info.event_listener_list, listener);
- if ((ret = activate_thread()) < 0) {
+ if ((ret = event_activate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET)) < 0) {
s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
DbgFree(listener);
}
return DBOX_STATUS_ERROR_NOT_EXIST;
}
- if (s_info.event_handler_activated == 0) {
+ if (s_info.event_handler_activated == EVENT_HANDLER_DEACTIVATED) {
ErrPrint("Event handler is not actiavated\n");
s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
DbgFree(listener);
return DBOX_STATUS_ERROR_NONE;
}
- deactivate_thread();
+ event_deactivate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET);
return DBOX_STATUS_ERROR_NONE;
}