shell: Move space_for_handle into Workspaces
This commit is contained in:
parent
c09a735289
commit
996b5a8227
4 changed files with 36 additions and 16 deletions
|
|
@ -506,6 +506,7 @@ where
|
|||
if current.0 != desc.handle {
|
||||
state
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle(&desc.handle)
|
||||
.map(|w| w.tiling_layer.tree())
|
||||
} else {
|
||||
|
|
@ -532,6 +533,7 @@ where
|
|||
|
||||
let workspace = state
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle(¤t.0)
|
||||
.ok_or(OutputNoMode)?;
|
||||
|
||||
|
|
@ -563,6 +565,7 @@ where
|
|||
|
||||
let workspace = state
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle(&previous)
|
||||
.ok_or(OutputNoMode)?;
|
||||
let has_fullscreen = workspace.fullscreen.is_some();
|
||||
|
|
|
|||
|
|
@ -944,6 +944,14 @@ impl Workspaces {
|
|||
self.sets.values().flat_map(|set| set.workspaces.iter())
|
||||
}
|
||||
|
||||
pub fn space_for_handle(&self, handle: &WorkspaceHandle) -> Option<&Workspace> {
|
||||
self.spaces().find(|w| &w.handle == handle)
|
||||
}
|
||||
|
||||
pub fn space_for_handle_mut(&mut self, handle: &WorkspaceHandle) -> Option<&mut Workspace> {
|
||||
self.spaces_mut().find(|w| &w.handle == handle)
|
||||
}
|
||||
|
||||
pub fn spaces_for_output(&self, output: &Output) -> impl Iterator<Item = &Workspace> {
|
||||
self.sets
|
||||
.get(output)
|
||||
|
|
@ -1236,14 +1244,6 @@ impl Shell {
|
|||
.find(|workspace| workspace.mapped().any(|m| m == mapped))
|
||||
}
|
||||
|
||||
pub fn space_for_handle(&self, handle: &WorkspaceHandle) -> Option<&Workspace> {
|
||||
self.workspaces.spaces().find(|w| &w.handle == handle)
|
||||
}
|
||||
|
||||
pub fn space_for_handle_mut(&mut self, handle: &WorkspaceHandle) -> Option<&mut Workspace> {
|
||||
self.workspaces.spaces_mut().find(|w| &w.handle == handle)
|
||||
}
|
||||
|
||||
pub fn outputs(&self) -> impl DoubleEndedIterator<Item = &Output> {
|
||||
self.workspaces.sets.keys().chain(
|
||||
self.workspaces
|
||||
|
|
@ -1439,16 +1439,21 @@ impl Shell {
|
|||
previous_workspace: &WorkspaceHandle,
|
||||
target_layer: ManagedLayer,
|
||||
) {
|
||||
if self.space_for_handle(previous_workspace).is_none() {
|
||||
if self
|
||||
.workspaces
|
||||
.space_for_handle(previous_workspace)
|
||||
.is_none()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
let Some(workspace) = self.space_for_handle_mut(¤t_workspace) else { return };
|
||||
let Some(workspace) = self.workspaces.space_for_handle_mut(¤t_workspace) else { return };
|
||||
let _ = workspace.unmap(&mapped);
|
||||
}
|
||||
|
||||
let new_workspace_output = self
|
||||
.workspaces
|
||||
.space_for_handle(&previous_workspace)
|
||||
.unwrap()
|
||||
.output()
|
||||
|
|
@ -1460,7 +1465,10 @@ impl Shell {
|
|||
.toplevel_enter_workspace(&window, &previous_workspace);
|
||||
}
|
||||
|
||||
let new_workspace = self.space_for_handle_mut(&previous_workspace).unwrap();
|
||||
let new_workspace = self
|
||||
.workspaces
|
||||
.space_for_handle_mut(&previous_workspace)
|
||||
.unwrap();
|
||||
match target_layer {
|
||||
ManagedLayer::Floating => new_workspace.floating_layer.map(mapped, None),
|
||||
ManagedLayer::Tiling => {
|
||||
|
|
@ -1522,6 +1530,7 @@ impl Shell {
|
|||
let new_workspace_handle = state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle(&previous_workspace)
|
||||
.is_some()
|
||||
.then_some(previous_workspace)
|
||||
|
|
@ -1745,6 +1754,7 @@ impl Shell {
|
|||
let new_workspace_handle = state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle(&previous_workspace)
|
||||
.is_some()
|
||||
.then_some(previous_workspace)
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ impl ScreencopyHandler for State {
|
|||
}
|
||||
};
|
||||
|
||||
let workspace = match self.common.shell.space_for_handle_mut(&handle) {
|
||||
let workspace = match self.common.shell.workspaces.space_for_handle_mut(&handle) {
|
||||
Some(workspace) => workspace,
|
||||
None => {
|
||||
session.failed(FailureReason::InvalidWorkspace);
|
||||
|
|
@ -343,7 +343,7 @@ impl ScreencopyHandler for State {
|
|||
.push((session, params));
|
||||
}
|
||||
SessionType::Workspace(_output, handle) => {
|
||||
match self.common.shell.space_for_handle_mut(&handle) {
|
||||
match self.common.shell.workspaces.space_for_handle_mut(&handle) {
|
||||
Some(workspace) => workspace.pending_buffers.push((session, params)),
|
||||
None => session.failed(FailureReason::InvalidWorkspace),
|
||||
};
|
||||
|
|
@ -422,7 +422,8 @@ impl ScreencopyHandler for State {
|
|||
}
|
||||
}
|
||||
SessionType::Workspace(_, handle) => {
|
||||
if let Some(workspace) = self.common.shell.space_for_handle_mut(&handle) {
|
||||
if let Some(workspace) = self.common.shell.workspaces.space_for_handle_mut(&handle)
|
||||
{
|
||||
workspace.pending_buffers.retain(|(s, _)| s != &session);
|
||||
workspace.screencopy_sessions.retain(|s| s != &session);
|
||||
}
|
||||
|
|
@ -1092,7 +1093,7 @@ impl Common {
|
|||
}
|
||||
}
|
||||
SessionType::Workspace(_output, handle) => {
|
||||
if let Some(space) = self.shell.space_for_handle_mut(&handle) {
|
||||
if let Some(space) = self.shell.workspaces.space_for_handle_mut(&handle) {
|
||||
if space.screencopy_sessions.iter().any(|s| s == &session) {
|
||||
space.pending_buffers.push((session, params));
|
||||
}
|
||||
|
|
@ -1247,7 +1248,12 @@ impl State {
|
|||
.map(|o| (o.clone(), self.common.shell.active_space(o).handle.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
if let Some((handle, output)) = self.common.shell.workspace_for_surface(surface) {
|
||||
let workspace = self.common.shell.space_for_handle_mut(&handle).unwrap();
|
||||
let workspace = self
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle_mut(&handle)
|
||||
.unwrap();
|
||||
if !workspace.pending_buffers.is_empty() {
|
||||
// TODO: replace with drain_filter....
|
||||
let mut i = 0;
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ impl XdgShellHandler for State {
|
|||
let new_workspace_handle = self
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.space_for_handle(&previous_workspace)
|
||||
.is_some()
|
||||
.then_some(previous_workspace)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue