Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework DnD redux #4079

Merged
merged 24 commits into from
Jan 28, 2025
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2594b83
feat: DnD changes so far (rebased)
amrbashir Jan 8, 2025
1069dd8
fix: translate xdnd coordinates to root window
valadaptive Jan 8, 2025
b3510c2
feat: DnD example/test
valadaptive Jan 8, 2025
d100b86
fix: make DnD compile and function on macOS
valadaptive Jan 8, 2025
9bf7a4e
fix: make DnD compile and function on Windows
valadaptive Jan 8, 2025
7c293f5
chore: format according to nightly rules
valadaptive Jan 8, 2025
35a972f
docs: expand drag event documentation
valadaptive Jan 8, 2025
36438b1
docs(changelog): better document DnD changes
valadaptive Jan 8, 2025
c5e3575
x11: store dnd.position as pair of i16
valadaptive Jan 8, 2025
a2b150b
appkit: use ProtocolObject<dyn NSDraggingInfo>
valadaptive Jan 8, 2025
5bbbedd
windows: only emit DragEnter if enter_is_valid
valadaptive Jan 10, 2025
3d3f6fb
x11: store translated DnD coords
valadaptive Jan 10, 2025
bafb090
x11: don't emit DragLeave without DragEnter
valadaptive Jan 10, 2025
2873e88
refactor: reword drag events to match pointer ones
valadaptive Jan 10, 2025
991b4c8
feat: add position to DragLeft
valadaptive Jan 10, 2025
dcfb62d
macos: implement position on DragLeft
valadaptive Jan 10, 2025
6b4b84b
refactor: DragDrop -> DragDropped
valadaptive Jan 10, 2025
a4be71e
docs: clarify drag events
valadaptive Jan 10, 2025
df8e5ce
examples/dnd: handle RedrawRequested event
valadaptive Jan 13, 2025
f55a534
x11: DnD code style tweaks
valadaptive Jan 17, 2025
2f589b5
windows: import DnD events at top of file
valadaptive Jan 17, 2025
59dd7ed
windows: drop_handler.enter_is_valid -> valid
valadaptive Jan 17, 2025
2153865
windows: in DnD, always set pdwEffect
valadaptive Jan 17, 2025
731a0ce
Don't rename protocol parameter
madsmtm Jan 28, 2025
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
Prev Previous commit
Next Next commit
macos: implement position on DragLeft
The Swift docs say the dragging info may be
nullable here specifically:
https://developer.apple.com/documentation/appkit/nsdraggingdestination/draggingexited(_:)
valadaptive committed Jan 17, 2025
commit dcfb62d2999b5a28b2877516a4e908db7aefbac7
11 changes: 9 additions & 2 deletions src/platform_impl/apple/appkit/window_delegate.rs
Original file line number Diff line number Diff line change
@@ -457,9 +457,16 @@ declare_class!(

/// Invoked when the dragging operation is cancelled
#[method(draggingExited:)]
fn dragging_exited(&self, _sender: Option<&NSObject>) {
fn dragging_exited(&self, info: Option<&ProtocolObject<dyn NSDraggingInfo>>) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For @madsmtm: is this the right way to represent a sender param that may be null? The Swift docs note that for this specific callback, this parameter is nullable.

(As a side node, kinda alarming how the Objective-C docs just don't mention its nullability at all, as far as I can tell. Any idea what's going on there?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is correct, see also the docs in objc2-app-kit. In the future, I plan to make it required to have the same signature as in objc2-app-kit, but haven't gotten around to it yet.

The docs on Apple's website don't mention it, probably to be less verbose, but the header does contain a nullability attribute:

// AppKit.framework/Headers/NSDragging.h
- (void)draggingExited:(nullable id <NSDraggingInfo>)sender;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please keep the name as sender.

trace_scope!("draggingExited:");
self.queue_event(WindowEvent::DragLeft { position: None } );

let position = info.map(|info| {
let dl = unsafe { info.draggingLocation() };
let dl = self.view().convertPoint_fromView(dl, None);
LogicalPosition::<f64>::from((dl.x, dl.y)).to_physical(self.scale_factor())
});

self.queue_event(WindowEvent::DragLeft { position } );
}
}