1
0
Fork 0
forked from wry/wry

ext-workspace-manager-v1: order workspaces numerically

This commit is contained in:
kossLAN 2026-05-03 05:45:10 -04:00
parent 206a5fb19e
commit 41bc660401
No known key found for this signature in database
3 changed files with 43 additions and 6 deletions

View file

@ -43,6 +43,12 @@ impl WorkspaceManagerState {
manager.announce_workspace(output, ws);
}
}
pub fn update_workspace_coordinates(&self, output: &OutputNode) {
for manager in self.managers.lock().values() {
manager.send_workspace_coordinates(output);
}
}
}
pub async fn workspace_manager_done(state: Rc<State>) {

View file

@ -15,6 +15,7 @@ use {
utils::{clonecell::CloneCell, opt::Opt, syncqueue::SyncQueue},
wire::{ExtWorkspaceManagerV1Id, ext_workspace_manager_v1::*},
},
numeric_sort::cmp,
std::{cell::Cell, rc::Rc},
thiserror::Error,
};
@ -152,12 +153,7 @@ impl ExtWorkspaceManagerV1 {
ws.send_capabilities();
ws.send_id(&workspace.name);
ws.send_name(&workspace.name);
let coord = output
.workspaces
.iter()
.position(|w| w.id == workspace.id)
.unwrap_or(0) as u32;
ws.send_coordinates(&[coord]);
ws.send_coordinates(&[workspace_coordinate(output, workspace)]);
ws.send_current_state();
if let Some(group) = group {
group.send_workspace_enter(&ws);
@ -165,6 +161,25 @@ impl ExtWorkspaceManagerV1 {
self.schedule_done();
}
pub(super) fn send_workspace_coordinates(&self, output: &OutputNode) {
let mut sent_any = false;
let mut workspaces: Vec<_> = output
.workspaces
.iter()
.filter(|workspace| !workspace.is_dummy)
.collect();
workspaces.sort_by(|a, b| cmp(&a.name, &b.name));
for (coord, workspace) in workspaces.iter().enumerate() {
if let Some(workspace) = workspace.ext_workspaces.get(&self.manager_id) {
workspace.send_coordinates(&[coord as u32]);
sent_any = true;
}
}
if sent_any {
self.schedule_done();
}
}
fn send_workspace_group(&self, workspace_group: &ExtWorkspaceGroupHandleV1) {
self.client.event(WorkspaceGroup {
self_id: self.id,
@ -210,6 +225,19 @@ impl ExtWorkspaceManagerV1 {
}
}
fn workspace_coordinate(output: &OutputNode, workspace: &WorkspaceNode) -> u32 {
let mut workspaces: Vec<_> = output
.workspaces
.iter()
.filter(|workspace| !workspace.is_dummy)
.collect();
workspaces.sort_by(|a, b| cmp(&a.name, &b.name));
workspaces
.iter()
.position(|w| w.id == workspace.id)
.unwrap_or(0) as u32
}
global_base!(
ExtWorkspaceManagerV1Global,
ExtWorkspaceManagerV1,

View file

@ -761,6 +761,9 @@ impl OutputNode {
client.error(e);
}
self.state.workspace_managers.announce_workspace(self, &ws);
self.state
.workspace_managers
.update_workspace_coordinates(self);
self.schedule_update_render_data();
ws
}