about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2020-04-17T00·00+0000
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2020-05-06T00·00+0000
commitce2625d050b1a4aa5815dc488880b85d0270d743 (patch)
tree83e152f26bfc4e80d0db3877b3ada0795f9e474e
parent95d6aa96cfaac1a3b474ca16bac70945ad909b01 (diff)
Run hook upon input mode change
	* exwm-input.el (exwm-input-input-mode-change-hook): Add new hook
	for code to run upon input mode change.
	(exwm-input--grab-keyboard, exwm-input--release-keyboard): Run it.
-rw-r--r--exwm-input.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 9ba3502a4da0..2d784073e77e 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -145,6 +145,10 @@ This value should always be overwritten.")
 (defvar exwm-input--event-hook nil
   "Hook to run when EXWM receives an event.")
 
+(defvar exwm-input-input-mode-change-hook nil
+  "Hook to run when an input mode changes on an `exwm-mode' buffer.
+Current buffer will be the `exwm-mode' buffer when this hook runs.")
+
 (defvar exwm-workspace--current)
 (declare-function exwm-floating--do-moveresize "exwm-floating.el"
                   (data _synthetic))
@@ -793,7 +797,8 @@ button event."
     (let ((buffer (exwm--id->buffer id)))
       (when buffer
         (with-current-buffer buffer
-          (setq exwm--input-mode 'line-mode))))))
+          (setq exwm--input-mode 'line-mode)
+          (run-hooks 'exwm-input-input-mode-change-hook))))))
 
 (defun exwm-input--release-keyboard (&optional id)
   "Ungrab all key events on window ID."
@@ -810,7 +815,8 @@ button event."
     (let ((buffer (exwm--id->buffer id)))
       (when buffer
         (with-current-buffer buffer
-          (setq exwm--input-mode 'char-mode))))))
+          (setq exwm--input-mode 'char-mode)
+          (run-hooks 'exwm-input-input-mode-change-hook))))))
 
 ;;;###autoload
 (defun exwm-input-grab-keyboard (&optional id)