Skip to content

Commit

Permalink
fix: mini-frame is slow in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kiennq committed Apr 27, 2020
1 parent 3aa8de5 commit e4fc024
Showing 1 changed file with 41 additions and 26 deletions.
67 changes: 41 additions & 26 deletions mini-frame.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

;;; Code:

(eval-when-compile
(require 'cl-lib))

(defgroup mini-frame nil
"Show minibuffer in child frame."
:group 'minibuffer)
Expand Down Expand Up @@ -209,7 +212,8 @@ ALIST is passed to `window--display-buffer'."
(minibuffer . nil)
(undecorated . t)
(internal-border-width . 3)
(drag-internal-border . t))
(drag-internal-border . t)
(z-group . above))
parent-frame-parameters
show-parameters)))
(set-face-background 'fringe nil mini-frame-completions-frame))
Expand Down Expand Up @@ -237,26 +241,26 @@ ALIST is passed to `window--display-buffer'."
(unless selected-is-mini-frame
(setq mini-frame-selected-frame selected-frame)
(modify-frame-parameters mini-frame-frame parent-frame-parameters))
(progn
(setq mini-frame-selected-frame selected-frame)
(setq mini-frame-frame
(make-frame (append '((visibility . nil)
(minibuffer . only)
(undecorated . t)
(keep-ratio . t)
(user-position . t)
(user-size . t)
(internal-border-width . 3)
(drag-internal-border . t))
parent-frame-parameters
show-parameters)))
(set-face-background 'fringe nil mini-frame-frame)))
(setq mini-frame-selected-frame selected-frame)
(setq mini-frame-frame
(make-frame (append '((visibility . nil)
(minibuffer . only)
(undecorated . t)
(keep-ratio . t)
(user-position . t)
(user-size . t)
(internal-border-width . 3)
(drag-internal-border . t)
(z-group . above))
parent-frame-parameters
show-parameters)))
(set-face-background 'fringe nil mini-frame-frame))
(modify-frame-parameters mini-frame-frame show-parameters)
(when (and (frame-live-p mini-frame-completions-frame)
(frame-visible-p mini-frame-completions-frame))
(make-frame-invisible mini-frame-completions-frame))
(make-frame-visible mini-frame-frame)
(select-frame-set-input-focus mini-frame-frame)
(select-frame-set-input-focus mini-frame-frame 'norecord)
(setq default-directory dd)
(apply fn args)))

Expand All @@ -283,10 +287,11 @@ ALIST is passed to `window--display-buffer'."
(eq ignored-command this-command))
(throw 'ignored t)))))
(apply fn args))
((and (frame-live-p mini-frame-frame)
(frame-visible-p mini-frame-frame))
(mini-frame--display fn args))
(t
(when (and (frame-live-p mini-frame-frame)
(frame-visible-p mini-frame-frame)
(eq system-type 'windows-nt))
(make-frame-invisible mini-frame-frame))
(let ((after-make-frame-functions nil)
(resize-mini-frames (when mini-frame-resize
#'mini-frame--resize-mini-frame))
Expand All @@ -311,14 +316,24 @@ ALIST is passed to `window--display-buffer'."
(unwind-protect
(mini-frame--display fn args)
(when (frame-live-p mini-frame-completions-frame)
(make-frame-invisible mini-frame-completions-frame))
(when (frame-live-p mini-frame-selected-frame)
(select-frame-set-input-focus mini-frame-selected-frame))
(make-frame-invisible mini-frame-completions-frame)
(modify-frame-parameters mini-frame-completions-frame '((parent-frame))))
(if (frame-live-p mini-frame-selected-frame)
(select-frame-set-input-focus mini-frame-selected-frame)
;; trying to find an alternate frame to return the focus
(when-let (fr (cl-find-if-not
(lambda (fr)
(or (equal fr mini-frame-completions-frame)
(equal fr mini-frame-frame)
(frame-parameter fr 'parent-frame)))
(frame-list)))
(select-frame-set-input-focus fr)))
(when (frame-live-p mini-frame-frame)
(if (eq system-type 'windows-nt)
;; FIXME sometime buffer is not visible on windows
(delete-frame mini-frame-frame)
(make-frame-invisible mini-frame-frame))))))))
;; (if (eq system-type 'windows-nt)
;; FIXME sometime buffer is not visible on windows
;; (delete-frame mini-frame-frame)
(make-frame-invisible mini-frame-frame)
(modify-frame-parameters mini-frame-frame '((parent-frame)))))))))

;;;###autoload
(define-minor-mode mini-frame-mode
Expand Down

0 comments on commit e4fc024

Please sign in to comment.