2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <sys/types.h>
27 #include <com-core_packet.h>
30 #include <livebox-errno.h>
37 #include "provider_buffer.h"
38 #include "provider_buffer_internal.h"
40 #define EAPI __attribute__((visibility("default")))
43 struct dlist *buffer_list;
48 static inline struct fb_info *send_acquire_request(enum target_type type, const char *pkgname, const char *id, int w, int h, int size)
50 struct packet *packet;
51 struct packet *result;
52 const char *buffer_id;
56 packet = packet_create("acquire_buffer", "issiii", type, pkgname, id, w, h, size);
58 ErrPrint("Failed to build a packet\n");
62 result = com_core_packet_oneshot_send(SLAVE_SOCKET, packet, 0.0f);
63 packet_destroy(packet);
66 ErrPrint("Failed to send a request\n");
70 if (packet_get(result, "is", &status, &buffer_id) != 2) {
71 ErrPrint("Failed to get a result packet\n");
77 ErrPrint("Failed to acquire buffer: %d\n", status);
82 ret = fb_create(buffer_id, w, h);
84 * \TODO: Implements me
86 DbgPrint("type: 0x%X, name: %s, pkgname[%s], id[%s], w[%d], h[%d], size[%d], buffer_id[%s], fb[%p]\n", type, provider_name(), pkgname, id, w, h, size, buffer_id, ret);
92 static inline int send_release_request(enum target_type type, const char *pkgname, const char *id)
94 struct packet *packet;
95 struct packet *result;
98 packet = packet_create("release_buffer", "iss", type, pkgname, id);
100 ErrPrint("Failed to build a packet\n");
101 return LB_STATUS_ERROR_FAULT;
104 result = com_core_packet_oneshot_send(SLAVE_SOCKET, packet, 0.0f);
105 packet_destroy(packet);
107 ErrPrint("Failed to send a request\n");
108 return LB_STATUS_ERROR_FAULT;
111 if (packet_get(result, "i", &ret) != 1) {
112 ErrPrint("Invalid result packet\n");
113 ret = LB_STATUS_ERROR_INVALID;
116 packet_unref(result);
120 static inline struct fb_info *send_resize_request(enum target_type type, const char *pkgname, const char *id, int w, int h)
122 struct packet *packet;
123 struct packet *result;
125 const char *buffer_id;
128 packet = packet_create("resize_buffer", "issii", type, pkgname, id, w, h);
130 ErrPrint("Faield to build a packet\n");
134 result = com_core_packet_oneshot_send(SLAVE_SOCKET, packet, 0.0f);
135 packet_destroy(packet);
137 ErrPrint("Failed to send a request\n");
141 if (packet_get(result, "is", &ret, &buffer_id) != 2) {
142 ErrPrint("Invalid result packet\n");
143 packet_unref(result);
147 fb = (ret == 0) ? fb_create(buffer_id, w, h) : NULL;
148 packet_unref(result);
152 struct livebox_buffer *provider_buffer_find_buffer(enum target_type type, const char *pkgname, const char *id)
156 struct livebox_buffer *info;
158 dlist_foreach_safe(s_info.buffer_list, l, n, info) {
159 if (info->type != type)
162 if (!strcmp(info->pkgname, pkgname) && !strcmp(info->id, id))
169 EAPI int provider_buffer_set_user_data(struct livebox_buffer *handle, void *data)
171 if (!handle || handle->state != BUFFER_CREATED) {
172 ErrPrint("info is not valid\n");
173 return LB_STATUS_ERROR_INVALID;
176 handle->user_data = data;
177 return LB_STATUS_SUCCESS;
180 EAPI void *provider_buffer_user_data(struct livebox_buffer *handle)
182 if (!handle || handle->state != BUFFER_CREATED) {
183 ErrPrint("info is not valid\n");
187 return handle->user_data;
190 EAPI struct livebox_buffer *provider_buffer_acquire(enum target_type type, const char *pkgname, const char *id, int width, int height, int pixel_size, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data)
192 struct livebox_buffer *info;
194 if (width <= 0 || height <= 0 || pixel_size <= 0) {
195 ErrPrint("Invalid size: %dx%d, %d\n", width, height, pixel_size);
200 ErrPrint("Invalid parameter: pkgname is NIL\n");
205 ErrPrint("Invalid ID: id is NIL\n");
210 DbgPrint("Event handler is not speicified\n");
212 DbgPrint("acquire_buffer: [%s] %s, %dx%d, size: %d, handler: %p\n",
213 type == TYPE_LB ? "LB" : "PD", id,
214 width, height, pixel_size, handler);
216 info = malloc(sizeof(*info));
218 ErrPrint("Heap: %s\n", strerror(errno));
222 info->pkgname = strdup(pkgname);
223 if (!info->pkgname) {
224 ErrPrint("Heap: %s\n", strerror(errno));
229 info->id = strdup(id);
231 ErrPrint("Heap: %s\n", strerror(errno));
237 info->fb = send_acquire_request(type, pkgname, id, width, height, pixel_size);
239 ErrPrint("Failed to acquire a info\n");
247 info->height = height;
248 info->pixel_size = pixel_size;
249 info->handler = handler;
252 info->state = BUFFER_CREATED;
254 s_info.buffer_list = dlist_prepend(s_info.buffer_list, info);
258 EAPI int provider_buffer_resize(struct livebox_buffer *info, int w, int h)
262 if (!info || info->state != BUFFER_CREATED) {
263 ErrPrint("info is not valid\n");
264 return LB_STATUS_ERROR_INVALID;
267 fb = send_resize_request(info->type, info->pkgname, info->id, w, h);
269 return LB_STATUS_ERROR_INVALID;
273 * Even if we destroy the buffer object,
274 * if the user references it, it will not be destroyed,
275 * it only can be destroyed when there is no reference exists.
278 return LB_STATUS_SUCCESS;
281 EAPI void *provider_buffer_ref(struct livebox_buffer *info)
283 if (!info || info->state != BUFFER_CREATED) {
284 ErrPrint("info is not valid\n");
288 return fb_acquire_buffer(info->fb);
291 EAPI int provider_buffer_unref(void *ptr)
294 ErrPrint("PTR is not valid\n");
295 return LB_STATUS_ERROR_INVALID;
298 return fb_release_buffer(ptr);
301 EAPI int provider_buffer_release(struct livebox_buffer *info)
305 if (!info || info->state != BUFFER_CREATED) {
306 ErrPrint("Buffer handler is NULL\n");
307 return LB_STATUS_ERROR_INVALID;
310 dlist_remove_data(s_info.buffer_list, info);
312 ret = send_release_request(info->type, info->pkgname, info->id);
314 ErrPrint("Failed to send a release request\n");
317 * But go ahead to destroy this buffer object
321 info->state = BUFFER_DESTROYED;
325 return LB_STATUS_SUCCESS;
328 EAPI int provider_buffer_sync(struct livebox_buffer *info)
330 if (!info || info->state != BUFFER_CREATED) {
331 ErrPrint("Buffer handler is NULL\n");
332 return LB_STATUS_ERROR_INVALID;
335 return fb_sync(info->fb);
338 EAPI enum target_type provider_buffer_type(struct livebox_buffer *info)
340 if (!info || info->state != BUFFER_CREATED) {
341 ErrPrint("Buffer handler is NULL\n");
348 EAPI const char *provider_buffer_pkgname(struct livebox_buffer *info)
350 if (!info || info->state != BUFFER_CREATED) {
351 ErrPrint("Buffer handler is NULL\n");
355 return info->pkgname;
360 * Getting the URI of given buffer.
362 EAPI const char *provider_buffer_id(struct livebox_buffer *info)
364 if (!info || info->state != BUFFER_CREATED) {
365 ErrPrint("Buffer handler is NULL\n");
372 EAPI int provider_buffer_get_size(struct livebox_buffer *info, int *w, int *h, int *pixel_size)
374 if (!info || info->state != BUFFER_CREATED) {
375 ErrPrint("Buffer handler is NULL\n");
376 return LB_STATUS_ERROR_INVALID;
386 *pixel_size = info->pixel_size;
388 return LB_STATUS_SUCCESS;
391 EAPI const char *provider_buffer_uri(struct livebox_buffer *info)
393 if (!info || info->state != BUFFER_CREATED) {
394 ErrPrint("Buffer handler is NULL\n");
398 return fb_id(info->fb);
403 * If the given buffer is created as pixmap,
404 * This function returns pixmap ID.
406 EAPI unsigned long provider_buffer_pixmap_id(struct livebox_buffer *info)
409 unsigned long pixmap;
411 if (!info || info->state != BUFFER_CREATED) {
412 ErrPrint("Buffer handler is NULL\n");
416 id = fb_id(info->fb);
420 if (sscanf(id, SCHEMA_PIXMAP "%lu", &pixmap) != 1) {
421 ErrPrint("Invalid ID: %s\n", id);
428 EAPI int provider_buffer_pixmap_is_support_hw(struct livebox_buffer *info)
431 return LB_STATUS_ERROR_INVALID;
433 return fb_has_gem(info->fb);
436 EAPI int provider_buffer_pixmap_create_hw(struct livebox_buffer *info)
438 if (!fb_has_gem(info->fb))
439 return LB_STATUS_ERROR_INVALID;
441 return fb_create_gem(info->fb);
444 EAPI int provider_buffer_pixmap_destroy_hw(struct livebox_buffer *info)
446 if (!info || !fb_has_gem(info->fb))
447 return LB_STATUS_ERROR_INVALID;
449 return fb_destroy_gem(info->fb);
452 EAPI void *provider_buffer_pixmap_hw_addr(struct livebox_buffer *info)
456 if (!info || !fb_has_gem(info->fb))
459 addr = fb_acquire_gem(info->fb);
460 fb_release_gem(info->fb);
465 EAPI int provider_buffer_pre_render(struct livebox_buffer *info)
467 int ret = LB_STATUS_SUCCESS;
470 return LB_STATUS_ERROR_INVALID;
472 if (fb_has_gem(info->fb))
473 ret = fb_acquire_gem(info->fb) ? 0 : -EFAULT;
478 EAPI int provider_buffer_post_render(struct livebox_buffer *info)
480 int ret = LB_STATUS_SUCCESS;
483 return LB_STATUS_ERROR_INVALID;
485 if (fb_has_gem(info->fb))
486 ret = fb_release_gem(info->fb);
491 int provider_buffer_init(void *display)
493 return fb_init(display);
496 int provider_buffer_fini(void)
501 struct packet *provider_buffer_lb_key_down(pid_t pid, int handle, const struct packet *packet)
508 struct livebox_buffer *info;
510 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
511 ErrPrint("Invalid packet\n");
515 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
517 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
525 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
526 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
530 (void)info->handler(info, BUFFER_EVENT_KEY_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
537 struct packet *provider_buffer_lb_key_up(pid_t pid, int handle, const struct packet *packet)
544 struct livebox_buffer *info;
546 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
547 ErrPrint("Invalid packet\n");
551 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
553 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
561 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
562 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
566 (void)info->handler(info, BUFFER_EVENT_KEY_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
573 struct packet *provider_buffer_lb_mouse_enter(pid_t pid, int handle, const struct packet *packet)
580 struct livebox_buffer *info;
582 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
583 ErrPrint("Invalid packet\n");
587 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
589 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
596 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
597 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
601 (void)info->handler(info, BUFFER_EVENT_ENTER, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
608 struct packet *provider_buffer_lb_mouse_leave(pid_t pid, int handle, const struct packet *packet)
615 struct livebox_buffer *info;
617 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
618 ErrPrint("Invalid packet\n");
622 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
624 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
631 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
632 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
636 (void)info->handler(info, BUFFER_EVENT_LEAVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
643 struct packet *provider_buffer_lb_mouse_down(pid_t pid, int handle, const struct packet *packet)
650 struct livebox_buffer *info;
652 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
653 ErrPrint("Invalid packet\n");
657 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
659 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
666 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
667 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
671 (void)info->handler(info, BUFFER_EVENT_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
678 struct packet *provider_buffer_lb_mouse_up(pid_t pid, int handle, const struct packet *packet)
685 struct livebox_buffer *info;
687 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
688 ErrPrint("Invalid packet\n");
692 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
694 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
701 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
702 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
706 (void)info->handler(info, BUFFER_EVENT_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
713 struct packet *provider_buffer_lb_mouse_move(pid_t pid, int handle, const struct packet *packet)
720 struct livebox_buffer *info;
722 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
723 ErrPrint("Invalid packet\n");
727 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
729 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
736 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
737 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
740 (void)info->handler(info, BUFFER_EVENT_MOVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
747 struct packet *provider_buffer_pd_key_down(pid_t pid, int handle, const struct packet *packet)
754 struct livebox_buffer *info;
756 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
757 ErrPrint("Invalid packet\n");
761 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
763 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
770 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
771 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
775 (void)info->handler(info, BUFFER_EVENT_KEY_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
782 struct packet *provider_buffer_pd_key_up(pid_t pid, int handle, const struct packet *packet)
789 struct livebox_buffer *info;
791 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
792 ErrPrint("Invalid packet\n");
796 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
798 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
805 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
806 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
810 (void)info->handler(info, BUFFER_EVENT_KEY_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
817 struct packet *provider_buffer_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
824 struct livebox_buffer *info;
826 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
827 ErrPrint("Invalid packet\n");
831 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
833 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
840 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
841 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
845 (void)info->handler(info, BUFFER_EVENT_ENTER, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
852 struct packet *provider_buffer_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
859 struct livebox_buffer *info;
861 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
862 ErrPrint("Invalid packet\n");
866 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
868 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
875 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
876 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
880 (void)info->handler(info, BUFFER_EVENT_LEAVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
887 struct packet *provider_buffer_pd_mouse_down(pid_t pid, int handle, const struct packet *packet)
894 struct livebox_buffer *info;
896 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
897 ErrPrint("Invalid packet\n");
901 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
903 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
910 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
911 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
915 (void)info->handler(info, BUFFER_EVENT_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
922 struct packet *provider_buffer_pd_mouse_up(pid_t pid, int handle, const struct packet *packet)
929 struct livebox_buffer *info;
931 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
932 ErrPrint("Invalid packet\n");
936 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
938 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
945 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
946 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
950 (void)info->handler(info, BUFFER_EVENT_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
957 struct packet *provider_buffer_pd_mouse_move(pid_t pid, int handle, const struct packet *packet)
964 struct livebox_buffer *info;
966 if (packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y) != 5) {
967 ErrPrint("Invalid packet\n");
971 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
973 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
980 if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
981 ErrPrint("Failed to get buffer size [%s:%s]\n", pkgname, id);
985 (void)info->handler(info, BUFFER_EVENT_MOVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
992 struct packet *provider_buffer_pd_access_action_up(pid_t pid, int handle, const struct packet *packet)
1000 struct livebox_buffer *info;
1002 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1004 ErrPrint("Invalid packet\n");
1008 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1010 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1014 if (info->handler) {
1018 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1019 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1021 (void)info->handler(info, BUFFER_EVENT_ACTION_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1028 struct packet *provider_buffer_pd_access_action_down(pid_t pid, int handle, const struct packet *packet)
1030 const char *pkgname;
1036 struct livebox_buffer *info;
1038 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1040 ErrPrint("Invalid packet\n");
1044 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1046 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1050 if (info->handler) {
1054 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1055 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1057 (void)info->handler(info, BUFFER_EVENT_ACTION_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1064 struct packet *provider_buffer_pd_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
1066 const char *pkgname;
1072 struct livebox_buffer *info;
1074 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1076 ErrPrint("Invalid packet\n");
1080 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1082 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1086 if (info->handler) {
1090 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1091 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1093 (void)info->handler(info, BUFFER_EVENT_SCROLL_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1100 struct packet *provider_buffer_pd_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
1102 const char *pkgname;
1108 struct livebox_buffer *info;
1110 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1112 ErrPrint("Invalid packet\n");
1116 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1118 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1122 if (info->handler) {
1126 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1127 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1129 (void)info->handler(info, BUFFER_EVENT_SCROLL_MOVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1136 struct packet *provider_buffer_pd_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
1138 const char *pkgname;
1144 struct livebox_buffer *info;
1146 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1148 ErrPrint("Invalid packet\n");
1152 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1154 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1158 if (info->handler) {
1162 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1163 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1165 (void)info->handler(info, BUFFER_EVENT_SCROLL_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1172 struct packet *provider_buffer_pd_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
1174 const char *pkgname;
1180 struct livebox_buffer *info;
1182 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1184 ErrPrint("Invalid packet\n");
1188 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1190 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1194 if (info->handler) {
1198 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1199 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1201 (void)info->handler(info, BUFFER_EVENT_UNHIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1208 struct packet *provider_buffer_pd_access_hl(pid_t pid, int handle, const struct packet *packet)
1210 const char *pkgname;
1216 struct livebox_buffer *info;
1218 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1220 ErrPrint("Invalid packet\n");
1224 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1226 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1230 if (info->handler) {
1234 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1235 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1237 (void)info->handler(info, BUFFER_EVENT_HIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1244 struct packet *provider_buffer_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
1246 const char *pkgname;
1252 struct livebox_buffer *info;
1254 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1256 ErrPrint("Invalid packet\n");
1260 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1262 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1266 if (info->handler) {
1270 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1271 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1273 (void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_PREV, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1280 struct packet *provider_buffer_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet)
1282 const char *pkgname;
1288 struct livebox_buffer *info;
1290 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1292 ErrPrint("Invalid packet\n");
1296 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1298 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1302 if (info->handler) {
1306 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1307 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1309 (void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_NEXT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1316 struct packet *provider_buffer_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
1318 const char *pkgname;
1324 struct livebox_buffer *info;
1326 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1328 ErrPrint("Invalid packet\n");
1332 info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
1334 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1338 if (info->handler) {
1342 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1343 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1345 (void)info->handler(info, BUFFER_EVENT_ACTIVATE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1352 struct packet *provider_buffer_lb_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
1354 const char *pkgname;
1360 struct livebox_buffer *info;
1362 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1364 ErrPrint("Invalid packet\n");
1368 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1370 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1374 if (info->handler) {
1378 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1379 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1381 (void)info->handler(info, BUFFER_EVENT_UNHIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1388 struct packet *provider_buffer_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
1390 const char *pkgname;
1396 struct livebox_buffer *info;
1398 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1400 ErrPrint("Invalid packet\n");
1404 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1406 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1410 if (info->handler) {
1414 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1415 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1417 (void)info->handler(info, BUFFER_EVENT_HIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1424 struct packet *provider_buffer_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
1426 const char *pkgname;
1432 struct livebox_buffer *info;
1434 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1436 ErrPrint("Invalid packet\n");
1440 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1442 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1446 if (info->handler) {
1450 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1451 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1453 (void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_PREV, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1460 struct packet *provider_buffer_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
1462 const char *pkgname;
1468 struct livebox_buffer *info;
1470 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1472 ErrPrint("Invalid packet\n");
1476 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1478 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1482 if (info->handler) {
1486 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1487 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1489 (void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_NEXT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1496 struct packet *provider_buffer_lb_access_action_up(pid_t pid, int handle, const struct packet *packet)
1498 const char *pkgname;
1504 struct livebox_buffer *info;
1506 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1508 ErrPrint("Invalid packet\n");
1512 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1514 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1518 if (info->handler) {
1522 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1523 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1525 (void)info->handler(info, BUFFER_EVENT_ACTION_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1532 struct packet *provider_buffer_lb_access_action_down(pid_t pid, int handle, const struct packet *packet)
1534 const char *pkgname;
1540 struct livebox_buffer *info;
1542 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1544 ErrPrint("Invalid packet\n");
1548 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1550 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1554 if (info->handler) {
1558 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1559 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1561 (void)info->handler(info, BUFFER_EVENT_ACTION_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1568 struct packet *provider_buffer_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
1570 const char *pkgname;
1576 struct livebox_buffer *info;
1578 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1580 ErrPrint("Invalid packet\n");
1584 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1586 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1590 if (info->handler) {
1594 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1595 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1597 (void)info->handler(info, BUFFER_EVENT_SCROLL_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1604 struct packet *provider_buffer_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
1606 const char *pkgname;
1612 struct livebox_buffer *info;
1614 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1616 ErrPrint("Invalid packet\n");
1620 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1622 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1626 if (info->handler) {
1630 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1631 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1633 (void)info->handler(info, BUFFER_EVENT_SCROLL_MOVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1640 struct packet *provider_buffer_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
1642 const char *pkgname;
1648 struct livebox_buffer *info;
1650 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1652 ErrPrint("Invalid packet\n");
1656 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1658 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1662 if (info->handler) {
1666 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1667 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1669 (void)info->handler(info, BUFFER_EVENT_SCROLL_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
1676 struct packet *provider_buffer_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
1678 const char *pkgname;
1684 struct livebox_buffer *info;
1686 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1688 ErrPrint("Invalid packet\n");
1692 info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
1694 ErrPrint("Failed to find a buffer [%s:%s]\n", pkgname, id);
1698 if (info->handler) {
1702 if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
1703 ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
1705 (void)info->handler(info, BUFFER_EVENT_ACTIVATE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);