Rework Drag-And-Drop API (#4079)
* Add cursor position drag and drop events.
* Reword drag events to match pointer ones.
* appkit: Use `convertPoint_fromView` for coordinate conversion.
* appkit: use ProtocolObject<dyn NSDraggingInfo>.
* x11: store dnd.position as pair of i16
It's what translate_coords takes anyway, so the extra precision is
misleading if we're going to cast it to i16 everywhere it's used.
We can also simplify the "unpacking" from the XdndPosition message--we
can and should use the value of 16 as the shift instead of
size_of::<c_short> * 2 or something like that, because the specification
gives us the constant 16.
* x11: store translated DnD coords.
* x11: don't emit DragLeave without DragEnter.
* windows: only emit DragEnter if valid.
* windows: in DnD, always set pdwEffect.
It appears other apps (like Chromium) set pdwEffect on Drop too:
61a391b86b/ui/base/dragdrop/drop_target_win.cc
* docs: make it clearer that drag events are for dragged *files*.
* examples/dnd: handle RedrawRequested event.
Co-authored-by: amrbashir <amr.bashir2015@gmail.com>
This commit is contained in:
parent
77f1c73f06
commit
f5dcd2aabe
11 changed files with 327 additions and 121 deletions
|
|
@ -165,6 +165,25 @@ changelog entry.
|
|||
- Rename `VideoModeHandle` to `VideoMode`, now it only stores plain data.
|
||||
- Make `Fullscreen::Exclusive` contain `(MonitorHandle, VideoMode)`.
|
||||
- On Wayland, no longer send an explicit clearing `Ime::Preedit` just prior to a new `Ime::Preedit`.
|
||||
- Reworked the file drag-and-drop API.
|
||||
|
||||
The `WindowEvent::DroppedFile`, `WindowEvent::HoveredFile` and `WindowEvent::HoveredFileCancelled`
|
||||
events have been removed, and replaced with `WindowEvent::DragEntered`, `WindowEvent::DragMoved`,
|
||||
`WindowEvent::DragDropped` and `WindowEvent::DragLeft`.
|
||||
|
||||
The old drag-and-drop events were emitted once per file. This occurred when files were *first*
|
||||
hovered over the window, dropped, or left the window. The new drag-and-drop events are emitted
|
||||
once per set of files dragged, and include a list of all dragged files. They also include the
|
||||
pointer position.
|
||||
|
||||
The rough correspondence is:
|
||||
- `WindowEvent::HoveredFile` -> `WindowEvent::DragEntered`
|
||||
- `WindowEvent::DroppedFile` -> `WindowEvent::DragDropped`
|
||||
- `WindowEvent::HoveredFileCancelled` -> `WindowEvent::DragLeft`
|
||||
|
||||
The `WindowEvent::DragMoved` event is entirely new, and is emitted whenever the pointer moves
|
||||
whilst files are being dragged over the window. It doesn't contain any file paths, just the
|
||||
pointer position.
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue