Drag-n-drop broken since Ubuntu 22.04
xingrz opened this issue · comments
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
- Run
cargo run --example simple
. - Drop a file onto the window.
- 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.
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](https://private-user-images.githubusercontent.com/288288/329489089-cceae894-c15c-47be-a673-f21a3c47e036.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTU4NjQ4NDgsIm5iZiI6MTcxNTg2NDU0OCwicGF0aCI6Ii8yODgyODgvMzI5NDg5MDg5LWNjZWFlODk0LWMxNWMtNDdiZS1hNjczLWYyMWEzYzQ3ZTAzNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNTE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDUxNlQxMzAyMjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hYzg2MTFmNGVlYjNkMmU1ZjkxOTIzMGM0Nzc0YTk1MGQ1YTVmOTQ0MmU1MWU0MTdlZDBjOTNmYTllZjc1ZmI2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.3XK2sYO34oanMd2IOofzGe8WQVEm9f2nyXKJyf3loDE)
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.
wry/src/webkitgtk/drag_drop.rs
Lines 110 to 115 in daa6136
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](https://private-user-images.githubusercontent.com/288288/329543113-894a6410-cfa2-4c02-b397-b32df2ddfdb6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTU4NjQ4NDgsIm5iZiI6MTcxNTg2NDU0OCwicGF0aCI6Ii8yODgyODgvMzI5NTQzMTEzLTg5NGE2NDEwLWNmYTItNGMwMi1iMzk3LWIzMmRmMmRkZmRiNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNTE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDUxNlQxMzAyMjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jODdmZTNjOWEwYTY1ZDJlMDQwYzNjNzUxOWY4ZmIwZGNiOGE3OWVlODc4YzBlYTE0NDhkOWJjNTZiODM0MzdmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.qpHBKHDDXbB1Lt-lc_HGQy30WysBPD7bTbOppqTMXUQ)
On Ubuntu 22.04:
![image](https://private-user-images.githubusercontent.com/288288/329543553-cf9ee6c8-12ca-4c14-9ed3-05ac3ba537fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTU4NjQ4NDgsIm5iZiI6MTcxNTg2NDU0OCwicGF0aCI6Ii8yODgyODgvMzI5NTQzNTUzLWNmOWVlNmM4LTEyY2EtNGMxNC05ZWQzLTA1YWMzYmE1MzdmYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNTE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDUxNlQxMzAyMjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YzNjNTY2ODUzMzE2MzY5ZTcxNDBlZjRjZTMwMDgyNGY3MjJjNzcxYzJjMGQxODJhNDgxZDNiNTJkODZjMGVkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.I6pZyNYyV0dK_Bpp944ccDd2qlXV7FwmMYKk5MvmsHk)
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.