mtl.el: enable on the hooked frame, defensively

mtl--maybe-enable-on-startup enabled the SELECTED frame instead of the
frame being created (mid-creation the new frame is not selected yet),
and an error there aborted frame creation: tooltip, child and TTY
frames must simply be skipped.  Use the hook's frame argument, guard on
display-graphic-p and swallow enable errors.

The application bundle now ships a site-start.el that turns the GPU
backend on by default (EMACS_GPU_DISABLE=1 reverts to the stock
backend); the bundle-build recipe adds it after make install.
This commit is contained in:
Andros Fenollosa 2026-06-04 20:23:25 +02:00
parent 226c5188b5
commit 35b5c6d093

View file

@ -301,12 +301,16 @@ at the end. One video per frame; a previous one is replaced."
;; ---------------------------------------------------------------------------
;; Startup integration
(defun mtl--maybe-enable-on-startup (&optional _frame)
"Enable Metal on the initial frame if `mtl-enable-on-startup' is set."
(defun mtl--maybe-enable-on-startup (&optional frame)
"Enable Metal on FRAME (or the selected frame) per `mtl-enable-on-startup'."
(when (and mtl-enable-on-startup
(fboundp 'mtl-backend-p)
(mtl-backend-p))
(mtl-enable (selected-frame))))
(let ((f (or frame (selected-frame))))
;; New frames pass through here mid-creation; tooltip/child/TTY
;; frames must not abort frame creation with an error.
(when (display-graphic-p f)
(ignore-errors (mtl-enable f))))))
(add-hook 'after-make-frame-functions #'mtl--maybe-enable-on-startup)