From a6548057b6c2a30956035e16e6550bdbc3a274cc Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 23 Apr 2024 17:23:57 -0700 Subject: [PATCH] Don't hide toplevel until drag is started Seems to fix behavior on Sway, but on Smithay still destroys the drag grab once the surface that started it is gone. --- src/main.rs | 10 ++++++++++ src/view/mod.rs | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1b254b2..6158923 100644 --- a/src/main.rs +++ b/src/main.rs @@ -203,6 +203,7 @@ struct App { conf: Conf, core: cosmic::app::Core, drop_target: Option<(ZcosmicWorkspaceHandleV1, wl_output::WlOutput)>, + dnd_started: bool, } impl App { @@ -399,6 +400,14 @@ impl Application for App { } } } + WaylandEvent::DndOffer(evt) => { + // We don't hide the toplevel from the view until we get a + // `DndOffer` event, to make sure `start_grab` isn't called + // after the subsurface is destroyed. + // + // There should be a better way to do this. + self.dnd_started = true; + } _ => {} }, Msg::Wayland(evt) => { @@ -505,6 +514,7 @@ impl Application for App { .iter() .find(|(_, x)| &x.output == output) { + self.dnd_started = false; self.drag_surface = Some((id, drag_surface, size)); return start_drag( vec![mime_type.to_string()], diff --git a/src/view/mod.rs b/src/view/mod.rs index 95d1ff2..d5519ad 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -33,7 +33,9 @@ pub(crate) fn layer_surface<'a>( } let mut drag_toplevel = None; if let Some((_, DragSurface::Toplevel { handle, .. }, _)) = &app.drag_surface { - drag_toplevel = Some(handle); + if app.dnd_started { + drag_toplevel = Some(handle); + } } let layout = app.conf.workspace_config.workspace_layout; let sidebar = workspaces_sidebar(