1
0
Fork 0
forked from wry/wry

seperate workspaces by monitor

This commit is contained in:
kossLAN 2026-05-16 18:34:20 -04:00
parent c555593ae2
commit a29937ebe8
No known key found for this signature in database
5 changed files with 44 additions and 20 deletions

View file

@ -698,8 +698,14 @@ impl ConfigProxyHandler {
} }
fn get_existing_workspace(&self, ws: Workspace) -> Result<Option<Rc<WorkspaceNode>>, CphError> { fn get_existing_workspace(&self, ws: Workspace) -> Result<Option<Rc<WorkspaceNode>>, CphError> {
self.get_workspace(ws) self.get_workspace(ws).map(|name| {
.map(|ws| self.state.workspaces.get(&*ws)) self.state
.workspaces
.lock()
.values()
.find(|ws| ws.name.as_str() == name.as_str())
.cloned()
})
} }
fn get_device_handler_data( fn get_device_handler_data(
@ -1054,9 +1060,10 @@ impl ConfigProxyHandler {
fn handle_set_seat_workspace(&self, seat: Seat, ws: Workspace) -> Result<(), CphError> { fn handle_set_seat_workspace(&self, seat: Seat, ws: Workspace) -> Result<(), CphError> {
let seat = self.get_seat(seat)?; let seat = self.get_seat(seat)?;
let name = self.get_workspace(ws)?; let name = self.get_workspace(ws)?;
let workspace = match self.state.workspaces.get(name.deref()) { let output = seat.get_fallback_output();
let workspace = match output.find_workspace(name.deref()) {
Some(ws) => ws, Some(ws) => ws,
_ => seat.get_fallback_output().create_workspace(name.deref()), _ => output.create_workspace(name.deref()),
}; };
seat.set_workspace(&workspace); seat.set_workspace(&workspace);
Ok(()) Ok(())
@ -1065,12 +1072,12 @@ impl ConfigProxyHandler {
fn handle_set_window_workspace(&self, window: Window, ws: Workspace) -> Result<(), CphError> { fn handle_set_window_workspace(&self, window: Window, ws: Workspace) -> Result<(), CphError> {
let window = self.get_window(window)?; let window = self.get_window(window)?;
let name = self.get_workspace(ws)?; let name = self.get_workspace(ws)?;
let workspace = match self.state.workspaces.get(name.deref()) { let Some(output) = window.node_output() else {
return Ok(());
};
let workspace = match output.find_workspace(name.deref()) {
Some(ws) => ws, Some(ws) => ws,
_ => match window.node_output() { _ => output.create_workspace(name.deref()),
Some(o) => o.create_workspace(name.deref()),
_ => return Ok(()),
},
}; };
toplevel_set_workspace(&self.state, window, &workspace); toplevel_set_workspace(&self.state, window, &workspace);
Ok(()) Ok(())

View file

@ -265,7 +265,15 @@ impl JayTreeQueryRequestHandler for JayTreeQuery {
Some(n) => Visitor(self).visit_workspace(&n), Some(n) => Visitor(self).visit_workspace(&n),
None => self.send_not_found(), None => self.send_not_found(),
}, },
Root::WorkspaceName(n) => match self.client.state.workspaces.get(n) { Root::WorkspaceName(n) => match self
.client
.state
.workspaces
.lock()
.values()
.find(|ws| ws.name.as_str() == n.as_str())
.cloned()
{
Some(n) => Visitor(self).visit_workspace(&n), Some(n) => Visitor(self).visit_workspace(&n),
None => self.send_not_found(), None => self.send_not_found(),
}, },

View file

@ -151,7 +151,8 @@ impl ExtWorkspaceManagerV1 {
workspace.ext_workspaces.set(self.manager_id, ws.clone()); workspace.ext_workspaces.set(self.manager_id, ws.clone());
self.send_workspace(&ws); self.send_workspace(&ws);
ws.send_capabilities(); ws.send_capabilities();
ws.send_id(&workspace.name); let workspace_id = format!("{:?}/{}", output.global.output_id.hash, workspace.name);
ws.send_id(&workspace_id);
ws.send_name(&workspace.name); ws.send_name(&workspace.name);
ws.send_coordinates(&[workspace_coordinate(output, workspace)]); ws.send_coordinates(&[workspace_coordinate(output, workspace)]);
ws.send_current_state(); ws.send_current_state();
@ -307,12 +308,12 @@ impl ExtWorkspaceManagerV1RequestHandler for ExtWorkspaceManagerV1 {
self.client.state.tree_changed(); self.client.state.tree_changed();
} }
WorkspaceChange::CreateWorkspace(name, output) => { WorkspaceChange::CreateWorkspace(name, output) => {
if self.client.state.workspaces.contains(&name) {
return Ok(());
}
let Some(output) = output.node() else { let Some(output) = output.node() else {
return Ok(()); return Ok(());
}; };
if output.find_workspace(&name).is_some() {
return Ok(());
}
output.create_workspace(&name); output.create_workspace(&name);
} }
} }

View file

@ -105,6 +105,7 @@ use {
FoundNode, LatchListener, Node, NodeIds, NodeVisitorBase, OutputNode, PlaceholderNode, FoundNode, LatchListener, Node, NodeIds, NodeVisitorBase, OutputNode, PlaceholderNode,
TearingMode, TileState, ToplevelData, ToplevelIdentifier, ToplevelNode, TearingMode, TileState, ToplevelData, ToplevelIdentifier, ToplevelNode,
ToplevelNodeBase, Transform, VrrMode, WorkspaceDisplayOrder, WorkspaceNode, ToplevelNodeBase, Transform, VrrMode, WorkspaceDisplayOrder, WorkspaceNode,
WorkspaceNodeId,
WsMoveConfig, generic_node_visitor, move_ws_to_output, WsMoveConfig, generic_node_visitor, move_ws_to_output,
}, },
udmabuf::UdmabufHolder, udmabuf::UdmabufHolder,
@ -177,7 +178,7 @@ pub struct State {
pub input_device_ids: InputDeviceIds, pub input_device_ids: InputDeviceIds,
pub node_ids: NodeIds, pub node_ids: NodeIds,
pub root: Rc<DisplayNode>, pub root: Rc<DisplayNode>,
pub workspaces: CopyHashMap<String, Rc<WorkspaceNode>>, pub workspaces: CopyHashMap<WorkspaceNodeId, Rc<WorkspaceNode>>,
pub dummy_output: CloneCell<Option<Rc<OutputNode>>>, pub dummy_output: CloneCell<Option<Rc<OutputNode>>>,
pub backend_events: AsyncQueue<BackendEvent>, pub backend_events: AsyncQueue<BackendEvent>,
pub input_device_handlers: RefCell<AHashMap<InputDeviceId, InputDeviceData>>, pub input_device_handlers: RefCell<AHashMap<InputDeviceId, InputDeviceData>>,
@ -936,10 +937,10 @@ impl State {
name: &str, name: &str,
output: Option<Rc<OutputNode>>, output: Option<Rc<OutputNode>>,
) { ) {
let ws = match self.workspaces.get(name) { let output = output.unwrap_or_else(|| seat.get_fallback_output());
let ws = match output.find_workspace(name) {
Some(ws) => ws, Some(ws) => ws,
_ => { _ => {
let output = output.unwrap_or_else(|| seat.get_fallback_output());
if output.is_dummy { if output.is_dummy {
log::warn!("Not showing workspace because seat is on dummy output"); log::warn!("Not showing workspace because seat is on dummy output");
return; return;

View file

@ -677,7 +677,7 @@ impl OutputNode {
let name = 'name: { let name = 'name: {
for i in 1.. { for i in 1.. {
let name = i.to_string(); let name = i.to_string();
if !self.state.workspaces.contains(&name) { if self.find_workspace(&name).is_none() {
break 'name name; break 'name name;
} }
} }
@ -686,6 +686,13 @@ impl OutputNode {
self.create_workspace(&name) self.create_workspace(&name)
} }
pub fn find_workspace(&self, name: &str) -> Option<Rc<WorkspaceNode>> {
self.workspaces
.iter()
.find(|ws| ws.name.as_str() == name)
.map(|ws| (*ws).clone())
}
pub fn show_workspace(&self, ws: &Rc<WorkspaceNode>) -> bool { pub fn show_workspace(&self, ws: &Rc<WorkspaceNode>) -> bool {
let mut seats = SmallVec::new(); let mut seats = SmallVec::new();
if let Some(old) = self.workspace.set(Some(ws.clone())) { if let Some(old) = self.workspace.set(Some(ws.clone())) {
@ -705,7 +712,7 @@ impl OutputNode {
wh.handle_destroyed(); wh.handle_destroyed();
} }
old.clear(); old.clear();
self.state.workspaces.remove(&old.name); self.state.workspaces.remove(&old.id);
} else { } else {
old.set_visible(false); old.set_visible(false);
old.flush_jay_workspaces(); old.flush_jay_workspaces();
@ -747,7 +754,7 @@ impl OutputNode {
self.workspaces.add_last(ws.clone()) self.workspaces.add_last(ws.clone())
}; };
*ws.output_link.borrow_mut() = Some(link); *ws.output_link.borrow_mut() = Some(link);
self.state.workspaces.set(name.to_string(), ws.clone()); self.state.workspaces.set(ws.id, ws.clone());
if self.workspace.is_none() { if self.workspace.is_none() {
self.show_workspace(&ws); self.show_workspace(&ws);
} }