Skip to content

Commit

Permalink
Add workspaces_for_output helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Jan 24, 2025
1 parent 88b35e3 commit ba52d69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ impl App {
self.workspaces.iter_mut().find(|i| &i.handle == handle)
}

// TODO iterate in order based on `coordinates`
fn workspaces_for_output<'a>(
&'a self,
output: &'a wl_output::WlOutput,
) -> impl Iterator<Item = &Workspace> + 'a {
self.workspaces
.iter()
.filter(|w| w.outputs.contains(output))
}

fn toplevel_for_handle_mut(
&mut self,
handle: &ZcosmicToplevelHandleV1,
Expand Down
9 changes: 3 additions & 6 deletions src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ pub(crate) fn layer_surface<'a>(
}
let layout = app.conf.workspace_config.workspace_layout;
let sidebar = workspaces_sidebar(
app.workspaces
.iter()
.filter(|i| i.outputs.contains(&surface.output)),
app.workspaces_for_output(&surface.output),
&surface.output,
layout,
drop_target,
Expand All @@ -80,9 +78,8 @@ pub(crate) fn layer_surface<'a>(
);
// TODO multiple active workspaces? Not currently supported by cosmic.
let first_active_workspace = app
.workspaces
.iter()
.find(|i| i.outputs.contains(&surface.output) && i.is_active);
.workspaces_for_output(&surface.output)
.find(|w| w.is_active);
let toplevels = if let Some(workspace) = first_active_workspace {
toplevel_dnd_destination(
DropTarget::OutputToplevels(workspace.handle.clone(), surface.output.clone()),
Expand Down

0 comments on commit ba52d69

Please sign in to comment.