input: Fix double borrow

This commit is contained in:
Victoria Brekenfeld 2022-03-30 23:24:29 +02:00
parent 69c71179d4
commit 6a376c3481

View file

@ -200,16 +200,14 @@ impl Common {
let serial = SERIAL_COUNTER.next_serial(); let serial = SERIAL_COUNTER.next_serial();
let time = Event::time(&event); let time = Event::time(&event);
seat.get_keyboard().unwrap().input::<(), _>( if let Some(action) = seat
keycode, .get_keyboard()
state, .unwrap()
serial, .input(keycode, state, serial, time, |modifiers, handle| {
time,
|modifiers, handle| {
if state == KeyState::Released if state == KeyState::Released
&& userdata.get::<SupressedKeys>().unwrap().filter(&handle) && userdata.get::<SupressedKeys>().unwrap().filter(&handle)
{ {
return FilterResult::Intercept(()); return FilterResult::Intercept(None);
} }
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
@ -223,7 +221,8 @@ impl Common {
state == KeyState::Pressed, state == KeyState::Pressed,
modifiers.clone(), modifiers.clone(),
); );
return FilterResult::Intercept(()); userdata.get::<SupressedKeys>().unwrap().add(&handle);
return FilterResult::Intercept(None);
} }
if self.egui.log_state.wants_keyboard() { if self.egui.log_state.wants_keyboard() {
self.egui.log_state.handle_keyboard( self.egui.log_state.handle_keyboard(
@ -231,7 +230,8 @@ impl Common {
state == KeyState::Pressed, state == KeyState::Pressed,
modifiers.clone(), modifiers.clone(),
); );
return FilterResult::Intercept(()); userdata.get::<SupressedKeys>().unwrap().add(&handle);
return FilterResult::Intercept(None);
} }
} }
} }
@ -241,36 +241,32 @@ impl Common {
if state == KeyState::Pressed if state == KeyState::Pressed
&& binding.modifiers == *modifiers && binding.modifiers == *modifiers
&& handle.raw_syms().contains(&binding.key) && handle.raw_syms().contains(&binding.key)
{
userdata.get::<SupressedKeys>().unwrap().add(&handle);
return FilterResult::Intercept(Some(action));
}
}
FilterResult::Forward
})
.flatten()
{ {
match action { match action {
Action::Terminate => { Action::Terminate => {
userdata
.get::<SupressedKeys>()
.unwrap()
.add(&handle);
self.should_stop = true; self.should_stop = true;
return FilterResult::Intercept(());
} }
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
Action::Debug => { Action::Debug => {
self.egui.active = !self.egui.active; self.egui.active = !self.egui.active;
userdata
.get::<SupressedKeys>()
.unwrap()
.add(&handle);
return FilterResult::Intercept(());
} }
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
Action::Debug => slog_scope::info!( Action::Debug => {
"Debug overlay not included in this version" slog_scope::info!("Debug overlay not included in this version")
), }
Action::Close => { Action::Close => {
let current_output = active_output(seat, &self); let current_output = active_output(seat, &self);
let workspace = let workspace = self.shell.active_space_mut(&current_output);
self.shell.active_space_mut(&current_output); if let Some(window) = workspace.focus_stack(seat).last() {
if let Some(window) =
workspace.focus_stack(seat).last()
{
#[allow(irrefutable_let_patterns)] #[allow(irrefutable_let_patterns)]
if let Kind::Xdg(xdg) = &window.toplevel() { if let Kind::Xdg(xdg) = &window.toplevel() {
xdg.send_close(); xdg.send_close();
@ -283,23 +279,19 @@ impl Common {
0 => 9, 0 => 9,
x => x - 1, x => x - 1,
}; };
self.shell.activate( self.shell
seat, .activate(seat, &current_output, workspace as usize);
&current_output,
workspace as usize,
);
userdata
.get::<SupressedKeys>()
.unwrap()
.add(&handle);
return FilterResult::Intercept(());
} }
Action::MoveToWorkspace(num) => { Action::MoveToWorkspace(key_num) => {
let current_output = active_output(seat, &self); let current_output = active_output(seat, &self);
let workspace = match key_num {
0 => 9,
x => x - 1,
};
self.shell.move_current_window( self.shell.move_current_window(
seat, seat,
&current_output, &current_output,
*num, workspace as usize,
); );
} }
Action::Focus(focus) => { Action::Focus(focus) => {
@ -313,16 +305,10 @@ impl Common {
} }
Action::Orientation(orientation) => { Action::Orientation(orientation) => {
let output = active_output(seat, &self); let output = active_output(seat, &self);
self.shell.set_orientation( self.shell.set_orientation(&seat, &output, *orientation);
&seat,
&output,
*orientation,
);
return FilterResult::Intercept(());
} }
Action::Spawn(command) => { Action::Spawn(command) => {
if let Err(err) = if let Err(err) = std::process::Command::new("/bin/sh")
std::process::Command::new("/bin/sh")
.arg("-c") .arg("-c")
.arg(command) .arg(command)
.env("WAYLAND_DISPLAY", &self.socket) .env("WAYLAND_DISPLAY", &self.socket)
@ -330,19 +316,9 @@ impl Common {
{ {
slog_scope::warn!("Failed to spawn: {}", err); slog_scope::warn!("Failed to spawn: {}", err);
} }
userdata
.get::<SupressedKeys>()
.unwrap()
.add(&handle);
return FilterResult::Intercept(());
} }
} }
} }
}
FilterResult::Forward
},
);
break; break;
} }
} }