-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire up groups and outptu change events
- Loading branch information
Showing
13 changed files
with
150 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(in-package #:mahogany) | ||
|
||
|
||
|
||
(defun group-add-output (group output) | ||
(declare (type mahogany-output output) | ||
(type mahogany-group group)) | ||
(with-accessors ((output-map mahogany-group-output-map)) group | ||
(multiple-value-bind (x y) (hrt:output-position (mahogany-output-hrt-output output)) | ||
(multiple-value-bind (width height) (hrt:output-resolution (mahogany-output-hrt-output output)) | ||
(setf (gethash (mahogany-output-full-name output) output-map) | ||
(make-basic-tree :x x :y y :width width :height height)) | ||
(log-string :trace "Group map: ~S" output-map))))) | ||
|
||
(defun group-reconfigure-outputs (group outputs) | ||
"Re-examine where the outputs are and adjust the trees that are associated with them | ||
to match." | ||
(with-accessors ((output-map mahogany-group-output-map)) group | ||
(loop for mh-output across outputs | ||
do (with-accessors ((full-name mahogany-output-full-name) | ||
(hrt-output mahogany-output-hrt-output)) | ||
mh-output | ||
(alexandria:when-let ((tree (gethash full-name output-map))) | ||
(multiple-value-bind (x y) (hrt:output-position hrt-output) | ||
(mahogany/tree:set-position (root-tree tree) x y)) | ||
(multiple-value-bind (width height) (hrt:output-resolution hrt-output) | ||
(mahogany/tree:set-dimensions (root-tree tree) width height))))))) | ||
|
||
|
||
(defun group-remove-output (group output) | ||
(declare (type mahogany-output output) | ||
(type mahogany-group group)) | ||
(remhash (mahogany-output-full-name output) (mahogany-group-output-map group))) | ||
|
||
(defun group-add-view (group view) | ||
(declare (type mahogany-group group)) | ||
(push view (mahogany-group-views group))) | ||
|
||
(defun group-remove-view (group view) | ||
(declare (type mahogany-group group)) | ||
(with-accessors ((view-list mahogany-group-views)) group | ||
(setf view-list (remove view view-list :test #'cffi:pointer-eq)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
(in-package #:mahogany) | ||
|
||
(defun %get-output-full-name (hrt-output) | ||
(let ((make (hrt-output-make hrt-output)) | ||
(name (hrt-output-name hrt-output)) | ||
(serial (hrt-output-serial hrt-output)) | ||
(model (hrt-output-model hrt-output))) | ||
(concatenate 'string | ||
(or name "") | ||
(or make "") | ||
(or model "") | ||
(or serial "")))) | ||
|
||
(defun construct-mahogany-output (hrt-output) | ||
(let ((name (%get-output-full-name hrt-output))) | ||
(%make-mahogany-output hrt-output name))) | ||
|
||
(cffi:defcallback handle-new-output :void ((output (:pointer (:struct hrt-output)))) | ||
(log-string :trace "New output added") | ||
(vector-push-extend (make-mahogany-output output) (mahogany-state-outputs *compositor-state*))) | ||
(let ((mh-output (construct-mahogany-output output))) | ||
(mahogany-state-output-add *compositor-state* mh-output))) | ||
|
||
(cffi:defcallback handle-output-removed :void ((output (:pointer (:struct hrt-output)))) | ||
(log-string :trace "Output removed") | ||
(with-accessors ((outputs mahogany-state-outputs)) *compositor-state* | ||
(setf outputs (delete output outputs :key #'mahogany-output-hrt-output)))) | ||
(mahogany-state-output-remove *compositor-state* output)) | ||
|
||
(cffi:defcallback handle-output-layout-change :void () | ||
(mahogany-state-output-reconfigure *compositor-state*)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters