mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-27 13:07:59 +01:00
Make button events working with winner-mode
* exwm-input.el (exwm-input--fake-last-command): Extracted for reuse. (exwm-input--on-ButtonPress, exwm-input--on-KeyPress-line-mode): Use it.
This commit is contained in:
parent
edb930005b
commit
0368127976
1 changed files with 17 additions and 11 deletions
|
@ -396,7 +396,7 @@ ARGS are additional arguments to CALLBACK."
|
||||||
"Handle ButtonPress event."
|
"Handle ButtonPress event."
|
||||||
(let ((obj (make-instance 'xcb:ButtonPress))
|
(let ((obj (make-instance 'xcb:ButtonPress))
|
||||||
(mode xcb:Allow:SyncPointer)
|
(mode xcb:Allow:SyncPointer)
|
||||||
button-event window buffer frame)
|
button-event window buffer frame fake-last-command)
|
||||||
(xcb:unmarshal obj data)
|
(xcb:unmarshal obj data)
|
||||||
(exwm--log "major-mode=%s buffer=%s"
|
(exwm--log "major-mode=%s buffer=%s"
|
||||||
major-mode (buffer-name (current-buffer)))
|
major-mode (buffer-name (current-buffer)))
|
||||||
|
@ -423,6 +423,7 @@ ARGS are additional arguments to CALLBACK."
|
||||||
(exwm-floating--start-moveresize event))
|
(exwm-floating--start-moveresize event))
|
||||||
(buffer
|
(buffer
|
||||||
;; Click to focus
|
;; Click to focus
|
||||||
|
(setq fake-last-command t)
|
||||||
(unless (eq window (selected-window))
|
(unless (eq window (selected-window))
|
||||||
(setq frame (window-frame window))
|
(setq frame (window-frame window))
|
||||||
(unless (eq frame exwm-workspace--current)
|
(unless (eq frame exwm-workspace--current)
|
||||||
|
@ -451,7 +452,10 @@ ARGS are additional arguments to CALLBACK."
|
||||||
(setq mode (exwm-input--on-ButtonPress-char-mode)))))))
|
(setq mode (exwm-input--on-ButtonPress-char-mode)))))))
|
||||||
(t
|
(t
|
||||||
;; Replay this event by default.
|
;; Replay this event by default.
|
||||||
|
(setq fake-last-command t)
|
||||||
(setq mode xcb:Allow:ReplayPointer))))
|
(setq mode xcb:Allow:ReplayPointer))))
|
||||||
|
(when fake-last-command
|
||||||
|
(exwm-input--fake-last-command))
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:AllowEvents :mode mode :time xcb:Time:CurrentTime))
|
(make-instance 'xcb:AllowEvents :mode mode :time xcb:Time:CurrentTime))
|
||||||
(xcb:flush exwm--connection))
|
(xcb:flush exwm--connection))
|
||||||
|
@ -657,6 +661,12 @@ Current buffer must be an `exwm-mode' buffer."
|
||||||
"A placeholder command."
|
"A placeholder command."
|
||||||
(interactive))
|
(interactive))
|
||||||
|
|
||||||
|
(defun exwm-input--fake-last-command ()
|
||||||
|
"Fool some packages into thinking there is a change in the buffer."
|
||||||
|
(setq last-command #'exwm-input--noop)
|
||||||
|
(run-hooks 'pre-command-hook)
|
||||||
|
(run-hooks 'post-command-hook))
|
||||||
|
|
||||||
(defun exwm-input--on-KeyPress-line-mode (key-press raw-data)
|
(defun exwm-input--on-KeyPress-line-mode (key-press raw-data)
|
||||||
"Parse X KeyPress event to Emacs key event and then feed the command loop."
|
"Parse X KeyPress event to Emacs key event and then feed the command loop."
|
||||||
(with-slots (detail state) key-press
|
(with-slots (detail state) key-press
|
||||||
|
@ -686,16 +696,12 @@ Current buffer must be an `exwm-mode' buffer."
|
||||||
:destination (slot-value key-press 'event)
|
:destination (slot-value key-press 'event)
|
||||||
:event-mask xcb:EventMask:NoEvent
|
:event-mask xcb:EventMask:NoEvent
|
||||||
:event raw-data)))
|
:event raw-data)))
|
||||||
(if defining-kbd-macro
|
(when event
|
||||||
(when event
|
(if (not defining-kbd-macro)
|
||||||
;; Make Emacs aware of this event when defining keyboard macros.
|
(exwm-input--fake-last-command)
|
||||||
(set-transient-map `(keymap (t . ,#'exwm-input--noop)))
|
;; Make Emacs aware of this event when defining keyboard macros.
|
||||||
(exwm-input--unread-event event))
|
(set-transient-map `(keymap (t . ,#'exwm-input--noop)))
|
||||||
;; Fool some packages into thinking there is a change in the buffer.
|
(exwm-input--unread-event event))))
|
||||||
(when event
|
|
||||||
(setq last-command #'exwm-input--noop)
|
|
||||||
(run-hooks 'pre-command-hook)
|
|
||||||
(run-hooks 'post-command-hook))))
|
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:AllowEvents
|
(make-instance 'xcb:AllowEvents
|
||||||
:mode mode
|
:mode mode
|
||||||
|
|
Loading…
Reference in a new issue