keyd icon indicating copy to clipboard operation
keyd copied to clipboard

Middlemouse - ignore single clicks, but register holding down the button

Open anijatsu opened this issue 1 year ago • 1 comments

Hi, I'm trying to work around an issue while working with miro.com boards using the Google Chrome browser (/w Wayland #ozone-platform-hint flag set) on Ubuntu 24.04.01 LTS with GNOME Wayland.

I use the scroll wheel to pan around the board, but often this also registers a singular scroll wheel click (middlemouse), causing a clipboard insert action instead of a continuous viewport pan.

I'd like to configure keyd to only allow holding down the middlemouse button, but ignoring single clicks while I'm using Chrome.

However I notice two things:

  • Overload doesn't seem to achieve this behavior, or I misunderstand how it's supposed to be used
  • Defining the application binary name ([chrome]) as the section name doesn't seem to have Chrome adhere to rules from keyd. If I use the same line in the [main] section the rule I specify does work, but then it of course applies to all applications.
[ids]
1532:0090
[chrome]
middlemouse = overload(escape, middlemouse)

I also want to note that using Gnome Tweaks to disable Middle Click Paste doesn't apply to Chrome's behavior. I assume the browser has its own implementation for handling kb/m inputs.

anijatsu avatar Oct 18 '24 08:10 anijatsu

keyd cannot by itself apply bindings only to specific applications; the keyd-application-mapper companion script (which is shipped with keyd) can. See the manual for that application for specifics.

overload is indeed not used in that way; its first argument is a layer that will be activated as soon as the press of that key overlaps with a subsequent key.

In fact, I don't think that your use case is currently facilitated. middlemouse = timeout(noop, 200, middlemouse) comes close, but it would mean that you'd get a delay before the activation of middlemouse, which is probably not what you want.

You want to immediately generate the keydown, but generate escape if the keyup happens too soon. I vaguely remember there have been some related feature requests; if I have time I will look for them.

nsbgn avatar Oct 18 '24 15:10 nsbgn