Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/platform/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ impl ViewImpl for BaseviewView {
let drop_data = get_drop_data(sender);

let event = MouseEvent::DragEntered {
position: get_drag_position(sender).to_physical(this.view.backing_scale_factor()),
position: get_drag_position(this.view, sender)
.to_physical(this.view.backing_scale_factor()),
modifiers: make_modifiers(modifiers),
data: drop_data,
};
Expand All @@ -578,7 +579,8 @@ impl ViewImpl for BaseviewView {
let drop_data = get_drop_data(sender);

let event = MouseEvent::DragMoved {
position: get_drag_position(sender).to_physical(this.view.backing_scale_factor()),
position: get_drag_position(this.view, sender)
.to_physical(this.view.backing_scale_factor()),
modifiers: make_modifiers(modifiers),
data: drop_data,
};
Expand All @@ -602,7 +604,8 @@ impl ViewImpl for BaseviewView {
let drop_data = get_drop_data(sender);

let event = MouseEvent::DragDropped {
position: get_drag_position(sender).to_physical(this.view.backing_scale_factor()),
position: get_drag_position(this.view, sender)
.to_physical(this.view.backing_scale_factor()),
modifiers: make_modifiers(modifiers),
data: drop_data,
};
Expand Down Expand Up @@ -797,12 +800,15 @@ fn new_tracking_area(this: &NSView) -> Retained<NSTrackingArea> {
}
}

fn get_drag_position(sender: Option<&ProtocolObject<dyn NSDraggingInfo>>) -> LogicalPosition<f64> {
let point = match sender {
Some(sender) => sender.draggingLocation(),
None => NSPoint::ZERO,
fn get_drag_position(
view: &NSView, sender: Option<&ProtocolObject<dyn NSDraggingInfo>>,
) -> LogicalPosition<f64> {
let Some(sender) = sender else {
return LogicalPosition::new(0.0, 0.0);
};

// Flip the Y coordinate to match CursorMoved coordinate space.
let point = view.convertPoint_fromView(sender.draggingLocation(), None);
LogicalPosition::new(point.x, point.y)
}

Expand Down
Loading