From 182ffbed6c7334ee51cb5cd2645ba0ee42c4da13 Mon Sep 17 00:00:00 2001 From: Matt Beshara Date: Mon, 6 Sep 2021 14:46:16 +1000 Subject: [PATCH 1/3] =?UTF-8?q?Use=20a=20hash=20table=20to=20cache=20resul?= =?UTF-8?q?t=20of=20=E2=80=98exwm-workspace--client-p=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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'. --- exwm-workspace.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/exwm-workspace.el b/exwm-workspace.el index cff17f3..c1de5da 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -165,10 +165,19 @@ NIL if FRAME is not a workspace" "Return t if FRAME is a workspace." (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) "Return non-nil if FRAME is an emacsclient frame." - (or (frame-parameter frame 'client) - (not (display-graphic-p frame)))) + (let* ((frame (or frame (selected-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 "Keymap used for interactively selecting workspace.") From 8905e85d34082e6a0a175edc9954eb2d8d0e1473 Mon Sep 17 00:00:00 2001 From: Matt Beshara Date: Wed, 15 Sep 2021 12:49:49 +1000 Subject: [PATCH 2/3] =?UTF-8?q?Rename=20variable=20using=20=E2=80=98exwm-w?= =?UTF-8?q?orkspace=E2=80=99=20package=20prefix;=20add=20docstring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * exwm-workspace.el (exwm-workspace--client-p-hash-table): Rename `exwm--client-p-hash-table'. --- exwm-workspace.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exwm-workspace.el b/exwm-workspace.el index c1de5da..ddf20ea 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -165,18 +165,20 @@ NIL if FRAME is not a workspace" "Return t if FRAME is a workspace." (memq frame exwm-workspace--list)) -(defvar exwm--client-p-hash-table - (make-hash-table :test 'eq :weakness 'key)) +(defvar exwm-workspace--client-p-hash-table + (make-hash-table :test 'eq :weakness 'key) + "Used to cache the results of calling ‘exwm-workspace--client-p’.") (defsubst exwm-workspace--client-p (&optional frame) "Return non-nil if FRAME is an emacsclient frame." (let* ((frame (or frame (selected-frame))) - (cached-value (gethash frame exwm--client-p-hash-table 'absent))) + (cached-value + (gethash frame exwm-workspace--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) + exwm-workspace--client-p-hash-table) cached-value))) (defvar exwm-workspace--switch-map nil From d0b0b38c8709c9d429b3697aea30814717d802d7 Mon Sep 17 00:00:00 2001 From: Matt Beshara Date: Sat, 2 Oct 2021 14:28:18 +1000 Subject: [PATCH 3/3] Explicitly remove workspace frames from client-p cache when deleted * exwm-workspace.el (exwm-workspace--on-delete-frame): Clean up hash table entries upon removing a workspace. --- exwm-workspace.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exwm-workspace.el b/exwm-workspace.el index ddf20ea..996d33f 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -1469,7 +1469,8 @@ the next workspace." ;; care of converting a workspace into a regular unmanaged frame. (let ((exwm-workspace--create-silently t)) (make-frame))) - (exwm-workspace--remove-frame-as-workspace frame)))) + (exwm-workspace--remove-frame-as-workspace frame) + (remhash frame exwm--client-p-hash-table)))) (defun exwm-workspace--on-after-make-frame (frame) "Hook run upon `make-frame' that configures FRAME as a workspace."