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

Drag-n-drop broken since Ubuntu 22.04 #1256

Open
xingrz opened this issue May 10, 2024 · 0 comments
Open

Drag-n-drop broken since Ubuntu 22.04 #1256

xingrz opened this issue May 10, 2024 · 0 comments

Comments

@xingrz
Copy link

xingrz commented May 10, 2024

Describe the bug
Since #1187, drag-n-drop is broken on Ubuntu. When a file is dropped onto the window, FileDropEvent::Cancelled is raised instead of the expected DragDropEvent::Drop.

This seems to be the root cause of tauri-apps/tauri#9725.

Steps To Reproduce

  1. Run cargo run --example simple.
  2. Drop a file onto the window.
  3. Observe the Terminal output, DragLeave is printed twice, and the view navigates to the dropped file's location.

Expected behavior
A line DragDrop: /path/to/file/dropped should be printed on the Terminal, and the webview should not navigate to the dropped file's path.

Screenshots
image

Platform and Versions (please complete the following information):
OS: Ubuntu 24.04
Rustc: rustc 1.78.0 (9b00956e5 2024-04-29)

Additional context
I backported the drag-n-drop sample to v0.37.0 before #1187 was merged and added some logs for debugging. Cancelled is unexpectedly raised twice. However, since we did not consider controller.enter() and controller.leave() at that version, it coincidentally produced the expected behavior.

image

I also noticed that both the current and original implementations intend to use the time parameter to determine the number of drag-leave events. However, in my tests, this parameter was 0 for both occurrences. I am unsure whether this is an issue with my desktop environment or a misunderstanding in the implementation's handling of the time parameter.

webview.connect_drag_leave(move |_, _, time| {
if time == 0 {
controller.leave();
controller.call(DragDropEvent::Leave);
}
});

UPDATE: I tried version 0.24.0, which uses libwebkit2gtk 4.0 (before the upgrade to 4.1). On Ubuntu 20.04, the time parameter for drag-leave was indeed not 0, which allowed the logic to function correctly. However, starting with Ubuntu 22.04, it consistently passes a time of 0, resulting in the cancelled event being triggered twice.

On Ubuntu 20.04:

image

On Ubuntu 22.04:

image

UPDATE2: It indeed appears to be an issue with Wayland. I switched back to Xorg on Ubuntu 22.04 and Ubuntu 24.04 and repeated the test. This time, the drap-leave signal only appeared once and provided the time parameter correctly. Everything worked as expected.

@xingrz xingrz changed the title Drag-n-drop was not handled properly on Ubuntu Drag-n-drop broken since Ubuntu 22.04 May 10, 2024
xingrz added a commit to xingrz/wry that referenced this issue May 15, 2024
No idea how to do it right. Do a dirty hack to make it works.

See tauri-apps#1256 for details.
xingrz added a commit to xingrz/wry that referenced this issue May 27, 2024
No idea how to do it right. Do a dirty hack to make it works.

See tauri-apps#1256 for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants