diff --git a/heart/include/hrt/hrt_view.h b/heart/include/hrt/hrt_view.h index 4c660e9..93b4220 100644 --- a/heart/include/hrt/hrt_view.h +++ b/heart/include/hrt/hrt_view.h @@ -65,4 +65,10 @@ void hrt_view_focus(struct hrt_view *view, struct hrt_seat *seat); **/ void hrt_view_unfocus(struct hrt_view *view, struct hrt_seat *seat); +/** + * Stop the given view from being displayed + **/ +void hrt_view_set_hidden(struct hrt_view *view, bool hidden); + + #endif diff --git a/heart/src/view.c b/heart/src/view.c index c3261a9..bb73856 100644 --- a/heart/src/view.c +++ b/heart/src/view.c @@ -69,3 +69,7 @@ void hrt_view_unfocus(struct hrt_view *view, struct hrt_seat *seat) { wlr_xdg_toplevel_set_activated(toplevel, false); wlr_seat_keyboard_notify_clear_focus(seat->seat); } + +void hrt_view_set_hidden(struct hrt_view *view, bool hidden) { + wlr_scene_node_set_enabled(&view->scene_tree->node, !hidden); +} diff --git a/lisp/bindings/hrt-bindings.lisp b/lisp/bindings/hrt-bindings.lisp index 4e62585..0d672cf 100644 --- a/lisp/bindings/hrt-bindings.lisp +++ b/lisp/bindings/hrt-bindings.lisp @@ -127,6 +127,11 @@ it visible to the user." (view (:pointer (:struct hrt-view))) (seat (:pointer (:struct hrt-seat)))) +(cffi:defcfun ("hrt_view_set_hidden" hrt-view-set-hidden) :void + "Stop the given view from being displayed" + (view (:pointer (:struct hrt-view))) + (hidden :bool)) + ;; next section imported from file build/include/hrt/hrt_output.h (cffi:defcstruct hrt-output diff --git a/lisp/bindings/package.lisp b/lisp/bindings/package.lisp index 5b997e1..426a0de 100644 --- a/lisp/bindings/package.lisp +++ b/lisp/bindings/package.lisp @@ -28,6 +28,7 @@ #:view-hrt-view #:focus-view #:unfocus-view + #:view-set-hidden ;; seat callbacks #:button-event #:wheel-event #:keyboard-keypress-event #:hrt-server diff --git a/lisp/bindings/wrappers.lisp b/lisp/bindings/wrappers.lisp index 277f80e..62cae44 100644 --- a/lisp/bindings/wrappers.lisp +++ b/lisp/bindings/wrappers.lisp @@ -34,6 +34,12 @@ (declare (type view view)) (hrt-view-unfocus (view-hrt-view view) seat)) +(declaim (inline view-set-hidden)) +(defun view-set-hidden (view hidden) + (declare (type view view) + (type boolean hidden)) + (hrt-view-set-hidden (view-hrt-view view) hidden)) + (defmethod mh/interface:set-dimensions ((view view) width height) (hrt-view-set-size (view-hrt-view view) width height)) diff --git a/lisp/group.lisp b/lisp/group.lisp index 4b99bb6..e7f653c 100644 --- a/lisp/group.lisp +++ b/lisp/group.lisp @@ -62,6 +62,27 @@ to match." (when (and (mahogany-group-current-frame group) (= 0 (hash-table-count output-map))) (group-unfocus-frame group (mahogany-group-current-frame group) seat))))) +(defun %add-hidden (hidden-list view) + (ring-list:add-item hidden-list view) + (hrt:view-set-hidden view t)) + +(defun %swap-next-hidden (hidden-list view) + (let ((swapped (ring-list:swap-next hidden-list view))) + (hrt:view-set-hidden view t) + (hrt:view-set-hidden swapped nil) + swapped)) + +(defun %swap-prev-hidden (hidden-list view) + (let ((swapped (ring-list:swap-previous hidden-list view))) + (hrt:view-set-hidden view t) + (hrt:view-set-hidden swapped nil) + swapped)) + +(defun %pop-hidden-item (hidden-list) + (alexandria:when-let ((popped (ring-list:pop-item hidden-list))) + (hrt:view-set-hidden popped nil) + popped)) + (defun group-add-view (group view) (declare (type mahogany-group group) (type hrt:view view)) @@ -72,7 +93,7 @@ to match." (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)) + (%add-hidden hidden view)) (setf (tree:frame-view current-frame) view)))) (defun group-remove-view (group view) @@ -87,7 +108,7 @@ to match." (dolist (f (mahogany/tree:get-populated-frames (mahogany/tree:root-tree container))) (when (equalp (tree:frame-view f) view) (setf (tree:frame-view f) nil) - (alexandria:when-let ((new-view (ring-list:pop-item hidden))) + (alexandria:when-let ((new-view (%pop-hidden-item hidden))) (setf (tree:frame-view f) new-view))))) output-map) (ring-list:remove-item hidden view) @@ -111,8 +132,8 @@ currently focused frame" (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)))) + (alexandria:when-let ((view (tree:frame-view view-frame))) + (%add-hidden (mahogany-group-hidden-views group) view)))) (tree:replace-frame tree-root current-frame #'hide-and-disable)))) (defun group-next-hidden (group) @@ -122,8 +143,8 @@ currently focused frame" (next-view)) (when (> (ring-list:ring-list-size hidden-views) 0) (alexandria:if-let ((view (tree:frame-view current-frame))) - (setf next-view (ring-list:swap-next hidden-views view)) - (setf next-view (ring-list:pop-item hidden-views))) + (setf next-view (%swap-next-hidden hidden-views view)) + (setf next-view (%pop-hidden-item hidden-views))) (setf (tree:frame-view current-frame) next-view)))) (defun group-previous-hidden (group) @@ -133,6 +154,6 @@ currently focused frame" (next-view)) (when (> (ring-list:ring-list-size hidden-views) 0) (alexandria:if-let ((view (tree:frame-view current-frame))) - (setf next-view (ring-list:swap-previous hidden-views view)) - (setf next-view (ring-list:pop-item-prev hidden-views))) + (setf next-view (%swap-prev-hidden hidden-views view)) + (setf next-view (%pop-hidden-item hidden-views))) (setf (tree:frame-view current-frame) next-view))))