Commit graph

167 commits

Author SHA1 Message Date
Adrián Medraño Calvo
612e64bf9b Update copyright year to 2023 2023-08-18 00:00:00 +00:00
Adrián Medraño Calvo
d8fcf18db7 Declare defsubst indentation
* exwm-core.el (exwm--id->buffer, exwm--buffer->id, exwm--terminal-p):
* exwm-input.el (exwm-input--unread-event):
* exwm-workspace.el (exwm-workspace--position)
(exwm-workspace--workspace-p): Declare indentation.
2023-08-18 00:00:00 +00:00
Adrián Medraño Calvo
b100eb74c5 Merge branch 'nbarrientos.github.com/ib_exwm_conn_nil' into externals/exwm 2023-06-14 00:00:00 +00:00
Adrián Medraño Calvo
7318f857f2 Observe connection status on deinitialization
* exwm-workspace.el (exwm-workspace--remove-frame-as-workspace):
Add optional argument quit.

* exwm-background.el (exwm-background--exit):
* exwm-input.el (exwm-input--exit):
* exwm-manage.el (exwm-manage--unmanage-window):
* exwm-systemtray.el (exwm-systemtray--exit):
* exwm-workspace.el (exwm-workspace--exit-minibuffer-frame)
(exwm-workspace--exit):
* exwm-xim.el (exwm-xim--exit): Observe connection status when
deinitializing in order to support deinitializing when the
connection breaks.
2023-06-09 00:00:00 +00:00
Nacho Barrientos
4d5b0e81cd Make sure the buffer that generates the event is current
* exwm-input.el (exwm-input--on-ButtonPress): Set current buffer
when running pre- and post-command hooks.
2023-06-09 00:00:00 +00:00
Nacho Barrientos
cff02333e2 Don't assume that exwm--connection is non-nil
`exwm-input--exit` could be called (via `exwm-exit`) from `exwm-init`
in case of error when initialising EXWM. It could happen that the bit
that failed when exwm-init is executed was the call to `xcb:connect`,
hence `exwm--connection` would be nil when errors are handled (and
`exwm-exit` is called).

Without this patch, in the case above, the user will see a crash as
there's no method allowing a nil XCB connection object:

  Debugger entered--Lisp error:
  (cl-no-applicable-method xcb:-+request nil #<xcb:SetInputFocus ...

even worse, not even giving the chance to the `warn` call in
`exwm-init`'s error handler to actually inform the user about the
actual problem ("[XELB] Connection timeout", for instance).

* exwm-input.el (exwm-input--exit): Check `exwm--connection' is
set before trying to send requests.
2023-06-09 00:00:00 +00:00
Adrián Medraño Calvo
d6f62ff55a Check EXWM terminal instead of client or graphical frames
* exwm-core.el (exwm--terminal-p): Add function.
* exwm.el (exwm--confirm-kill-terminal): Use it.
* exwm-input.el (exwm-input--on-buffer-list-update): Use it.
(exwm-input--on-minibuffer-setup)
(exwm-input--on-minibuffer-exit): Use it.
(exwm-input--on-minibuffer-exit): Use the minibuffer's selected
window's frame or selected frame instead of current workspace.
(exwm-input--on-echo-area-dirty): Removed test, as it's checked in
`exwm-input--on-minibuffer-setup'.
* exwm-layout.el (exwm-layout--on-minibuffer-setup)
(exwm-layout--on-echo-area-change): Use it.
(exwm-layout--on-echo-area-change): Refresh layout the
frame of selected window's minibuffer if it's an EXWM frame.
* exwm-workspace.el (exwm-workspace--update-minibuffer-height)
(exwm-workspace--on-minibuffer-setup)
(exwm-workspace--on-minibuffer-exit)
(exwm-workspace--on-echo-area-dirty)
(exwm-workspace--on-echo-area-clear)
(exwm-workspace--on-delete-frame): Use it.
* exwm-workspace.el (exwm-workspace--client-p-hash-table): Remove
variable.
(exwm-workspace--client-p): Remove function.
2022-02-01 00:00:00 +00:00
Adrián Medraño Calvo
c1206ac665 Update copyright year to 2021 2021-10-29 00:00:00 +00:00
Chris Feng
0368127976 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.
2020-07-12 00:00:00 +00:00
Adrián Medraño Calvo
ce2625d050 Run hook upon input mode change
* exwm-input.el (exwm-input-input-mode-change-hook): Add new hook
	for code to run upon input mode change.
	(exwm-input--grab-keyboard, exwm-input--release-keyboard): Run it.
2020-05-06 00:00:00 +00:00
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