[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/exwm dff1ef6 1/7: Simplify input handling
From: |
Chris Feng |
Subject: |
[elpa] externals/exwm dff1ef6 1/7: Simplify input handling |
Date: |
Sun, 14 Oct 2018 06:08:23 -0400 (EDT) |
branch: externals/exwm
commit dff1ef6a3c36fd7d8b3a3bafbd66a91b8e576b26
Author: Adrián Medraño Calvo <address@hidden>
Commit: Adrián Medraño Calvo <address@hidden>
Simplify input handling
No functional change.
* exwm-input.el (exwm-input--current-input-mode): New function
indicating keyboard input mode.
(exwm-input--on-KeyPress, exwm-input--update-mode-line): Use
`exwm-input--current-input-mode'.
(exwm-input-grab-keyboard, exwm-input-release-keyboard)
(exwm-input--update-mode-line): Simplify.
* exwh-core.el (exwm--on-KeyPress): Remove variable, use
`exwm--keyboard-grabbed' and `exwm-input--current-input-mode'
instead.
---
exwm-core.el | 6 ++----
exwm-input.el | 50 +++++++++++++++++++++++++++++---------------------
exwm-layout.el | 3 ++-
3 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/exwm-core.el b/exwm-core.el
index 66eb98c..612a26f 100644
--- a/exwm-core.el
+++ b/exwm-core.el
@@ -158,9 +158,7 @@ least SECS seconds later."
(defvar-local exwm--mode-line-format nil) ;save mode-line-format
(defvar-local exwm--floating-frame-position nil) ;set when hidden.
(defvar-local exwm--fixed-size nil) ;fixed size
-(defvar-local exwm--keyboard-grabbed nil) ;Keyboard grabbed.
-(defvar-local exwm--on-KeyPress ;KeyPress event handler
- #'exwm-input--on-KeyPress-line-mode)
+(defvar-local exwm--input-mode 'line-mode) ;Keyboard grabbed.
;; Properties
(defvar-local exwm--desktop nil "_NET_WM_DESKTOP.")
(defvar-local exwm-window-type nil "_NET_WM_WINDOW_TYPE.")
@@ -252,7 +250,7 @@ least SECS seconds later."
"*Keyboard*"
"---"
["Toggle keyboard mode" exwm-input-toggle-keyboard]
- ["Send key" exwm-input-send-next-key exwm--keyboard-grabbed]
+ ["Send key" exwm-input-send-next-key (eq exwm--input-mode 'line-mode)]
;; This is merely a reference.
("Send simulation key" :filter
(lambda (&rest _args)
diff --git a/exwm-input.el b/exwm-input.el
index 57fed2d..d9ad3d3 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -428,9 +428,13 @@ ARGS are additional arguments to CALLBACK."
(let ((obj (make-instance 'xcb:KeyPress)))
(xcb:unmarshal obj data)
(exwm--log "major-mode=%s buffer=%s"
- major-mode (buffer-name (current-buffer)))
+ major-mode (buffer-name (current-buffer)))
(if (derived-mode-p 'exwm-mode)
- (funcall exwm--on-KeyPress obj data)
+ (cl-case (exwm-input--current-input-mode)
+ (line-mode
+ (exwm-input--on-KeyPress-line-mode obj data))
+ (char-mode
+ (exwm-input--on-KeyPress-char-mode obj data)))
(exwm-input--on-KeyPress-char-mode obj))))
(defun exwm-input--on-CreateNotify (data _synthetic)
@@ -654,17 +658,24 @@ instead."
:time xcb:Time:CurrentTime))
(xcb:flush exwm--connection))
+(defun exwm-input--current-input-mode ()
+ "Return current input mode.
+The return value is one of the symbols \\='line-mode or \\=`char-mode.
+
+Current buffer must be an `exwm-mode' buffer."
+ exwm--input-mode)
+
(defun exwm-input--update-mode-line (id)
"Update the propertized `mode-line-process' for window ID."
(let (help-echo cmd mode)
- (cl-case exwm--on-KeyPress
- ((exwm-input--on-KeyPress-line-mode)
+ (cl-case (exwm-input--current-input-mode)
+ (line-mode
(setq mode "line"
help-echo "mouse-1: Switch to char-mode"
cmd `(lambda ()
(interactive)
(exwm-input-release-keyboard ,id))))
- ((exwm-input--on-KeyPress-char-mode)
+ (char-mode
(setq mode "char"
help-echo "mouse-1: Switch to line-mode"
cmd `(lambda ()
@@ -680,7 +691,8 @@ instead."
(keymap
(mode-line
keymap
- (down-mouse-1 . ,cmd)))))))))
+ (down-mouse-1 . ,cmd))))))
+ (force-mode-line-update))))
(defun exwm-input--grab-keyboard (&optional id)
"Grab all key events on window ID."
@@ -697,7 +709,7 @@ instead."
:keyboard-mode xcb:GrabMode:Sync))
(exwm--log "Failed to grab keyboard for #x%x" id))
(with-current-buffer (exwm--id->buffer id)
- (setq exwm--on-KeyPress #'exwm-input--on-KeyPress-line-mode))))
+ (setq exwm--input-mode 'line-mode))))
(defun exwm-input--release-keyboard (&optional id)
"Ungrab all key events on window ID."
@@ -712,7 +724,7 @@ instead."
(exwm--log "Failed to release keyboard for #x%x" id))
(exwm-input--grab-global-prefix-keys id)
(with-current-buffer (exwm--id->buffer id)
- (setq exwm--on-KeyPress #'exwm-input--on-KeyPress-char-mode))))
+ (setq exwm--input-mode 'char-mode))))
;;;###autoload
(defun exwm-input-grab-keyboard (&optional id)
@@ -721,11 +733,8 @@ instead."
(exwm--buffer->id (window-buffer)))))
(when id
(exwm--log "id=#x%x" id)
- (with-current-buffer (exwm--id->buffer id)
- (exwm-input--grab-keyboard id)
- (setq exwm--keyboard-grabbed t)
- (exwm-input--update-mode-line id)
- (force-mode-line-update))))
+ (exwm-input--grab-keyboard id)
+ (exwm-input--update-mode-line id)))
;;;###autoload
(defun exwm-input-release-keyboard (&optional id)
@@ -734,11 +743,8 @@ instead."
(exwm--buffer->id (window-buffer)))))
(when id
(exwm--log "id=#x%x" id)
- (with-current-buffer (exwm--id->buffer id)
- (exwm-input--release-keyboard id)
- (setq exwm--keyboard-grabbed nil)
- (exwm-input--update-mode-line id)
- (force-mode-line-update))))
+ (exwm-input--release-keyboard id)
+ (exwm-input--update-mode-line id)))
;;;###autoload
(defun exwm-input-toggle-keyboard (&optional id)
@@ -748,9 +754,11 @@ instead."
(when id
(exwm--log "id=#x%x" id)
(with-current-buffer (exwm--id->buffer id)
- (if exwm--keyboard-grabbed
- (exwm-input-release-keyboard id)
- (exwm-reset)))))
+ (cl-case (exwm-input--current-input-mode)
+ (line-mode
+ (exwm-input-release-keyboard id))
+ (char-mode
+ (exwm-reset))))))
(defun exwm-input--fake-key (event)
"Fake a key event equivalent to Emacs event EVENT."
diff --git a/exwm-layout.el b/exwm-layout.el
index 56faadd..90988fa 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -45,6 +45,7 @@
(defvar exwm-layout--timer nil "Timer used to track echo area changes.")
(defvar exwm-workspace--current)
+(declare-function exwm-input--current-input-mode "exwm-input.el")
(declare-function exwm-input--release-keyboard "exwm-input.el")
(declare-function exwm-input--grab-keyboard "exwm-input.el")
(declare-function exwm-input-grab-keyboard "exwm-input.el")
@@ -199,7 +200,7 @@
(make-instance 'xcb:ewmh:set-_NET_WM_STATE :window exwm--id :data []))
(xcb:flush exwm--connection)
(set-window-dedicated-p (get-buffer-window) nil)
- (when exwm--keyboard-grabbed
+ (when (eq 'line-mode (exwm-input--current-input-mode))
(exwm-input--grab-keyboard exwm--id))))
;;;###autoload
- [elpa] externals/exwm updated (472f7cb -> 449cd9d), Chris Feng, 2018/10/14
- [elpa] externals/exwm 57d0e9e 3/7: Support binding mouse events in line-mode, Chris Feng, 2018/10/14
- [elpa] externals/exwm dff1ef6 1/7: Simplify input handling,
Chris Feng <=
- [elpa] externals/exwm c9984ca 2/7: Fix focus jumps with minibuffer-only frames, Chris Feng, 2018/10/14
- [elpa] externals/exwm 98847a9 6/7: Merge branch 'medranocalvo/reduce-workspace-switch-flicker' into externals/exwm, Chris Feng, 2018/10/14
- [elpa] externals/exwm 449cd9d 7/7: Bump version to 0.20, Chris Feng, 2018/10/14
- [elpa] externals/exwm 5c9fcc0 5/7: Merge branch 'medranocalvo/fix-minibuffer-only-focus-jump' into externals/exwm, Chris Feng, 2018/10/14
- [elpa] externals/exwm 24287f2 4/7: Reduce flicker when switching workspaces, Chris Feng, 2018/10/14