-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix(wl_data_device): drop and leave event handling #409
Conversation
43321ba
to
251321d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably document that the users should destroy the offer? It would also be nice to get which compositors do what you say in particular, but just for the reference.
examples/data_device.rs
Outdated
@@ -860,6 +862,7 @@ impl DataSourceHandler for DataDeviceWindow { | |||
_qh: &QueueHandle<Self>, | |||
source: &wayland_client::protocol::wl_data_source::WlDataSource, | |||
) { | |||
println!("FINISHED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a debug leftover, given how it's written compared to other logging we have around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the message above it, but I can change how both messages are written.
So far I was able to recreate the issue in Cosmic, sway, and Pop on wayland (Gnome), but I can double check vanilla Gnome too |
That's more than enough I guess, just mention that in the commit. We could probably use some RAII so users won't worry about that, but I'm not familiar with dnd myself much and can just look into the code. |
pub(crate) fn drop_performed(&self) { | ||
let mut inner = self.inner.lock().unwrap(); | ||
|
||
if let DataDeviceOffer::Drag(ref mut o) = inner.deref_mut().offer { | ||
o.dropped = true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this as a separate function if it's used only once in Drop
handler?
if !self.left || self.dropped { | ||
receive(&self.data_offer, mime_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document why it's like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment that explains why
be3196d
to
48d4613
Compare
I was able to recreate the issue in Cosmic, sway, and Pop on wayland (Gnome) refactor(data-device): merge both cases in leave Co-authored-by: Kirill Chibisov <contact@kchibisov.com> chore(data-device): document that the offer may need to be manually destroyed after leave cleanup(data-device): example println capitalization
48d4613
to
502b1bc
Compare
While the spec says to destroy the wl_data_offer after wl_data_device::leave, I think compositors often send the leave event right away after a drop. This is a bit problematic if an application hasn't finished receiving the data and then the data offer is destroyed before it can make the finish request. I believe this can currently be recreated in the data_device example. The source never receives a finish event because the offer was destroyed and isn't alive by the time we make the request.
This PR tries to avoid destroying an offer after the leave event if a drop event already occurred. It also tries to avoid making request besides finish or destroy.