Class WindowsDrag

java.lang.Object
limn.backend.lwjgl.transfer.WindowsDrag

public final class WindowsDrag extends Object
The system's drag and drop on Windows, which is OLE's: a window is a destination once an IDropTarget is registered for it, and a drag out of it is DoDragDrop with a data object and an IDropSource.

The two objects are made here, each a table of callbacks; the data object is the shell's (SHCreateDataObject), filled with what a copy would put on the clipboard, in the same formats by a data object of ours inside it, which makes each format when a target asks for it.

DoDragDrop does not return until the drag is over, and runs a loop of its own meanwhile: the application's loop does not turn. It is called from a task posted to the UI thread, so that the scene has heard its drag was taken before the first answer is asked of it, and the destination paints the window itself after each answer, as on macOS.

The modifier keys do not reach the window during that loop. They arrive with each call, and choose among what the source allows as the platform has it: Control copies, Shift moves, both or Alt link.

  • Method Details

    • install

      public static @Nullable WindowsDrag install(long hwnd, UiRuntime ui, Supplier<WindowInput> input, Supplier<float[]> pointer, Runnable paint, BooleanSupplier animate)
      Makes a window a source and a destination of the system's drags. UI thread.
      Parameters:
      hwnd - the window
      ui - the UI runtime
      input - the window's input, as it is at the time of each call; may answer null
      pointer - the pointer in the window's logical points, x then y
      paint - paints the window now, from inside OLE's own loop
      animate - paints the frame the window is waiting for, if any, and says whether it now waits for another
      Returns:
      the window's drag, or null where OLE would not have it, which is logged
    • close

      public void close()
      Stops the window being a destination. UI thread.
    • start

      public boolean start(DragRequest request)
      Begins a drag the system drives. UI thread.
      Parameters:
      request - what is dragged
      Returns:
      whether it was taken: the drag itself runs from the UI thread's queue, and the request hears its end