Expand modifiers on a nested remap

Fix #91
This commit is contained in:
Takashi Kokubun 2022-04-27 20:06:15 -07:00
parent bdf3af41f8
commit 2c4e3574e3
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
3 changed files with 6 additions and 3 deletions

View File

@ -32,7 +32,7 @@ where
// Expand ModifierState::Either to Left and Right. Not leaving Either to save some space and computation.
// Note that we currently don't have `Both`. Does anybody need it?
fn expand_modifiers(key_press: KeyPress) -> Vec<KeyPress> {
pub fn expand_modifiers(key_press: KeyPress) -> Vec<KeyPress> {
if key_press.shift == ModifierState::Either {
expand_modifier(key_press, &Modifier::Shift)
} else if key_press.control == ModifierState::Either {

View File

@ -3,7 +3,7 @@ pub mod application;
mod key;
pub mod key_action;
pub mod key_press;
mod keymap;
pub mod keymap;
mod modmap;
mod remap;

View File

@ -3,6 +3,7 @@ use crate::config::action::Action;
use crate::config::application::Application;
use crate::config::key_action::KeyAction;
use crate::config::key_press::{KeyPress, Modifier, ModifierState};
use crate::config::keymap::expand_modifiers;
use crate::Config;
use evdev::uinput::VirtualDevice;
use evdev::{EventType, InputEvent, Key};
@ -217,7 +218,9 @@ impl EventHandler {
Action::Remap(action) => {
let mut override_remap: HashMap<KeyPress, Vec<Action>> = HashMap::new();
for (key_press, actions) in action.remap.iter() {
override_remap.insert(key_press.clone(), actions.to_vec());
for key_press in expand_modifiers(key_press.clone()) {
override_remap.insert(key_press, actions.to_vec());
}
}
self.override_remap = Some(override_remap);
if let Some(timeout) = action.timeout {