/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
namespace
{
-static constexpr int32_t DEFAULT_POSITION = -1;
-}
+static constexpr int32_t DEFAULT_POSITION = -1;
+static constexpr int32_t INVALID_ECORE_WL2_WINDOW_ID = -1;
+} // namespace
static bool IsIntersection(int px, int py, int tx, int ty, int tw, int th)
{
static Eina_Bool EcoreEventDataSourceEnd(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Data_Source_End *ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_End*>(event);
- DragAndDropEcoreWl* dndImpl = reinterpret_cast<DragAndDropEcoreWl*>(data);
+ Ecore_Wl2_Event_Data_Source_End* ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_End*>(event);
+ DragAndDropEcoreWl* dndImpl = reinterpret_cast<DragAndDropEcoreWl*>(data);
if(ev->cancelled)
{
dndImpl->CallSourceEvent(Dali::DragAndDrop::SourceEventType::CANCEL);
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);
- mLeaveHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_LEAVE, EcoreEventDataLeave, 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);
+ mEnterHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_ENTER, EcoreEventDataEnter, this);
+ mLeaveHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_LEAVE, EcoreEventDataLeave, this);
}
DragAndDropEcoreWl::~DragAndDropEcoreWl()
}
}
- auto parent = Dali::DevelWindow::Get(target);
- Ecore_Wl2_Window* parentWindow = AnyCast<Ecore_Wl2_Window*>(parent.GetNativeHandle());
- if(parentWindow == nullptr)
+ auto window = Dali::DevelWindow::Get(target);
+
+ int parentWindowId = INVALID_ECORE_WL2_WINDOW_ID;
+
+ if(!window)
{
- return false;
+ // Target is stil not scene-on
+ // Add dummy target data, and wait until target is on scene.
+ target.OnSceneSignal().Connect(this, &DragAndDropEcoreWl::DropTargetSceneOn);
+ }
+ else
+ {
+ Ecore_Wl2_Window* parentWindow = AnyCast<Ecore_Wl2_Window*>(window.GetNativeHandle());
+ if(parentWindow == nullptr)
+ {
+ return false;
+ }
+ parentWindowId = ecore_wl2_window_id_get(parentWindow);
}
DropTarget targetData;
- targetData.target = target;
- targetData.callback = callback;
- targetData.inside = false;
- targetData.parentWindowId = ecore_wl2_window_id_get(parentWindow);
+ targetData.target = target;
+ targetData.callback = callback;
+ targetData.inside = false;
+ targetData.parentWindowId = parentWindowId;
mDropTargets.push_back(targetData);
{
for(std::size_t i = 0; i < mDropTargets.size(); i++)
{
- if(mDropTargets[i].inside)
- {
- Dali::DragAndDrop::DragEvent dragEvent;
- dragEvent.SetAction(Dali::DragAndDrop::DragType::LEAVE);
- Dali::Vector2 position(DEFAULT_POSITION, DEFAULT_POSITION);
- dragEvent.SetPosition(position);
- mDropTargets[i].callback(dragEvent);
- }
- mDropTargets[i].inside = false;
+ if(mDropTargets[i].inside)
+ {
+ Dali::DragAndDrop::DragEvent dragEvent;
+ dragEvent.SetAction(Dali::DragAndDrop::DragType::LEAVE);
+ Dali::Vector2 position(DEFAULT_POSITION, DEFAULT_POSITION);
+ dragEvent.SetPosition(position);
+ mDropTargets[i].callback(dragEvent);
+ }
+ mDropTargets[i].inside = false;
}
}
-
void DragAndDropEcoreWl::SendData(void* event)
{
Ecore_Wl2_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send*>(event);
return false;
}
+void DragAndDropEcoreWl::DropTargetSceneOn(Dali::Actor target)
+{
+ // Disconnect scene on signal
+ target.OnSceneSignal().Disconnect(this, &DragAndDropEcoreWl::DropTargetSceneOn);
+
+ for(auto iter = mDropTargets.begin(), iterEnd = mDropTargets.end(); iter != iterEnd; iter++)
+ {
+ if((*iter).target == target)
+ {
+ auto window = Dali::DevelWindow::Get(target);
+
+ Ecore_Wl2_Window* parentWindow = AnyCast<Ecore_Wl2_Window*>(window.GetNativeHandle());
+ if(parentWindow == nullptr)
+ {
+ return;
+ }
+
+ (*iter).parentWindowId = ecore_wl2_window_id_get(parentWindow);
+ break;
+ }
+ }
+}
+
} // namespace Adaptor
} // namespace Internal
#define DALI_INTERNAL_DRAG_AND_DROP_ECORE_WL2_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* DragAndDrop Implementation
*/
-class DragAndDropEcoreWl : public Dali::Internal::Adaptor::DragAndDrop
+class DragAndDropEcoreWl : public Dali::Internal::Adaptor::DragAndDrop,
+ public Dali::ConnectionTracker
{
public:
/**
void ResetDropTargets();
private:
+ /**
+ * @brief Callback function to check whether listening target is scene on.
+ * Note that This signal will be called only if AddListener target is not scene on.
+ */
+ void DropTargetSceneOn(Dali::Actor target);
+
+private:
DragAndDropEcoreWl(const DragAndDropEcoreWl&) = delete;
DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&) = delete;
DragAndDropEcoreWl(DragAndDropEcoreWl&&) = delete;
int mDataSize{0};
Dali::Vector2 mPosition;
Dali::DragAndDrop::SourceFunction mSourceCallback{nullptr};
- std::vector<DropTarget> mDropTargets;
+ std::vector<DropTarget> mDropTargets;
}; // class DragAndDropEcoreWl
} // namespace Adaptor