shell: Using parking_lot's RwLock for fairness guarantees

This commit is contained in:
Victoria Brekenfeld 2025-05-20 17:41:27 +02:00 committed by Victoria Brekenfeld
parent 8194be30c6
commit 465813c1c5
42 changed files with 247 additions and 396 deletions

View file

@ -118,7 +118,7 @@ use std::{
collections::HashSet,
ffi::OsString,
process::Child,
sync::{atomic::AtomicBool, Arc, Mutex, Once, RwLock},
sync::{atomic::AtomicBool, Arc, Mutex, Once},
time::{Duration, Instant},
};
@ -195,7 +195,7 @@ pub struct Common {
pub event_loop_signal: LoopSignal,
pub popups: PopupManager,
pub shell: Arc<RwLock<Shell>>,
pub shell: Arc<parking_lot::RwLock<Shell>>,
pub clock: Clock<Monotonic>,
pub startup_done: Arc<AtomicBool>,
@ -307,7 +307,7 @@ impl BackendData {
test_only: bool,
loop_handle: &LoopHandle<'static, State>,
screen_filter: &ScreenFilter,
shell: Arc<RwLock<Shell>>,
shell: Arc<parking_lot::RwLock<Shell>>,
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
xdg_activation_state: &XdgActivationState,
startup_done: Arc<AtomicBool>,
@ -327,7 +327,7 @@ impl BackendData {
_ => unreachable!("No backend set when applying output config"),
}?;
let mut shell = shell.write().unwrap();
let mut shell = shell.write();
for output in result {
// apply to Output
let final_config = output
@ -561,7 +561,7 @@ impl State {
DataControlState::new::<Self, _>(dh, Some(&primary_selection_state), |_| true)
});
let shell = Arc::new(RwLock::new(Shell::new(&config)));
let shell = Arc::new(parking_lot::RwLock::new(Shell::new(&config)));
let layer_shell_state =
WlrLayerShellState::new_with_filter::<State, _>(dh, client_is_privileged);
@ -700,7 +700,7 @@ impl Common {
output: &Output,
render_element_states: &RenderElementStates,
) {
let shell = self.shell.read().unwrap();
let shell = self.shell.read();
let processor = |surface: &WlSurface, states: &SurfaceData| {
let primary_scanout_output = update_surface_primary_scanout_output(
surface,
@ -802,7 +802,7 @@ impl Common {
render_element_states: &RenderElementStates,
mut dmabuf_feedback: impl FnMut(DrmNode) -> Option<SurfaceDmabufFeedback>,
) {
let shell = self.shell.read().unwrap();
let shell = self.shell.read();
if let Some(session_lock) = shell.session_lock.as_ref() {
if let Some(lock_surface) = session_lock.surfaces.get(output) {
@ -995,7 +995,7 @@ impl Common {
}
}
let shell = self.shell.read().unwrap();
let shell = self.shell.read();
if let Some(session_lock) = shell.session_lock.as_ref() {
if let Some(lock_surface) = session_lock.surfaces.get(output) {