fixed plugin image size problem
[framework/uifw/elementary.git] / src / modules / ctxpopup_copypasteUI / cbhm_helper.c
1 #include "cbhm_helper.h"
2
3 #ifdef HAVE_ELEMENTARY_X
4 #include <X11/Xlib.h>
5 #include <X11/Xatom.h>
6 #define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN"
7 #define ATOM_CBHM_MSG "CBHM_MSG"
8 #define ATOM_CBHM_COUNT_GET "CBHM_cCOUNT"
9 #define ATOM_CBHM_SERIAL_NUMBER "CBHM_SERIAL_NUMBER"
10 #define MSG_CBHM_COUNT_GET "get count"
11 #define ATOM_CBHM_ERROR "CBHM_ERROR"
12 #define ATOM_CBHM_ITEM "CBHM_ITEM"
13 #endif
14
15 #ifdef HAVE_ELEMENTARY_X
16 Ecore_X_Window
17 _cbhm_window_get()
18 {
19    Ecore_X_Atom x_atom_cbhm = ecore_x_atom_get(ATOM_CBHM_WINDOW_NAME);
20    Ecore_X_Window x_cbhm_win = 0;
21    unsigned char *buf = NULL;
22    int num = 0;
23    int ret = ecore_x_window_prop_property_get(0, x_atom_cbhm, XA_WINDOW, 0, &buf, &num);
24    DMSG("ret: %d, num: %d\n", ret, num);
25    if (ret && num)
26      memcpy(&x_cbhm_win, buf, sizeof(Ecore_X_Window));
27    if (buf)
28      free(buf);
29    return x_cbhm_win;
30 }
31 #endif
32
33 Eina_Bool
34 _cbhm_msg_send(Evas_Object *obj, char *msg)
35 {
36 #ifdef HAVE_ELEMENTARY_X
37    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
38    Ecore_X_Atom x_atom_cbhm_msg = ecore_x_atom_get(ATOM_CBHM_MSG);
39    Ecore_X_Window xwin = ecore_evas_software_x11_window_get(
40       ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
41
42    DMSG("x_cbhm: 0x%x\n", x_cbhm_win);
43    if (!x_cbhm_win || !x_atom_cbhm_msg)
44      return EINA_FALSE;
45
46    XClientMessageEvent m;
47    memset(&m, 0, sizeof(m));
48    m.type = ClientMessage;
49    m.display = ecore_x_display_get();
50    m.window = xwin;
51    m.message_type = x_atom_cbhm_msg;
52    m.format = 8;
53    snprintf(m.data.b, 20, "%s", msg);
54
55    XSendEvent(ecore_x_display_get(), x_cbhm_win, False, NoEventMask, (XEvent*)&m);
56
57    ecore_x_sync();
58    return EINA_TRUE;
59 #else
60    return EINA_FALSE;
61 #endif
62 }
63
64 #ifdef HAVE_ELEMENTARY_X
65 void *
66 _cbhm_reply_get(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom *x_data_type, int *num)
67 {
68    unsigned char *data = NULL;
69    if (x_data_type)
70      *x_data_type = 0;
71    if (!property)
72       return NULL;
73    ecore_x_sync();
74    if (num)
75      *num = 0;
76
77    long unsigned int num_ret = 0, bytes = 0;
78    int ret = 0, size_ret;
79    unsigned int i;
80    unsigned char *prop_ret;
81    Ecore_X_Atom type_ret;
82    ret = XGetWindowProperty(ecore_x_display_get(), xwin, property, 0, LONG_MAX,
83                             False, ecore_x_window_prop_any_type(), (Atom *)&type_ret, &size_ret,
84                             &num_ret, &bytes, &prop_ret);
85    if (ret != Success)
86      return NULL;
87    if (!num_ret)
88      {
89         XFree(prop_ret);
90         return NULL;
91      }
92
93    if (!(data = malloc(num_ret * size_ret / 8)))
94      {
95         XFree(prop_ret);
96         return NULL;
97      }
98
99    switch (size_ret) {
100       case 8:
101         for (i = 0; i < num_ret; i++)
102           (data)[i] = prop_ret[i];
103         break;
104
105       case 16:
106         for (i = 0; i < num_ret; i++)
107           ((unsigned short *)data)[i] = ((unsigned short *)prop_ret)[i];
108         break;
109
110       case 32:
111         for (i = 0; i < num_ret; i++)
112           ((unsigned int *)data)[i] = ((unsigned long *)prop_ret)[i];
113         break;
114      }
115
116    XFree(prop_ret);
117
118    if (num)
119      *num = num_ret;
120    if (x_data_type)
121      *x_data_type = type_ret;
122
123    return data;
124 }
125 #endif
126
127 int
128 _cbhm_item_count_get(Evas_Object *obj)
129 {
130 #ifdef HAVE_ELEMENTARY_X
131    char *ret, count;
132    Ecore_X_Atom x_atom_cbhm_count_get = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
133    Ecore_X_Window cbhm_xwin = _cbhm_window_get();
134    DMSG("x_win: 0x%x, x_atom: %d\n", cbhm_xwin, x_atom_cbhm_count_get);
135    ret = _cbhm_reply_get(cbhm_xwin, x_atom_cbhm_count_get, NULL, NULL);
136    if (ret)
137      {
138         count = atoi(ret);
139         DMSG("count: %d\n", count);
140         free(ret);
141         return count;
142      }
143    DMSG("ret: 0x%x\n", ret);
144 #endif
145    return -1;
146 }
147 /*
148 int
149 _cbhm_item_count_get(Evas_Object *obj)
150 {
151 #ifdef HAVE_ELEMENTARY_X
152    char *ret, count;
153    if(_cbhm_msg_send(obj, MSG_CBHM_COUNT_GET))
154      {
155         DMSG("message send success\n");
156         Ecore_X_Atom x_atom_cbhm_count_get = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
157         Ecore_X_Window xwin = ecore_evas_software_x11_window_get(
158            ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
159         DMSG("x_win: 0x%x, x_atom: %d\n", xwin, x_atom_cbhm_count_get);
160         ret = _cbhm_reply_get(xwin, x_atom_cbhm_count_get, NULL, NULL);
161         if (ret)
162           {
163              count = atoi(ret);
164              DMSG("count: %d\n", count);
165              free(ret);
166              return count;
167           }
168         DMSG("ret: 0x%x\n", ret);
169      }
170 #endif
171    return -1;
172 }
173 */
174
175 #ifdef HAVE_ELEMENTARY_X
176 Eina_Bool
177 _cbhm_item_get(Evas_Object *obj, int index, Ecore_X_Atom *data_type, char **buf)
178 #else
179 Eina_Bool
180 _cbhm_item_get(Evas_Object *obj, int index, void *data_type, char **buf)
181 #endif
182
183 {
184    if (buf)
185      *buf = NULL;
186    if (data_type)
187      *(int *)data_type = 0;
188
189 #ifdef HAVE_ELEMENTARY_X
190    Ecore_X_Window cbhm_xwin = _cbhm_window_get();
191    char send_buf[20];
192    char *ret;
193
194    snprintf(send_buf, 20, "CBHM_ITEM%d", index);
195    Ecore_X_Atom x_atom_cbhm_item = ecore_x_atom_get(send_buf);
196    Ecore_X_Atom x_atom_item_type = 0;
197
198    DMSG("x_win: 0x%x, x_atom: %d\n", cbhm_xwin, x_atom_cbhm_item);
199    ret = _cbhm_reply_get(cbhm_xwin, x_atom_cbhm_item, &x_atom_item_type, NULL);
200    if (ret)
201      {
202         DMSG("data_type: %d, buf: %s\n", x_atom_item_type, ret);
203         if (buf)
204           *buf = ret;
205         else
206           free(ret);
207
208         if (data_type)
209           *data_type = x_atom_item_type;
210
211         Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
212         if (x_atom_item_type == x_atom_cbhm_error)
213           return EINA_FALSE;
214      }
215    DMSG("ret: 0x%x\n", ret);
216 /*
217    Ecore_X_Window xwin = ecore_evas_software_x11_window_get(
218       ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
219    char send_buf[20];
220    char *ret;
221
222    snprintf(send_buf, 20, "GET_ITEM%d", index);
223    if (_cbhm_msg_send(obj, send_buf))
224      {
225         DMSG("message send success\n");
226         Ecore_X_Atom x_atom_cbhm_item = ecore_x_atom_get(ATOM_CBHM_ITEM);
227         Ecore_X_Atom x_atom_item_type = 0;
228
229         DMSG("x_win: 0x%x, x_atom: %d\n", xwin, x_atom_cbhm_item);
230         ret = _cbhm_reply_get(xwin, x_atom_cbhm_item, &x_atom_item_type, NULL);
231         if (ret)
232           {
233              DMSG("data_type: %d, buf: %s\n", x_atom_item_type, ret);
234              if (buf)
235                *buf = ret;
236              else
237                free(ret);
238              if (data_type)
239                *data_type = x_atom_item_type;
240
241              Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
242              if (x_atom_item_type == x_atom_cbhm_error)
243                return EINA_FALSE;
244           }
245         DMSG("ret: 0x%x\n", ret);
246      }
247 */
248 #endif
249    return EINA_FALSE;
250 }
251
252 #ifdef HAVE_ELEMENTARY_X
253 Eina_Bool
254 _cbhm_item_set(Evas_Object *obj, Ecore_X_Atom data_type, char *item_data)
255 {
256    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
257    Ecore_X_Atom x_atom_cbhm_item = ecore_x_atom_get(ATOM_CBHM_ITEM);
258    ecore_x_window_prop_property_set(x_cbhm_win, x_atom_cbhm_item, data_type, 8, item_data, strlen(item_data) + 1);
259    ecore_x_sync();
260    if (_cbhm_msg_send(obj, "SET_ITEM"))
261      {
262         DMSG("message send success\n");
263         return EINA_TRUE;
264      }
265    return EINA_FALSE;
266 }
267 #endif
268
269 unsigned int
270 _cbhm_serial_number_get()
271 {
272    unsigned int senum = 0;
273 #ifdef HAVE_ELEMENTARY_X
274    unsigned char *buf = NULL;
275    Ecore_X_Atom x_atom_cbhm_SN = ecore_x_atom_get(ATOM_CBHM_SERIAL_NUMBER);
276    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
277    buf = _cbhm_reply_get(x_cbhm_win, x_atom_cbhm_SN, NULL, NULL);
278    if (buf)
279      {
280         memcpy(&senum, buf, sizeof(senum));
281         free(buf);
282      }
283 #endif
284    return senum;
285 }
286
287 //////////////////////////////////////////////////////////////////////////////
288 // old elm_cbmh_helper                                                      //
289 //////////////////////////////////////////////////////////////////////////////
290 //#include <Elementary.h>
291 //#include "elm_priv.h"
292 //
293 //#ifdef HAVE_ELEMENTARY_X
294 //#include <X11/Xlib.h>
295 //#include <X11/Xatom.h>
296 //#endif
297 //
298 ///**
299 // * @defgroup CBHM_helper CBHM_helper
300 // * @ingroup Elementary
301 // *
302 // * retrieving date from Clipboard History Manager
303 // * CBHM_helper supports to get CBHM's contents
304 // */
305 //
306 //
307 //#define ATOM_CLIPBOARD_NAME "CLIPBOARD"
308 //#define ATOM_CLIPBOARD_MANGER_NAME "CLIPBOARD_MANAGER"
309 //#define CLIPBOARD_MANAGER_WINDOW_TITLE_STRING "X11_CLIPBOARD_HISTORY_MANAGER"
310 //#define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN"
311 //
312 //#ifdef HAVE_ELEMENTARY_X
313 //static Ecore_X_Display *cbhm_disp = NULL;
314 //static Ecore_X_Window cbhm_win = None;
315 //static Ecore_X_Window self_win = None;
316 //#endif
317 //static Eina_Bool init_flag = EINA_FALSE;
318 //
319 //void _get_clipboard_window();
320 //unsigned int _get_cbhm_serial_number();
321 //void _search_clipboard_window(Ecore_X_Window w);
322 //int _send_clipboard_events(char *cmd);
323 //#ifdef HAVE_ELEMENTARY_X
324 //int _get_clipboard_data(Atom datom, char **datomptr);
325 //#endif
326 //
327 //void _get_clipboard_window()
328 //{
329 //#ifdef HAVE_ELEMENTARY_X
330 //   Atom actual_type;
331 //   int actual_format;
332 //   unsigned long nitems, bytes_after;
333 //   unsigned char *prop_return = NULL;
334 //   Atom atomCbhmWin = XInternAtom(cbhm_disp, ATOM_CBHM_WINDOW_NAME, False);
335 //   if(Success ==
336 //      XGetWindowProperty(cbhm_disp, DefaultRootWindow(cbhm_disp), atomCbhmWin,
337 //                         0, sizeof(Ecore_X_Window), False, XA_WINDOW,
338 //                         &actual_type, &actual_format, &nitems, &bytes_after, &prop_return) &&
339 //      prop_return)
340 //     {
341 //        cbhm_win = *(Ecore_X_Window*)prop_return;
342 //        XFree(prop_return);
343 //        fprintf(stderr, "## find clipboard history manager at root\n");
344 //     }
345 //#endif
346 //}
347 //
348 //unsigned int _get_cbhm_serial_number()
349 //{
350 //   unsigned int senum = 0;
351 //#ifdef HAVE_ELEMENTARY_X
352 //   Atom actual_type;
353 //   int actual_format;
354 //   unsigned long nitems, bytes_after;
355 //   unsigned char *prop_return = NULL;
356 //   Atom atomCbhmSN = XInternAtom(cbhm_disp, "CBHM_SERIAL_NUMBER", False);
357 //
358 //   // FIXME : is it really needed?
359 //   XSync(cbhm_disp, EINA_FALSE);
360 //
361 //   if(Success ==
362 //      XGetWindowProperty(cbhm_disp, cbhm_win, atomCbhmSN,
363 //                         0, sizeof(Ecore_X_Window), False, XA_INTEGER,
364 //                         &actual_type, &actual_format, &nitems, &bytes_after, &prop_return) &&
365 //      prop_return)
366 //     {
367 //        senum = *(unsigned int*)prop_return;
368 //        XFree(prop_return);
369 //     }
370 //   fprintf(stderr, "## chbm_serial = %d\n", senum);
371 //#endif
372 //   return senum;
373 //}
374 //
375 //void _search_clipboard_window(Ecore_X_Window w)
376 //{
377 //#ifdef HAVE_ELEMENTARY_X
378 //   // Get the PID for the current Window.
379 //   Atom atomWMName = XInternAtom(cbhm_disp, "_NET_WM_NAME", False);
380 //   Atom atomUTF8String = XInternAtom(cbhm_disp, "UTF8_STRING", False);
381 //   Atom type;
382 //   int format;
383 //   unsigned long nitems;
384 //   unsigned long bytes_after;
385 //   unsigned long nsize = 0;
386 //   unsigned char *propName = 0;
387 //   if(Success ==
388 //      XGetWindowProperty(cbhm_disp, w, atomWMName, 0, (long)nsize, False,
389 //                         atomUTF8String, &type, &format, &nitems, &bytes_after, &propName))
390 //
391 //     {
392 //        if(propName != 0)
393 //          {
394 //             if (strcmp((const char *)CLIPBOARD_MANAGER_WINDOW_TITLE_STRING,(const char *)propName) == 0)
395 //               cbhm_win = w;
396 //             XFree(propName);
397 //          }
398 //     }
399 //
400 //   // Recurse into child windows.
401 //   Window wroot;
402 //   Window wparent;
403 //   Window *wchild;
404 //   unsigned nchildren;
405 //   int i;
406 //   if(0 != XQueryTree(cbhm_disp, w, &wroot, &wparent, &wchild, &nchildren))
407 //     {
408 //        for(i = 0; i < nchildren; i++)
409 //          _search_clipboard_window(wchild[i]);
410 //        XFree(wchild);
411 //     }
412 //#endif
413 //}
414 //
415 //int _send_clipboard_events(char *cmd)
416 //{
417 //   if (cmd == NULL)
418 //     return -1;
419 //
420 //#ifdef HAVE_ELEMENTARY_X
421 //   Atom atomCBHM_MSG = XInternAtom(cbhm_disp, "CBHM_MSG", False);
422 //
423 //   XClientMessageEvent m;
424 //   memset(&m, 0, sizeof(m));
425 //   m.type = ClientMessage;
426 //   m.display = cbhm_disp;
427 //   m.window = self_win;
428 //   m.message_type = atomCBHM_MSG;
429 //   m.format = 8;
430 //   sprintf(m.data.b, "%s", cmd);
431 //
432 //   XSendEvent(cbhm_disp, cbhm_win, False, NoEventMask, (XEvent*)&m);
433 //#endif
434 //   return 0;
435 //}
436 //
437 //#ifdef HAVE_ELEMENTARY_X
438 //int _get_clipboard_data(Atom datom, char **datomptr)
439 //{
440 //   // Atom atomUTF8String = XInternAtom(cbhm_disp, "UTF8_STRING", False);
441 //   Atom type;
442 //   int format;
443 //   unsigned long nitems;
444 //   unsigned long nsize;
445 //   unsigned char *propname = NULL;
446 //
447 //   // FIXME : is it really needed?
448 //   XSync(cbhm_disp, EINA_FALSE);
449 //
450 //   if (Success ==
451 //       XGetWindowProperty(cbhm_disp, self_win, datom, 0, 0, False,
452 //                          AnyPropertyType, &type, &format, &nitems, &nsize, &propname))
453 //     {
454 //        XFree(propname);
455 //     }
456 //   else
457 //     return -1;
458 //
459 //   /*
460 //      fprintf(stderr, "## format = %d\n", format);
461 //      fprintf(stderr, "## nsize = %d\n", nsize);
462 //    */
463 //
464 //   if (format != 8)
465 //     return -1;
466 //
467 //   if (Success ==
468 //       XGetWindowProperty(cbhm_disp, self_win, datom, 0, (long)nsize, False,
469 //                          AnyPropertyType, &type, &format, &nitems, &nsize, &propname))
470 //     {
471 //        if (nsize != 0)
472 //          {
473 //             XGetWindowProperty(cbhm_disp, self_win, datom, 0, (long)nsize, False,
474 //                                AnyPropertyType, &type, &format, &nitems, &nsize, &propname);
475 //          }
476 //
477 //        if(propname != NULL)
478 //          {
479 //             //                       fprintf(stderr, "## get data(0x%x) : %s\n", propname, propname);
480 //             //                       fprintf(stderr, "## after nsize = %d\n", nsize);
481 //             *datomptr = (char*)propname;
482 //             //                       XFree(propName);
483 //          }
484 //
485 //        XDeleteProperty(cbhm_disp, self_win, datom);
486 //        XFlush(cbhm_disp);
487 //     }
488 //
489 //   if (propname != NULL)
490 //     return 0;
491 //
492 //   *datomptr = NULL;
493 //   return -1;
494 //}
495 //#endif
496 //
497 //void free_clipboard_data(char *dptr)
498 //{
499 //#ifdef HAVE_ELEMENTARY_X
500 //   XFree(dptr);
501 //   return;
502 //#endif
503 //}
504 //
505 //
506 ///**
507 // * initalizing CBHM_helper
508 // *
509 // * @param self The self window object which receive events
510 // * @return return TRUE or FALSE if it cannot be created
511 // *
512 // * @ingroup CBHM_helper
513 // */
514 //EAPI Eina_Bool
515 //elm_cbhm_helper_init(Evas_Object *self)
516 //{
517 //   init_flag = EINA_FALSE;
518 //
519 //#ifdef HAVE_ELEMENTARY_X
520 //   cbhm_disp = ecore_x_display_get();
521 //   if (cbhm_disp == NULL)
522 //     return init_flag;
523 //   if (cbhm_win == None)
524 //     _get_clipboard_window();
525 //   if (cbhm_win == None)
526 //     _search_clipboard_window(DefaultRootWindow(cbhm_disp));
527 //   if (self_win == None)
528 //     self_win = ecore_evas_software_x11_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(self)));
529 //
530 //   if (cbhm_disp && cbhm_win && self_win)
531 //     init_flag = EINA_TRUE;
532 //#endif
533 //   return init_flag;
534 //}
535 //
536 ///**
537 // * getting serial number of CBHM
538 // *
539 // * @return return serial number of clipboard history manager
540 // *
541 // * @ingroup CBHM_helper
542 // */
543 //EAPI unsigned int
544 //elm_cbhm_get_serial_number()
545 //{
546 //   if (init_flag == EINA_FALSE)
547 //     return 0;
548 //
549 //   unsigned int num = 0;
550 //   num = _get_cbhm_serial_number();
551 //   return num;
552 //}
553 //
554 ///**
555 // * getting count of CBHM's contents
556 // *
557 // * @return return count of history contents
558 // *
559 // * @ingroup CBHM_helper
560 // */
561 //EAPI int
562 //elm_cbhm_get_count()
563 //{
564 //   if (init_flag == EINA_FALSE)
565 //     return -1;
566 //
567 //   char *retptr = NULL;
568 //   int count = 0;
569 //
570 //   _send_clipboard_events("get count");
571 //
572 //#ifdef HAVE_ELEMENTARY_X
573 //   Atom atomCBHM_cCOUNT = XInternAtom(cbhm_disp, "CBHM_cCOUNT", False);
574 //
575 //   _get_clipboard_data(atomCBHM_cCOUNT, &retptr);
576 //#endif
577 //
578 //   if (retptr != NULL)
579 //     {
580 //        fprintf(stderr, "## c get retptr : %s\n", retptr);
581 //        count = atoi(retptr);
582 //
583 //        free_clipboard_data(retptr);
584 //        retptr = NULL;
585 //     }
586 //
587 //   return count;
588 //}
589 //
590 ///**
591 // * getting raw data of CBHM's contents
592 // *
593 // * @return return raw data of history contents
594 // *
595 // * @ingroup CBHM_helper
596 // */
597 //EAPI int
598 //elm_cbhm_get_raw_data()
599 //{
600 //   if (init_flag == EINA_FALSE)
601 //     return -1;
602 //
603 //   char *retptr = NULL;
604 //
605 //   _send_clipboard_events("get raw");
606 //
607 //#ifdef HAVE_ELEMENTARY_X
608 //   Atom atomCBHM_cRAW = XInternAtom(cbhm_disp, "CBHM_cRAW", False);
609 //
610 //   _get_clipboard_data(atomCBHM_cRAW, &retptr);
611 //#endif
612 //
613 //   if (retptr != NULL)
614 //     {
615 //        free_clipboard_data(retptr);
616 //        retptr = NULL;
617 //     }
618 //
619 //   return 0;
620 //}
621 //
622 ///**
623 // * sending raw command to CBHM
624 // *
625 // * @return void
626 // *
627 // * @ingroup CBHM_helper
628 // */
629 //EAPI void
630 //elm_cbhm_send_raw_data(char *cmd)
631 //{
632 //   if (init_flag == EINA_FALSE)
633 //     return;
634 //
635 //   if (cmd == NULL)
636 //     return;
637 //
638 //   _send_clipboard_events(cmd);
639 //   fprintf(stderr, "## cbhm - send raw cmd = %s\n", cmd);
640 //
641 //   return;
642 //}
643 //
644 ///**
645 // * getting data by history position of CBHM's contents
646 // * 0 is current content.
647 // *
648 // * @return return data pointer of position of history contents
649 // *
650 // * @ingroup CBHM_helper
651 // */
652 //EAPI int
653 //elm_cbhm_get_data_by_position(int pos, char **dataptr)
654 //{
655 //   if (init_flag == EINA_FALSE)
656 //     return -1;
657 //
658 //   char reqbuf[16];
659 //   int ret = 0;
660 //   sprintf(reqbuf, "get #%d", pos);
661 //
662 //   _send_clipboard_events(reqbuf);
663 //
664 //   sprintf(reqbuf, "CBHM_c%d", pos);
665 //
666 //#ifdef HAVE_ELEMENTARY_X
667 //   Atom atomCBHM_cPOS = XInternAtom(cbhm_disp, reqbuf, False);
668 //
669 //   ret = _get_clipboard_data(atomCBHM_cPOS, dataptr);
670 //#endif
671 //
672 //   if (ret >= 0 && *dataptr != NULL)
673 //     {
674 //        //            fprintf(stderr, "## d get retptr : %s\n", *dataptr);
675 //        //            fprintf(stderr, "## dptr = 0x%x\n", *dataptr);
676 //
677 //        return 0;
678 //     }
679 //
680 //   return -1;
681 //}
682 //
683 ///**
684 // * free data by history position of CBHM's contents
685 // *
686 // * @return None
687 // *
688 // * @ingroup CBHM_helper
689 // */
690 //EAPI void
691 //elm_cbhm_free_data(char *dptr)
692 //{
693 //   if (dptr != NULL)
694 //     free_clipboard_data(dptr);
695 //}