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:
Chris Feng 2016-08-24 19:21:17 +08:00
parent cb75d4814d
commit a913621302
3 changed files with 22 additions and 8 deletions

View file

@ -150,10 +150,7 @@
"*General*"
"---"
["Toggle floating" exwm-floating-toggle-floating]
["Enter fullscreen" exwm-layout-set-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)]
["Toggle fullscreen mode" exwm-layout-toggle-fullscreen]
["Hide window" exwm-floating-hide exwm--floating-frame]
"---"
@ -168,10 +165,7 @@
"---"
"*Keyboard*"
"---"
["Capture keyboard" exwm-input-release-keyboard exwm--keyboard-grabbed]
;; 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)]
["Toggle keyboard mode" exwm-input-toggle-keyboard]
["Send key" exwm-input-send-next-key exwm--keyboard-grabbed]
;; This is merely a reference.
("Send simulation key" :filter

View file

@ -567,6 +567,16 @@ This value should always be overwritten.")
(exwm-input--update-mode-line id)
(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)
"Fake a key event equivalent to Emacs event EVENT."
(let* ((keysym (xcb:keysyms:event->keysym exwm--connection event))

View file

@ -260,6 +260,16 @@
(delq xcb:Atom:_NET_WM_STATE_FULLSCREEN exwm--ewmh-state))
(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
"When non-nil, prevent EXWM buffers from being selected by `other-buffer'.")