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.
This commit is contained in:
Ian Douglas Scott 2024-04-23 17:23:57 -07:00
parent c75a48535a
commit a6548057b6
2 changed files with 13 additions and 1 deletions

View file

@ -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()],

View file

@ -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(