From f07435e22b99ccc095c35861dfc76e617ab91d02 Mon Sep 17 00:00:00 2001 From: Matt Spear Date: Mon, 7 Mar 2011 22:40:24 -0800 Subject: [PATCH 1/2] add command hook --- bindings.lisp | 3 ++- primitives.lisp | 9 +++++++++ user.lisp | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bindings.lisp b/bindings.lisp index e8d11b6..66e43f8 100644 --- a/bindings.lisp +++ b/bindings.lisp @@ -232,7 +232,8 @@ from most specific groups to most general groups.") "Command mode allows you to type ratpoison commands without needing the @key{C-t} prefix. Keys not bound in StumpWM will still get sent to the current window. To exit command mode, type @key{C-g}." - (message "Press C-g to exit command-mode.") + (setf *in-command-mode* T) + (run-hook-with-args *command-mode-hook* T) (push-top-map *root-map*)) (defcommand set-prefix-key (key) ((:key "Key: ")) diff --git a/primitives.lisp b/primitives.lisp index 10ca8df..ef96629 100644 --- a/primitives.lisp +++ b/primitives.lisp @@ -146,8 +146,17 @@ be an integer.") (defvar *message-window-timer* nil "Keep track of the timer that hides the message window.") +(defvar *in-command-mode* nil + "If T then is in command mode, otherwise nil") + ;;; Hooks +(defvar *command-mode-hook* (list #'(lambda (start) + (when (eq start T) + (message "Press C-g to exit command-mode.")))) + "A hook called whenever command mode is started or exited + it is givet nil on exit, T on start") + (defvar *urgent-window-hook* '() "A hook called whenever a window sets the property indicating that it demands the user's attention") diff --git a/user.lisp b/user.lisp index e9ca71c..ec7bf86 100644 --- a/user.lisp +++ b/user.lisp @@ -213,7 +213,11 @@ such a case, kill the shell command to resume StumpWM." "" ;; This way you can exit from command mode (when (pop-top-map) - (message "Exited."))) + (if *in-command-mode* + (progn + (run-hook-with-args *command-mode-hook* nil) + (setf *in-command-mode* nil)) + (message "Exited.")))) (defcommand-alias abort keyboard-quit) -- 1.7.3.5 From 3b91f965c626a09c2f64da119ef2b61fb74cf18a Mon Sep 17 00:00:00 2001 From: Matt Spear Date: Mon, 7 Mar 2011 22:45:07 -0800 Subject: [PATCH 2/2] ordering --- core.lisp | 5 +++-- user.lisp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core.lisp b/core.lisp index b32dc00..b7fc450 100644 --- a/core.lisp +++ b/core.lisp @@ -115,8 +115,9 @@ (defun ungrab-pointer () "Remove the grab on the cursor and restore the cursor shape." - (xlib:ungrab-pointer *display*) - (xlib:display-finish-output *display*)) + (unless *in-command-mode* + (xlib:ungrab-pointer *display*) + (xlib:display-finish-output *display*))) (defun grab-keyboard (xwin) (let ((ret (xlib:grab-keyboard xwin :owner-p nil diff --git a/user.lisp b/user.lisp index ec7bf86..50202e2 100644 --- a/user.lisp +++ b/user.lisp @@ -215,8 +215,8 @@ such a case, kill the shell command to resume StumpWM." (when (pop-top-map) (if *in-command-mode* (progn - (run-hook-with-args *command-mode-hook* nil) - (setf *in-command-mode* nil)) + (setf *in-command-mode* nil) + (run-hook-with-args *command-mode-hook* nil)) (message "Exited.")))) (defcommand-alias abort keyboard-quit) -- 1.7.3.5