X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fdrag-and-drop%2Ftizen-wayland%2Fdrag-and-drop-impl-ecore-wl2.cpp;h=1f81f63d54533d9990354c5080d9ddb258da05a3;hb=fd24ffc204a00745fac271166c0d9407cd492675;hp=dd020c0a293cabb1a6d232c84e732f8cc8c22cf9;hpb=8a7e2ce1e854930e158f4c49e4431ba4e9791dcf;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.cpp b/dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.cpp index dd020c0..1f81f63 100644 --- a/dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.cpp +++ b/dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.cpp @@ -51,6 +51,29 @@ static Eina_Bool EcoreEventDataSend(void* data, int type, void* event) return ECORE_CALLBACK_PASS_ON; } +static Eina_Bool EcoreEventDataSourceEnd(void* data, int type, void* event) +{ + Ecore_Wl2_Event_Data_Source_End *ev = reinterpret_cast(event); + DragAndDropEcoreWl* dndImpl = reinterpret_cast(data); + if(ev->cancelled) + { + dndImpl->CallSourceEvent(Dali::DragAndDrop::SourceEventType::CANCEL); + } + else + { + dndImpl->CallSourceEvent(Dali::DragAndDrop::SourceEventType::ACCEPT); + } + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool EcoreEventDataSourceDrop(void* data, int type, void* event) +{ + DragAndDropEcoreWl* dndImpl = reinterpret_cast(data); + dndImpl->CallSourceEvent(Dali::DragAndDrop::SourceEventType::FINISH); + return ECORE_CALLBACK_PASS_ON; +} + static Eina_Bool EcoreEventOfferDataReady(void* data, int type, void* event) { DragAndDropEcoreWl* dndImpl = reinterpret_cast(data); @@ -75,6 +98,16 @@ static Eina_Bool EcoreEventDataDrop(void* data, int type, void* event) return ECORE_CALLBACK_PASS_ON; } +static Eina_Bool EcoreEventDataEnter(void* data, int type, void* event) +{ + Ecore_Wl2_Event_Dnd_Enter* ev = reinterpret_cast(event); + + // Set default offer is reject + ecore_wl2_offer_accept(ev->offer, NULL); + + return ECORE_CALLBACK_PASS_ON; +} + Dali::DragAndDrop GetDragAndDrop() { Dali::DragAndDrop dnd; @@ -104,21 +137,33 @@ Dali::DragAndDrop GetDragAndDrop() DragAndDropEcoreWl::DragAndDropEcoreWl() { - mSendHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this); - mReceiveHandler = ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventOfferDataReady, this); - mMotionHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_MOTION, EcoreEventDataMotion, this); - mDropHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_DROP, EcoreEventDataDrop, this); + // Source Events + mSendHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this); + mSourceEndHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_END, EcoreEventDataSourceEnd, this); + mSourceDropHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_DROP, EcoreEventDataSourceDrop, this); + + // Target Events + mReceiveHandler = ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventOfferDataReady, this); + mMotionHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_MOTION, EcoreEventDataMotion, this); + mDropHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_DROP, EcoreEventDataDrop, this); + mEnterHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_ENTER, EcoreEventDataEnter, this); } DragAndDropEcoreWl::~DragAndDropEcoreWl() { + // Source Events ecore_event_handler_del(mSendHandler); + ecore_event_handler_del(mSourceEndHandler); + ecore_event_handler_del(mSourceDropHandler); + + // Target Events ecore_event_handler_del(mReceiveHandler); ecore_event_handler_del(mMotionHandler); ecore_event_handler_del(mDropHandler); + ecore_event_handler_del(mEnterHandler); } -bool DragAndDropEcoreWl::StartDragAndDrop(Dali::Actor source, Dali::Actor shadow, const Dali::DragAndDrop::DragData& data) +bool DragAndDropEcoreWl::StartDragAndDrop(Dali::Actor source, Dali::Window shadowWindow, const Dali::DragAndDrop::DragData& data, Dali::DragAndDrop::SourceFunction callback) { // Get Parent Window auto parent = Dali::DevelWindow::Get(source); @@ -127,16 +172,11 @@ bool DragAndDropEcoreWl::StartDragAndDrop(Dali::Actor source, Dali::Actor shadow mMimeType = data.GetMimeType(); mData = data.GetData(); - // Apply Shadow Property - shadow.SetProperty(Dali::Actor::Property::SIZE, Vector2(150, 150)); - shadow.SetProperty(Dali::Actor::Property::OPACITY, 0.9f); + // Set Source Event + mSourceCallback = callback; - // Create Drag Window - mDragWindow = Dali::Window::New(Dali::PositionSize(0, 0, 150, 150), "DragWindow", "class", true); - mDragWindow.SetTransparency(true); - mDragWindow.SetSize(Dali::Window::WindowSize(150, 150)); - mDragWindow.SetBackgroundColor(Color::TRANSPARENT); - mDragWindow.Add(shadow); + // Set Drag Window + mDragWindow = shadowWindow; // Start Drag and Drop Ecore_Wl2_Window* parentWindow = AnyCast(parent.GetNativeHandle()); @@ -158,6 +198,9 @@ bool DragAndDropEcoreWl::StartDragAndDrop(Dali::Actor source, Dali::Actor shadow // Start wayland drag and drop mSerial = ecore_wl2_dnd_drag_start(input, parentWindow, dragWindow); + // Call Start Event + CallSourceEvent(Dali::DragAndDrop::SourceEventType::START); + return true; } @@ -197,6 +240,14 @@ bool DragAndDropEcoreWl::RemoveListener(Dali::Actor target) return true; } +void DragAndDropEcoreWl::CallSourceEvent(Dali::DragAndDrop::SourceEventType type) +{ + if(mSourceCallback) + { + mSourceCallback(type); + } +} + void DragAndDropEcoreWl::SendData(void* event) { Ecore_Wl2_Event_Data_Source_Send* ev = reinterpret_cast(event); @@ -248,6 +299,7 @@ void DragAndDropEcoreWl::ReceiveData(void* event) Dali::DragAndDrop::DragEvent dragEvent(Dali::DragAndDrop::DragType::DROP, mPosition, ev->mimetype, ev->data); mDropTargets[mTargetIndex].callback(dragEvent); mDropTargets[mTargetIndex].inside = false; + ecore_wl2_offer_finish(ev->offer); } mTargetIndex = -1; } @@ -273,6 +325,8 @@ bool DragAndDropEcoreWl::CalculateDragEvent(void* event) dragEvent.SetAction(Dali::DragAndDrop::DragType::ENTER); dragEvent.SetPosition(curPosition); mDropTargets[i].callback(dragEvent); + // Accept Offer + ecore_wl2_offer_mimes_set(ev->offer, ecore_wl2_offer_mimes_get(ev->offer)); } else if(!currentInside && mDropTargets[i].inside) { @@ -281,6 +335,8 @@ bool DragAndDropEcoreWl::CalculateDragEvent(void* event) dragEvent.SetAction(Dali::DragAndDrop::DragType::LEAVE); dragEvent.SetPosition(curPosition); mDropTargets[i].callback(dragEvent); + // Reject Offer + ecore_wl2_offer_accept(ev->offer, NULL); } else if(currentInside && mDropTargets[i].inside) { @@ -315,7 +371,6 @@ bool DragAndDropEcoreWl::CalculateViewRegion(void* event) char* mimetype = (char*)eina_array_data_get(ecore_wl2_offer_mimes_get(ev->offer), 0); if(mimetype) { - ecore_wl2_offer_accept(ev->offer, mimetype); ecore_wl2_offer_receive(ev->offer, mimetype); Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL); Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);