protocols/workspace: Track group a workspace is on, and update

It seems previously, workspace migration due to output add could result in
a workspace being removed from a group, but not added to the new group
for existing clients, because the workspace group creation didn't happen
until `done`. And `send_workspace_to_client` didn't send
`workspace_enter` except when a workspace instance is newly created.

That logic worked with the old protocol, but now a workspace can be
moved to a different group.

Seems to fix the issue with workspaces disappearing from the workspaces
view in https://github.com/pop-os/cosmic-comp/issues/1470. I don't seem
to be able to reproduce the panel auto-hide issue, but have seen it in
the past. So it may or may not be prevented from happening now.
This commit is contained in:
Ian Douglas Scott 2025-07-02 14:47:43 -07:00 committed by Victoria Brekenfeld
parent 1564b9d1a3
commit 2b4890c550
2 changed files with 26 additions and 31 deletions

View file

@ -46,6 +46,7 @@ pub struct WorkspaceGroupData {
#[derive(Default)]
pub struct WorkspaceDataInner {
pub(super) group: Option<ExtWorkspaceGroupHandleV1>,
name: String,
capabilities: Option<ext_workspace_handle_v1::WorkspaceCapabilities>,
coordinates: Vec<u32>,
@ -403,7 +404,6 @@ where
},
) {
mngr.workspace(&handle);
group.workspace_enter(&handle);
if let Some(id) = workspace.ext_id.clone() {
handle.id(id);
}
@ -427,6 +427,14 @@ where
.unwrap();
let mut changed = false;
if handle_state.group.as_ref() != Some(group) {
if let Some(old_group) = &handle_state.group {
old_group.workspace_leave(&instance);
}
group.workspace_enter(&instance);
handle_state.group = Some(group.clone());
}
if handle_state.name != workspace.name {
instance.name(workspace.name.clone());
handle_state.name = workspace.name.clone();