shell: Using parking_lot's RwLock for fairness guarantees
This commit is contained in:
parent
8194be30c6
commit
465813c1c5
42 changed files with 247 additions and 396 deletions
|
|
@ -112,7 +112,6 @@ impl Shell {
|
|||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.element_for_surface(window)
|
||||
.cloned(),
|
||||
_ => None,
|
||||
|
|
@ -123,17 +122,12 @@ impl Shell {
|
|||
return;
|
||||
}
|
||||
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.write()
|
||||
.unwrap()
|
||||
.append_focus_stack(&mapped, seat);
|
||||
state.common.shell.write().append_focus_stack(&mapped, seat);
|
||||
}
|
||||
|
||||
update_focus_state(seat, target, state, serial, update_cursor);
|
||||
|
||||
state.common.shell.write().unwrap().update_active();
|
||||
state.common.shell.write().update_active();
|
||||
}
|
||||
|
||||
pub fn append_focus_stack(&mut self, mapped: &CosmicMapped, seat: &Seat<State>) {
|
||||
|
|
@ -242,7 +236,7 @@ fn update_focus_state(
|
|||
if should_update_cursor && state.common.config.cosmic_conf.cursor_follows_focus {
|
||||
if target.is_some() {
|
||||
//need to borrow mutably for surface under
|
||||
let shell = state.common.shell.read().unwrap();
|
||||
let shell = state.common.shell.read();
|
||||
// get the top left corner of the target element
|
||||
let geometry = shell.focused_geometry(target.unwrap());
|
||||
if let Some(geometry) = geometry {
|
||||
|
|
@ -292,7 +286,6 @@ fn update_focus_state(
|
|||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.get_output_for_focus(seat)
|
||||
.as_ref(),
|
||||
)
|
||||
|
|
@ -339,14 +332,13 @@ impl Common {
|
|||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
for seat in &seats {
|
||||
{
|
||||
let shell = state.common.shell.read().unwrap();
|
||||
let shell = state.common.shell.read();
|
||||
let focused_output = seat.focused_output();
|
||||
let active_output = seat.active_output();
|
||||
|
||||
|
|
@ -365,7 +357,7 @@ impl Common {
|
|||
update_pointer_focus(state, &seat);
|
||||
|
||||
let output = seat.focused_or_active_output();
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let mut shell = state.common.shell.write();
|
||||
let last_known_focus = ActiveFocus::get(&seat);
|
||||
|
||||
if let Some(target) = last_known_focus {
|
||||
|
|
@ -454,7 +446,7 @@ impl Common {
|
|||
}
|
||||
}
|
||||
|
||||
state.common.shell.write().unwrap().update_active()
|
||||
state.common.shell.write().update_active()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +574,7 @@ fn update_pointer_focus(state: &mut State, seat: &Seat<State>) {
|
|||
let output = seat.active_output();
|
||||
let position = pointer.current_location().as_global();
|
||||
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let mut shell = state.common.shell.write();
|
||||
let under = State::surface_under(position, &output, &mut shell)
|
||||
.map(|(target, pos)| (target, pos.as_logical()));
|
||||
drop(shell);
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ impl IsAlive for KeyboardFocusTarget {
|
|||
|
||||
impl PointerTarget<State> for PointerFocusTarget {
|
||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
let toplevel = self.toplevel(&*data.common.shell.read().unwrap());
|
||||
let toplevel = self.toplevel(&*data.common.shell.read());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
session.set_cursor_pos(Some(
|
||||
|
|
@ -270,7 +270,7 @@ impl PointerTarget<State> for PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
let toplevel = self.toplevel(&*data.common.shell.read().unwrap());
|
||||
let toplevel = self.toplevel(&*data.common.shell.read());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
session.set_cursor_pos(Some(
|
||||
|
|
@ -346,7 +346,7 @@ impl PointerTarget<State> for PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
|
||||
let toplevel = self.toplevel(&*data.common.shell.read().unwrap());
|
||||
let toplevel = self.toplevel(&*data.common.shell.read());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
session.set_cursor_pos(None);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue