fixed grabbing if no window is focused.

This commit is contained in:
frese 2003-04-01 13:08:19 +00:00
parent cd58a58e42
commit 6eeef48f98
1 changed files with 15 additions and 16 deletions

View File

@ -89,22 +89,23 @@
(let* ((fwin (get-input-focus-window dpy)) ;; can be pointer-root and none
(path (reverse (if (or (equal? fwin none)
(equal? fwin pointer-root))
'()
(list (default-root-window dpy))
(window-path dpy fwin))))
;; find all that match the first key and are registered for a
;; window on the path
(grabs (flatten
(filter
(lambda (x) x)
(map (lambda (win)
(filter
(lambda (grab)
(let ((first (car (key-grab:keys grab))))
(and (equal? win (key-grab:window grab))
(enum-set=? (key:modifiers first)
(key-event-state event))
(equal? (key:keycode first)
(key-event-keycode event)))))
grabs))
path))))
(map (lambda (win)
(filter
(lambda (grab)
(let ((first (car (key-grab:keys grab))))
(and (equal? win (key-grab:window grab))
(enum-set=? (key:modifiers first)
(key-event-state event))
(equal? (key:keycode first)
(key-event-keycode event)))))
grabs))
path)))
;; make an alist mapping a grab to the keys that are not entered
(grabs-rests (map (lambda (g)
(cons g (cdr (key-grab:keys g))))
grabs))
@ -112,7 +113,6 @@
(let ((dones (map car (filter (lambda (grab-rest)
(null? (cdr grab-rest)))
grabs-rests))))
(mdisplay "winner? dones: " dones "\n")
(let loop ((dones dones))
(if (null? dones)
#f
@ -129,7 +129,6 @@
dpy (default-root-window dpy) (event-mask key-press)
(lambda (event-channel)
(let loop ((grabs-rests grabs-rests))
(mdisplay "grabs-rests: " grabs-rests "\n")
(and (not (null? grabs-rests))
(or (winner? grabs-rests)
(let ((e (receive event-channel)))