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
|
|
@ -95,7 +95,7 @@ impl FrameExtentsHeuristic {
|
|||
|
||||
impl XConnection {
|
||||
// This is adequate for inner_position
|
||||
pub fn translate_coords(
|
||||
pub fn translate_coords_root(
|
||||
&self,
|
||||
window: xproto::Window,
|
||||
root: xproto::Window,
|
||||
|
|
@ -103,6 +103,19 @@ impl XConnection {
|
|||
self.xcb_connection().translate_coordinates(window, root, 0, 0)?.reply().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn translate_coords(
|
||||
&self,
|
||||
src_w: xproto::Window,
|
||||
dst_w: xproto::Window,
|
||||
src_x: i16,
|
||||
src_y: i16,
|
||||
) -> Result<xproto::TranslateCoordinatesReply, X11Error> {
|
||||
self.xcb_connection()
|
||||
.translate_coordinates(src_w, dst_w, src_x, src_y)?
|
||||
.reply()
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
// This is adequate for surface_size
|
||||
pub fn get_geometry(
|
||||
&self,
|
||||
|
|
@ -189,7 +202,7 @@ impl XConnection {
|
|||
// that, fullscreen windows often aren't nested.
|
||||
let (inner_y_rel_root, child) = {
|
||||
let coords = self
|
||||
.translate_coords(window, root)
|
||||
.translate_coords_root(window, root)
|
||||
.expect("Failed to translate window coordinates");
|
||||
(coords.dst_y, coords.child)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue