summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2015-03-26 22:26:18 +0000
committerThiep Ha <thiepha@gmail.com>2015-06-02 21:50:24 +0900
commite06316882c8dd9f0987a386d41bba6d300324d7d (patch)
treebb756bcc69587c1b673215bb7278bf255b5bbc4e
parent06e10f97b19b5a316697463e2f78d53a3516d70f (diff)
DnD/Wl: Add type converters
We support different types for DnD, but there is no converters. This patch adds converters for types, so that we can send different data for different types.
-rw-r--r--src/lib/elm_cnp.c258
1 files changed, 253 insertions, 5 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 2916a6f55..6d4418902 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -252,6 +252,17 @@ static Eina_Bool _x11_elm_selection_selection_has_owner (Evas_Object *obj EINA_
252 252
253#endif 253#endif
254 254
255#ifdef HAVE_ELEMENTARY_WAYLAND
256typedef struct _Wl_Cnp_Selection Wl_Cnp_Selection;
257
258typedef Eina_Bool (*Wl_Converter_Fn_Cb) (char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret);
259static Eina_Bool _wl_targets_converter(char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret);
260static Eina_Bool _wl_general_converter(char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret);
261static Eina_Bool _wl_image_converter(char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret);
262static Eina_Bool _wl_text_converter(char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret);
263static Eina_Bool _wl_vcard_converter(char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret);
264#endif
265
255struct _Cnp_Atom 266struct _Cnp_Atom
256{ 267{
257 const char *name; 268 const char *name;
@@ -264,6 +275,10 @@ struct _Cnp_Atom
264 /* Atom */ 275 /* Atom */
265 Ecore_X_Atom x_atom; 276 Ecore_X_Atom x_atom;
266#endif 277#endif
278#ifdef HAVE_ELEMENTARY_WAYLAND
279 Wl_Converter_Fn_Cb wl_converter;
280#endif
281
267 void *_term; 282 void *_term;
268}; 283};
269 284
@@ -444,6 +459,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
444 .x_response = _x11_response_handler_targets, 459 .x_response = _x11_response_handler_targets,
445 .x_notify = _x11_notify_handler_targets, 460 .x_notify = _x11_notify_handler_targets,
446#endif 461#endif
462#ifdef HAVE_ELEMENTARY_WAYLAND
463 .wl_converter = _wl_targets_converter,
464#endif
447 }, 465 },
448 ARRAYINIT(CNP_ATOM_ATOM) { 466 ARRAYINIT(CNP_ATOM_ATOM) {
449 .name = "ATOM", // for opera browser 467 .name = "ATOM", // for opera browser
@@ -453,6 +471,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
453 .x_response = _x11_response_handler_targets, 471 .x_response = _x11_response_handler_targets,
454 .x_notify = _x11_notify_handler_targets, 472 .x_notify = _x11_notify_handler_targets,
455#endif 473#endif
474#ifdef HAVE_ELEMENTARY_WAYLAND
475 .wl_converter = _wl_targets_converter,
476#endif
456 }, 477 },
457 ARRAYINIT(CNP_ATOM_XELM) { 478 ARRAYINIT(CNP_ATOM_XELM) {
458 .name = "application/x-elementary-markup", 479 .name = "application/x-elementary-markup",
@@ -460,6 +481,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
460#ifdef HAVE_ELEMENTARY_X 481#ifdef HAVE_ELEMENTARY_X
461 .x_converter = _x11_general_converter, 482 .x_converter = _x11_general_converter,
462#endif 483#endif
484#ifdef HAVE_ELEMENTARY_WAYLAND
485 .wl_converter = _wl_general_converter,
486#endif
463 }, 487 },
464 ARRAYINIT(CNP_ATOM_text_uri) { 488 ARRAYINIT(CNP_ATOM_text_uri) {
465 .name = "text/uri", 489 .name = "text/uri",
@@ -468,6 +492,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
468 .x_converter = _x11_general_converter, 492 .x_converter = _x11_general_converter,
469 .x_notify = _x11_notify_handler_uri, 493 .x_notify = _x11_notify_handler_uri,
470#endif 494#endif
495#ifdef HAVE_ELEMENTARY_WAYLAND
496 .wl_converter = _wl_general_converter,
497#endif
471 }, 498 },
472 ARRAYINIT(CNP_ATOM_text_urilist) { 499 ARRAYINIT(CNP_ATOM_text_urilist) {
473 .name = "text/uri-list", 500 .name = "text/uri-list",
@@ -476,6 +503,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
476 .x_converter = _x11_general_converter, 503 .x_converter = _x11_general_converter,
477 .x_notify = _x11_notify_handler_uri, 504 .x_notify = _x11_notify_handler_uri,
478#endif 505#endif
506#ifdef HAVE_ELEMENTARY_WAYLAND
507 .wl_converter = _wl_general_converter,
508#endif
479 }, 509 },
480 ARRAYINIT(CNP_ATOM_text_x_vcard) { 510 ARRAYINIT(CNP_ATOM_text_x_vcard) {
481 .name = "text/x-vcard", 511 .name = "text/x-vcard",
@@ -484,6 +514,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
484 .x_converter = _x11_vcard_send, 514 .x_converter = _x11_vcard_send,
485 .x_notify = _x11_vcard_receive, 515 .x_notify = _x11_vcard_receive,
486#endif 516#endif
517#ifdef HAVE_ELEMENTARY_WAYLAND
518 .wl_converter = _wl_vcard_converter,
519#endif
487 }, 520 },
488 ARRAYINIT(CNP_ATOM_image_png) { 521 ARRAYINIT(CNP_ATOM_image_png) {
489 .name = "image/png", 522 .name = "image/png",
@@ -492,6 +525,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
492 .x_converter = _x11_image_converter, 525 .x_converter = _x11_image_converter,
493 .x_notify = _x11_notify_handler_image, 526 .x_notify = _x11_notify_handler_image,
494#endif 527#endif
528#ifdef HAVE_ELEMENTARY_WAYLAND
529 .wl_converter = _wl_image_converter,
530#endif
495 }, 531 },
496 ARRAYINIT(CNP_ATOM_image_jpeg) { 532 ARRAYINIT(CNP_ATOM_image_jpeg) {
497 .name = "image/jpeg", 533 .name = "image/jpeg",
@@ -500,6 +536,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
500 .x_converter = _x11_image_converter, 536 .x_converter = _x11_image_converter,
501 .x_notify = _x11_notify_handler_image, 537 .x_notify = _x11_notify_handler_image,
502#endif 538#endif
539#ifdef HAVE_ELEMENTARY_WAYLAND
540 .wl_converter = _wl_image_converter,
541#endif
503 }, 542 },
504 ARRAYINIT(CNP_ATOM_image_bmp) { 543 ARRAYINIT(CNP_ATOM_image_bmp) {
505 .name = "image/x-ms-bmp", 544 .name = "image/x-ms-bmp",
@@ -508,6 +547,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
508 .x_converter = _x11_image_converter, 547 .x_converter = _x11_image_converter,
509 .x_notify = _x11_notify_handler_image, 548 .x_notify = _x11_notify_handler_image,
510#endif 549#endif
550#ifdef HAVE_ELEMENTARY_WAYLAND
551 .wl_converter = _wl_image_converter,
552#endif
511 }, 553 },
512 ARRAYINIT(CNP_ATOM_image_gif) { 554 ARRAYINIT(CNP_ATOM_image_gif) {
513 .name = "image/gif", 555 .name = "image/gif",
@@ -516,6 +558,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
516 .x_converter = _x11_image_converter, 558 .x_converter = _x11_image_converter,
517 .x_notify = _x11_notify_handler_image, 559 .x_notify = _x11_notify_handler_image,
518#endif 560#endif
561#ifdef HAVE_ELEMENTARY_WAYLAND
562 .wl_converter = _wl_image_converter,
563#endif
519 }, 564 },
520 ARRAYINIT(CNP_ATOM_image_tiff) { 565 ARRAYINIT(CNP_ATOM_image_tiff) {
521 .name = "image/tiff", 566 .name = "image/tiff",
@@ -524,6 +569,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
524 .x_converter = _x11_image_converter, 569 .x_converter = _x11_image_converter,
525 .x_notify = _x11_notify_handler_image, 570 .x_notify = _x11_notify_handler_image,
526#endif 571#endif
572#ifdef HAVE_ELEMENTARY_WAYLAND
573 .wl_converter = _wl_image_converter,
574#endif
527 }, 575 },
528 ARRAYINIT(CNP_ATOM_image_svg) { 576 ARRAYINIT(CNP_ATOM_image_svg) {
529 .name = "image/svg+xml", 577 .name = "image/svg+xml",
@@ -532,6 +580,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
532 .x_converter = _x11_image_converter, 580 .x_converter = _x11_image_converter,
533 .x_notify = _x11_notify_handler_image, 581 .x_notify = _x11_notify_handler_image,
534#endif 582#endif
583#ifdef HAVE_ELEMENTARY_WAYLAND
584 .wl_converter = _wl_image_converter,
585#endif
535 }, 586 },
536 ARRAYINIT(CNP_ATOM_image_xpm) { 587 ARRAYINIT(CNP_ATOM_image_xpm) {
537 .name = "image/x-xpixmap", 588 .name = "image/x-xpixmap",
@@ -540,6 +591,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
540 .x_converter = _x11_image_converter, 591 .x_converter = _x11_image_converter,
541 .x_notify = _x11_notify_handler_image, 592 .x_notify = _x11_notify_handler_image,
542#endif 593#endif
594#ifdef HAVE_ELEMENTARY_WAYLAND
595 .wl_converter = _wl_image_converter,
596#endif
543 }, 597 },
544 ARRAYINIT(CNP_ATOM_image_tga) { 598 ARRAYINIT(CNP_ATOM_image_tga) {
545 .name = "image/x-tga", 599 .name = "image/x-tga",
@@ -548,6 +602,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
548 .x_converter = _x11_image_converter, 602 .x_converter = _x11_image_converter,
549 .x_notify = _x11_notify_handler_image, 603 .x_notify = _x11_notify_handler_image,
550#endif 604#endif
605#ifdef HAVE_ELEMENTARY_WAYLAND
606 .wl_converter = _wl_image_converter,
607#endif
551 }, 608 },
552 ARRAYINIT(CNP_ATOM_image_ppm) { 609 ARRAYINIT(CNP_ATOM_image_ppm) {
553 .name = "image/x-portable-pixmap", 610 .name = "image/x-portable-pixmap",
@@ -556,6 +613,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
556 .x_converter = _x11_image_converter, 613 .x_converter = _x11_image_converter,
557 .x_notify = _x11_notify_handler_image, 614 .x_notify = _x11_notify_handler_image,
558#endif 615#endif
616#ifdef HAVE_ELEMENTARY_WAYLAND
617 .wl_converter = _wl_image_converter,
618#endif
559 }, 619 },
560/* 620/*
561 ARRAYINIT(CNP_ATOM_text_html_utf8) { 621 ARRAYINIT(CNP_ATOM_text_html_utf8) {
@@ -565,6 +625,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
565 .x_converter = _x11_general_converter, 625 .x_converter = _x11_general_converter,
566 .x_notify = _x11_notify_handler_html, 626 .x_notify = _x11_notify_handler_html,
567#endif 627#endif
628#ifdef HAVE_ELEMENTARY_WAYLAND
629 .wl_converter = _wl_general_converter,
630#endif
568 }, 631 },
569 ARRAYINIT(CNP_ATOM_text_html) { 632 ARRAYINIT(CNP_ATOM_text_html) {
570 .name = "text/html", 633 .name = "text/html",
@@ -573,6 +636,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
573 .x_converter = _x11_general_converter, 636 .x_converter = _x11_general_converter,
574 .x_notify = _x11_notify_handler_html, 637 .x_notify = _x11_notify_handler_html,
575#endif 638#endif
639#ifdef HAVE_ELEMENTARY_WAYLAND
640 .wl_converter = _wl_general_converter,
641#endif
576 }, 642 },
577 */ 643 */
578 ARRAYINIT(CNP_ATOM_UTF8STRING) { 644 ARRAYINIT(CNP_ATOM_UTF8STRING) {
@@ -582,6 +648,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
582 .x_converter = _x11_text_converter, 648 .x_converter = _x11_text_converter,
583 .x_notify = _x11_notify_handler_text, 649 .x_notify = _x11_notify_handler_text,
584#endif 650#endif
651#ifdef HAVE_ELEMENTARY_WAYLAND
652 .wl_converter = _wl_text_converter,
653#endif
585 }, 654 },
586 ARRAYINIT(CNP_ATOM_STRING) { 655 ARRAYINIT(CNP_ATOM_STRING) {
587 .name = "STRING", 656 .name = "STRING",
@@ -590,6 +659,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
590 .x_converter = _x11_text_converter, 659 .x_converter = _x11_text_converter,
591 .x_notify = _x11_notify_handler_text, 660 .x_notify = _x11_notify_handler_text,
592#endif 661#endif
662#ifdef HAVE_ELEMENTARY_WAYLAND
663 .wl_converter = _wl_text_converter,
664#endif
593 }, 665 },
594 ARRAYINIT(CNP_ATOM_COMPOUND_TEXT) { 666 ARRAYINIT(CNP_ATOM_COMPOUND_TEXT) {
595 .name = "COMPOUND_TEXT", 667 .name = "COMPOUND_TEXT",
@@ -598,6 +670,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
598 .x_converter = _x11_text_converter, 670 .x_converter = _x11_text_converter,
599 .x_notify = _x11_notify_handler_text, 671 .x_notify = _x11_notify_handler_text,
600#endif 672#endif
673#ifdef HAVE_ELEMENTARY_WAYLAND
674 .wl_converter = _wl_text_converter,
675#endif
601 }, 676 },
602 ARRAYINIT(CNP_ATOM_TEXT) { 677 ARRAYINIT(CNP_ATOM_TEXT) {
603 .name = "TEXT", 678 .name = "TEXT",
@@ -606,6 +681,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
606 .x_converter = _x11_text_converter, 681 .x_converter = _x11_text_converter,
607 .x_notify = _x11_notify_handler_text, 682 .x_notify = _x11_notify_handler_text,
608#endif 683#endif
684#ifdef HAVE_ELEMENTARY_WAYLAND
685 .wl_converter = _wl_text_converter,
686#endif
609 }, 687 },
610 ARRAYINIT(CNP_ATOM_text_plain_utf8) { 688 ARRAYINIT(CNP_ATOM_text_plain_utf8) {
611 .name = "text/plain;charset=utf-8", 689 .name = "text/plain;charset=utf-8",
@@ -614,6 +692,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
614 .x_converter = _x11_text_converter, 692 .x_converter = _x11_text_converter,
615 .x_notify = _x11_notify_handler_text, 693 .x_notify = _x11_notify_handler_text,
616#endif 694#endif
695#ifdef HAVE_ELEMENTARY_WAYLAND
696 .wl_converter = _wl_text_converter,
697#endif
617 }, 698 },
618 ARRAYINIT(CNP_ATOM_text_plain) { 699 ARRAYINIT(CNP_ATOM_text_plain) {
619 .name = "text/plain", 700 .name = "text/plain",
@@ -622,6 +703,9 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
622 .x_converter = _x11_text_converter, 703 .x_converter = _x11_text_converter,
623 .x_notify = _x11_notify_handler_text, 704 .x_notify = _x11_notify_handler_text,
624#endif 705#endif
706#ifdef HAVE_ELEMENTARY_WAYLAND
707 .wl_converter = _wl_text_converter,
708#endif
625 }, 709 },
626}; 710};
627 711
@@ -2404,8 +2488,6 @@ _x11_elm_selection_selection_has_owner(Evas_Object *obj EINA_UNUSED)
2404#endif 2488#endif
2405 2489
2406#ifdef HAVE_ELEMENTARY_WAYLAND 2490#ifdef HAVE_ELEMENTARY_WAYLAND
2407typedef struct _Wl_Cnp_Selection Wl_Cnp_Selection;
2408
2409struct _Wl_Cnp_Selection 2491struct _Wl_Cnp_Selection
2410{ 2492{
2411 char *selbuf; 2493 char *selbuf;
@@ -2429,6 +2511,156 @@ struct _Wl_Cnp_Selection
2429 Eina_Bool active : 1; 2511 Eina_Bool active : 1;
2430}; 2512};
2431 2513
2514static Eina_Bool
2515_wl_targets_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret)
2516{
2517 cnp_debug("in\n");
2518 if (!data_ret) return EINA_FALSE;
2519
2520 const char *sep = "\n";
2521 char *aret;
2522 int len = 0;
2523 int i = 0;
2524 Elm_Sel_Format formats = ELM_SEL_FORMAT_NONE;
2525
2526 for (i = 0; i < CNP_N_ATOMS; i++)
2527 {
2528 if (!strcmp(target, _atoms[i].name))
2529 {
2530 formats = _atoms[i].formats;
2531 }
2532 }
2533 for (i = 0; i < CNP_N_ATOMS; i++)
2534 {
2535 if (formats & _atoms[i].formats)
2536 {
2537 len += strlen(_atoms[i].name) + strlen(sep);
2538 }
2539 }
2540 aret = calloc(1, len * sizeof(char));
2541 if (!aret) return EINA_FALSE;
2542 for (i = 0; i < CNP_N_ATOMS; i++)
2543 {
2544 if (formats & _atoms[i].formats)
2545 {
2546 aret = strcat(aret, _atoms[i].name);
2547 aret = strcat(aret, sep);
2548 }
2549 }
2550 *data_ret = aret;
2551 if (size_ret) *size_ret = len;
2552
2553 return EINA_TRUE;
2554}
2555
2556static Eina_Bool
2557_wl_general_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *data, int size, void **data_ret, int *size_ret)
2558{
2559 cnp_debug("in\n");
2560 Elm_Sel_Format formats = ELM_SEL_FORMAT_NONE;
2561 int i = 0;
2562 for (i = 0; i < CNP_N_ATOMS; i++)
2563 {
2564 if (!strcmp(target, _atoms[i].name))
2565 {
2566 formats = _atoms[i].formats;
2567 break;
2568 }
2569 }
2570 if (formats == ELM_SEL_FORMAT_NONE)
2571 {
2572 if (data_ret)
2573 {
2574 *data_ret = malloc(size * sizeof(char) + 1);
2575 if (!*data_ret) return EINA_FALSE;
2576 memcpy(*data_ret, data, size);
2577 ((char**)(data_ret))[0][size] = 0;
2578 }
2579 if (size_ret) *size_ret = size;
2580 }
2581 else
2582 {
2583 if (data)
2584 {
2585 if (data_ret) *data_ret = strdup(data);
2586 if (size_ret) *size_ret = strlen(data);
2587 }
2588 else
2589 {
2590 if (data_ret) *data_ret = NULL;
2591 if (size_ret) *size_ret = 0;
2592 }
2593 }
2594
2595 return EINA_TRUE;
2596}
2597
2598static Eina_Bool
2599_wl_image_converter(char *target EINA_UNUSED, Wl_Cnp_Selection *sel EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret EINA_UNUSED, int *size_ret EINA_UNUSED)
2600{
2601 cnp_debug("in\n");
2602 return EINA_TRUE;
2603}
2604
2605static Eina_Bool
2606_wl_text_converter(char *target, Wl_Cnp_Selection *sel, void *data, int size, void **data_ret, int *size_ret)
2607{
2608 cnp_debug("in\n");
2609 int i = 0;
2610 Elm_Sel_Format formats = ELM_SEL_FORMAT_NONE;
2611
2612 for (i = 0; i < CNP_N_ATOMS; i++)
2613 {
2614 if (!strcmp(target, _atoms[i].name))
2615 {
2616 formats = _atoms[i].formats;
2617 break;
2618 }
2619 }
2620 if (formats == ELM_SEL_FORMAT_NONE)
2621 {
2622 if (data_ret)
2623 {
2624 *data_ret = malloc(size * sizeof(char) + 1);
2625 if (!*data_ret) return EINA_FALSE;
2626 memcpy(*data_ret, data, size);
2627 ((char**)(data_ret))[0][size] = 0;
2628 if (size_ret) *size_ret = size;
2629 return EINA_TRUE;
2630 }
2631 }
2632 else if ((formats & ELM_SEL_FORMAT_MARKUP) ||
2633 (formats & ELM_SEL_FORMAT_HTML))
2634 {
2635 *data_ret = _elm_util_mkup_to_text(data);
2636 if (size_ret && *data_ret) *size_ret = strlen(*data_ret);
2637 }
2638 else if (formats & ELM_SEL_FORMAT_TEXT)
2639 {
2640 *data_ret = strdup(data);
2641 if (size_ret && *data_ret) *size_ret = strlen(*data_ret);
2642 }
2643 else if (formats & ELM_SEL_FORMAT_IMAGE)
2644 {
2645 cnp_debug("Image %s\n", evas_object_type_get(sel->widget));
2646 evas_object_image_file_get(elm_photocam_internal_image_get(sel->widget),
2647 (const char **)data_ret, NULL);
2648 if (!data_ret) *data_ret = strdup("No file");
2649 else *data_ret = strdup(*data_ret);
2650 if (size_ret) *size_ret = strlen(*data_ret);
2651 }
2652 return EINA_TRUE;
2653}
2654
2655static Eina_Bool
2656_wl_vcard_converter(char *target EINA_UNUSED, Wl_Cnp_Selection *sel EINA_UNUSED, void *data, int size EINA_UNUSED, void **data_ret, int *size_ret)
2657{
2658 cnp_debug("in\n");
2659 if (data_ret) *data_ret = strdup(data);
2660 if (size_ret) *size_ret = strlen(data);
2661 return EINA_TRUE;
2662}
2663
2432static Eina_Bool _wl_elm_cnp_init(void); 2664static Eina_Bool _wl_elm_cnp_init(void);
2433 2665
2434static Wl_Cnp_Selection wl_cnp_selection = 2666static Wl_Cnp_Selection wl_cnp_selection =
@@ -3232,6 +3464,7 @@ _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
3232 { 3464 {
3233 cnp_debug("Request data of type %s\n", drop->last.type); 3465 cnp_debug("Request data of type %s\n", drop->last.type);
3234 wl_cnp_selection.requestwidget = drop->obj; 3466 wl_cnp_selection.requestwidget = drop->obj;
3467 wl_cnp_selection.requestformat = drop->last.format;
3235 evas_object_event_callback_add(wl_cnp_selection.requestwidget, 3468 evas_object_event_callback_add(wl_cnp_selection.requestwidget,
3236 EVAS_CALLBACK_DEL, 3469 EVAS_CALLBACK_DEL,
3237 _wl_sel_obj_del2, 3470 _wl_sel_obj_del2,
@@ -3253,15 +3486,29 @@ _wl_dnd_send(void *data, int type EINA_UNUSED, void *event)
3253 int len_written = 0; 3486 int len_written = 0;
3254 Wl_Cnp_Selection *sel; 3487 Wl_Cnp_Selection *sel;
3255 Ecore_Wl_Event_Data_Source_Send *ev; 3488 Ecore_Wl_Event_Data_Source_Send *ev;
3489 void *data_ret = NULL;
3490 int len_ret = 0;
3491 int i = 0;
3256 3492
3257 cnp_debug("In\n"); 3493 cnp_debug("In\n");
3258 ev = event; 3494 ev = event;
3259 sel = data; 3495 sel = data;
3260 3496
3261 len_remained = sel->buflen; 3497 for (i = 0; i < CNP_N_ATOMS; i++)
3262 buf = sel->selbuf; 3498 {
3499 if (!strcmp(_atoms[i].name, ev->type))
3500 {
3501 cnp_debug("Found a type: %s\n", _atoms[i].name);
3502 _atoms[i].wl_converter(ev->type, sel, sel->selbuf,
3503 sel->buflen, &data_ret, &len_ret);
3504 break;
3505 }
3506 }
3263 3507
3264 while (len_written < sel->buflen) 3508 len_remained = len_ret;
3509 buf = data_ret;
3510
3511 while (len_written < len_ret)
3265 { 3512 {
3266 ret = write(ev->fd, buf, len_remained); 3513 ret = write(ev->fd, buf, len_remained);
3267 if (ret == -1) break; 3514 if (ret == -1) break;
@@ -3269,6 +3516,7 @@ _wl_dnd_send(void *data, int type EINA_UNUSED, void *event)
3269 len_written += ret; 3516 len_written += ret;
3270 len_remained -= ret; 3517 len_remained -= ret;
3271 } 3518 }
3519 free(data_ret);
3272 3520
3273 close(ev->fd); 3521 close(ev->fd);
3274 return ECORE_CALLBACK_PASS_ON; 3522 return ECORE_CALLBACK_PASS_ON;