Fix unreading 'return event
* exwm-xim.el (exwm-xim--event-pending): Drop unused variable. (exwm-xim--handle-forward-event-request): Convert 'return back to ?\n to avoid error.
This commit is contained in:
parent
fe2336a11e
commit
672a5e2a23
1 changed files with 38 additions and 43 deletions
81
exwm-xim.el
81
exwm-xim.el
|
@ -152,8 +152,6 @@ C,no"
|
||||||
(defvar exwm-xim--property-index 0 "For generating a unique property name.")
|
(defvar exwm-xim--property-index 0 "For generating a unique property name.")
|
||||||
(defvar exwm-xim--im-id 0 "Last IM ID.")
|
(defvar exwm-xim--im-id 0 "Last IM ID.")
|
||||||
(defvar exwm-xim--ic-id 0 "Last IC ID.")
|
(defvar exwm-xim--ic-id 0 "Last IC ID.")
|
||||||
(defvar exwm-xim--event-pending nil
|
|
||||||
"Indicating whether Emacs requires more events.")
|
|
||||||
|
|
||||||
;; X11 atoms.
|
;; X11 atoms.
|
||||||
(defvar exwm-xim--@server nil)
|
(defvar exwm-xim--@server nil)
|
||||||
|
@ -546,43 +544,40 @@ The actual XIM request is in client message data or a property."
|
||||||
exwm-xim--conn
|
exwm-xim--conn
|
||||||
(car keysym)
|
(car keysym)
|
||||||
(logand state (lognot (cdr keysym)))))))
|
(logand state (lognot (cdr keysym)))))))
|
||||||
(if exwm-xim--event-pending
|
(if (or (not im-func)
|
||||||
;; In case any event reaches here, it should be forwarded
|
;; `list' is the default method.
|
||||||
;; to Emacs.
|
(eq im-func #'list)
|
||||||
(when event
|
(not event)
|
||||||
(setq unread-command-events
|
;; Select only printable keys.
|
||||||
(append unread-command-events (list event))))
|
(not (integerp event)) (> #x20 event) (< #x7e event))
|
||||||
(setq exwm-xim--event-pending t)
|
;; Either there is no active input method, or invalid key
|
||||||
(if (or (not im-func)
|
;; is detected.
|
||||||
;; `list' is the default method.
|
(with-slots (im-id ic-id serial-number event) req
|
||||||
(eq im-func #'list)
|
(exwm-xim--make-request
|
||||||
(not event)
|
(make-instance 'xim:forward-event
|
||||||
;; Select only printable keys.
|
:im-id im-id
|
||||||
(not (integerp event)) (> #x20 event) (< #x7e event))
|
:ic-id ic-id
|
||||||
;; Either there is no active input method, or invalid key
|
:flag xim:commit-flag:synchronous
|
||||||
;; is detected.
|
:serial-number serial-number
|
||||||
(with-slots (im-id ic-id serial-number event) req
|
:event event)
|
||||||
(exwm-xim--make-request
|
conn client-xwin)
|
||||||
(make-instance 'xim:forward-event
|
(xcb:flush conn))
|
||||||
:im-id im-id
|
(when (eq exwm--selected-input-mode 'char-mode)
|
||||||
:ic-id ic-id
|
;; Grab keyboard temporarily for char-mode.
|
||||||
:flag xim:commit-flag:synchronous
|
(exwm-input--grab-keyboard))
|
||||||
:serial-number serial-number
|
(unwind-protect
|
||||||
:event event)
|
(with-temp-buffer
|
||||||
conn client-xwin)
|
;; Always show key strokes.
|
||||||
(xcb:flush conn))
|
(let ((input-method-use-echo-area t))
|
||||||
(when (eq exwm--selected-input-mode 'char-mode)
|
(while (or event unread-command-events)
|
||||||
;; Grab keyboard temporarily for char-mode.
|
(unless event
|
||||||
(exwm-input--grab-keyboard))
|
(setq event (pop unread-command-events)))
|
||||||
(unwind-protect
|
;; `quail-input-method' seems to unread 'return instead of
|
||||||
(with-temp-buffer
|
;; ?\n hence this conversion.
|
||||||
;; Always show key strokes.
|
(when (eq event 'return)
|
||||||
(let ((input-method-use-echo-area t))
|
(setq event ?\n))
|
||||||
(while (or event unread-command-events)
|
(when (characterp event)
|
||||||
(unless event
|
(setq result (funcall im-func event))
|
||||||
(setq event (pop unread-command-events)))
|
|
||||||
(setq result (funcall im-func event)
|
|
||||||
event nil)
|
|
||||||
;; This also works for portable character encoding.
|
;; This also works for portable character encoding.
|
||||||
(setq result
|
(setq result
|
||||||
(encode-coding-string (concat result)
|
(encode-coding-string (concat result)
|
||||||
|
@ -596,10 +591,10 @@ The actual XIM request is in client message data or a property."
|
||||||
:length (length result)
|
:length (length result)
|
||||||
:string result)
|
:string result)
|
||||||
conn client-xwin)
|
conn client-xwin)
|
||||||
(xcb:flush conn))))
|
(xcb:flush conn))
|
||||||
(when (eq exwm--selected-input-mode 'char-mode)
|
(setq event nil))))
|
||||||
(exwm-input--release-keyboard))))
|
(when (eq exwm--selected-input-mode 'char-mode)
|
||||||
(setq exwm-xim--event-pending nil))))
|
(exwm-input--release-keyboard))))))
|
||||||
|
|
||||||
(defun exwm-xim--make-request (req conn client-xwin)
|
(defun exwm-xim--make-request (req conn client-xwin)
|
||||||
"Make an XIM request REQ via connection CONN.
|
"Make an XIM request REQ via connection CONN.
|
||||||
|
|
Loading…
Reference in a new issue