state: Move shell behind RwLock
This commit is contained in:
parent
647deb81f1
commit
5d5a510691
45 changed files with 2657 additions and 2097 deletions
|
|
@ -52,8 +52,9 @@ impl ScreencopyHandler for State {
|
|||
.upgrade()
|
||||
.and_then(|output| constraints_for_output(&output, &mut self.backend)),
|
||||
ImageSourceData::Workspace(handle) => {
|
||||
let workspace = self.common.shell.workspaces.space_for_handle(&handle)?;
|
||||
constraints_for_output(workspace.output(), &mut self.backend)
|
||||
let shell = self.common.shell.read().unwrap();
|
||||
let output = shell.workspaces.space_for_handle(&handle)?.output();
|
||||
constraints_for_output(output, &mut self.backend)
|
||||
}
|
||||
ImageSourceData::Toplevel(window) => {
|
||||
constraints_for_toplevel(window, &mut self.backend)
|
||||
|
|
@ -65,6 +66,8 @@ impl ScreencopyHandler for State {
|
|||
let size = if let Some((geometry, _)) = self
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.last_active()
|
||||
.cursor_geometry((0.0, 0.0), self.common.clock.now())
|
||||
|
|
@ -98,8 +101,8 @@ impl ScreencopyHandler for State {
|
|||
output.add_session(session);
|
||||
}
|
||||
ImageSourceData::Workspace(handle) => {
|
||||
let Some(workspace) = self.common.shell.workspaces.space_for_handle_mut(&handle)
|
||||
else {
|
||||
let mut shell = self.common.shell.write().unwrap();
|
||||
let Some(workspace) = shell.workspaces.space_for_handle_mut(&handle) else {
|
||||
session.stop();
|
||||
return;
|
||||
};
|
||||
|
|
@ -127,7 +130,14 @@ impl ScreencopyHandler for State {
|
|||
}
|
||||
fn new_cursor_session(&mut self, session: CursorSession) {
|
||||
let (pointer_loc, pointer_size, hotspot) = {
|
||||
let seat = self.common.shell.seats.last_active();
|
||||
let seat = self
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.last_active()
|
||||
.clone();
|
||||
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let pointer_loc = pointer.current_location().to_i32_round().as_global();
|
||||
|
|
@ -183,8 +193,8 @@ impl ScreencopyHandler for State {
|
|||
output.add_cursor_session(session);
|
||||
}
|
||||
ImageSourceData::Workspace(handle) => {
|
||||
let Some(workspace) = self.common.shell.workspaces.space_for_handle_mut(&handle)
|
||||
else {
|
||||
let mut shell = self.common.shell.write().unwrap();
|
||||
let Some(workspace) = shell.workspaces.space_for_handle_mut(&handle) else {
|
||||
session.stop();
|
||||
return;
|
||||
};
|
||||
|
|
@ -215,9 +225,10 @@ impl ScreencopyHandler for State {
|
|||
workspace.add_cursor_session(session);
|
||||
}
|
||||
ImageSourceData::Toplevel(mut toplevel) => {
|
||||
if let Some(element) = self.common.shell.element_for_surface(&toplevel) {
|
||||
let shell = self.common.shell.read().unwrap();
|
||||
if let Some(element) = shell.element_for_surface(&toplevel) {
|
||||
if element.has_active_window(&toplevel) {
|
||||
if let Some(workspace) = self.common.shell.space_for(element) {
|
||||
if let Some(workspace) = shell.space_for(element) {
|
||||
if let Some(geometry) = workspace.element_geometry(element) {
|
||||
let mut surface_geo = element.active_window_geometry().as_local();
|
||||
surface_geo.loc += geometry.loc;
|
||||
|
|
@ -268,12 +279,20 @@ impl ScreencopyHandler for State {
|
|||
return;
|
||||
}
|
||||
|
||||
let seat = self.common.shell.seats.last_active().clone();
|
||||
let seat = self
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.last_active()
|
||||
.clone();
|
||||
render_cursor_to_buffer(self, &session, frame, &seat);
|
||||
}
|
||||
|
||||
fn frame_aborted(&mut self, frame: Frame) {
|
||||
for mut output in self.common.shell.outputs().cloned() {
|
||||
let shell = self.common.shell.read().unwrap();
|
||||
for mut output in shell.outputs().cloned() {
|
||||
output.remove_frame(&frame)
|
||||
}
|
||||
}
|
||||
|
|
@ -286,7 +305,13 @@ impl ScreencopyHandler for State {
|
|||
}
|
||||
}
|
||||
ImageSourceData::Workspace(handle) => {
|
||||
if let Some(workspace) = self.common.shell.workspaces.space_for_handle_mut(&handle)
|
||||
if let Some(workspace) = self
|
||||
.common
|
||||
.shell
|
||||
.write()
|
||||
.unwrap()
|
||||
.workspaces
|
||||
.space_for_handle_mut(&handle)
|
||||
{
|
||||
workspace.remove_session(session)
|
||||
}
|
||||
|
|
@ -304,7 +329,13 @@ impl ScreencopyHandler for State {
|
|||
}
|
||||
}
|
||||
ImageSourceData::Workspace(handle) => {
|
||||
if let Some(workspace) = self.common.shell.workspaces.space_for_handle_mut(&handle)
|
||||
if let Some(workspace) = self
|
||||
.common
|
||||
.shell
|
||||
.write()
|
||||
.unwrap()
|
||||
.workspaces
|
||||
.space_for_handle_mut(&handle)
|
||||
{
|
||||
workspace.remove_cursor_session(session)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,18 +189,16 @@ pub fn render_workspace_to_buffer(
|
|||
#[cfg(feature = "debug")]
|
||||
puffin::profile_function!();
|
||||
|
||||
let Some(workspace) = state.common.shell.workspaces.space_for_handle(&handle) else {
|
||||
let shell = state.common.shell.read().unwrap();
|
||||
let Some(workspace) = shell.workspaces.space_for_handle(&handle) else {
|
||||
session.stop();
|
||||
return;
|
||||
};
|
||||
|
||||
let output = workspace.output().clone();
|
||||
let idx = state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.idx_for_handle(&output, &handle)
|
||||
.unwrap();
|
||||
let idx = shell.workspaces.idx_for_handle(&output, &handle).unwrap();
|
||||
std::mem::drop(shell);
|
||||
|
||||
let mode = output
|
||||
.current_mode()
|
||||
.map(|mode| mode.size.to_logical(1).to_buffer(1, Transform::Normal));
|
||||
|
|
@ -286,7 +284,7 @@ pub fn render_workspace_to_buffer(
|
|||
dt,
|
||||
age,
|
||||
additional_damage,
|
||||
&common.shell,
|
||||
&*common.shell.read().unwrap(),
|
||||
&common.config,
|
||||
&common.theme,
|
||||
common.clock.now(),
|
||||
|
|
@ -314,7 +312,7 @@ pub fn render_workspace_to_buffer(
|
|||
dt,
|
||||
age,
|
||||
additional_damage,
|
||||
&common.shell,
|
||||
&*common.shell.read().unwrap(),
|
||||
&common.config,
|
||||
&common.theme,
|
||||
common.clock.now(),
|
||||
|
|
@ -535,21 +533,23 @@ pub fn render_window_to_buffer(
|
|||
.map(Into::<WindowCaptureElement<R>>::into),
|
||||
);
|
||||
|
||||
let seat = common.shell.seats.last_active().clone();
|
||||
if let Some(location) = {
|
||||
if let Some(mapped) = common.shell.element_for_surface(window) {
|
||||
mapped.cursor_position(&seat).and_then(|mut p| {
|
||||
p -= mapped.active_window_offset().to_f64();
|
||||
if p.x < 0. || p.y < 0. {
|
||||
None
|
||||
} else {
|
||||
Some(p)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} {
|
||||
let shell = common.shell.read().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let location = if let Some(mapped) = shell.element_for_surface(window) {
|
||||
mapped.cursor_position(&seat).and_then(|mut p| {
|
||||
p -= mapped.active_window_offset().to_f64();
|
||||
if p.x < 0. || p.y < 0. {
|
||||
None
|
||||
} else {
|
||||
Some(p)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
std::mem::drop(shell);
|
||||
|
||||
if let Some(location) = location {
|
||||
if draw_cursor {
|
||||
elements.extend(
|
||||
cursor::draw_cursor(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue