Skip to content

Commit

Permalink
transient--display-action: Pre-calculate frame dimensions
Browse files Browse the repository at this point in the history
When displaying the transient menu in a dedicated frame, calculate
the approximate dimensions beforehand to avoid potentially massive
flickering due to resizing and to improve placement.
  • Loading branch information
tarsius committed Dec 12, 2024
1 parent de98430 commit c651e9c
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -3948,13 +3948,23 @@ have a history of their own.")
(transient--fit-window-to-buffer transient--window)))))

(defun transient--display-action ()
(cond ((oref transient--prefix display-action))
((memq 'display-buffer-full-frame
(ensure-list (car transient-display-buffer-action)))
(user-error "%s disallowed in %s"
'display-buffer-full-frame
'transient-display-buffer-action))
(transient-display-buffer-action)))
(let ((action
(cond ((oref transient--prefix display-action))
((memq 'display-buffer-full-frame
(ensure-list (car transient-display-buffer-action)))
(user-error "%s disallowed in %s"
'display-buffer-full-frame
'transient-display-buffer-action))
(transient-display-buffer-action))))
(when (assq 'pop-up-frame-parameters (cdr action))
(setq action (copy-tree action))
(pcase-let ((`(,height ,width)
(buffer-line-statistics transient--buffer))
(params (assq 'pop-up-frame-parameters (cdr action))))
(setf (alist-get 'height params) height)
(setf (alist-get 'width params)
(max width (or transient-minimal-frame-width 0)))))
action))

(defun transient--fit-window-to-buffer (window)
(set-window-parameter window 'window-preserved-size nil)
Expand Down

0 comments on commit c651e9c

Please sign in to comment.