diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 00fdeb7b..e1fed28e 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1693,8 +1693,7 @@ impl Shell { self.pending_layers.retain(|(s, _, _)| s.alive()); self.pending_windows.retain(|(s, _, _)| s.alive()); - self.toplevel_info_state - .refresh(Some(&self.workspace_state)); + self.toplevel_info_state.refresh(&self.workspace_state); } pub fn on_commit(&mut self, surface: &WlSurface) { @@ -1867,7 +1866,11 @@ impl Shell { state.common.shell.workspaces.active_mut(&output) }; - state.common.shell.toplevel_info_state.new_toplevel(&window); + state + .common + .shell + .toplevel_info_state + .new_toplevel(&window, &state.common.shell.workspace_state); state .common .shell diff --git a/src/wayland/protocols/toplevel_info.rs b/src/wayland/protocols/toplevel_info.rs index 216d363d..2e72e95b 100644 --- a/src/wayland/protocols/toplevel_info.rs +++ b/src/wayland/protocols/toplevel_info.rs @@ -100,7 +100,7 @@ where ) { let instance = data_init.init(resource, ()); for window in &state.toplevel_info_state().toplevels { - send_toplevel_to_client::(dh, Some(state.workspace_state()), &instance, window); + send_toplevel_to_client::(dh, state.workspace_state(), &instance, window); } state.toplevel_info_state_mut().instances.push(instance); } @@ -213,12 +213,12 @@ where } } - pub fn new_toplevel(&mut self, toplevel: &W) { + pub fn new_toplevel(&mut self, toplevel: &W, workspace_state: &WorkspaceState) { toplevel .user_data() .insert_if_missing(ToplevelState::default); for instance in &self.instances { - send_toplevel_to_client::(&self.dh, None, instance, toplevel); + send_toplevel_to_client::(&self.dh, workspace_state, instance, toplevel); } self.toplevels.push(toplevel.clone()); } @@ -265,7 +265,7 @@ where self.toplevels.retain(|w| w != toplevel); } - pub fn refresh(&mut self, workspace_state: Option<&WorkspaceState>) { + pub fn refresh(&mut self, workspace_state: &WorkspaceState) { self.toplevels.retain(|window| { let mut state = window .user_data() @@ -305,7 +305,7 @@ where fn send_toplevel_to_client( dh: &DisplayHandle, - workspace_state: Option<&WorkspaceState>, + workspace_state: &WorkspaceState, info: &ZcosmicToplevelInfoV1, window: &W, ) where @@ -422,33 +422,27 @@ fn send_toplevel_to_client( handle_state.outputs = state.outputs.clone(); } - if let Some(workspace_state) = workspace_state { - for new_workspace in state - .workspaces - .iter() - .filter(|w| !handle_state.workspaces.contains(w)) - { - if let Some(handle) = - workspace_state.raw_workspace_handle(&new_workspace, &instance.id()) - { - instance.workspace_enter(&handle); - changed = true; - } + for new_workspace in state + .workspaces + .iter() + .filter(|w| !handle_state.workspaces.contains(w)) + { + if let Some(handle) = workspace_state.raw_workspace_handle(&new_workspace, &instance.id()) { + instance.workspace_enter(&handle); + changed = true; } - for old_workspace in handle_state - .workspaces - .iter() - .filter(|w| !state.workspaces.contains(w)) - { - if let Some(handle) = - workspace_state.raw_workspace_handle(&old_workspace, &instance.id()) - { - instance.workspace_leave(&handle); - changed = true; - } - } - handle_state.workspaces = state.workspaces.clone(); } + for old_workspace in handle_state + .workspaces + .iter() + .filter(|w| !state.workspaces.contains(w)) + { + if let Some(handle) = workspace_state.raw_workspace_handle(&old_workspace, &instance.id()) { + instance.workspace_leave(&handle); + changed = true; + } + } + handle_state.workspaces = state.workspaces.clone(); if changed { instance.done();