From e4c029ef4d6a8b52fbf742a5838664aa5bff6cda Mon Sep 17 00:00:00 2001 From: Stuart Dilts Date: Wed, 6 Nov 2024 11:58:37 -0700 Subject: [PATCH] Implement maximize-current-frame keybinding This keybinding removes all the splits in a tree container and replaces the frame(s) with the current one. --- lisp/group.lisp | 10 ++++++++++ lisp/key-bindings.lisp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/lisp/group.lisp b/lisp/group.lisp index 20691b8..2157e6f 100644 --- a/lisp/group.lisp +++ b/lisp/group.lisp @@ -102,3 +102,13 @@ to match." (alexandria:if-let ((view-frame (tree:find-empty-frame frame))) (return-from tree:find-empty-frame view-frame) (go :top))))))) + +(defun group-maximize-current-frame (group) + (declare (type mahogany-group group)) + (let* ((current-frame (mahogany-group-current-frame group)) + (container (mahogany/tree:find-frame-container current-frame)) + (tree-root (tree:root-tree container))) + (flet ((hide-and-disable (view-frame) + (alexandria:when-let (view (tree:frame-view view-frame)) + (ring-list:add-item (mahogany-group-hidden-views group) view)))) + (tree:replace-frame tree-root current-frame #'hide-and-disable)))) diff --git a/lisp/key-bindings.lisp b/lisp/key-bindings.lisp index a826ce7..16fe434 100644 --- a/lisp/key-bindings.lisp +++ b/lisp/key-bindings.lisp @@ -24,6 +24,11 @@ (when frame (tree:split-frame-v frame :direction :top)))) +(defun maximize-current-frame (sequence seat) + (declare (ignore sequence seat)) + (let ((group (mahogany-current-group *compositor-state*))) + (group-maximize-current-frame group))) + (setf (mahogany-state-keybindings *compositor-state*) (list (define-kmap (kbd "C-t") (define-kmap @@ -31,4 +36,5 @@ (kbd "c") #'open-terminal (kbd "s") #'split-frame-v (kbd "S") #'split-frame-h + (kbd "Q") #'maximize-current-frame (kbd "+") #'open-kcalc))))