mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-23 19:47:58 +01:00
Add toggle commands
* exwm-input.el (exwm-input-toggle-keyboard): New command for toggling keyboard mode. * exwm-layout.el (exwm-layout-toggle-fullscreen): New command for toggling fullscreen mode. * exwm-core.el (exwm-mode-menu, exwm-mode-map): Use them.
This commit is contained in:
parent
cb75d4814d
commit
a913621302
3 changed files with 22 additions and 8 deletions
10
exwm-core.el
10
exwm-core.el
|
@ -150,10 +150,7 @@
|
||||||
"*General*"
|
"*General*"
|
||||||
"---"
|
"---"
|
||||||
["Toggle floating" exwm-floating-toggle-floating]
|
["Toggle floating" exwm-floating-toggle-floating]
|
||||||
["Enter fullscreen" exwm-layout-set-fullscreen
|
["Toggle fullscreen mode" exwm-layout-toggle-fullscreen]
|
||||||
(null (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))]
|
|
||||||
["Leave fullscreen" exwm-reset
|
|
||||||
(memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)]
|
|
||||||
["Hide window" exwm-floating-hide exwm--floating-frame]
|
["Hide window" exwm-floating-hide exwm--floating-frame]
|
||||||
|
|
||||||
"---"
|
"---"
|
||||||
|
@ -168,10 +165,7 @@
|
||||||
"---"
|
"---"
|
||||||
"*Keyboard*"
|
"*Keyboard*"
|
||||||
"---"
|
"---"
|
||||||
["Capture keyboard" exwm-input-release-keyboard exwm--keyboard-grabbed]
|
["Toggle keyboard mode" exwm-input-toggle-keyboard]
|
||||||
;; It's recommended to use `exwm-reset' rather than
|
|
||||||
;; `exwm-input-grab-keyboard' to release keyboard (enter line-mode).
|
|
||||||
["Release keyboard" exwm-reset (not exwm--keyboard-grabbed)]
|
|
||||||
["Send key" exwm-input-send-next-key exwm--keyboard-grabbed]
|
["Send key" exwm-input-send-next-key exwm--keyboard-grabbed]
|
||||||
;; This is merely a reference.
|
;; This is merely a reference.
|
||||||
("Send simulation key" :filter
|
("Send simulation key" :filter
|
||||||
|
|
|
@ -567,6 +567,16 @@ This value should always be overwritten.")
|
||||||
(exwm-input--update-mode-line id)
|
(exwm-input--update-mode-line id)
|
||||||
(force-mode-line-update))))
|
(force-mode-line-update))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun exwm-input-toggle-keyboard (&optional id)
|
||||||
|
"Toggle between 'line-mode' and 'char-mode'."
|
||||||
|
(interactive (list (exwm--buffer->id (window-buffer))))
|
||||||
|
(when id
|
||||||
|
(with-current-buffer (exwm--id->buffer id)
|
||||||
|
(if exwm--keyboard-grabbed
|
||||||
|
(exwm-input-release-keyboard id)
|
||||||
|
(exwm-reset)))))
|
||||||
|
|
||||||
(defun exwm-input--fake-key (event)
|
(defun exwm-input--fake-key (event)
|
||||||
"Fake a key event equivalent to Emacs event EVENT."
|
"Fake a key event equivalent to Emacs event EVENT."
|
||||||
(let* ((keysym (xcb:keysyms:event->keysym exwm--connection event))
|
(let* ((keysym (xcb:keysyms:event->keysym exwm--connection event))
|
||||||
|
|
|
@ -260,6 +260,16 @@
|
||||||
(delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))
|
(delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))
|
||||||
(call-interactively #'exwm-input-grab-keyboard)))
|
(call-interactively #'exwm-input-grab-keyboard)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun exwm-layout-toggle-fullscreen (&optional id)
|
||||||
|
"Toggle fullscreen mode."
|
||||||
|
(interactive (list (exwm--buffer->id (window-buffer))))
|
||||||
|
(when id
|
||||||
|
(with-current-buffer (exwm--id->buffer id)
|
||||||
|
(if (memq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state)
|
||||||
|
(exwm-reset)
|
||||||
|
(exwm-layout-set-fullscreen id)))))
|
||||||
|
|
||||||
(defvar exwm-layout--other-buffer-exclude-exwm-mode-buffers nil
|
(defvar exwm-layout--other-buffer-exclude-exwm-mode-buffers nil
|
||||||
"When non-nil, prevent EXWM buffers from being selected by `other-buffer'.")
|
"When non-nil, prevent EXWM buffers from being selected by `other-buffer'.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue