Commit graph

157 commits

Author SHA1 Message Date
Chris Feng
95d6aa96cf Merge branch 'Curiosidad-Racional/patch-1' into externals/exwm 2020-03-29 00:00:00 +00:00
Chris Feng
5f9ba9772f Additional fix for winner-mode
* exwm-input.el (exwm-input--on-KeyPress-line-mode): Check incomplete
key presses (which generate no valid events) before running
`pre-command-hook' and `post-command-hook'.
2020-03-29 00:00:00 +00:00
Curiosidad-Racional
dc5cc1dead
Fixed fail update when current buffer differs from window
Local variable `exwm--input-mode' from different buffer when current buffer don't contains #id window.

`with-current-buffer' changes buffer after `cl-case' with local `exwm--input-mode'
2020-03-21 13:51:09 +01:00
Chris Feng
ed0f63327d Make exwm-mode buffers work with winner-mode
* exwm-input.el (exwm-input--noop): New placeholder command.
(exwm-input--on-pre-command, exwm-input--on-post-command): Ignore this
command.
(exwm-input--on-KeyPress-line-mode): Set `last-command' to make
winner-undo start over from the newest config; run
`post-command-hook' to make winner-mode save configs; run
`pre-command-hook' in case required by some other package.
2020-03-01 00:00:00 +00:00
Chris Feng
27a884e947 Update copyright year to 2020 2020-02-02 00:00:00 +00:00
Chris Feng
6a3e9b2c64 Avoid redundant input focus transfer
* exwm-input.el (exwm-input--set-focus): Check for current focused
X window before making an input focus transfer.
(exwm-input--on-buffer-list-update): Remove the `this-command' check.
2019-12-01 00:00:00 +00:00
Chris Feng
3420cd24d1 Add support for accessing keymaps in char-mode
* exwm-input.el (exwm-input-invoke-factory): New macro for generating
new commands that invoke corresponding prefix keys.
2019-11-03 00:00:00 +00:00
Chris Feng
1772b98452 Loosen the requirements for input focus update
* exwm-input.el (exwm-input--on-buffer-list-update): No more check
on current buffer (the check on buffer name was dropped in a1cf0d9b8).
2019-10-27 00:00:00 +00:00
Chris Feng
3c8b395058 Fix `exwm-input-set-simulation-key'
* exwm-input.el (exwm-input--read-keys): Return nil on empty input so
that `exwm-input-set-simulation-key' can ignore it.
(exwm-input-set-simulation-key): Improve prompt.
2019-10-13 00:00:00 +00:00
Steven Allen
5a43dbecc7 Add minibuffer-keyboard-quit to the default pre-post-command-blacklist
* exwm-input.el (exwm-input-pre-post-command-blacklist): Add
`minibuffer-keyboard-quit' to the blacklist. This is invoked when the user
aborts a the minibuffer with C-g.
2019-10-07 00:00:00 +00:00
Steven Allen
f14bd2a110 Set the current buffer before handling key events
There's no guarantee that the global current buffer matches the selected
window's buffer. For example, the following  will output "*Messages*" regardless
of the actual current buffer:

  (progn
    (run-at "1 sec" nil (lambda ()
                          (with-current-buffer (get-buffer "*Messages*")
                            (sit-for 5))))
    (run-at "2 sec" nil (lambda () (message (buffer-name)))))

* exwm-input.el (exwm-input--on-KeyPress): Set the current buffer to selected
window's current buffer.
2019-10-06 08:28:03 +09:00
Chris Feng
9eed52ee2b Avoid calling `x-focus-frame' on non-graphical frames
* exwm-workspace.el (exwm-workspace--client-p): Also account for
non-graphical frames.
* exwm-input.el (exwm-input--on-minibuffer-setup)
(exwm-input--on-minibuffer-exit): Exclude emacsclient frames.
2019-10-02 00:00:00 +00:00
Chris Feng
7778766af8 Allow customizing undetectable commands
* exwm-input.el (exwm-input-pre-post-command-blacklist): List of
commands undetectable with `post-command-hook'.
(exwm-input--on-pre-command): Use it.
2019-10-02 00:00:00 +00:00
Chris Feng
9bea3c9bcd Make input focus continue to work after EXWM exits
* exwm-input.el (exwm-input--exit): Set input focus 'revert-to' to
'PointerRoot' so that user can set input focus to X windows with
pointer after EXWM exits (and there's no other WM).
2019-09-22 00:00:00 +00:00
Chris Feng
9c85f172e5 Skip global keys unavailable in X server
* exwm-input.el (exwm-input--grab-global-prefix-keys): Some global
keys might not be available in X server (perhaps due to
misconfiguration).
2019-09-22 00:00:00 +00:00
Chris Feng
5b9f4b0851 Make it possible to answer questions from Emacs when in char-mode
* exwm-input.el (exwm-input--echo-area-timer): New variable storing
the timer used for detecting echo area messages.
(exwm-input--on-minibuffer-setup, exwm-input--on-minibuffer-exit)
(exwm-input--on-echo-area-dirty, exwm-input--on-echo-area-clear): New
functions for grabbing/releasing keyboard when minibuffer/echo becomes
active/inactive.
(exwm-input--init, exwm-input--exit): Register/Unregister them.
(exwm-input--grab-keyboard, exwm-input--release-keyboard): Validate
buffers.
2019-08-18 00:00:00 +00:00
Chris Feng
a1cf0d9b85 Avoid checking `*temp*' buffers
* exwm-input.el (exwm-input--on-buffer-list-update): The way of
detecting a switch from a `*temp*' buffer does not always work.
Disable it until we find a better way.
2019-08-11 00:00:00 +00:00
Chris Feng
37098a4009 Fix detection of modifier keys in Emacs events
* exwm-input.el (exwm-input--grab-global-prefix-keys)
(exwm-input--fake-key):
* exwm-xim.el (exwm-xim--handle-forward-event-request): X11 allows
multiple combinations of KEYSYM-MODIFIERS to generate a same
KEYSYM, thus the result of an Emacs event to KEYSYM-MODIFIERS
conversion is not necessarily unique.  Previously the result of
`xcb:keysyms:event->keysym' is misused as the modifiers returned is
actually the ones should be consumed.
2019-08-05 00:00:00 +00:00
Sebastian Wålinder
0a3dde042a Added option to have a key that ends exwm-input-send-next-key
* exwm-input.el (exwm-input-send-next-key): Accept an optional end key.
2019-07-14 00:00:00 +00:00
Chris Feng
aa92c7be8c Avoid workspace switch loop with `mouse-autoselect-window' enabled
* exwm-input.el (exwm-input--last-enter-notify-position): New variable
storing last mouse position.
(exwm-input--on-EnterNotify): Avoid switching workspace when mouse
position is not changed (the event is a result of a workspace switch).
2019-06-16 00:00:00 +00:00
Chris Feng
73b4d6f966 ; Follows up 2019-03-24 00:00:00 +00:00
Chris Feng
2434bdb57d Fix compatibility issue with Emacs 25
* exwm-input.el (exwm-input--unread-event): `string-version-lessp' is
not available on Emacs 25.
2019-02-11 00:00:00 +00:00
Chris Feng
225c68d4ce Merge branch 'retain-echo-area-until-input' of https://github.com/medranocalvo/exwm into medranocalvo/retain-echo-area-until-input 2019-02-06 00:00:00 +00:00
Ian Eure
ec108a61dc Cleanup simulation key config issues
* exwm-input.el (exwm-input-simulation-keys): Original key only has
one option, so probably shouldn’t be a `choice` type; Move the
"User-defined" key value to the top, since that’s the one someone is
most likely to want).

* exwm-config.el (exwm-config-default): Only set custom vars if there
isn’t a saved value for them.
2019-02-06 00:00:00 +00:00
Chris Feng
0f7269c4ec Add input method support
; The code is basically refactored from
; https://github.com/ch11ng/exim to get better maintenance.

* exwm-xim.el: New module making Emacs's builtin input methods usable
for interacting with X windows.

* exwm-core.el (exwm--intern-atom): New function for intern X11 atoms.
* exwm-input.el (exwm-input--init):
* exwm-manage.el (exwm-manage--init): Use it.
2019-02-06 00:00:00 +00:00
Chris Feng
993ca8a13a Update copyright year to 2019 2019-02-01 00:00:00 +00:00
Chris Feng
4f854e9fff Fix issue with managed tray icons
* exwm-input.el (exwm-input--on-ButtonPress): Replay button events
destined for managed tray icons.
2019-01-20 00:00:00 +00:00
Chris Feng
2efd7495d9 Avoid unnecessary focus changes when creating/killing buffers
* exwm-input.el (exwm-input--skip-buffer-list-update): New internal
variable for skipping the next 'buffer-list-update'.
(exwm-input--on-buffer-list-update): Skip when
`exwm-input--skip-buffer-list-update` is set.

* exwm-manage.el (exwm-manage--manage-window): Set
`exwm-input--skip-buffer-list-update` when creating/killing buffers.
2018-12-16 00:00:00 +00:00
Chris Feng
58f7916619 ; Improve debug logs. 2018-12-02 00:00:00 +00:00
Chris Feng
38e343ff07 Avoid unnecessary keyboard grab/ungrab in char-mode
* exwm-input.el (exwm-input--cache-event): Optimize the handling of
single event global key by not grabbing/ungrabbing the keyboard.
2018-11-25 00:00:00 +00:00
Adrián Medraño Calvo
cd7b32d1c2 Hide minibuffer upon receiving any event
* exwm-input.el (exwm-input--event-hook): New variable.
(exwm-input--on-ButtonPress, exwm-input--on-KeyPress): Run
`exwm-input--event-hook'.
* exwm-workspace.el (exwm-workspace--init, exwm-workspace--exit):
Hide minibuffer upon noticing an event.
2018-11-03 12:00:00 +00:00
Adrián Medraño Calvo
eb91ee2c77 Restore keyboard grabbing after exiting fullscreen
Recover the difference between the input mode selected by the user and
actual one, which might be transient.  This was inadvertently removed in
recent changes.

* exwm-core.el (exwm--selected-input-mode): New variable.
* exwm-input.el (exwm-input-grab-keyboard)
(exwm-input-release-keyboard): Use it.
* exwm-layout.el (exwm-layout-unset-fullscreen): Return to the
selected input mode.
2018-10-21 12:00:00 +00:00
Adrián Medraño Calvo
dba1ed94c2 Do away with `exwm-input--input-mode'
* exwm-input.el (exwm-input--update-mode-line): Remove.
(exwm-input--on-ButtonPress, exwm-input--on-KeyPress)
(exwm-input--update-mode-line, exwm-input-toggle-keyboard): Use
`exwm--input-mode' variable directly.
2018-10-21 12:00:00 +00:00
Chris Feng
5c9fcc0cd4 Merge branch 'medranocalvo/fix-minibuffer-only-focus-jump' into externals/exwm 2018-10-14 00:00:00 +00:00
Adrián Medraño Calvo
57d0e9e1d3 Support binding mouse events in line-mode
* exwm-input.el (exwm-input--event-passthrough-p): Predicate
checking whether an event should be forwarded to Emacs.
(exwm-input--on-KeyPress-line-mode): Use it.
* exwm-input.el (exwm-input--cache-event): Protect against
translations swallow the event.
* exwm-input.el (exwm-input--on-ButtonPress-line-mode)
(exwm-input--on-ButtonPress-char-mode): New functions.
(exwm-input--on-ButtonPress): Forward bound mouse events to Emacs
when in line-mode.
2018-10-08 12:00:00 +00:00
Adrián Medraño Calvo
c9984ca216 Fix focus jumps with minibuffer-only frames
* exwm-input.el (exwm-input--update-focus): Focus the minibuffer's
frame, which is different than that of the
`minibuffer-selected-window' on minibuffer-only frames.
(exwm-input--on-minibuffer-setup, exwm-input--init)
(exwm-input-exit): Remove unneeded function.
2018-10-08 12:00:00 +00:00
Adrián Medraño Calvo
dff1ef6a3c 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.
2018-10-08 12:00:00 +00:00
Chris Feng
b6a3b7b3ad ; Unimportant tweaks 2018-08-19 00:00:00 +00:00
Adrián Medraño Calvo
33dec8d1a3 Trace more functions 2018-08-13 12:00:00 +00:00
Chris Feng
f45e9b9273 Fix XTerm crash on startup
* exwm-input.el (exwm-input--set-focus): Applications like XTerm
crashes on receiving WM_TAKE_FOCUS so only send it to X windows
accepting it.
2018-07-15 00:00:00 +08:00
Chris Feng
bc5f0b3ffa ; Use `derived-mode-p'. 2018-07-15 00:00:00 +08:00
Chris Feng
6be729847e Also send a WM_TAKE_FOCUS when setting focus with SetInputFocus
* exwm-input.el (exwm-input--set-focus): Send an extra WM_TAKE_FOCUS
event to workaround the key replay issue with Xorg 1.20 when keyboard
is grabbed.
2018-07-15 00:00:00 +08:00
Chris Feng
4bb2d87a8d Revert "Grab & Replay key events with XI2 and XTEST"
This reverts commit 0680be104f.
2018-07-15 00:00:00 +08:00
Chris Feng
0680be104f Grab & Replay key events with XI2 and XTEST
; A change has been made in Xorg server 1.20 that replaying a key
; event with keyboard grabbed would generate extra focus change and
; enter/leave events.  This basically breaks line-mode for apps like
; Firefox.  This commit reimplements the grab & replay functionality
; with XI2 and XTEST.

* exwm-input.el (exwm-input--devices): New variable for caching slave
keyboards.
(exwm-input--update-devices): Update it and re-grab keys if necessary.
(exwm-input--on-Hierarchy): Event listener for the Hierarchy event
that would in turn call `exwm-input--update-devices' to update the
cache.

* exwm-input.el (exwm-input--on-KeyPress): Use XI2 KeyPress events.
(exwm-input--on-KeyRelease): Event listener for the KeyRelease events.
(exwm-input--grab-global-prefix-keys): Use XI2 and also select
KeyRelease events.
(exwm-input--on-KeyPress-line-mode): Use XI2 KeyPress events and
replay key events with XTEST.
(exwm-input--on-KeyPress-char-mode, exwm-input--grab-keyboard)
(exwm-input--release-keyboard): Use XI2 KeyPress events.

* exwm-input.el (exwm-input--init): Initialize the XI2 and XTEST
extensions; add listeners for XI2 KeyPress, KeyRelease and Hierarchy
events.
2018-06-18 22:33:38 +08:00
Chris Feng
fbdcd42b0a Add support for various key processing variables
* exwm-input.el (exwm-input--mimic-read-event): New function for
handling `extra-keyboard-modifiers' and `keyboard-translate-table'.
(exwm-input--cache-event): Do not unread events here.
(exwm-input--on-KeyPress-line-mode)
(exwm-input--on-KeyPress-char-mode): Compare with preprocessed events
and unread raw ones.

* exwm-input.el (exwm-input--on-KeyPress-line-mode): Add support for
`overriding-terminal-local-map'.
2018-04-01 23:30:19 +08:00
Chris Feng
10eb27eddc Fix local simulation keys
* exwm-input.el (exwm-input--on-KeyPress-line-mode): Do not test
`exwm-mode-map' to see if a key should be forwarded to Emacs as it's
overridden when local simulation keys are present.
2018-03-23 23:55:28 +08:00
Chris Feng
02b1be7160 Avoid entering line-mode after exit minibuffer
* exwm-input.el (exwm-input--on-pre-command): Keys should be forwarded
to the X window (if its Emacs window is currently selected) after
exiting the minibuffer.
2018-03-23 23:53:05 +08:00
Chris Feng
3f6c609a2b Fix regressions
(exwm-init): Do not signal an error on startup.

* exwm-floating.el (exwm-floating-toggle-floating):
* exwm-input (exwm-input-send-next-key)
(exwm-input-send-simulation-key):
* exwm-layout (exwm-layout-set-fullscreen)
(exwm-layout-unset-fullscreen, exwm-layout-toggle-fullscreen): Fix
incorrect use of `cl-return-from'.
2018-03-10 17:28:43 +08:00
Chris Feng
2f430db735 Minor fixes 2018-03-09 01:06:39 +08:00
Adrián Medraño Calvo
cf98e3d921 Name all helper windows created by EXWM
* exwm-workspace.el (exwm-workspace--add-frame-as-workspace)
(exwm-workspace--init):
* exwm-input.el (exwm-input--init):
* exwm-floating.el (exwm-floating--set-floating): Name created
helper windows with prefix "EXWM".
2018-03-06 00:00:00 +00:00