allow to skip key event on KeyRelease actions (#420)

pull/423/head
Chakib Benziane 3 months ago committed by GitHub
parent cfe5b4f855
commit 45ddd0180c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -201,6 +201,7 @@ modmap:
alone_timeout_millis: 1000 # Optional
# Hook `keymap` action on key press/release events.
KEY_XXX:
skip_key_event: false # Optional, skip original key event ,defaults to false
press: { launch: ["xdotool", "mousemove", "0", "7200"] } # Required
release: { launch: ["xdotool", "mousemove", "0", "0"] } # Required
application: # Optional

@ -31,6 +31,8 @@ pub struct MultiPurposeKey {
#[derive(Clone, Debug, Deserialize)]
pub struct PressReleaseKey {
#[serde(default)]
pub skip_key_event: bool ,
#[serde(deserialize_with = "deserialize_actions")]
pub press: Vec<KeymapAction>,
#[serde(deserialize_with = "deserialize_actions")]

@ -329,7 +329,7 @@ impl EventHandler {
// fallthrough on state discrepancy
vec![(key, value)]
}
ModmapAction::PressReleaseKey(PressReleaseKey { press, release }) => {
ModmapAction::PressReleaseKey(PressReleaseKey { skip_key_event, press, release }) => {
// Just hook actions, and then emit the original event. We might want to
// support reordering the key event and dispatched actions later.
if value == PRESS || value == RELEASE {
@ -344,8 +344,14 @@ impl EventHandler {
&key,
)?;
}
// Dispatch the original key as well
vec![(key, value)]
if skip_key_event {
// Do not dispatch the original key
vec![(Key::KEY_UNKNOWN, value)]
} else {
// dispatch the original key
vec![(key, value)]
}
}
};
Ok(keys)

Loading…
Cancel
Save