From a9397727d2a0d07a0a3aeed83a21e44c638677ef Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 27 Oct 2018 14:15:08 +0000 Subject: Relax matching of URL modifiers To click on links in the alternate screen buffer, it is necessary that the `shift` button is held down, otherwise mouse events are captured by the application. However this would also require that `Shift` is added to the `mouse.url.modifiers` option. Thus it is not possible anymore to click on URLs unless the shift button is always held down. To resolve this issue, the matching of modifiers has been relaxed. If a modifier is specified in the config, it is always required to be held down. However if a modifier is held down which is not specified, it is still accpeted. This one-way relaxed matching allows clicking on links with or without shift held down without having to make use of the `mouse.url.modifiers` setting at all. --- src/config.rs | 11 +++++++++++ src/input.rs | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 2e746623..0c774f37 100644 --- a/src/config.rs +++ b/src/config.rs @@ -106,6 +106,17 @@ pub struct Url { pub modifiers: ModifiersState, } +impl Url { + // Make sure that modifiers in the config are always present, + // but ignore surplus modifiers. + pub fn mods_match_relaxed(&self, mods: ModifiersState) -> bool { + !((self.modifiers.shift && !mods.shift) + || (self.modifiers.ctrl && !mods.ctrl) + || (self.modifiers.alt && !mods.alt) + || (self.modifiers.logo && !mods.logo)) + } +} + fn deserialize_modifiers<'a, D>(deserializer: D) -> ::std::result::Result where D: de::Deserializer<'a> { diff --git a/src/input.rs b/src/input.rs index 49a9101e..b705fd19 100644 --- a/src/input.rs +++ b/src/input.rs @@ -520,7 +520,9 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { // Spawn URL launcher when clicking on URLs fn launch_url(&self, modifiers: ModifiersState) -> Option<()> { - if modifiers != self.mouse_config.url.modifiers || self.ctx.mouse().block_url_launcher { + if !self.mouse_config.url.mods_match_relaxed(modifiers) + || self.ctx.mouse().block_url_launcher + { return None; } -- cgit v1.2.3-54-g00ecf