diff --git a/src/main.rs b/src/main.rs index 6ac0e6f..f9c58be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,7 +122,7 @@ enum Msg { Vec, (f32, f32), ), - DndWorkspaceLeave, + DndWorkspaceLeave(ZcosmicWorkspaceHandleV1, wl_output::WlOutput), DndWorkspaceDrop, DndWorkspaceData(String, Vec), SourceFinished, @@ -523,9 +523,12 @@ impl Application for App { ]); } } - Msg::DndWorkspaceLeave => { - // XXX Doesn't work since leave for a widget may come after enter for another - self.drop_target = None; + Msg::DndWorkspaceLeave(handle, output) => { + // Currently in iced-sctk, a `DndOfferEvent::Motion` may cause a leave event after + // an enter event, based on which widget handles it first. So we need a test here. + if self.drop_target == Some((handle, output)) { + self.drop_target = None; + } return accept_mime_type(None); } Msg::DndWorkspaceDrop => { diff --git a/src/view/mod.rs b/src/view/mod.rs index 77d5f34..7ef2834 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -177,7 +177,10 @@ fn workspace_sidebar_entry<'a>( .on_enter(|actions, mime, pos| { Msg::DndWorkspaceEnter(workspace.handle.clone(), output.clone(), actions, mime, pos) }) - .on_exit(Msg::DndWorkspaceLeave) + .on_exit(Msg::DndWorkspaceLeave( + workspace.handle.clone(), + output.clone(), + )) .on_drop(Msg::DndWorkspaceDrop) .on_data(Msg::DndWorkspaceData) //)