mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-12-03 17:38:00 +01:00
Use a hash table to cache result of ‘exwm-workspace--client-p’
* exwm-workspace.el (exwm--client-p-hash-table): New variable. (exwm-workspace--client-p): Use `exwm--client-p-hash-table' to store which workspace frames are client frames instead of frequently invoking `frame-parameter'.
This commit is contained in:
parent
1863361674
commit
182ffbed6c
1 changed files with 11 additions and 2 deletions
|
@ -165,10 +165,19 @@ NIL if FRAME is not a workspace"
|
||||||
"Return t if FRAME is a workspace."
|
"Return t if FRAME is a workspace."
|
||||||
(memq frame exwm-workspace--list))
|
(memq frame exwm-workspace--list))
|
||||||
|
|
||||||
|
(defvar exwm--client-p-hash-table
|
||||||
|
(make-hash-table :test 'eq :weakness 'key))
|
||||||
|
|
||||||
(defsubst exwm-workspace--client-p (&optional frame)
|
(defsubst exwm-workspace--client-p (&optional frame)
|
||||||
"Return non-nil if FRAME is an emacsclient frame."
|
"Return non-nil if FRAME is an emacsclient frame."
|
||||||
(or (frame-parameter frame 'client)
|
(let* ((frame (or frame (selected-frame)))
|
||||||
(not (display-graphic-p frame))))
|
(cached-value (gethash frame exwm--client-p-hash-table 'absent)))
|
||||||
|
(if (eq cached-value 'absent)
|
||||||
|
(puthash frame
|
||||||
|
(or (frame-parameter frame 'client)
|
||||||
|
(not (display-graphic-p frame)))
|
||||||
|
exwm--client-p-hash-table)
|
||||||
|
cached-value)))
|
||||||
|
|
||||||
(defvar exwm-workspace--switch-map nil
|
(defvar exwm-workspace--switch-map nil
|
||||||
"Keymap used for interactively selecting workspace.")
|
"Keymap used for interactively selecting workspace.")
|
||||||
|
|
Loading…
Reference in a new issue