summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conf.c13
-rw-r--r--src/event.c453
-rw-r--r--src/instance.c85
-rw-r--r--src/main.c4
-rw-r--r--src/script_handler.c8
-rw-r--r--src/server.c693
-rw-r--r--src/slave_life.c1
-rw-r--r--src/slave_rpc.c20
8 files changed, 1127 insertions, 150 deletions
diff --git a/src/conf.c b/src/conf.c
index aab6a7a..f0ab7ea 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -71,6 +71,7 @@ HAPI struct conf g_conf = {
.root = "/opt/usr/live/",
.script_port = "/usr/share/data-provider-master/plugin-script/",
.db = "/opt/dbspace/.livebox.db",
+ .input = "/dev/input/event1",
},
.ping_time = 240.0f,
@@ -307,6 +308,14 @@ static void share_path_handler(char *buffer)
DbgPrint("Shared folder: %s\n", g_conf.path.image);
}
+static void input_path_handler(char *buffer)
+{
+ g_conf.path.input = strdup(buffer);
+ if (!g_conf.path.input)
+ ErrPrint("Heap: %s\n", strerror(errno));
+ DbgPrint("Input device: %s\n", g_conf.path.input);
+}
+
static void ping_time_handler(char *buffer)
{
if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1)
@@ -469,6 +478,10 @@ HAPI int conf_loader(void)
.handler = com_core_thread_handler,
},
{
+ .name = "input",
+ .handler = input_path_handler,
+ },
+ {
.name = NULL,
.handler = NULL,
},
diff --git a/src/event.c b/src/event.c
new file mode 100644
index 0000000..0062abb
--- /dev/null
+++ b/src/event.c
@@ -0,0 +1,453 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <linux/input.h>
+
+#include <Eina.h>
+#include <Ecore.h>
+#include <dlog.h>
+
+#include "util.h"
+#include "debug.h"
+#include "conf.h"
+#include "event.h"
+
+#define CRITICAL_SECTION_BEGIN(lock) do { \
+ int ret; \
+ ret = pthread_mutex_lock(&lock); \
+ if (ret != 0) { \
+ ErrPrint("Unable to get lock: %s\n", strerror(ret)); \
+ } \
+} while (0)
+
+#define CRITICAL_SECTION_END(lock) do { \
+ int ret; \
+ ret = pthread_mutex_unlock(&lock); \
+ if (ret != 0) { \
+ ErrPrint("Unable to unlock: %s\n", strerror(ret)); \
+ } \
+} while (0)
+
+#define CANCEL_SECTION_BEGIN() do { \
+ int ret; \
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); \
+ if (ret != 0) \
+ ErrPrint("Unable to set cancelate state: %s\n", strerror(ret)); \
+} while (0)
+
+#define CANCEL_SECTION_END() do { \
+ int ret; \
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); \
+ if (ret != 0) \
+ ErrPrint("Unable to set cancelate state: %s\n", strerror(ret)); \
+} while (0)
+
+#define PIPE_READ 0
+#define PIPE_WRITE 1
+#define EVENT_CH 'e'
+
+int errno;
+
+static struct info {
+ pthread_t tid;
+ Eina_List *event_list;
+ int handle;
+ pthread_mutex_t event_list_lock;
+ int evt_pipe[2];
+ Ecore_Fd_Handler *event_handler;
+
+ int (*event_cb)(enum event_state state, struct event_data *event, void *data);
+ void *cbdata;
+
+ enum event_state event_state;
+ struct event_data event_data;
+
+ int x;
+ int y;
+} s_info = {
+ .event_list = NULL,
+ .handle = -1,
+ .event_handler = NULL,
+
+ .event_cb = NULL,
+ .cbdata = NULL,
+
+ .event_state = EVENT_STATE_DEACTIVATE,
+
+ .event_data = {
+ .x = 0,
+ .y = 0,
+ .device = -1,
+ },
+};
+
+HAPI int event_init(void)
+{
+ int ret;
+ ret = pthread_mutex_init(&s_info.event_list_lock, NULL);
+ if (ret != 0) {
+ ErrPrint("Mutex: %s\n", strerror(ret));
+ return -EFAULT;
+ }
+ return 0;
+}
+
+HAPI int event_fini(void)
+{
+ int ret;
+ ret = pthread_mutex_destroy(&s_info.event_list_lock);
+ if (ret != 0)
+ ErrPrint("Mutex destroy failed: %s\n", strerror(ret));
+ return 0;
+}
+
+static inline int processing_input_event(struct input_event *event)
+{
+ struct event_data *item;
+
+ switch (event->type) {
+ case EV_SYN:
+ switch (event->code) {
+ case SYN_REPORT:
+ if (s_info.event_data.x < 0 || s_info.event_data.y < 0) {
+ /* Waiting full event packet */
+ break;
+ }
+
+ item = malloc(sizeof(*item));
+ if (item) {
+ char event_ch;
+
+ memcpy(item, &s_info.event_data, sizeof(*item));
+
+ CRITICAL_SECTION_BEGIN(s_info.event_list_lock);
+ s_info.event_list = eina_list_append(s_info.event_list, item);
+ CRITICAL_SECTION_END(s_info.event_list_lock);
+
+ event_ch = EVENT_CH;
+ if (write(s_info.evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
+ ErrPrint("Unable to send an event: %s\n", strerror(errno));
+ return -EIO;
+ }
+ }
+ break;
+ case SYN_CONFIG:
+ break;
+ case SYN_MT_REPORT:
+ break;
+ /*
+ case SYN_DROPPED:
+ DbgPrint("EV_SYN, SYN_DROPPED\n");
+ break;
+ */
+ default:
+ DbgPrint("EV_SYN, 0x%x\n", event->code);
+ break;
+ }
+ break;
+ case EV_KEY:
+ break;
+ case EV_REL:
+ break;
+ case EV_ABS:
+ switch (event->code) {
+ case ABS_DISTANCE:
+ break;
+ case ABS_MT_POSITION_X:
+ s_info.event_data.x = event->value - s_info.x;
+ break;
+ case ABS_MT_POSITION_Y:
+ s_info.event_data.y = event->value - s_info.y;
+ break;
+ case ABS_MT_SLOT:
+ break;
+ case ABS_MT_TRACKING_ID:
+ s_info.event_data.device = event->value;
+ break;
+ case ABS_MT_TOUCH_MAJOR:
+ break;
+ case ABS_MT_TOUCH_MINOR:
+ break;
+ case ABS_MT_WIDTH_MAJOR:
+ break;
+ case ABS_MT_WIDTH_MINOR:
+ break;
+ default:
+ DbgPrint("EV_ABS, 0x%x\n", event->code);
+ break;
+ }
+ break;
+ case EV_MSC:
+ break;
+ case EV_SW:
+ break;
+ case EV_LED:
+ break;
+ case EV_SND:
+ break;
+ case EV_REP:
+ break;
+ case EV_FF:
+ break;
+ case EV_PWR:
+ break;
+ case EV_FF_STATUS:
+ break;
+ default:
+ DbgPrint("0x%X, 0x%X\n", event->type, event->code);
+ break;
+ }
+
+ return 0;
+}
+
+static void *event_main(void *data)
+{
+ fd_set set;
+ int ret = 0;
+ struct input_event input_event;
+ char *ptr = (char *)&input_event;
+ int offset = 0;
+ int readsize = 0;
+
+ DbgPrint("event_main initiated\n");
+
+ while (1) {
+ CANCEL_SECTION_BEGIN();
+ FD_ZERO(&set);
+ FD_SET(s_info.handle, &set);
+ ret = select(s_info.handle + 1, &set, NULL, NULL, NULL);
+ if (ret < 0) {
+ ret = -errno;
+ if (errno == EINTR) {
+ DbgPrint("Select receives INTR\n");
+ CANCEL_SECTION_END();
+ continue;
+ }
+ ErrPrint("Error: %s\n", strerror(errno));
+ CANCEL_SECTION_END();
+ return (void *)ret;
+ } else if (ret == 0) {
+ ErrPrint("Timeout expired\n");
+ CANCEL_SECTION_END();
+ return (void *)-ETIMEDOUT;
+ }
+ CANCEL_SECTION_END();
+
+ if (!FD_ISSET(s_info.handle, &set)) {
+ ErrPrint("Unexpected handle is toggled\n");
+ ret = -EINVAL;
+ break;
+ }
+
+ readsize = read(s_info.handle, ptr + offset, sizeof(input_event) - offset);
+ if (readsize < 0) {
+ ErrPrint("Unable to read device: %s / fd: %d / offset: %d / size: %d - %d\n", strerror(errno), s_info.handle, offset, sizeof(input_event), readsize);
+ ret = -EFAULT;
+ break;
+ }
+
+ offset += readsize;
+ if (offset == sizeof(input_event)) {
+ offset = 0;
+ if (processing_input_event(&input_event) < 0) {
+ ret = -EFAULT;
+ break;
+ }
+ }
+ }
+
+ return (void *)ret;
+}
+
+static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
+{
+ int fd;
+ struct event_data *item;
+ char event_ch;
+
+ fd = ecore_main_fd_handler_fd_get(handler);
+ if (fd < 0) {
+ ErrPrint("Invalid fd\n");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (read(fd, &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
+ ErrPrint("Unable to read event ch: %s\n", strerror(errno));
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ CRITICAL_SECTION_BEGIN(s_info.event_list_lock);
+ item = eina_list_nth(s_info.event_list, 0);
+ if (item)
+ s_info.event_list = eina_list_remove(s_info.event_list, item);
+ else
+ ErrPrint("Unable to get event\n");
+ CRITICAL_SECTION_END(s_info.event_list_lock);
+
+ if (item && s_info.event_cb) {
+ switch (s_info.event_state) {
+ case EVENT_STATE_DEACTIVATE:
+ s_info.event_state = EVENT_STATE_ACTIVATE;
+ break;
+ case EVENT_STATE_ACTIVATE:
+ s_info.event_state = EVENT_STATE_ACTIVATED;
+ break;
+ case EVENT_STATE_ACTIVATED:
+ default:
+ break;
+ }
+ s_info.event_cb(s_info.event_state, item, s_info.cbdata);
+ }
+
+ free(item);
+ return ECORE_CALLBACK_RENEW;
+}
+
+HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
+{
+ int status;
+
+ if (s_info.handle >= 0) {
+ DbgPrint("Already activated\n");
+ return 0;
+ }
+
+ s_info.handle = open(INPUT_PATH, O_RDONLY);
+ if (s_info.handle < 0) {
+ ErrPrint("Unable to access the device: %s\n", strerror(errno));
+ return -EIO;
+ }
+
+ if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+
+ if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+
+ status = pipe2(s_info.evt_pipe, O_NONBLOCK | O_CLOEXEC);
+ if (status < 0) {
+ ErrPrint("Unable to prepare evt pipe: %s\n", strerror(errno));
+ if (close(s_info.handle) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+ s_info.handle = -1;
+ return -EFAULT;
+ }
+
+ s_info.event_handler = ecore_main_fd_handler_add(s_info.evt_pipe[PIPE_READ], ECORE_FD_READ, event_read_cb, NULL, NULL, NULL);
+ if (!s_info.event_handler) {
+ if (close(s_info.handle) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_READ]) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_WRITE]) < 0)
+ ErrPrint("Failed to close handle: %s\n", strerror(errno));
+
+ s_info.handle = -1;
+ return -EFAULT;
+ }
+
+ status = pthread_create(&s_info.tid, NULL, event_main, NULL);
+ if (status != 0) {
+ ErrPrint("Failed to initiate the thread: %s\n", strerror(status));
+ ecore_main_fd_handler_del(s_info.event_handler);
+ s_info.event_handler = NULL;
+
+ if (close(s_info.handle) < 0)
+ ErrPrint("close: %s\n", strerror(errno));
+ s_info.handle = -1;
+
+ if (close(s_info.evt_pipe[PIPE_READ]) < 0)
+ ErrPrint("close: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_WRITE]) < 0)
+ ErrPrint("close: %s\n", strerror(errno));
+
+ return -EFAULT;
+ }
+
+ s_info.event_cb = event_cb;
+ s_info.cbdata = data;
+ s_info.x = x;
+ s_info.y = y;
+
+ DbgPrint("Event handler activated\n");
+ return 0;
+}
+
+HAPI int event_deactivate(void)
+{
+ int status;
+ struct event_data *event;
+ void *ret;
+
+ if (s_info.handle < 0) {
+ ErrPrint("Event handler is not actiavated\n");
+ return 0;
+ }
+
+ status = pthread_cancel(s_info.tid);
+ if (status != 0)
+ ErrPrint("Failed to cacnel a thread: %s\n", strerror(errno));
+
+ status = pthread_join(s_info.tid, &ret);
+ if (status != 0)
+ ErrPrint("Failed to join a thread: %s\n", strerror(errno));
+ else if (ret == PTHREAD_CANCELED)
+ DbgPrint("Thread is canceled\n");
+
+ ecore_main_fd_handler_del(s_info.event_handler);
+ s_info.event_handler = NULL;
+
+ if (close(s_info.evt_pipe[PIPE_READ]) < 0)
+ ErrPrint("Failed to close: %s\n", strerror(errno));
+
+ if (close(s_info.evt_pipe[PIPE_WRITE]) < 0)
+ ErrPrint("Failed to close: %s\n", strerror(errno));
+
+ if (close(s_info.handle) < 0)
+ ErrPrint("Unable to release the fd: %s\n", strerror(errno));
+
+ s_info.handle = -1;
+ DbgPrint("Event handler deactivated\n");
+
+ EINA_LIST_FREE(s_info.event_list, event) {
+ if (s_info.event_cb) {
+ if (s_info.event_state == EVENT_STATE_DEACTIVATE) {
+ s_info.event_state = EVENT_STATE_ACTIVATE;
+ } else if (s_info.event_state == EVENT_STATE_ACTIVATE) {
+ s_info.event_state = EVENT_STATE_ACTIVATED;
+ }
+ s_info.event_cb(s_info.event_state, event, s_info.cbdata);
+ }
+ free(event);
+ }
+
+ if (s_info.event_state != EVENT_STATE_DEACTIVATE) {
+ s_info.event_state = EVENT_STATE_DEACTIVATE;
+
+ if (s_info.event_cb)
+ s_info.event_cb(s_info.event_state, &s_info.event_data, s_info.cbdata);
+ }
+
+ s_info.event_data.x = -1;
+ s_info.event_data.y = -1;
+
+ return 0;
+}
+
+HAPI int event_is_activated(void)
+{
+ return s_info.handle >= 0;
+}
+
+/* End of a file */
diff --git a/src/instance.c b/src/instance.c
index fc66287..a0e2e7f 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -72,6 +72,11 @@ struct period_cbdata {
double period;
};
+struct event_item {
+ int (*event_cb)(struct inst_info *inst, void *data);
+ void *data;
+};
+
struct inst_info {
struct pkg_info *info;
@@ -129,6 +134,8 @@ struct inst_info {
int refcnt;
Ecore_Timer *update_timer; /*!< Only used for secured livebox */
+
+ Eina_List *delete_event_list;
};
#define CLIENT_SEND_EVENT(instance, packet) ((instance)->client ? client_rpc_async_request((instance)->client, (packet)) : client_broadcast((instance), (packet)))
@@ -442,12 +449,81 @@ static int send_pd_destroyed_to_client(struct inst_info *inst, int status)
return CLIENT_SEND_EVENT(inst, packet);
}
+static inline void invoke_delete_callbacks(struct inst_info *inst)
+{
+ Eina_List *l;
+ Eina_List *n;
+ struct event_item *item;
+
+ EINA_LIST_FOREACH_SAFE(inst->delete_event_list, l, n, item) {
+ if (item->event_cb(inst, item->data) < 0) {
+ if (eina_list_data_find(inst->delete_event_list, item)) {
+ inst->delete_event_list = eina_list_remove(inst->delete_event_list, item);
+ free(item);
+ }
+ }
+ }
+}
+
+HAPI int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data)
+{
+ struct event_item *item;
+
+ if (!event_cb)
+ return -EINVAL;
+
+ switch (type) {
+ case INSTANCE_EVENT_DESTROY:
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
+
+ item->event_cb = event_cb;
+ item->data = data;
+
+ inst->delete_event_list = eina_list_append(inst->delete_event_list, item);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data))
+{
+ Eina_List *l;
+ Eina_List *n;
+ struct event_item *item;
+
+ switch (type) {
+ case INSTANCE_EVENT_DESTROY:
+ EINA_LIST_FOREACH_SAFE(inst->delete_event_list, l, n, item) {
+ if (item->event_cb == event_cb) {
+ inst->delete_event_list = eina_list_remove(inst->delete_event_list, item);
+ free(item);
+ return 0;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return -ENOENT;
+}
+
static inline void destroy_instance(struct inst_info *inst)
{
struct pkg_info *pkg;
enum lb_type lb_type;
enum pd_type pd_type;
struct slave_node *slave;
+ struct event_item *item;
+
+ invoke_delete_callbacks(inst);
pkg = inst->info;
@@ -492,6 +568,9 @@ static inline void destroy_instance(struct inst_info *inst)
* will be released by the package object
* it is readonly value for instances
*/
+ EINA_LIST_FREE(inst->delete_event_list, item) {
+ free(item);
+ }
DbgFree(inst->category);
DbgFree(inst->cluster);
DbgFree(inst->content);
@@ -2425,14 +2504,12 @@ HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *clie
*/
if (package_pd_type(info) == PD_TYPE_BUFFER) {
instance_ref(inst);
- if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0) {
+ if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0)
instance_unref(inst);
- }
} else if (package_pd_type(info) == PD_TYPE_SCRIPT) {
instance_ref(inst);
- if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0) {
+ if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0)
instance_unref(inst);
- }
}
inst->pd.owner = client;
diff --git a/src/main.c b/src/main.c
index 32538bd..afdce30 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,7 @@
#include "util.h"
#include "debug.h"
#include "critical_log.h"
+#include "event.h"
#if defined(FLOG)
FILE *__file_log_fp;
@@ -110,6 +111,7 @@ static inline int app_create(void)
ret = server_init();
DbgPrint("Server initialized: %d\n", ret);
+ event_init();
return 0;
}
@@ -117,6 +119,8 @@ static inline int app_terminate(void)
{
int ret;
+ event_fini();
+
ret = setting_fini();
DbgPrint("Finalize setting : %d\n", ret);
diff --git a/src/script_handler.c b/src/script_handler.c
index 2fe88da..ff8f82d 100644
--- a/src/script_handler.c
+++ b/src/script_handler.c
@@ -118,8 +118,8 @@ struct script_info {
int w;
int h;
- double x;
- double y;
+ int x;
+ int y;
int down;
struct script_port *port;
@@ -221,7 +221,7 @@ int script_signal_emit(Evas *e, const char *part, const char *signal, double sx,
if (!part || strlen(part) == 0)
part = "";
- ret = instance_signal_emit(info->inst, signal, part, sx, sy, ex, ey, info->x, info->y, info->down);
+ ret = instance_signal_emit(info->inst, signal, part, sx, sy, ex, ey, (double)info->x / (double)info->w, (double)info->y / (double)info->h, info->down);
return ret;
}
@@ -1298,7 +1298,7 @@ HAPI int script_fini(void)
return 0;
}
-HAPI int script_handler_update_pointer(struct script_info *info, double x, double y, int down)
+HAPI int script_handler_update_pointer(struct script_info *info, int x, int y, int down)
{
if (!info)
return 0;
diff --git a/src/server.c b/src/server.c
index c22c399..012fd9b 100644
--- a/src/server.c
+++ b/src/server.c
@@ -46,6 +46,7 @@
#include "abi.h"
#include "liveinfo.h"
#include "io.h"
+#include "event.h"
static struct info {
int info_fd;
@@ -71,6 +72,169 @@ struct deleted_item {
struct inst_info *inst;
};
+static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ struct slave_node *slave;
+ struct packet *packet;
+ const char *cmdstr;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return -EINVAL;
+
+ slave = package_slave(pkg);
+ if (!slave)
+ return -EINVAL;
+
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ cmdstr = "lb_mouse_down";
+ break;
+ case EVENT_STATE_ACTIVATED:
+ cmdstr = "lb_mouse_move";
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ cmdstr = "lb_mouse_up";
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
+ if (!packet)
+ return -EFAULT;
+
+ return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
+}
+
+static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct script_info *script;
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ double timestamp;
+ Evas *e;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return 0;
+
+ script = instance_lb_script(inst);
+ if (!script)
+ return -EFAULT;
+
+ e = script_handler_evas(script);
+ if (!e)
+ return -EFAULT;
+
+ timestamp = util_timestamp();
+
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+ break;
+ case EVENT_STATE_ACTIVATED:
+ script_handler_update_pointer(script, event_info->x, event_info->y, -1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 0);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ struct slave_node *slave;
+ struct packet *packet;
+ const char *cmdstr;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return -EINVAL;
+
+ slave = package_slave(pkg);
+ if (!slave)
+ return -EINVAL;
+
+ DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ cmdstr = "pd_mouse_down";
+ break;
+ case EVENT_STATE_ACTIVATED:
+ cmdstr = "pd_mouse_move";
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ cmdstr = "pd_mouse_up";
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
+ if (!packet)
+ return -EFAULT;
+
+ return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
+}
+
+static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+{
+ struct script_info *script;
+ struct inst_info *inst = data;
+ const struct pkg_info *pkg;
+ double timestamp;
+ Evas *e;
+
+ pkg = instance_package(inst);
+ if (!pkg)
+ return 0;
+
+ script = instance_pd_script(inst);
+ if (!script)
+ return -EFAULT;
+
+ e = script_handler_evas(script);
+ if (!e)
+ return -EFAULT;
+
+ DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
+ timestamp = util_timestamp();
+
+ switch (state) {
+ case EVENT_STATE_ACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+ break;
+ case EVENT_STATE_ACTIVATED:
+ script_handler_update_pointer(script, event_info->x, event_info->y, -1);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ script_handler_update_pointer(script, event_info->x, event_info->y, 0);
+ evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
+ evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
{
struct client_node *client;
@@ -144,8 +308,8 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet
const char *id;
const char *event;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
int ret;
struct inst_info *inst;
@@ -156,14 +320,14 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet
goto out;
}
- ret = packet_get(packet, "sssddd", &pkgname, &id, &event, &timestamp, &x, &y);
+ ret = packet_get(packet, "sssdii", &pkgname, &id, &event, &timestamp, &x, &y);
if (ret != 6) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
+ DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%d] y[%d]\n", pid, pkgname, id, event, timestamp, x, y);
/*!
* \NOTE:
@@ -619,11 +783,9 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -634,8 +796,8 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
@@ -733,11 +895,9 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -748,8 +908,8 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
@@ -847,11 +1007,9 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -862,14 +1020,14 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+ DbgPrint("(%dx%d)\n", x, y);
/*!
* \NOTE:
@@ -945,7 +1103,7 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
}
script_handler_update_pointer(script, x, y, 1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
ret = 0;
} else {
@@ -964,11 +1122,9 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -979,14 +1135,14 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+ DbgPrint("(%dx%d)\n", x, y);
/*!
* \NOTE:
* Trust the package name which are sent by the client.
@@ -1061,7 +1217,7 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
}
script_handler_update_pointer(script, x, y, 0);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
ret = 0;
} else {
@@ -1080,11 +1236,9 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1095,14 +1249,14 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
}
- DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+ DbgPrint("(%dx%d)\n", x, y);
/*!
* \NOTE:
* Trust the package name which are sent by the client.
@@ -1177,7 +1331,7 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
}
script_handler_update_pointer(script, x, y, -1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
@@ -1195,11 +1349,9 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1210,8 +1362,8 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
@@ -1290,7 +1442,7 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p
}
script_handler_update_pointer(script, x, y, -1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
@@ -1302,17 +1454,296 @@ out:
return NULL;
}
+static int inst_del_cb(struct inst_info *inst, void *data)
+{
+ event_deactivate();
+ return -1; /* Delete this callback */
+}
+
+static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_lb_route_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_lb_consume_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+out:
+ return NULL;
+}
+
+static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+out:
+ return NULL;
+}
+
+static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_pd_route_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (event_is_activated()) {
+ if (event_deactivate() == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ }
+
+ ret = event_activate(x, y, event_pd_consume_cb, inst);
+ if (ret == 0)
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double timestamp;
+ int x;
+ int y;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ client = client_find_by_pid(pid);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (package_is_fault(pkg)) {
+ /*!
+ * \note
+ * If the package is registered as fault module,
+ * slave has not load it, so we don't need to do anything at here!
+ */
+ DbgPrint("Package[%s] is faulted\n", pkgname);
+ ret = -EFAULT;
+ } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ ret = event_deactivate();
+ if (ret == 0)
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
+ } else {
+ ErrPrint("Unsupported package\n");
+ ret = -EINVAL;
+ }
+out:
+ return NULL;
+}
+
static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1323,8 +1754,8 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
@@ -1421,11 +1852,9 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1436,8 +1865,8 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
@@ -1535,11 +1964,9 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1550,8 +1977,8 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
@@ -1631,7 +2058,7 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p
}
script_handler_update_pointer(script, x, y, 1);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
ret = 0;
} else {
@@ -1650,11 +2077,9 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1665,8 +2090,8 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
goto out;
@@ -1746,7 +2171,7 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac
}
script_handler_update_pointer(script, x, y, 0);
- evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
ret = 0;
} else {
@@ -1765,11 +2190,9 @@ static struct packet *client_pd_access_read(pid_t pid, int handle, const struct
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1780,8 +2203,8 @@ static struct packet *client_pd_access_read(pid_t pid, int handle, const struct
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
@@ -1881,11 +2304,9 @@ static struct packet *client_pd_access_read_prev(pid_t pid, int handle, const st
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -1896,8 +2317,8 @@ static struct packet *client_pd_access_read_prev(pid_t pid, int handle, const st
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
@@ -1997,11 +2418,9 @@ static struct packet *client_pd_access_read_next(pid_t pid, int handle, const st
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2012,8 +2431,8 @@ static struct packet *client_pd_access_read_next(pid_t pid, int handle, const st
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
@@ -2113,11 +2532,9 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2128,8 +2545,8 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
@@ -2229,11 +2646,9 @@ static struct packet *client_pd_key_down(pid_t pid, int handle, const struct pac
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2244,8 +2659,8 @@ static struct packet *client_pd_key_down(pid_t pid, int handle, const struct pac
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
- if (ret != 7) {
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
+ if (ret != 5) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
goto out;
@@ -2403,11 +2818,9 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2418,7 +2831,7 @@ static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packe
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Invalid parameter\n");
ret = -EINVAL;
@@ -2519,11 +2932,9 @@ static struct packet *client_lb_access_read(pid_t pid, int handle, const struct
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2534,7 +2945,7 @@ static struct packet *client_lb_access_read(pid_t pid, int handle, const struct
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
@@ -2636,11 +3047,9 @@ static struct packet *client_lb_access_read_prev(pid_t pid, int handle, const st
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2651,7 +3060,7 @@ static struct packet *client_lb_access_read_prev(pid_t pid, int handle, const st
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
@@ -2753,11 +3162,9 @@ static struct packet *client_lb_access_read_next(pid_t pid, int handle, const st
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2768,7 +3175,7 @@ static struct packet *client_lb_access_read_next(pid_t pid, int handle, const st
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
@@ -2870,11 +3277,9 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -2885,7 +3290,7 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
@@ -2987,11 +3392,9 @@ static struct packet *client_lb_key_down(pid_t pid, int handle, const struct pac
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -3002,7 +3405,7 @@ static struct packet *client_lb_key_down(pid_t pid, int handle, const struct pac
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
@@ -3104,11 +3507,9 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
const char *pkgname;
const char *id;
int ret;
- int w;
- int h;
double timestamp;
- double x;
- double y;
+ int x;
+ int y;
struct inst_info *inst;
const struct pkg_info *pkg;
@@ -3119,7 +3520,7 @@ static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packe
goto out;
}
- ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, &timestamp, &x, &y);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &x, &y);
if (ret != 7) {
ErrPrint("Parameter is not matched\n");
ret = -EINVAL;
@@ -5264,6 +5665,22 @@ static struct method s_client_table[] = {
.handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
},
{
+ .cmd = "lb_mouse_set",
+ .handler = client_lb_mouse_set,
+ },
+ {
+ .cmd = "lb_mouse_unset",
+ .handler = client_lb_mouse_unset,
+ },
+ {
+ .cmd = "pd_mouse_set",
+ .handler = client_pd_mouse_set,
+ },
+ {
+ .cmd = "pd_mouse_unset",
+ .handler = client_pd_mouse_unset,
+ },
+ {
.cmd = "change,visibility",
.handler = client_change_visibility,
},
diff --git a/src/slave_life.c b/src/slave_life.c
index 3665b4d..3f72323 100644
--- a/src/slave_life.c
+++ b/src/slave_life.c
@@ -389,6 +389,7 @@ static Eina_Bool activate_timer_cb(void *data)
if (ret < 0)
ErrPrint("Terminate failed, pid %d\n", slave->pid);
}
+
slave = slave_deactivated(slave);
ErrPrint("Slave is not activated in %lf sec (slave: %p)\n", SLAVE_ACTIVATE_TIME, slave);
return ECORE_CALLBACK_CANCEL;
diff --git a/src/slave_rpc.c b/src/slave_rpc.c
index 2aa8229..4853d97 100644
--- a/src/slave_rpc.c
+++ b/src/slave_rpc.c
@@ -19,6 +19,7 @@
#include <errno.h> /* errno */
#include <unistd.h> /* pid_t */
#include <stdlib.h> /* free */
+#include <assert.h>
#include <Eina.h>
#include <Ecore.h>
@@ -291,18 +292,29 @@ static int slave_deactivate_cb(struct slave_node *slave, void *data)
ErrPrint("slave has no pong timer\n");
}
- EINA_LIST_FOREACH_SAFE(s_info.command_list, l, n, command) {
- if (command->slave == slave) {
- s_info.command_list = eina_list_remove(s_info.command_list, command);
+ if (rpc->handle < 0) {
+ EINA_LIST_FREE(rpc->pending_list, command) {
+ assert(command->slave == slave);
+ if (command->ret_cb)
+ command->ret_cb(command->slave, NULL, command->cbdata);
destroy_command(command);
}
+ } else {
+ EINA_LIST_FOREACH_SAFE(s_info.command_list, l, n, command) {
+ if (command->slave == slave) {
+ s_info.command_list = eina_list_remove(s_info.command_list, command);
+ if (command->ret_cb)
+ command->ret_cb(command->slave, NULL, command->cbdata);
+ destroy_command(command);
+ }
+ }
}
/*!
* \note
* Reset handle
*/
- DbgPrint("Reset handle for %d\n", slave_pid(slave));
+ DbgPrint("Reset handle for %d (%d)\n", slave_pid(slave), rpc->handle);
rpc->handle = -1;
/*!