summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-10 09:20:18 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-10 21:21:41 +0100
commitad715eebd66156f4a391fd48f382e848aa6c4749 (patch)
tree474812e5800c2412db6945575d588b0d32bd11c7
parent838d2c27dc853a7ae622c89b859c7275a69bc862 (diff)
- motion,enter,leave can have negative coordinates.
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_dnd.c8
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_internal.h9
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c439
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h15
-rw-r--r--src/tests/ecore/ecore_evas_cnp_slave.c3
5 files changed, 468 insertions, 6 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_dnd.c b/src/lib/ecore_wl2/ecore_wl2_dnd.c
index fccbed468b..e60b71f629 100644
--- a/src/lib/ecore_wl2/ecore_wl2_dnd.c
+++ b/src/lib/ecore_wl2/ecore_wl2_dnd.c
@@ -545,6 +545,14 @@ ecore_wl2_dnd_selection_get(Ecore_Wl2_Input *input)
545 return input->selection.offer; 545 return input->selection.offer;
546} 546}
547 547
548EAPI Ecore_Wl2_Offer*
549ecore_wl2_dnd_offer_get(Ecore_Wl2_Input *input)
550{
551 EINA_SAFETY_ON_NULL_RETURN_VAL(input, NULL);
552
553 return input->drag.offer;
554}
555
548EAPI uint32_t 556EAPI uint32_t
549ecore_wl2_dnd_selection_set(Ecore_Wl2_Input *input, const char **types) 557ecore_wl2_dnd_selection_set(Ecore_Wl2_Input *input, const char **types)
550{ 558{
diff --git a/src/lib/ecore_wl2/ecore_wl2_internal.h b/src/lib/ecore_wl2/ecore_wl2_internal.h
index 98dd5c1b5a..c3df37e2ad 100644
--- a/src/lib/ecore_wl2/ecore_wl2_internal.h
+++ b/src/lib/ecore_wl2/ecore_wl2_internal.h
@@ -190,6 +190,15 @@ EAPI void ecore_wl2_dnd_drag_end(Ecore_Wl2_Input *input);
190 * @since 1.19 190 * @since 1.19
191 */ 191 */
192EAPI Ecore_Wl2_Offer* ecore_wl2_dnd_selection_get(Ecore_Wl2_Input *input); 192EAPI Ecore_Wl2_Offer* ecore_wl2_dnd_selection_get(Ecore_Wl2_Input *input);
193/**
194 * Get the offer which is currently resposible for the drag and drop buffer
195 *
196 * @param input the input object to use
197 *
198 * @ingroup Ecore_Wl2_Dnd_Group
199 * @since 1.24
200 */
201EAPI Ecore_Wl2_Offer* ecore_wl2_dnd_offer_get(Ecore_Wl2_Input *input);
193 202
194/** 203/**
195 * Set the types which are available from this client 204 * Set the types which are available from this client
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index e0e2094e2f..50fb81b593 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -4,6 +4,7 @@
4 4
5#include "ecore_evas_wayland_private.h" 5#include "ecore_evas_wayland_private.h"
6#include <Evas_Engine_Wayland.h> 6#include <Evas_Engine_Wayland.h>
7#include "ecore_wl2_internal.h"
7 8
8extern EAPI Eina_List *_evas_canvas_image_data_unset(Evas *eo_e); 9extern EAPI Eina_List *_evas_canvas_image_data_unset(Evas *eo_e);
9extern EAPI void _evas_canvas_image_data_regenerate(Eina_List *list); 10extern EAPI void _evas_canvas_image_data_regenerate(Eina_List *list);
@@ -32,6 +33,7 @@ static Eina_Array *_ecore_evas_wl_event_hdls;
32 33
33static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location); 34static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location);
34static void _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize); 35static void _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize);
36static void _ecore_evas_wl_selection_init(Ecore_Evas *ee);
35 37
36/* local functions */ 38/* local functions */
37static void 39static void
@@ -1440,6 +1442,15 @@ _ecore_evas_wl_common_free(Ecore_Evas *ee)
1440 if (wdata->frame) ecore_wl2_window_frame_callback_del(wdata->frame); 1442 if (wdata->frame) ecore_wl2_window_frame_callback_del(wdata->frame);
1441 wdata->frame = NULL; 1443 wdata->frame = NULL;
1442 ecore_event_handler_del(wdata->sync_handler); 1444 ecore_event_handler_del(wdata->sync_handler);
1445 ecore_event_handler_del(wdata->changed_handler);
1446 ecore_event_handler_del(wdata->send_handler);
1447 ecore_event_handler_del(wdata->offer_handler);
1448 ecore_event_handler_del(wdata->dnd_leave_handler);
1449 ecore_event_handler_del(wdata->dnd_enter_handler);
1450 ecore_event_handler_del(wdata->dnd_motion_handler);
1451 ecore_event_handler_del(wdata->dnd_drop_handler);
1452 ecore_event_handler_del(wdata->dnd_end_handler);
1453
1443 if (wdata->win) 1454 if (wdata->win)
1444 { 1455 {
1445 ecore_wl2_window_close_callback_set(wdata->win, NULL, NULL); 1456 ecore_wl2_window_close_callback_set(wdata->win, NULL, NULL);
@@ -2389,6 +2400,425 @@ _ecore_wl2_devices_setup(Ecore_Evas *ee, Ecore_Wl2_Display *display)
2389 return r; 2400 return r;
2390} 2401}
2391 2402
2403static void
2404_reeval_seat(unsigned int *seat, Ecore_Evas *ee)
2405{
2406 if (*seat == 0)
2407 *seat = evas_device_seat_id_get(evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_TYPE_SEAT));
2408}
2409
2410static inline void
2411_clear_selection(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer selection)
2412{
2413 Ecore_Evas_Engine_Wl_Data *edata = ee->engine.data;
2414 Ecore_Evas_Selection_Callbacks *cbs = &edata->selection_data[selection].callbacks;
2415
2416 EINA_SAFETY_ON_FALSE_RETURN(cbs->cancel);
2417
2418 cbs->cancel(ee, selection);
2419 eina_array_free(cbs->available_types);
2420 memset(cbs, 0, sizeof(Ecore_Evas_Selection_Callbacks));
2421}
2422
2423static void
2424_store_selection_cbs(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer selection, Eina_Array *available_types, Eina_Bool (*delivery)(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer buffer, const char *type, Eina_Rw_Slice *slice), void (*cancel)(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer buffer))
2425{
2426 Ecore_Evas_Wl_Selection_Data *sdata;
2427 Ecore_Evas_Engine_Wl_Data *edata;
2428 Ecore_Evas_Selection_Callbacks *cbs;
2429
2430 edata = ee->engine.data;
2431 sdata = &edata->selection_data[selection];
2432 cbs = &sdata->callbacks;
2433
2434 if (cbs->cancel)
2435 {
2436 _clear_selection(ee, selection);
2437 }
2438
2439 cbs->delivery = delivery;
2440 cbs->cancel = cancel;
2441 cbs->available_types = available_types;
2442}
2443
2444static inline Ecore_Wl2_Input*
2445_fetch_input(Ecore_Evas *ee, unsigned int seat)
2446{
2447 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2448 return ecore_wl2_display_input_find(ecore_wl2_window_display_get(wdata->win), seat);
2449}
2450
2451static Eina_Bool
2452_ecore_evas_wl_selection_claim(Ecore_Evas *ee, unsigned int seat, Ecore_Evas_Selection_Buffer selection, Eina_Array *available_types, Eina_Bool (*delivery)(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer buffer, const char *type, Eina_Rw_Slice *slice), void (*cancel)(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer buffer))
2453{
2454 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2455 Ecore_Evas_Wl_Selection_Data *data = &wdata->selection_data[selection];
2456 char *tmp_array[eina_array_count(available_types) + 1];
2457
2458 if (selection == ECORE_EVAS_SELECTION_BUFFER_SELECTION_BUFFER)
2459 {
2460 _store_selection_cbs(ee, selection, available_types, delivery, cancel);
2461 return EINA_TRUE;
2462 }
2463
2464 _reeval_seat(&seat, ee);
2465 _store_selection_cbs(ee, selection, available_types, delivery, cancel);
2466
2467 for (unsigned int i = 0; i < eina_array_count(available_types); ++i)
2468 {
2469 tmp_array[i] = eina_array_data_get(available_types, i);
2470 }
2471 tmp_array[eina_array_count(available_types)] = NULL;
2472
2473 data->sent_serial = ecore_wl2_dnd_selection_set(_fetch_input(ee, seat), (const char**)tmp_array);
2474 return EINA_TRUE;
2475}
2476
2477
2478static Eina_Future*
2479_ecore_evas_wl_selection_request(Ecore_Evas *ee, unsigned int seat, Ecore_Evas_Selection_Buffer selection, Eina_Array *acceptable_types)
2480{
2481 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2482 Ecore_Evas_Wl_Selection_Data *data = &wdata->selection_data[selection];
2483 Ecore_Wl2_Input *input;
2484 Ecore_Wl2_Offer *offer = NULL;
2485 Eina_Future *future;
2486
2487 _reeval_seat(&seat, ee);
2488 input = _fetch_input(ee, seat);
2489
2490 if (data->delivery)
2491 {
2492 eina_promise_reject(data->delivery, ecore_evas_request_replaced);
2493 data->delivery = NULL;
2494 }
2495 data->delivery = efl_loop_promise_new(efl_main_loop_get());
2496 future = eina_future_new(data->delivery);
2497
2498 if (selection == ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER)
2499 {
2500 offer = data->offer = wdata->external_offer;
2501 }
2502 else if (selection == ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER)
2503 {
2504 offer = data->offer = ecore_wl2_dnd_selection_get(input);
2505 }
2506
2507 if (!offer)
2508 {
2509 eina_promise_reject(data->delivery, ecore_evas_no_selection);
2510 data->delivery = NULL;
2511 }
2512 else
2513 {
2514 Eina_Array *available_types = ecore_wl2_offer_mimes_get(offer);
2515 char *selected_type = NULL;
2516
2517 for (unsigned int i = 0; i < eina_array_count(available_types) && !selected_type; ++i)
2518 {
2519 char *available_type = eina_array_data_get(available_types, i);
2520 for (unsigned int j = 0; j < eina_array_count(acceptable_types) && !selected_type; ++j)
2521 {
2522 char *acceptable_type = eina_array_data_get(acceptable_types, j);
2523 if (eina_streq(acceptable_type, available_type))
2524 {
2525 selected_type = available_type;
2526 data->later_convert = NULL;
2527 break;
2528 }
2529
2530 const char *convert_available_type;
2531 Eina_Iterator *convertions = eina_content_converter_possible_conversions(available_type);
2532 EINA_ITERATOR_FOREACH(convertions, convert_available_type)
2533 {
2534 if (eina_streq(convert_available_type, acceptable_type))
2535 {
2536 selected_type = available_type;
2537 data->later_convert = acceptable_type;
2538 }
2539 }
2540 }
2541
2542 }
2543 if (selected_type)
2544 {
2545 ecore_wl2_offer_receive(offer, selected_type);
2546 ecore_wl2_display_flush(ecore_wl2_input_display_get(input));
2547 }
2548 else
2549 {
2550 eina_promise_reject(data->delivery, ecore_evas_no_matching_type);
2551 data->delivery = NULL;
2552 }
2553 }
2554
2555 return future;
2556}
2557
2558static Eina_Bool
2559_ecore_evas_wl_selection_has_owner(Ecore_Evas *ee, unsigned int seat, Ecore_Evas_Selection_Buffer selection EINA_UNUSED)
2560{
2561 Ecore_Wl2_Input *input;
2562
2563 _reeval_seat(&seat, ee);
2564 input = _fetch_input(ee, seat);
2565
2566 if (selection == ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER )
2567 return !!ecore_wl2_dnd_selection_get(input);
2568 else if (selection == ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER)
2569 return !!ecore_wl2_dnd_offer_get(input);
2570 return EINA_FALSE; //the selection buffer is not supportet in wayland
2571}
2572
2573static Eina_Bool
2574_wl_selection_changed(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
2575{
2576 Ecore_Wl2_Event_Seat_Selection *sel = event;
2577 Ecore_Evas *ee = data;
2578 Ecore_Wl2_Input *input;
2579 unsigned int seat = sel->seat;
2580
2581 _reeval_seat(&seat, ee);
2582 input = _fetch_input(ee, seat);
2583 if (!ecore_wl2_dnd_selection_get(input))
2584 return ECORE_CALLBACK_PASS_ON;
2585
2586 if (ee->func.fn_selection_changed)
2587 ee->func.fn_selection_changed(ee, 0, ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER);
2588
2589 return ECORE_CALLBACK_PASS_ON;
2590}
2591
2592/*
2593static Eina_Bool
2594_wl_dnd_end(void *data, int type EINA_UNUSED, void *event)
2595{
2596 Ecore_Wl2_Event_Data_Source_End *ev = event;
2597 Ecore_Evas *ee = data;
2598
2599 return ECORE_CALLBACK_PASS_ON;
2600}
2601*/
2602
2603static Eina_Bool
2604_wl_interaction_send(void *data, int type EINA_UNUSED, void *event)
2605{
2606 Ecore_Wl2_Event_Data_Source_Send *ev = event;
2607 Ecore_Evas *ee = data;
2608 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2609 Ecore_Evas_Wl_Selection_Data *selection = NULL;
2610 Eina_Rw_Slice data_to_write;
2611 Ecore_Evas_Selection_Buffer buffer = ECORE_EVAS_SELECTION_BUFFER_LAST;
2612
2613 if (ev->serial == wdata->selection_data[ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER].sent_serial)
2614 buffer = ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER;
2615 else if (ev->serial == wdata->selection_data[ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER].sent_serial)
2616 {
2617 buffer = ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER;
2618 ee->drag.accepted = EINA_TRUE;
2619 }
2620
2621 if (buffer == ECORE_EVAS_SELECTION_BUFFER_LAST)
2622 {
2623 //silent return, this send request was *not* for this window
2624 return ECORE_CALLBACK_PASS_ON;
2625 }
2626
2627 selection = &wdata->selection_data[buffer];
2628 EINA_SAFETY_ON_NULL_GOTO(selection, end);
2629 EINA_SAFETY_ON_NULL_GOTO(selection->callbacks.delivery, end);
2630 EINA_SAFETY_ON_FALSE_GOTO(selection->callbacks.delivery(ee, buffer, ev->type, &data_to_write), end);
2631 EINA_SAFETY_ON_FALSE_GOTO(write(ev->fd, data_to_write.mem, data_to_write.len) == (ssize_t)data_to_write.len, end);
2632 close(ev->fd);
2633end:
2634 ecore_wl2_display_flush(ev->display);
2635 return ECORE_CALLBACK_PASS_ON;
2636}
2637
2638static Eina_Bool
2639_wl_selection_receive(void *data, int type EINA_UNUSED, void *event)
2640{
2641 Ecore_Evas *ee = data;
2642 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2643 Ecore_Wl2_Event_Offer_Data_Ready *ready = event;
2644 Ecore_Evas_Selection_Buffer selection = ECORE_EVAS_SELECTION_BUFFER_LAST;
2645
2646 for (int i = 0; i < ECORE_EVAS_SELECTION_BUFFER_LAST; ++i)
2647 {
2648 if (wdata->selection_data[i].offer == ready->offer)
2649 {
2650 selection = i;
2651 break;
2652 }
2653 }
2654
2655 if (selection == ECORE_EVAS_SELECTION_BUFFER_LAST)
2656 return ECORE_CALLBACK_PASS_ON;
2657
2658 //Now deliver the content
2659 Eina_Slice slice;
2660 slice.mem = ready->data;
2661 slice.len = ready->len;
2662
2663 Eina_Content *content = eina_content_new(slice, ready->mimetype);
2664
2665 if (wdata->selection_data[selection].later_convert)
2666 {
2667 Eina_Content *tmp = eina_content_convert(content, wdata->selection_data[selection].later_convert);
2668 wdata->selection_data[selection].later_convert = NULL;
2669 eina_content_free(content);
2670 content = tmp;
2671 }
2672
2673 eina_promise_resolve(wdata->selection_data[selection].delivery, eina_value_content_init(content));
2674 wdata->selection_data[selection].delivery = NULL;
2675 eina_content_free(content);
2676
2677 return ECORE_CALLBACK_PASS_ON;
2678}
2679
2680static Eina_Bool
2681_wl_selection_dnd_leave(void *data, int type EINA_UNUSED, void *event)
2682{
2683 Ecore_Evas *ee = data;
2684 Eina_Position2D cpos;
2685 Eina_Position2D fpos = EINA_POSITION2D(0, 0);
2686 Ecore_Wl2_Event_Dnd_Leave *ev = event;
2687 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2688
2689 if (ee->prop.window != (Ecore_Window)ev->win) return ECORE_CALLBACK_PASS_ON;
2690
2691 //evas_output_framespace_get(ee->evas, &fpos.x, &fpos.y, NULL, NULL);
2692 ecore_wl2_input_pointer_xy_get(ecore_wl2_display_input_find(ev->display, ev->seat), &cpos.x, &cpos.y);
2693 ecore_evas_dnd_leave(data, ev->seat, EINA_POSITION2D(cpos.x - fpos.x, cpos.y - fpos.y));
2694 wdata->external_offer = NULL;
2695
2696 return ECORE_CALLBACK_PASS_ON;
2697}
2698
2699static Eina_Bool
2700_wl_selection_dnd_motion(void *data, int type EINA_UNUSED, void *event)
2701{
2702 Ecore_Evas *ee = data;
2703 Ecore_Wl2_Event_Dnd_Motion *ev = event;
2704 Eina_Position2D fpos = EINA_POSITION2D(0, 0);
2705
2706 if (ee->prop.window != (Ecore_Window)ev->win) return ECORE_CALLBACK_PASS_ON;
2707
2708 evas_output_framespace_get(ee->evas, &fpos.x, &fpos.y, NULL, NULL);
2709 ecore_evas_dnd_position_set(data, ev->seat, EINA_POSITION2D(ev->x - fpos.x, ev->y - fpos.y));
2710 return ECORE_CALLBACK_PASS_ON;
2711}
2712static Eina_Bool
2713_wl_selection_dnd_enter(void *data, int type EINA_UNUSED, void *event)
2714{
2715 Ecore_Evas *ee = data;
2716 Ecore_Wl2_Event_Dnd_Enter *ev = event;
2717 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2718 Eina_Position2D fpos = EINA_POSITION2D(0, 0);
2719
2720 if (ee->prop.window != (Ecore_Window)ev->win) return ECORE_CALLBACK_PASS_ON;
2721
2722 evas_output_framespace_get(ee->evas, &fpos.x, &fpos.y, NULL, NULL);
2723 ecore_evas_dnd_enter(data, ev->seat, eina_array_iterator_new(ecore_wl2_offer_mimes_get(ev->offer)), EINA_POSITION2D(ev->x - fpos.x, ev->y - fpos.y));
2724 ecore_wl2_offer_mimes_set(ev->offer, ecore_wl2_offer_mimes_get(ev->offer));
2725 wdata->external_offer = ev->offer;
2726 return ECORE_CALLBACK_PASS_ON;
2727}
2728
2729static Eina_Bool
2730_wl_selection_dnd_drop(void *data, int type EINA_UNUSED, void *event)
2731{
2732 Ecore_Evas *ee = data;
2733 Ecore_Wl2_Event_Dnd_Drop *ev = event;
2734 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2735 if (ee->prop.window != (Ecore_Window)ev->win) return ECORE_CALLBACK_PASS_ON;
2736 wdata = ee->engine.data;
2737
2738 if (ee->func.fn_dnd_drop)
2739 ee->func.fn_dnd_drop(ee, ev->seat, ecore_evas_dnd_pos_get(ee, ev->seat), "move");
2740
2741 ecore_wl2_dnd_drag_end(_fetch_input(ee, ev->seat));
2742 wdata->external_offer = NULL;
2743
2744 return ECORE_CALLBACK_PASS_ON;
2745}
2746static Eina_Bool
2747_wl_selection_dnd_end(void *data, int type EINA_UNUSED, void *event)
2748{
2749 Ecore_Evas *ee = data;
2750 Ecore_Wl2_Event_Dnd_End *ev = event;
2751
2752 if (ee->prop.window != (Ecore_Window)ev->win) return ECORE_CALLBACK_PASS_ON;
2753
2754
2755 if (ee->drag.free)
2756 ee->drag.free(ee, ee->drag.data, ee->drag.accepted);
2757 ee->drag.free = NULL;
2758 //we got dropped, we should call
2759
2760 return ECORE_CALLBACK_PASS_ON;
2761}
2762
2763static void
2764_ecore_evas_wl_selection_init(Ecore_Evas *ee)
2765{
2766 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2767
2768 wdata->changed_handler = ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_SELECTION,
2769 _wl_selection_changed, ee);
2770 wdata->send_handler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND,
2771 _wl_interaction_send, ee);
2772 wdata->offer_handler = ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY,
2773 _wl_selection_receive, ee);
2774 wdata->dnd_leave_handler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_LEAVE,
2775 _wl_selection_dnd_leave, ee);
2776 wdata->dnd_motion_handler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_MOTION,
2777 _wl_selection_dnd_motion, ee);
2778 wdata->dnd_enter_handler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_ENTER,
2779 _wl_selection_dnd_enter, ee);
2780 wdata->dnd_drop_handler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_DROP,
2781 _wl_selection_dnd_drop, ee);
2782 wdata->dnd_end_handler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_DROP,
2783 _wl_selection_dnd_end, ee);
2784 for (int i = 0; i < ECORE_EVAS_SELECTION_BUFFER_LAST; ++i)
2785 {
2786 wdata->selection_data[i].callbacks.available_types = NULL;
2787 wdata->selection_data[i].callbacks.delivery = NULL;
2788 wdata->selection_data[i].callbacks.cancel = NULL;
2789 }
2790}
2791
2792static Eina_Bool
2793_ecore_evas_wl_dnd_start(Ecore_Evas *ee, unsigned int seat, Eina_Array *available_types, Ecore_Evas *drag_rep, Eina_Bool (*delivery)(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer buffer, const char *type, Eina_Rw_Slice *slice), void (*cancel)(Ecore_Evas *ee, Ecore_Evas_Selection_Buffer buffer), const char *action EINA_UNUSED)
2794{
2795 Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
2796 const char *tmp_array[eina_array_count(available_types) + 1];
2797
2798 _reeval_seat(&seat, ee);
2799 _store_selection_cbs(ee, ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER, available_types, delivery, cancel);
2800
2801 for (unsigned int i = 0; i < eina_array_count(available_types); ++i)
2802 {
2803 tmp_array[i] = eina_array_data_get(available_types, i);
2804 }
2805 tmp_array[eina_array_count(available_types)] = NULL;
2806
2807 ecore_wl2_dnd_drag_types_set(_fetch_input(ee, seat), (const char**)tmp_array);
2808 wdata->selection_data[ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER].sent_serial =
2809 ecore_wl2_dnd_drag_start(_fetch_input(ee, seat), (Ecore_Wl2_Window*)ee->prop.window, (Ecore_Wl2_Window*)drag_rep->prop.window);
2810 return EINA_TRUE;
2811}
2812
2813static Eina_Bool
2814_ecore_evas_wl_dnd_stop(Ecore_Evas *ee, unsigned int seat)
2815{
2816 _clear_selection(ee, ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER);
2817 _reeval_seat(&seat, ee);
2818 ecore_wl2_dnd_drag_end(_fetch_input(ee, seat));
2819 return EINA_TRUE;
2820}
2821
2392static Ecore_Evas_Engine_Func _ecore_wl_engine_func = 2822static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
2393{ 2823{
2394 _ecore_evas_wl_common_free, 2824 _ecore_evas_wl_common_free,
@@ -2474,9 +2904,11 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
2474 _ecore_evas_wl_common_pointer_device_xy_get, 2904 _ecore_evas_wl_common_pointer_device_xy_get,
2475 _ecore_evas_wl_common_prepare, 2905 _ecore_evas_wl_common_prepare,
2476 NULL, //fn_last_tick_get 2906 NULL, //fn_last_tick_get
2477 NULL, //fn_selection_claim 2907 _ecore_evas_wl_selection_claim, //fn_selection_claim
2478 NULL, //fn_selection_has_owner 2908 _ecore_evas_wl_selection_has_owner, //fn_selection_has_owner
2479 NULL, //fn_selection_request 2909 _ecore_evas_wl_selection_request, //fn_selection_request
2910 _ecore_evas_wl_dnd_start, //fn_dnd_start
2911 _ecore_evas_wl_dnd_stop, //fn_dnd_stop
2480}; 2912};
2481 2913
2482static void 2914static void
@@ -2653,6 +3085,7 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, Ecore_Window parent, i
2653 } 3085 }
2654 3086
2655 _ecore_evas_wl_common_wm_rotation_protocol_set(ee); 3087 _ecore_evas_wl_common_wm_rotation_protocol_set(ee);
3088 _ecore_evas_wl_selection_init(ee);
2656 3089
2657 ecore_evas_done(ee, EINA_FALSE); 3090 ecore_evas_done(ee, EINA_FALSE);
2658 3091
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
index e69970f262..52d025416d 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
@@ -34,12 +34,22 @@
34 34
35typedef struct _Ecore_Evas_Engine_Wl_Data Ecore_Evas_Engine_Wl_Data; 35typedef struct _Ecore_Evas_Engine_Wl_Data Ecore_Evas_Engine_Wl_Data;
36 36
37typedef struct _Ecore_Evas_Wl_Selection_Data Ecore_Evas_Wl_Selection_Data;
38
39struct _Ecore_Evas_Wl_Selection_Data {
40 Ecore_Evas_Selection_Callbacks callbacks;
41 Eina_Promise *delivery;
42 Ecore_Wl2_Offer *offer;
43 const char *later_convert;
44 uint32_t sent_serial; //The serial of the last sent selection op
45};
46
37struct _Ecore_Evas_Engine_Wl_Data 47struct _Ecore_Evas_Engine_Wl_Data
38{ 48{
39 Ecore_Wl2_Display *display; 49 Ecore_Wl2_Display *display;
40 Eina_List *regen_objs; 50 Eina_List *regen_objs;
41 Ecore_Wl2_Window *parent, *win; 51 Ecore_Wl2_Window *parent, *win;
42 Ecore_Event_Handler *sync_handler; 52 Ecore_Event_Handler *sync_handler, *changed_handler, *end_handler, *send_handler, *offer_handler, *dnd_leave_handler, *dnd_motion_handler, *dnd_enter_handler, *dnd_drop_handler, *dnd_end_handler;
43 int fx, fy, fw, fh; 53 int fx, fy, fw, fh;
44 Ecore_Wl2_Frame_Cb_Handle *frame; 54 Ecore_Wl2_Frame_Cb_Handle *frame;
45 int x_rel; 55 int x_rel;
@@ -47,7 +57,8 @@ struct _Ecore_Evas_Engine_Wl_Data
47 uint32_t timestamp; 57 uint32_t timestamp;
48 Eina_List *devices_list; 58 Eina_List *devices_list;
49 int cw, ch; 59 int cw, ch;
50 60 Ecore_Evas_Wl_Selection_Data selection_data[ECORE_EVAS_SELECTION_BUFFER_LAST];
61 Ecore_Wl2_Offer *external_offer;
51 struct 62 struct
52 { 63 {
53 Eina_Bool supported : 1; 64 Eina_Bool supported : 1;
diff --git a/src/tests/ecore/ecore_evas_cnp_slave.c b/src/tests/ecore/ecore_evas_cnp_slave.c
index 9c5db3fce5..35b5c6f467 100644
--- a/src/tests/ecore/ecore_evas_cnp_slave.c
+++ b/src/tests/ecore/ecore_evas_cnp_slave.c
@@ -60,7 +60,8 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
60 60
61 ecore_evas_init(); 61 ecore_evas_init();
62 62
63 Ecore_Evas *ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 0, 0); 63 Ecore_Evas *ee = ecore_evas_software_x11_new(NULL, 0, 0, 200, 200, EINA_TRUE);
64 //Ecore_Evas *ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 0, 0, EINA_FALSE);
64 65
65 if (eina_streq(goal, "--monitor")) 66 if (eina_streq(goal, "--monitor"))
66 { 67 {