From 56cfe7961ec8cd07dc286c37c9ae170342991740 Mon Sep 17 00:00:00 2001 From: Philippe Brochard Date: Thu, 26 Aug 2010 23:31:04 +0200 Subject: [PATCH] src/clfswm-circulate-mode.lisp (circulate-loop-function): Use is-a-key-pressed-p. src/xlib-util.lisp (is-a-key-pressed-p): New predicate. --- ChangeLog | 5 +++++ src/clfswm-circulate-mode.lisp | 31 ++----------------------------- src/xlib-util.lisp | 9 ++++++++- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2964bb3..64ba1b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-08-26 Philippe Brochard + * src/clfswm-circulate-mode.lisp (circulate-loop-function): + Use is-a-key-pressed-p. + + * src/xlib-util.lisp (is-a-key-pressed-p): New predicate. + * src/clfswm-keys.lisp (define-ungrab/grab): Use all values returned by xlib:keysym->keycodes. diff --git a/src/clfswm-circulate-mode.lisp b/src/clfswm-circulate-mode.lisp index 4590cac..9e87b0c 100644 --- a/src/clfswm-circulate-mode.lisp +++ b/src/clfswm-circulate-mode.lisp @@ -33,8 +33,6 @@ (defparameter *circulate-orig* nil) (defparameter *circulate-parent* nil) -(defparameter *circulate-leave-key* nil) - (defun draw-circulate-mode-window () (raise-window *circulate-window*) (clear-pixmap-buffer *circulate-window* *circulate-gc*) @@ -153,23 +151,6 @@ (define-circulate-release-key ("Alt_L" :alt) 'leave-circulate-mode)) -(defun set-circulate-leave-key () - (maphash #'(lambda (key value) - (when (and (listp value) (member 'leave-circulate-mode value)) - (setf *circulate-leave-key* (typecase (first key) - (character (list (char->keycode (first key)))) - (number (list (first key))) - (string (multiple-value-list - (xlib:keysym->keycodes *display* (keysym-name->keysym (first key))))))))) - *circulate-keys-release*)) - - - - - - - - (defun circulate-leave-function () (when *circulate-window* (xlib:destroy-window *circulate-window*)) @@ -180,15 +161,8 @@ *circulate-font* nil)) (defun circulate-loop-function () - ;;; Check if the key modifier is alway pressed - (let ((leave t)) - (loop for k across (xlib:query-keymap *display*) - for i from 0 - do (when (and (plusp k) (member i *circulate-leave-key*)) - (setf leave nil) - (return))) - (when leave - (leave-circulate-mode)))) + (unless (is-a-key-pressed-p) + (leave-circulate-mode))) (define-handler circulate-mode :key-press (code state) (unless (funcall-key-from-code *circulate-keys* code state) @@ -205,7 +179,6 @@ (defun circulate-mode (&key child-direction brother-direction) (setf *circulate-hit* 0) - (set-circulate-leave-key) (with-placement (*circulate-mode-placement* x y *circulate-width* *circulate-height*) (setf *circulate-font* (xlib:open-font *display* *circulate-font-string*) *circulate-window* (xlib:create-window :parent *root* diff --git a/src/xlib-util.lisp b/src/xlib-util.lisp index 8d0a975..1f6c20a 100644 --- a/src/xlib-util.lisp +++ b/src/xlib-util.lisp @@ -732,7 +732,7 @@ Expand in handle-event-fun-main-mode-key-press" "Alt_L" "Alt_R" "Meta_L" "Meta_R" "Hyper_L" "Hyper_R" "Mode_switch" "script_switch" "ISO_Level3_Shift" "Caps_Lock" "Scroll_Lock" "Num_Lock")) - (awhen (xlib:keysym->keycodes *display* (keysym-name->keysym name)) + (awhen (xlib:keysym->keycodes *display* (keysym-name->keysym name)) ;; PHIL: todo here (push it modifier-list)))) (defun modifier-p (code) @@ -801,3 +801,10 @@ Expand in handle-event-fun-main-mode-key-press" (xlib:copy-area *pixmap-buffer* gc 0 0 (xlib:drawable-width window) (xlib:drawable-height window) window 0 0)) + + +(defun is-a-key-pressed-p () + (loop for k across (xlib:query-keymap *display*) + when (plusp k) + return t)) + -- 2.11.4.GIT