ext-workspace-manager-v1: order workspaces numerically
This commit is contained in:
parent
206a5fb19e
commit
41bc660401
3 changed files with 43 additions and 6 deletions
|
|
@ -43,6 +43,12 @@ impl WorkspaceManagerState {
|
||||||
manager.announce_workspace(output, ws);
|
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>) {
|
pub async fn workspace_manager_done(state: Rc<State>) {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use {
|
||||||
utils::{clonecell::CloneCell, opt::Opt, syncqueue::SyncQueue},
|
utils::{clonecell::CloneCell, opt::Opt, syncqueue::SyncQueue},
|
||||||
wire::{ExtWorkspaceManagerV1Id, ext_workspace_manager_v1::*},
|
wire::{ExtWorkspaceManagerV1Id, ext_workspace_manager_v1::*},
|
||||||
},
|
},
|
||||||
|
numeric_sort::cmp,
|
||||||
std::{cell::Cell, rc::Rc},
|
std::{cell::Cell, rc::Rc},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
|
|
@ -152,12 +153,7 @@ impl ExtWorkspaceManagerV1 {
|
||||||
ws.send_capabilities();
|
ws.send_capabilities();
|
||||||
ws.send_id(&workspace.name);
|
ws.send_id(&workspace.name);
|
||||||
ws.send_name(&workspace.name);
|
ws.send_name(&workspace.name);
|
||||||
let coord = output
|
ws.send_coordinates(&[workspace_coordinate(output, workspace)]);
|
||||||
.workspaces
|
|
||||||
.iter()
|
|
||||||
.position(|w| w.id == workspace.id)
|
|
||||||
.unwrap_or(0) as u32;
|
|
||||||
ws.send_coordinates(&[coord]);
|
|
||||||
ws.send_current_state();
|
ws.send_current_state();
|
||||||
if let Some(group) = group {
|
if let Some(group) = group {
|
||||||
group.send_workspace_enter(&ws);
|
group.send_workspace_enter(&ws);
|
||||||
|
|
@ -165,6 +161,25 @@ impl ExtWorkspaceManagerV1 {
|
||||||
self.schedule_done();
|
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) {
|
fn send_workspace_group(&self, workspace_group: &ExtWorkspaceGroupHandleV1) {
|
||||||
self.client.event(WorkspaceGroup {
|
self.client.event(WorkspaceGroup {
|
||||||
self_id: self.id,
|
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!(
|
global_base!(
|
||||||
ExtWorkspaceManagerV1Global,
|
ExtWorkspaceManagerV1Global,
|
||||||
ExtWorkspaceManagerV1,
|
ExtWorkspaceManagerV1,
|
||||||
|
|
|
||||||
|
|
@ -761,6 +761,9 @@ impl OutputNode {
|
||||||
client.error(e);
|
client.error(e);
|
||||||
}
|
}
|
||||||
self.state.workspace_managers.announce_workspace(self, &ws);
|
self.state.workspace_managers.announce_workspace(self, &ws);
|
||||||
|
self.state
|
||||||
|
.workspace_managers
|
||||||
|
.update_workspace_coordinates(self);
|
||||||
self.schedule_update_render_data();
|
self.schedule_update_render_data();
|
||||||
ws
|
ws
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue