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

support WindowEvent::DroppedFile #524

Merged
merged 4 commits into from
Jul 29, 2024
Merged

Conversation

jm-observer
Copy link
Contributor

No description provided.

Comment on lines 397 to 407
pub(crate) fn dropped_file(&mut self, path: PathBuf) {
self.dropper_file = Some(path.clone());
self.event(Event::DroppedFile(DroppedFileEvent { path }));
}

pub(crate) fn pointer_move(&mut self, pos: Point) {
if let Some(path) = self.dropper_file.take() {
self.event(Event::DroppedFileWithPosition(
DroppedFileWithPositionEvent { path, pos },
));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The cursor position is stored in self.cursor_position. So we should be able to send the dropped file event with the cursor position when the dropped file event was trigger from winit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried. It's not accurate. The mouse coordinates are not updated when you drag and drop

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah it's something at winit's end. It should be fixed when this is implemented rust-windowing/winit#3833

Does it always emit pointer move after the file was dropped? If so, we don't need the drop file event without mouse position.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, my observation is this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we just have one event DroppedFile with both path and pos please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I just kept DroppedFileWithPositionEvent

@dzhou121
Copy link
Contributor

rename DroppedFileWithPosition to DroppedFile maybe?

@dzhou121 dzhou121 merged commit e1a7f99 into lapce:main Jul 29, 2024
7 checks passed
@jm-observer jm-observer deleted the drag_file branch July 30, 2024 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants