feat: allow naming pinned workspaces

This commit is contained in:
Robin Nehls 2026-05-30 19:14:13 +02:00 committed by Victoria Brekenfeld
parent 8f5f7c897d
commit db0b1afeb5
3 changed files with 19 additions and 3 deletions

View file

@ -63,5 +63,5 @@ pub struct PinnedWorkspace {
pub output: OutputMatch,
pub tiling_enabled: bool,
pub id: Option<String>,
// TODO: name
pub name: Option<String>,
}

View file

@ -439,6 +439,11 @@ fn create_workspace_from_pinned(
| WorkspaceCapabilities::Pin
| WorkspaceCapabilities::Move,
);
if let Some(ref name) = pinned.name {
state.set_workspace_name(&workspace_handle, name);
}
Workspace::from_pinned(
pinned,
workspace_handle,
@ -619,6 +624,7 @@ impl WorkspaceSet {
state,
self.workspaces.len() as u8 + 1,
&workspace.handle,
workspace.name.as_deref(),
// this method is only used by code paths related to dynamic workspaces, so this should be fine
);
self.workspaces.push(workspace);
@ -680,7 +686,12 @@ impl WorkspaceSet {
fn update_workspace_idxs(&self, state: &mut WorkspaceUpdateGuard<'_, State>) {
for (i, workspace) in self.workspaces.iter().enumerate() {
workspace_set_idx(state, i as u8 + 1, &workspace.handle);
workspace_set_idx(
state,
i as u8 + 1,
&workspace.handle,
workspace.name.as_deref(),
);
}
}
@ -5025,8 +5036,9 @@ fn workspace_set_idx(
state: &mut WorkspaceUpdateGuard<'_, State>,
idx: u8,
handle: &WorkspaceHandle,
name: Option<&str>,
) {
state.set_workspace_name(handle, format!("{}", idx));
state.set_workspace_name(handle, name.unwrap_or(&format!("{}", idx)));
state.set_workspace_coordinates(handle, &[idx as u32]);
}

View file

@ -111,6 +111,7 @@ pub struct Workspace {
pub fullscreen_surfaces: Vec<FullscreenSurface>,
pub pinned: bool,
pub id: Option<String>,
pub name: Option<String>,
pub handle: WorkspaceHandle,
pub focus_stack: FocusStacks,
@ -386,6 +387,7 @@ impl Workspace {
fullscreen_surfaces: Vec::new(),
pinned: false,
id: None,
name: None,
handle,
focus_stack: FocusStacks::default(),
image_copy: ImageCopySessions::default(),
@ -419,6 +421,7 @@ impl Workspace {
fullscreen_surfaces: Vec::new(),
pinned: true,
id: pinned.id.clone(),
name: pinned.name.clone(),
handle,
focus_stack: FocusStacks::default(),
image_copy: ImageCopySessions::default(),
@ -446,6 +449,7 @@ impl Workspace {
},
tiling_enabled: self.tiling_enabled,
id: self.id.clone(),
name: self.name.clone(),
})
} else {
None