From 2b5a1277a5270613d0e8bcada8327ba564135157 Mon Sep 17 00:00:00 2001 From: Stuart Dilts Date: Wed, 6 Nov 2024 11:54:54 -0700 Subject: [PATCH] Maitain a collection of "hidden" views Put the non-visible views in the new ring-list data structure so we can pull them out in the correct order. Use this to restore the most recently hidden view when a view is removed / closed. --- lisp/group.lisp | 14 ++++++++++---- lisp/objects.lisp | 1 + mahogany.asd | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/group.lisp b/lisp/group.lisp index 1733fd7..20691b8 100644 --- a/lisp/group.lisp +++ b/lisp/group.lisp @@ -66,25 +66,31 @@ to match." (declare (type mahogany-group group) (type hrt:view view)) (with-accessors ((views mahogany-group-views) - (outputs mahogany-group-output-map)) + (outputs mahogany-group-output-map) + (hidden mahogany-group-hidden-views)) group (push view (mahogany-group-views group)) (alexandria:when-let ((current-frame (mahogany-group-current-frame group))) + (alexandria:when-let ((view (tree:frame-view current-frame))) + (ring-list:add-item hidden view)) (setf (tree:frame-view current-frame) view)))) (defun group-remove-view (group view) (declare (type mahogany-group group)) (with-accessors ((view-list mahogany-group-views) - (output-map mahogany-group-output-map)) + (output-map mahogany-group-output-map) + (hidden mahogany-group-hidden-views)) group (maphash (lambda (key container) (declare (ignore key)) ;; OPTIMIZE ME: get-pouplated frames builds a list, we could use an iterator instead. (dolist (f (mahogany/tree:get-populated-frames (mahogany/tree:root-tree container))) (when (equalp (tree:frame-view f) view) - (log-string :trace "Removing view from frame") - (setf (tree:frame-view f) nil)))) + (setf (tree:frame-view f) nil) + (alexandria:when-let ((new-view (ring-list:pop-item hidden))) + (setf (tree:frame-view f) new-view))))) output-map) + (ring-list:remove-item hidden view) (setf view-list (remove view view-list :test #'equalp)))) (defmethod tree:find-empty-frame ((group mahogany-group)) diff --git a/lisp/objects.lisp b/lisp/objects.lisp index feaf306..ac6d69c 100644 --- a/lisp/objects.lisp +++ b/lisp/objects.lisp @@ -9,6 +9,7 @@ (number 1 :type fixnum :read-only t) (output-map (make-hash-table :test 'equal) :type hash-table :read-only t) (current-frame nil :type (or tree:frame null)) + (hidden-views (ring-list:make-ring-list) :type ring-list:ring-list) (views nil :type list)) (defclass mahogany-state () diff --git a/mahogany.asd b/mahogany.asd index ee0e2dd..2e7e825 100644 --- a/mahogany.asd +++ b/mahogany.asd @@ -43,7 +43,7 @@ (:file "frame" :depends-on ("tree-interface")) (:file "view" :depends-on ("tree-interface")))) (:file "package") - (:file "objects" :depends-on ("package")) + (:file "objects" :depends-on ("package" "ring-list")) (:file "group" :depends-on ("objects" "bindings")) (:file "state" :depends-on ("objects" "keyboard")) (:file "globals" :depends-on ("state" "objects" "system"))