3 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include <X11/Xatom.h>
24 Eina_Bool cbhm_send_event(AppData *ad, Ecore_X_Window xwin, char *msg)
26 ClipdrawerData *cd = ad->clipdrawer;
28 Ecore_X_Atom x_atom_cbhm_msg = ecore_x_atom_get("CBHM_MSG");
29 XClientMessageEvent m;
30 memset(&m, 0, sizeof(m));
31 m.type = ClientMessage;
32 m.display = ecore_x_display_get();
33 m.window = cd->x_main_win;
34 m.message_type = x_atom_cbhm_msg;
36 snprintf(m.data.b, 20, "%s", msg);
38 XSendEvent(ecore_x_display_get(), xwin, False, NoEventMask, (XEvent*)&m);
45 Ecore_X_Window get_selection_owner(AppData *ad, Ecore_X_Selection selection)
52 case ECORE_X_SELECTION_SECONDARY:
53 sel = ECORE_X_ATOM_SELECTION_SECONDARY;
55 case ECORE_X_SELECTION_CLIPBOARD:
56 sel = ECORE_X_ATOM_SELECTION_CLIPBOARD;
61 return XGetSelectionOwner(ad->x_disp, sel);
64 Eina_Bool is_cbhm_selection_owner(AppData *ad, Ecore_X_Selection selection)
67 if (!ad) return EINA_FALSE;
68 Ecore_X_Window sel_owner = get_selection_owner(ad, selection);
69 DMSG("selection_owner: 0x%x, x_event_win: 0x%x \n", sel_owner, ad->x_event_win);
70 if (sel_owner == ad->x_event_win)
75 Eina_Bool set_selection_owner(AppData *ad, Ecore_X_Selection selection, CNP_ITEM *item)
78 if (!ad) return EINA_FALSE;
80 if (!item && is_cbhm_selection_owner(ad, selection))
84 Eina_Bool (*selection_func)(Ecore_X_Window win, const void *data, int size) = NULL;
88 case ECORE_X_SELECTION_SECONDARY:
89 // ecore_x_selection_secondary_clear();
90 selection_func = ecore_x_selection_secondary_set;
91 ad->clip_selected_item = item;
93 case ECORE_X_SELECTION_CLIPBOARD:
94 // ecore_x_selection_clipboard_clear();
95 selection_func = ecore_x_selection_clipboard_set;
101 slot_selected_item_set(ad);
102 if (selection_func(ad->x_event_win, NULL, 0))
105 DMSG("ERROR: set selection failed\n");
109 static Eina_Bool selection_timer_cb(void *data)
113 XHandlerData *xd = ad->xhandler;
115 set_selection_owner(ad, ECORE_X_SELECTION_CLIPBOARD, NULL);
116 if (is_cbhm_selection_owner(ad, ECORE_X_SELECTION_CLIPBOARD))
118 ecore_timer_del(xd->selection_timer);
119 xd->selection_timer = NULL;
120 return ECORE_CALLBACK_CANCEL;
122 return ECORE_CALLBACK_RENEW;
125 static Eina_Bool _xsel_clear_cb(void *data, int type, void *event)
128 if (!data || !event) return EINA_TRUE;
130 XHandlerData *xd = ad->xhandler;
131 Ecore_X_Event_Selection_Clear *ev = event;
133 DMSG("in %s, ev->win: 0x%x\n", __func__, ev->win);
135 if (is_cbhm_selection_owner(ad, ev->selection)) return EINA_TRUE;
136 if (ev->selection != ECORE_X_SELECTION_CLIPBOARD)
137 return ECORE_CALLBACK_PASS_ON;
139 ecore_x_selection_clipboard_request(ad->x_event_win, ECORE_X_SELECTION_TARGET_TARGETS);
141 if (xd->selection_timer)
143 ecore_timer_del(xd->selection_timer);
144 xd->selection_timer = NULL;
146 xd->selection_timer = ecore_timer_add(SELECTION_CHECK_TIME, selection_timer_cb, ad);
148 return ECORE_CALLBACK_DONE;
151 static Eina_Bool _xsel_request_cb(void *data, int type, void *event)
154 if (!data || !event) return ECORE_CALLBACK_PASS_ON;
156 Ecore_X_Event_Selection_Request *ev = event;
160 DMSG("selection_owner: 0x%x, ev->... owner: 0x%x, req: 0x%x, selection: %s, target: %s, property: %s\n",
161 get_selection_owner(ad, ECORE_X_SELECTION_CLIPBOARD), ev->owner, ev->requestor,
162 names[0] = ecore_x_atom_name_get(ev->selection),
163 names[1] = ecore_x_atom_name_get(ev->target),
164 names[2] = ecore_x_atom_name_get(ev->property));
170 CNP_ITEM *item = NULL;
171 if (ev->selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
172 item = item_get_last(ad);
173 else if (ev->selection == ECORE_X_ATOM_SELECTION_SECONDARY)
174 item = ad->clip_selected_item;
176 return ECORE_CALLBACK_PASS_ON;
180 DMSG("has no item\n");
181 ecore_x_selection_notify_send(ev->requestor,
186 DMSG("change property notify\n");
188 return ECORE_CALLBACK_DONE;
191 Ecore_X_Atom property = None;
192 void *data_ret = NULL;
197 if (!generic_converter(ad, ev->target, item, &data_ret, &size_ret, &ttype, &tsize))
198 /* if (!ecore_x_selection_convert(ev->selection,
200 &data_ret, &len, &typeAtom, &typesize))*/
203 /* Refuse selection, conversion to requested target failed */
204 DMSG("converter return FALSE\n");
208 /* FIXME: This does not properly handle large data transfers */
209 ecore_x_window_prop_property_set(
216 property = ev->property;
218 DMSG("change property\n");
221 ecore_x_selection_notify_send(ev->requestor,
226 DMSG("change property notify\n");
228 return ECORE_CALLBACK_DONE;
231 static void send_convert_selection_target(AppData *ad, Ecore_X_Selection_Data_Targets *targets_data)
234 /* struct _Ecore_X_Selection_Data_Targets {
235 Ecore_X_Selection_Data data;
236 struct _Ecore_X_Selection_Data {
238 ECORE_X_SELECTION_CONTENT_NONE,
239 ECORE_X_SELECTION_CONTENT_TEXT,
240 ECORE_X_SELECTION_CONTENT_FILES,
241 ECORE_X_SELECTION_CONTENT_TARGETS,
242 ECORE_X_SELECTION_CONTENT_CUSTOM
247 int (*FREE)(void *data);
253 if (!targets_data || !ad)
255 Ecore_X_Atom *atomlist = (Ecore_X_Atom *)targets_data->data.data;
259 DMSG("targets_data->num_targets: 0x%x\n", targets_data->num_targets);
261 for (i = 0; i < targets_data->num_targets; i++)
263 DMSG("get target: %s\n", targets_data->targets[i]);
264 for (j = 0; j < ATOM_INDEX_MAX; j++)
266 for (k = 0; k < ad->targetAtoms[j].atom_cnt; k++)
268 if (!strcmp(targets_data->targets[i], ad->targetAtoms[j].name[k]))
270 DMSG("find matched target: %s\n", ad->targetAtoms[j].name[k]);
271 ecore_x_selection_clipboard_request(ad->x_event_win, ad->targetAtoms[j].name[k]);
277 DMSG("ERROR: get target atom failed\n");
280 static Eina_Bool _add_selection_imagepath(AppData* ad, char *str)
284 DMSG("get FILE: %s\n", str);
285 char *slash = strchr(str, '/');
286 while (slash && slash[0] == '/')
291 filepath = strdup(slash);
294 if (ecore_file_exists(filepath))
296 item_add_by_data(ad, ad->targetAtoms[ATOM_INDEX_IMAGE].atom[0], filepath, strlen(filepath) + 1);
306 DMSG("Error : it isn't normal file = %s\n", str);
310 static void _get_selection_data_files(AppData* ad, Ecore_X_Selection_Data_Files *files_data)
312 /* struct _Ecore_X_Selection_Data_Files {
313 Ecore_X_Selection_Data data;
319 for (i = 0; i < files_data->num_files; i++)
321 _add_selection_imagepath(ad, files_data->files[i]);
325 static Eina_Bool _xsel_notify_cb(void *data, int type, void *event)
329 return ECORE_CALLBACK_PASS_ON;
332 XHandlerData *xd = ad->xhandler;
333 if (xd->selection_timer)
335 ecore_timer_del(xd->selection_timer);
336 xd->selection_timer = NULL;
339 /* struct _Ecore_X_Event_Selection_Notify
343 Ecore_X_Selection selection;
348 Ecore_X_Event_Selection_Notify *ev = event;
350 switch (ev->selection)
352 case ECORE_X_SELECTION_CLIPBOARD:
354 case ECORE_X_SELECTION_SECONDARY:
355 case ECORE_X_SELECTION_PRIMARY:
356 case ECORE_X_SELECTION_XDND:
358 return ECORE_CALLBACK_PASS_ON;
361 goto set_clipboard_selection_owner;
363 /* struct _Ecore_X_Selection_Data {
365 ECORE_X_SELECTION_CONTENT_NONE,
366 ECORE_X_SELECTION_CONTENT_TEXT,
367 ECORE_X_SELECTION_CONTENT_FILES,
368 ECORE_X_SELECTION_CONTENT_TARGETS,
369 ECORE_X_SELECTION_CONTENT_CUSTOM
374 int (*FREE)(void *data);
376 Ecore_X_Selection_Data *sel_data = ev->data;
377 switch (sel_data->content)
379 case ECORE_X_SELECTION_CONTENT_NONE:
380 DMSG("ECORE_X_SELECTION_CONTENT_NONE\n");
382 case ECORE_X_SELECTION_CONTENT_TEXT:
383 DMSG("ECORE_X_SELECTION_CONTENT_TEXT\n");
384 /* struct _Ecore_X_Selection_Data_Text {
385 Ecore_X_Selection_Data data;
388 Ecore_X_Selection_Data_Text *text_data = ev->data;*/
389 // DMSG("sel_data->data: 0x%x, text_data->text: 0x%x\n", sel_data->data, text_data->text);
391 case ECORE_X_SELECTION_CONTENT_FILES:
392 DMSG("ECORE_X_SELECTION_CONTENT_FILES\n");
393 _get_selection_data_files(ad, ev->data);
394 goto set_clipboard_selection_owner;
396 case ECORE_X_SELECTION_CONTENT_TARGETS:
397 DMSG("ECORE_X_SELECTION_CONTENT_TARGETS\n");
398 send_convert_selection_target(ad, ev->data);
399 if (!is_cbhm_selection_owner(ad, ECORE_X_SELECTION_CLIPBOARD))
400 xd->selection_timer = ecore_timer_add(SELECTION_CHECK_TIME, selection_timer_cb, ad);
401 return ECORE_CALLBACK_DONE;
402 case ECORE_X_SELECTION_CONTENT_CUSTOM:
403 DMSG("ECORE_X_SELECTION_CONTENT_CUSTOM\n");
408 DMSG("get atom: %d(%s), target: %s, length: %d, format: %d\n",
409 ev->atom, name = ecore_x_atom_name_get(ev->atom), ev->target, sel_data->length, sel_data->format);
413 Ecore_X_Atom targetAtom = ecore_x_atom_get(ev->target);
414 char *stripstr = strndup(sel_data->data, sel_data->length);
415 DMSG("get data: %s, len: %d\n", stripstr, strlen(stripstr));
416 if (atom_type_index_get(ad, targetAtom) == ATOM_INDEX_IMAGE)
418 _add_selection_imagepath(ad, stripstr);
422 item_add_by_data(ad, targetAtom, stripstr, strlen(stripstr) + 1);
426 set_clipboard_selection_owner:
427 set_selection_owner(ad, ECORE_X_SELECTION_CLIPBOARD, NULL);
428 if (!is_cbhm_selection_owner(ad, ECORE_X_SELECTION_CLIPBOARD))
429 xd->selection_timer = ecore_timer_add(SELECTION_CHECK_TIME, selection_timer_cb, ad);
431 return ECORE_CALLBACK_DONE;
434 static Eina_Bool _xclient_msg_cb(void *data, int type, void *event)
438 XHandlerData *xd = ad->xhandler;
439 ClipdrawerData *cd = ad->clipdrawer;
441 /* struct _Ecore_X_Event_Client_Message {
443 Ecore_X_Atom message_type;
453 Ecore_X_Event_Client_Message *ev = event;
455 if (ev->message_type != xd->atomCBHM_MSG)
458 DTRACE("## %s\n", ev->data.b);
460 /* Atom cbhm_atoms[ITEM_CNT_MAX];
462 Ecore_X_Window reqwin = ev->win;*/
464 if (strcmp("set_owner", ev->data.b) == 0)
466 cbhm_send_event(ad, ev->win, "SET_OWNER");
468 else if (strncmp("show", ev->data.b, 4) == 0)
470 ad->x_active_win = ev->win;
471 if (ev->data.b[4] == '1')
472 clipdrawer_paste_textonly_set(ad, EINA_FALSE);
474 clipdrawer_paste_textonly_set(ad, EINA_TRUE);
476 clipdrawer_activate_view(ad);
478 else if (!strcmp("cbhm_hide", ev->data.b))
480 clipdrawer_lower_view(ad);
482 else if (!strcmp("get count", ev->data.b))
484 int icount = item_count_get(ad);
486 DMSG("## cbhm count : %d\n", icount);
487 snprintf(countbuf, 10, "%d", icount);
488 ecore_x_window_prop_property_set(
497 else if (strncmp("GET_ITEM", ev->data.b, 8) == 0)
501 xd->atomCBHM_ITEM = ecore_x_atom_get("CBHM_ITEM");
503 while ('0' <= ev->data.b[index] && ev->data.b[index] <= '9')
505 itempos = (itempos * 10) + (ev->data.b[index] - '0');
509 CNP_ITEM *item = item_get_by_index(ad, itempos);
512 Ecore_X_Atom itemtype = ecore_x_atom_get("CBHM_ERROR");
514 char error_buf[] = "OUT OF BOUND";
515 int bufsize = sizeof(error_buf);
516 ecore_x_window_prop_property_set(
523 DMSG("GET ITEM ERROR msg: %s, index: %d, item count: %d\n",
524 ev->data.b, itempos, item_count_get(ad));
528 ecore_x_window_prop_property_set(
531 ad->targetAtoms[item->type_index].atom[0],
535 DMSG("GET ITEM index: %d, item type: %d, item data: %s, item->len: %d\n",
536 itempos, ad->targetAtoms[item->type_index].atom[0],
537 item->data, item->len);
540 else if (strncmp("SET_ITEM", ev->data.b, 8) == 0)
544 unsigned long num_ret = 0;
545 unsigned long bytes = 0;
546 unsigned char *item_data = NULL;
547 unsigned char *prop_ret = NULL;
548 Ecore_X_Atom format = 0;
550 xd->atomCBHM_ITEM = ecore_x_atom_get("CBHM_ITEM");
551 ret = XGetWindowProperty(ecore_x_display_get(), ad->x_event_win, xd->atomCBHM_ITEM, 0, LONG_MAX, False, ecore_x_window_prop_any_type(),
552 (Atom*)&format, &size_ret, &num_ret, &bytes, &prop_ret);
556 DMSG("Failed Set Item\n");
565 if (!(item_data = malloc(num_ret * size_ret / 8)))
575 for (i = 0; i < num_ret; i++)
576 item_data[i] = prop_ret[i];
579 for (i = 0; i < num_ret; i++)
580 ((unsigned short *)item_data)[i] = ((unsigned short *)prop_ret)[i];
583 for (i = 0; i < num_ret; i++)
584 ((unsigned int *)item_data)[i] = ((unsigned long *)prop_ret)[i];
590 DMSG("item_data:%s format:%s(%d)\n", item_data, ecore_x_atom_name_get(format), format);
591 item_add_by_data(ad, format, item_data, strlen(item_data) + 1);
593 else if (strncmp("DEL_ITEM", ev->data.b, 8) == 0)
598 while ('0' <= ev->data.b[index] && ev->data.b[index] <= '9')
600 itempos = (itempos * 10) + (ev->data.b[index] - '0');
604 item_delete_by_index(ad, itempos);
606 /* else if (strncmp("get #", ev->data.b, 5) == 0)
608 // FIXME : handle greater than 9
609 int num = ev->data.b[5] - '0';
610 int cur = get_current_history_position();
612 if (num > ITEMS_CNT_MAX-1)
613 num = num-ITEMS_CNT_MAX;
615 if (num >= 0 && num < ITEMS_CNT_MAX)
617 DTRACE("## pos : #%d\n", num);
618 // FIXME : handle with correct atom
619 sprintf(atomname, "CBHM_c%d", num);
620 cbhm_atoms[0] = XInternAtom(g_disp, atomname, False);
622 CNP_ITEM *item = clipdr;
625 if (clipdrawer_get_item_data(ad, num) != NULL)
627 XChangeProperty(g_disp, reqwin, cbhm_atoms[0], atomUTF8String,
629 (unsigned char *) clipdrawer_get_item_data(ad, num),
630 (int) strlen(clipdrawer_get_item_data(ad, num)));
634 else if (strcmp("get all", ev->data.b) == 0)
636 // print_history_buffer();
637 pos = get_current_history_position();
638 for (i = 0; i < 5; i++)
640 DTRACE("## %d -> %d\n", i, pos);
641 sprintf(atomname, "CBHM_c%d", i);
642 cbhm_atoms[i] = XInternAtom(g_disp, atomname, False);
643 if (clipdrawer_get_item_data(ad, pos) != NULL)
645 XChangeProperty(g_disp, reqwin, cbhm_atoms[i], atomUTF8String,
647 (unsigned char *) clipdrawer_get_item_data(ad, pos),
648 (int) strlen(clipdrawer_get_item_data(ad, pos)));
652 pos = ITEMS_CNT_MAX-1;
655 /* else if (strcmp("get raw", ev->data.b) == 0)
658 if (get_storage_start_addr != NULL)
660 XChangeProperty(g_disp, reqwin, atomCBHM_cRAW, atomUTF8String,
662 (unsigned char *) get_storage_start_addr(),
663 (int) get_total_storage_size());
672 static Eina_Bool _xfocus_out_cb(void *data, int type, void *event)
676 DTRACE("XE:FOCUS OUT\n");
677 clipdrawer_lower_view(ad);
681 static Eina_Bool _xproperty_notify_cb(void *data, int type, void *event)
685 XHandlerData *xd = ad->xhandler;
686 ClipdrawerData *cd = ad->clipdrawer;
687 Ecore_X_Event_Window_Property *pevent = (Ecore_X_Event_Window_Property *)event;
689 if (ad->x_active_win != pevent->win)
692 if (xd->atomWindowRotate == pevent->atom)
694 int angle = get_active_window_degree(ad->x_active_win);
695 if (angle != cd->o_degree)
697 cd->o_degree = angle;
698 elm_win_rotation_set(cd->main_win, angle);
699 set_rotation_to_clipdrawer(cd);
706 static Eina_Bool _xzone_init_cb(void *data, int type, void *event)
709 if (!data || !event) return EINA_FALSE;
711 ClipdrawerData *cd = ad->clipdrawer;
712 XHandlerData *xd = ad->xhandler;
713 Ecore_X_Event_Window_Property *pevent = (Ecore_X_Event_Window_Property *)event;
715 if (pevent->atom == ECORE_X_ATOM_E_ILLUME_ZONE)
718 int val_len = ecore_x_window_prop_window_get(cd->x_main_win, ECORE_X_ATOM_E_ILLUME_ZONE, &zone, 1);
721 Ecore_X_Window zone = ecore_x_e_illume_zone_get(cd->x_main_win);
722 ecore_x_e_illume_clipboard_state_set(zone, ECORE_X_ILLUME_CLIPBOARD_STATE_OFF);
724 /* hide clipboard elm_win after initializing zone x_win */
725 evas_object_hide(cd->main_win);
726 ecore_event_handler_del(xd->xproperty_notify_handler);
727 xd->xproperty_notify_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, _xproperty_notify_cb, ad);
734 static Eina_Bool _xwin_destroy_cb(void *data, int type, void *event)
738 Ecore_X_Event_Window_Destroy *pevent = event;
739 if (ad->x_active_win != pevent->win)
740 return ECORE_CALLBACK_PASS_ON;
741 clipdrawer_lower_view(ad);
742 return ECORE_CALLBACK_DONE;
745 XHandlerData *init_xhandler(AppData *ad)
747 XHandlerData *xd = CALLOC(1, sizeof(XHandlerData));
750 xd->xsel_clear_handler = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, _xsel_clear_cb, ad);
751 xd->xsel_request_handler = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_REQUEST, _xsel_request_cb, ad);
752 xd->xsel_notify_handler = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, _xsel_notify_cb, ad);
753 xd->xclient_msg_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _xclient_msg_cb, ad);
754 xd->xfocus_out_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, _xfocus_out_cb, ad);
755 xd->xproperty_notify_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, _xzone_init_cb, ad);
756 xd->xwindow_destroy_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, _xwin_destroy_cb, ad);
758 ClipdrawerData *cd = ad->clipdrawer;
759 /* show clipboard elm_win to initialize zone x_win */
760 evas_object_show(cd->main_win);
762 xd->atomInc = ecore_x_atom_get("INCR");
763 xd->atomWindowRotate = ecore_x_atom_get("_E_ILLUME_ROTATE_WINDOW_ANGLE");
764 xd->atomCBHM_MSG = ecore_x_atom_get("CBHM_MSG");
765 xd->atomCBHM_ITEM = ecore_x_atom_get("CBHM_ITEM");
766 xd->atomCBHMCount = ecore_x_atom_get("CBHM_cCOUNT");
767 xd->atomUTF8String = ecore_x_atom_get("UTF8_STRING");
768 xd->atomCBHM_SELECTED_ITEM = ecore_x_atom_get("CBHM_SELECTED_ITEM");
771 for (i = 0; i < ITEM_CNT_MAX; i++)
774 snprintf(buf, sizeof(buf), "CBHM_ITEM%d", i);
775 xd->atomCBHM_ITEM = ecore_x_atom_get(buf);
781 void depose_xhandler(XHandlerData *xd)
783 ecore_event_handler_del(xd->xsel_clear_handler);
784 ecore_event_handler_del(xd->xsel_request_handler);
785 ecore_event_handler_del(xd->xsel_notify_handler);
786 ecore_event_handler_del(xd->xclient_msg_handler);
787 ecore_event_handler_del(xd->xfocus_out_handler);
788 ecore_event_handler_del(xd->xproperty_notify_handler);
789 ecore_event_handler_del(xd->xwindow_destroy_handler);
793 int get_active_window_degree(Ecore_X_Window active)
795 //ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE
798 unsigned char *prop_data = NULL;
800 int ret = ecore_x_window_prop_property_get(
801 active, ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
802 ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
803 if (ret && prop_data) memcpy(&rotation, prop_data, sizeof(int));
804 if (prop_data) FREE(prop_data);
808 void slot_property_set(AppData *ad, int index)
810 XHandlerData *xd = ad->xhandler;
819 EINA_LIST_FOREACH(ad->item_list, l, item)
821 snprintf(buf, sizeof(buf), "CBHM_ITEM%d", i);
822 xd->atomCBHM_ITEM = ecore_x_atom_get(buf);
825 ecore_x_window_prop_property_set(
828 ad->targetAtoms[item->type_index].atom[0],
832 DMSG("GET ITEM index: %d, item type: %d, item data: %s, item->len: %d\n",
833 i, ad->targetAtoms[item->type_index].atom[0],
834 item->data, item->len);
840 else if (index < ITEM_CNT_MAX)
843 snprintf(buf, sizeof(buf), "CBHM_ITEM%d", index);
844 xd->atomCBHM_ITEM = ecore_x_atom_get(buf);
846 CNP_ITEM *item = item_get_by_index(ad, index);
849 Ecore_X_Atom itemtype = ecore_x_atom_get("CBHM_ERROR");
851 char error_buf[] = "OUT OF BOUND";
852 int bufsize = sizeof(error_buf);
853 ecore_x_window_prop_property_set(
860 DMSG("CBHM Error: index: %d, item count: %d\n",
861 index, item_count_get(ad));
865 ecore_x_window_prop_property_set(
868 ad->targetAtoms[item->type_index].atom[0],
872 DMSG("GET ITEM index: %d, item type: %d, item data: %s, item->len: %d\n",
873 index, ad->targetAtoms[item->type_index].atom[0],
874 item->data, item->len);
879 DMSG("can't set property\n");
883 void slot_item_count_set(AppData *ad)
885 XHandlerData *xd = ad->xhandler;
887 int icount = item_count_get(ad);
889 snprintf(countbuf, 10, "%d", icount);
890 ecore_x_window_prop_property_set(
899 void slot_selected_item_set(AppData *ad)
901 XHandlerData *xd = ad->xhandler;
902 CNP_ITEM *item = ad->clip_selected_item;
907 snprintf(buf, sizeof(buf), "CBHM_SELECTED_ITEM");
908 xd->atomCBHM_SELECTED_ITEM = ecore_x_atom_get(buf);
910 ecore_x_window_prop_property_set(
912 xd->atomCBHM_SELECTED_ITEM,
913 ad->targetAtoms[item->type_index].atom[0],
920 Ecore_X_Atom itemtype = ecore_x_atom_get("CBHM_ERROR");
922 char error_buf[] = "NOT EXIST SELECTED ITEM";
923 int bufsize = sizeof(error_buf);
924 ecore_x_window_prop_property_set(
926 xd->atomCBHM_SELECTED_ITEM,