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