Files
reasampler/src/shell/actions/drag_out_win.h
T
daniel b71a05fbef Close the bridged-process hole in the drag-out hand-off gate
OsHandoff now needs the window-ownership proof AND a hit-test that named
nothing, so a bridged plugin's UI can't read as off-REAPER.
2026-08-03 16:42:59 -04:00

48 lines
2.8 KiB
C++

#pragma once
// drag_out_win — the host/OS boundary of native OS drag-out: whether the pointer has
// crossed it, whether the OS is ready to take the drag, and the hand-off itself, which
// gives a resolved existing-file path list to the OS's drag-drop machinery so the user can
// drop bank samples into Explorer / another app / another DAW. The pure gesture-boundary
// decision + path-list assembly live in drag_out.*.
//
// COPY-ONLY is STRUCTURAL on Windows: DoDragDrop's effect mask is DROPEFFECT_COPY
// alone — MOVE is never offered, so no target can pull a file out of the bank folder
// (only prune deletes bank bytes). macOS/Linux route through SWELL's file-list drag,
// which exposes no per-source effect mask, so there the copy-only guarantee rests on
// SWELL's copy semantics rather than an explicit mask.
//
// NON-DESTRUCTIVE: initiating a drag reads nothing but the path list; a cancelled or
// failed drag mutates no sample/index/selection.
#include <string>
#include <vector>
struct HWND__; // avoid dragging windows.h into every includer; the shell casts as needed.
namespace reasampler {
// `absolutePaths` must already be resolved/existing/de-duped (drag_out::assemblePathList
// output). No-op when empty. BLOCKING on Windows: OLE DoDragDrop runs its own modal
// message loop until drop/cancel. Returns true iff the drop was accepted
// (DROPEFFECT_COPY); the return is advisory — a failed drag surfaces no error.
bool initiateDragOut(HWND__* panelHwnd, const std::vector<std::string>& absolutePaths);
// Side-effect-free readiness probe for initiateDragOut. Call BEFORE tearing down internal drag
// state — an OS that isn't ready (OLE unavailable, HDROP build failure) must not consume the
// gesture like an empty payload would. Windows re-runs the OLE-init + HDROP checks and frees the
// probe HGLOBAL immediately; SWELL exposes no probe, so macOS/Linux reduces to the non-empty check.
bool canInitiateDragOut(const std::vector<std::string>& absolutePaths);
// True iff a window belonging to the host (REAPER) process sits under the screen point — the
// POSITIVE proof ui::DropContext::pointerOffHost is the negation of (that member owns the
// evidence rule). Nearly every REAPER surface qualifies whether or not GetThingFromPoint can
// name it, because the extension runs inside that process.
// The exception, and it ships: a plugin set to "Run as separate/dedicated process" draws its
// UI out of reaper_host32/64.exe, and WindowFromPoint descends to the deepest child — so this
// reports false over a bridged plugin's editor although the pointer never left REAPER. The
// law's hand-off gate absorbs that by also requiring REAPER's own hit-test to name nothing.
// Side-effect-free; safe on every mouse-move.
bool pointerOverHostWindow(int screenX, int screenY);
} // namespace reasampler