exwm-layout-toggle-fullscreen: work non-interactively

Previous behavior required explicitly passing an ID when called from lisp
programs. New behavior attempts to set the ID to window-buffer when not
explicitly passed as an argument. A user-error is thrown if current-buffer has
no X window ID.

See: https://github.com/emacs-exwm/exwm/issues/60
This commit is contained in:
Nicholas Vollmer 2024-06-19 18:34:58 -04:00 committed by Steven Allen
parent 41d1e6c1c3
commit 94c9f369dd

View file

@ -245,17 +245,17 @@ See variable `exwm-layout-auto-iconify'."
(exwm-input--grab-keyboard exwm--id)))) (exwm-input--grab-keyboard exwm--id))))
;;;###autoload ;;;###autoload
(cl-defun exwm-layout-toggle-fullscreen (&optional id) (defun exwm-layout-toggle-fullscreen (&optional id)
"Toggle fullscreen mode of X window ID." "Toggle fullscreen mode of X window ID.
(interactive (list (exwm--buffer->id (window-buffer)))) If ID is non-nil, default to ID of `window-buffer'."
(exwm--log "id=#x%x" (or id 0)) (interactive)
(unless (or id (derived-mode-p 'exwm-mode)) (setq id (or id (exwm--buffer->id (current-buffer))
(cl-return-from exwm-layout-toggle-fullscreen)) (user-error "Current buffer has no X window ID")))
(when id (exwm--log "id=#x%x" id)
(with-current-buffer (exwm--id->buffer id) (with-current-buffer (exwm--id->buffer id)
(if (exwm-layout--fullscreen-p) (if (exwm-layout--fullscreen-p)
(exwm-layout-unset-fullscreen id) (exwm-layout-unset-fullscreen id)
(exwm-layout-set-fullscreen id))))) (exwm-layout-set-fullscreen id))))
(defun exwm-layout--other-buffer-predicate (buffer) (defun exwm-layout--other-buffer-predicate (buffer)
"Return non-nil when the BUFFER may be displayed in selected frame. "Return non-nil when the BUFFER may be displayed in selected frame.