| 569 | WindowsGuiData GuiDragDropData; |
| 570 | |
| 571 | DragDropEffect Window::DoDragDrop(const StringView& data) |
| 572 | { |
| 573 | // Create background worker that will keep updating GUI (perform rendering) |
| 574 | const auto task = New<DoDragDropJob>(); |
| 575 | Task::StartNew(task); |
| 576 | while (task->GetState() == TaskState::Queued) |
| 577 | Platform::Sleep(1); |
| 578 | |
| 579 | // Create descriptors |
| 580 | FORMATETC fmtetc = { CF_TEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; |
| 581 | STGMEDIUM stgmed = { TYMED_HGLOBAL, { nullptr }, nullptr }; |
| 582 | |
| 583 | // Create a HGLOBAL inside the storage medium |
| 584 | stgmed.hGlobal = StringToHandle(data); |
| 585 | |
| 586 | // Create drop source |
| 587 | auto dropSource = new WindowsDragSource(&fmtetc, &stgmed, 1); |
| 588 | |
| 589 | // Do the drag drop operation |
| 590 | DWORD dwEffect; |
| 591 | HRESULT result = ::DoDragDrop(dropSource, dropSource, DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK | DROPEFFECT_SCROLL, &dwEffect); |
| 592 | |
| 593 | // Wait for job end |
| 594 | Platform::AtomicStore(&task->ExitFlag, 1); |
| 595 | task->Wait(); |
| 596 | |
| 597 | // Release allocated data |
| 598 | dropSource->Release(); |
| 599 | ReleaseStgMedium(&stgmed); |
| 600 | |
| 601 | // Fix hanging mouse state (Windows doesn't send WM_LBUTTONUP when we end the drag and drop) |
| 602 | if (Input::GetMouseButton(MouseButton::Left)) |
| 603 | { |
| 604 | ::POINT point; |
| 605 | ::GetCursorPos(&point); |
| 606 | #if PLATFORM_SDL |
| 607 | // Reset the internal button state in SDL |
| 608 | SendMessageA((HWND)_handle, WM_LBUTTONUP, 0, MAKELPARAM(point.x, point.y)); |
| 609 | #else |
| 610 | Input::Mouse->OnMouseUp(Float2((float)point.x, (float)point.y), MouseButton::Left, this); |
| 611 | #endif |
| 612 | } |
| 613 | |
| 614 | return SUCCEEDED(result) ? dropEffectFromOleEnum(dwEffect) : DragDropEffect::None; |
| 615 | } |
| 616 | |
| 617 | HRESULT Window::DragEnter(Windows::IDataObject* pDataObj, Windows::DWORD grfKeyState, Windows::POINTL pt, Windows::DWORD* pdwEffect) |
| 618 | { |
nothing calls this directly
no test coverage detected