emacs-exwm / exwm

Emacs X Window Manager
https://elpa.gnu.org/packages/exwm.html
GNU General Public License v3.0
270 stars 14 forks source link

Add an `exwm-input-modifiers` setting #40

Open Stebalien opened 5 months ago

Stebalien commented 5 months ago

Right now, it's possible to instruct EXWM to intercept specific keys and key-combo prefixes via exwm-input-prefix-keys. However, there's no way to instruct EXWM to intercept all key combos including a specific modifier (e.g., super). This could be useful as most applications avoid binding super, leaving it for the window manager (in this case, EXWM).

Stebalien commented 5 months ago

Note: right current the right way to handle this is to bind keys in exwm-input-global-keys. That will bind these keys:

  1. Only when EXWM is active.
  2. In both line and char mode.

IMO, a better alternative to an exwm-input-modifiers is to replace exwm-input-global-keys with a key map, asking users to bind their window management keys in that map instead.

minad commented 5 months ago

Yes, this would be great to have, both the keymap-based approach and the ability to reserve modifiers. I use super exclusively for global bindings. In my config I loop over the global-map and tab-bar-map, to extract all super keys and add them to exwm-input-prefix-keys.

Stebalien commented 5 months ago

I agree, both would be nice.

Personally, I defined a desktop-environment-mode minor mode with a desktop-environment-mode-map:

(define-minor-mode desktop-environment-mode
  "A global minor-mode that binds DE keys."
  :global t
  :group 'bindings
  :keymap (make-sparse-keymap))

Then set it as the parent map for exwm-mode-map:

(set-keymap-parent exwm-mode-map desktop-environment-mode-map)

That way I get these keys in both non-EXWM buffers and EXWM buffers. Ideally we'd do this as an exwm-minor-mode (https://github.com/ch11ng/exwm/pull/868).

minad commented 5 months ago

Oh, this is a great idea. I didn't know that this would work, but makes sense of course. We should definitely clean up the EXWM key map infrastructure such that it is more aligned with Emacs expectations.