translate button-event into key-event

Florian Loitsch Florian.Loitsch at
Fri Mar 23 15:04:18 PDT 2007

I'm trying to translate my 8th button into an "alt"-key by intercepting the 
button and sending a new key-event instead. This partially works, but when 
pressing another button at the same time this button is intercepted too, and 
I can't find any way to resend it (or just let it through). (Basically 
thumb-down, mouse1-click, thumb-up doesn't work.)

I've attached my program (90% of it are xlib-calls), but globally it consists 
of grabing the thumb-button (using XGrabButton), followed by an infinite loop 
intercepting the buttons and simulating key-events (XTestFakeKeyEvent).

I also noticed some strange behavior when using the thumb-buttons (8 and 9) on 
my Logitech mx400 (using the evdev driver):
$ ./translate
Grabbing Button...
thumb down
why?         (mouse1 down)
why?         (mouse1 up)
             (thump up event lost)
thumb down
thumb up
I'm losing the button-up event when I do a mouse1 click while holding down the 

// florian loitsch
Give a man a fire and he's warm for the whole day,
but set fire to him and he's warm for the rest of his life. - Terry Pratchett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 1330 bytes
Desc: not available
URL: <>

More information about the xorg mailing list