So I've been working on a mouse chording setup in Scheme that looks something like this:
(define (define-mouse-chords chord-key . definitions)
(let ((cmd #f))
(let ((key (list-ref definition 0)) (binding (list-ref definition 1)))
(xbindkey-function key (lambda () (set! cmd binding)))))
(xbindkey-function `(release ,chord-key)
(remove-xbindkey `(release ,chord-key))
(let ((key (list-ref definition 0)))
(set! cmd #f))
; (system "xdotool click 10")
(xbindkey-function chord-key start-mouse-chord))
(list '(release "b:1") "xdotool click 8")
(list '(release "b:2") "xdotool click 9")
The principle is that I define a single button to act as a "chord" button. When this button is pressed, additional bindings are registered corresponding to whatever actions I'm interested in. In this case, I've defined buttons 1 and 2 to act as "back" and "forward" buttons. The action command to be run is stored when the second button is pressed, and is run only when the chord button is finally released.
Now, all this works perfectly. What I'm struggling with is the commented-out clause that handles the case where the chord button is released without any command having been triggered. In this case, I'd really like the original chord button event to be passed through. You can see that I've tried using (ungrab-all-keys) to suspend existing bindings. However, this isn't working for me. In fact I've tried several approaches, without any success, including:
* Instead of (ungrab-all-keys), I've tried removing the binding for chord-key, then registering a binding for F12, then using "xdotool click 10 && xdotool key F12". For a reason I can't fathom, the binding never triggers, even if I press F12 manually. It works perfectly fine if I define the F12 binding at the root level, rather than on the fly, but that's not really the solution I'm looking for, since I don't really want to bind F12 permanently.
* I've tried introducing sleeps into the shell commands, in the hope that the additional time will allow whatever event queues might be involved to clear, but this doesn't seem to make any difference, even when using (run-command) to fork the process.
I'm somewhat at a loss now. How could I allow a single b:10 click through?
Thanks for any help,