Fix character loss with exwm-xim
* exwm-xim.el (exwm-xim--handle-forward-event-request): Events unread can either be reused by input methods or forwarded to X windows as is.
This commit is contained in:
parent
672a5e2a23
commit
75833e0c53
1 changed files with 57 additions and 50 deletions
37
exwm-xim.el
37
exwm-xim.el
|
@ -544,6 +544,9 @@ The actual XIM request is in client message data or a property."
|
|||
exwm-xim--conn
|
||||
(car keysym)
|
||||
(logand state (lognot (cdr keysym)))))))
|
||||
(while (or (slot-value req 'event) unread-command-events)
|
||||
(unless (slot-value req 'event)
|
||||
(setq event (pop unread-command-events)))
|
||||
(if (or (not im-func)
|
||||
;; `list' is the default method.
|
||||
(eq im-func #'list)
|
||||
|
@ -552,7 +555,19 @@ The actual XIM request is in client message data or a property."
|
|||
(not (integerp event)) (> #x20 event) (< #x7e event))
|
||||
;; Either there is no active input method, or invalid key
|
||||
;; is detected.
|
||||
(with-slots (im-id ic-id serial-number event) req
|
||||
(with-slots ((raw-event event)
|
||||
im-id ic-id serial-number)
|
||||
req
|
||||
(if raw-event
|
||||
(setq event raw-event)
|
||||
(setq keysym (xcb:keysyms:event->keysym exwm-xim--conn event))
|
||||
(with-slots (detail state) key-event
|
||||
(setf detail (xcb:keysyms:keysym->keycode exwm-xim--conn
|
||||
(car keysym))
|
||||
state (cdr keysym)))
|
||||
(setq event (let ((xcb:lsb lsb))
|
||||
(xcb:marshal key-event conn))))
|
||||
(when event
|
||||
(exwm-xim--make-request
|
||||
(make-instance 'xim:forward-event
|
||||
:im-id im-id
|
||||
|
@ -560,8 +575,7 @@ The actual XIM request is in client message data or a property."
|
|||
:flag xim:commit-flag:synchronous
|
||||
:serial-number serial-number
|
||||
:event event)
|
||||
conn client-xwin)
|
||||
(xcb:flush conn))
|
||||
conn client-xwin)))
|
||||
(when (eq exwm--selected-input-mode 'char-mode)
|
||||
;; Grab keyboard temporarily for char-mode.
|
||||
(exwm-input--grab-keyboard))
|
||||
|
@ -569,14 +583,6 @@ The actual XIM request is in client message data or a property."
|
|||
(with-temp-buffer
|
||||
;; Always show key strokes.
|
||||
(let ((input-method-use-echo-area t))
|
||||
(while (or event unread-command-events)
|
||||
(unless event
|
||||
(setq event (pop unread-command-events)))
|
||||
;; `quail-input-method' seems to unread 'return instead of
|
||||
;; ?\n hence this conversion.
|
||||
(when (eq event 'return)
|
||||
(setq event ?\n))
|
||||
(when (characterp event)
|
||||
(setq result (funcall im-func event))
|
||||
;; This also works for portable character encoding.
|
||||
(setq result
|
||||
|
@ -590,11 +596,12 @@ The actual XIM request is in client message data or a property."
|
|||
xim:commit-flag:x-lookup-chars)
|
||||
:length (length result)
|
||||
:string result)
|
||||
conn client-xwin)
|
||||
(xcb:flush conn))
|
||||
(setq event nil))))
|
||||
conn client-xwin)))
|
||||
(when (eq exwm--selected-input-mode 'char-mode)
|
||||
(exwm-input--release-keyboard))))))
|
||||
(exwm-input--release-keyboard))))
|
||||
(xcb:flush conn)
|
||||
(setf event nil
|
||||
(slot-value req 'event) nil))))
|
||||
|
||||
(defun exwm-xim--make-request (req conn client-xwin)
|
||||
"Make an XIM request REQ via connection CONN.
|
||||
|
|
Loading…
Reference in a new issue