Dealing with Stray Middle Click Events with Google Chrome in X11
Zürich, Schweiz
I am writing this mostly for posterity in case other people are running into this problem:
I’ve been using a Logitech Trackman Marble Mouse Trackball (p/n 810-000767) for many years in the X Window System1 — Linux and OpenBSD. It’s worked great — until about two years ago. I’ve not had the chance to bisect what has gone wrong — whether it is X11, an ecosystem library, or Google Chrome itself, but the problem is essentially this:
My Marble Mouse is configured to use the small button immediately on the right
side to perform horizontal and vertical panning of content while moving the
trackball (using the ScrollMethod and ScrollButton directives on the
libinput driver). But recently as the trackball moves (and emphasis on this
happening as the trackball moves), Google Chrome interprets this button press
as a middle click for pasting from the primary selection copy buffer. So
while panning, Chrome pans and the primary selection copy buffer’s content is
spuriously inserted into whatever text pane is in focus! Moreover, the paste
events can happen many times in rapid succession!
If you’re working with a rich text content box (presumably an EditContext), you can imagine how annoying this is: spontaneous text insertion of random-or-possibly-sensitive-text into a document!
This problem occurs with no other X11 clients: terminal emulators, graphical text editors, you-name-it. The thing is, I like the primary selection copy buffer concept, so I don’t want to disable this. And in all of these other applications, I can use this button to both pan and perform a middle click paste without a problem.
I’ve had to make my peace with a substandard solution: move primary selection pasting (through the middle click mnemonic) to another button, which is going to take my muscle memory a long time to learn.
I was able to fix this by adding a run-parts-style configuration fragment
in /etc/X11/xorg.conf.d:
| |
Note: You would want to corroborate your device’s name from the
MatchProductdirective with what you see inxinput list.
I want to thank Jordi Castells for his writeup that includes a precise button mapping dissection: Logitech Trackman in Linux.
I verified what’s happening with xev, and I see the correct events:
pre-change
ButtonPress(2)ButtonPress(7) - pan rightButtonRelease(7) - pan rightButtonPress(7) - pan rightButtonRelease(7) - pan right…
ButtonRelease(2)
post-change
ButtonPress(9)ButtonPress(7) - pan rightButtonRelease(7) - pan rightButtonPress(7) - pan rightButtonRelease(7) - pan right…
ButtonRelease(9)
Aside: Looking at
xevwas rather interesting, because I have never looked at precisely how the emulation mode works from an implementation standpoint:
- Button 4: pan up
- Button 5: pan down
- Button 7: pan right
- Button 8: pan left
Episodically in the pre-change configuration, I did see MotionNotify events
interspersed into the log. Is that a red herring, or an actual lead? Perhaps
there is a race with the processing of that event followed by these other
clicks? Hard to say. I’m still left with the question of why this problem
remains exclusively in Google Chrome and no other X11 client. I’m afraid
I don’t have the time to deeply investigate this further.
Funnily enough, this device is largely unusable in Wayland due to the inability to configure button mappings and other input parameters. I keep checking every couple of years, but no dice. ↩︎
- Tips (9)
- Unix (4)
- Ux (2)
- X-Window-System (2)