[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difficulty with ungrab-all-keys

From: Paul Dann
Subject: Difficulty with ungrab-all-keys
Date: Thu, 19 Dec 2019 15:47:24 +0000

So I've been working on a mouse chording setup in Scheme that looks something like this:

(define (define-mouse-chords chord-key . definitions)
  (define (start-mouse-chord)
    (let ((cmd #f))
        (lambda (definition)
          (let ((key (list-ref definition 0)) (binding (list-ref definition 1)))
            (xbindkey-function key (lambda () (set! cmd binding)))))
      (xbindkey-function `(release ,chord-key)
        (lambda ()
          (remove-xbindkey `(release ,chord-key))
            (lambda (definition)
              (let ((key (list-ref definition 0)))
                (remove-xbindkey key)))
          (if cmd
              (run-command cmd)
              (set! cmd #f))
            ; (begin
            ;   (ungrab-all-keys)
            ;   (system "xdotool click 10")
            ;   (grab-all-keys)
            ; )
  (xbindkey-function chord-key start-mouse-chord))

(define-mouse-chords "b:10"
  (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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]