state: Move shell behind RwLock
This commit is contained in:
parent
647deb81f1
commit
5d5a510691
45 changed files with 2657 additions and 2097 deletions
|
|
@ -185,6 +185,30 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_enter_output(toplevel: &impl Window, output: &Output) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().outputs.push(output.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_leave_output(toplevel: &impl Window, output: &Output) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().outputs.retain(|o| o != output);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_enter_workspace(toplevel: &impl Window, workspace: &WorkspaceHandle) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().workspaces.push(workspace.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_leave_workspace(toplevel: &impl Window, workspace: &WorkspaceHandle) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().workspaces.retain(|w| w != workspace);
|
||||
}
|
||||
}
|
||||
|
||||
impl<D, W> ToplevelInfoState<D, W>
|
||||
where
|
||||
D: GlobalDispatch<ZcosmicToplevelInfoV1, ToplevelInfoGlobalData>
|
||||
|
|
@ -223,30 +247,6 @@ where
|
|||
self.toplevels.push(toplevel.clone());
|
||||
}
|
||||
|
||||
pub fn toplevel_enter_output(&mut self, toplevel: &W, output: &Output) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().outputs.push(output.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_leave_output(&mut self, toplevel: &W, output: &Output) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().outputs.retain(|o| o != output);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_enter_workspace(&mut self, toplevel: &W, workspace: &WorkspaceHandle) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().workspaces.push(workspace.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_leave_workspace(&mut self, toplevel: &W, workspace: &WorkspaceHandle) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
state.lock().unwrap().workspaces.retain(|w| w != workspace);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_toplevel(&mut self, toplevel: &W) {
|
||||
if let Some(state) = toplevel.user_data().get::<ToplevelState>() {
|
||||
let mut state_inner = state.lock().unwrap();
|
||||
|
|
|
|||
|
|
@ -71,6 +71,29 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_rectangle_for(
|
||||
window: &impl ManagementWindow,
|
||||
) -> impl Iterator<Item = (WlSurface, Rectangle<i32, Logical>)> {
|
||||
if let Some(state) = window.user_data().get::<ToplevelState>() {
|
||||
let mut state = state.lock().unwrap();
|
||||
state
|
||||
.rectangles
|
||||
.retain(|(surface, _)| surface.upgrade().is_ok());
|
||||
Some(
|
||||
state
|
||||
.rectangles
|
||||
.iter()
|
||||
.map(|(surface, rect)| (surface.upgrade().unwrap(), *rect))
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter(),
|
||||
)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
} else {
|
||||
None.into_iter().flatten()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ToplevelManagerGlobalData {
|
||||
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
||||
}
|
||||
|
|
@ -102,30 +125,6 @@ impl ToplevelManagementState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rectangle_for(
|
||||
&mut self,
|
||||
window: &impl ManagementWindow,
|
||||
) -> impl Iterator<Item = (WlSurface, Rectangle<i32, Logical>)> {
|
||||
if let Some(state) = window.user_data().get::<ToplevelState>() {
|
||||
let mut state = state.lock().unwrap();
|
||||
state
|
||||
.rectangles
|
||||
.retain(|(surface, _)| surface.upgrade().is_ok());
|
||||
Some(
|
||||
state
|
||||
.rectangles
|
||||
.iter()
|
||||
.map(|(surface, rect)| (surface.upgrade().unwrap(), *rect))
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter(),
|
||||
)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
} else {
|
||||
None.into_iter().flatten()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn global_id(&self) -> GlobalId {
|
||||
self.global.clone()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue