Skip to content

Commit

Permalink
Implement maximize-current-frame keybinding
Browse files Browse the repository at this point in the history
This keybinding removes all the splits in a tree container and
replaces the frame(s) with the current one.
  • Loading branch information
sdilts committed Nov 6, 2024
1 parent 1f2babb commit 343fb19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lisp/group.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
6 changes: 6 additions & 0 deletions lisp/key-bindings.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@
(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
(kbd "q") #'handle-server-stop
(kbd "c") #'open-terminal
(kbd "s") #'split-frame-v
(kbd "S") #'split-frame-h
(kbd "Q") #'maximize-current-frame
(kbd "+") #'open-kcalc))))

0 comments on commit 343fb19

Please sign in to comment.