Skip to content

Commit

Permalink
Keep track of outputs in front end
Browse files Browse the repository at this point in the history
  • Loading branch information
sdilts committed Nov 10, 2023
1 parent dfe428a commit dbad1ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lisp/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
(declare (ignore seat))
(log-string :trace "cursor callback called"))

(cffi:defcallback output-callback :void ((seat (:pointer (:struct hrt-output))))
(declare (ignore seat))
(log-string :trace "output change callback called"))

(cffi:defcallback keyboard-callback :bool
((seat (:pointer (:struct hrt-seat)))
(info (:pointer (:struct hrt-keypress-info))))
Expand Down Expand Up @@ -46,8 +42,8 @@
(view-callbacks '(:struct hrt-view-callbacks))
(server '(:struct hrt-server)))
(init-callback-struct output-callbacks (:struct hrt-output-callbacks)
(output-added output-callback)
(output-removed output-callback))
(output-added handle-new-output)
(output-removed handle-output-removed))
(init-callback-struct seat-callbacks (:struct hrt-seat-callbacks)
(button-event cursor-callback)
(wheel-event cursor-callback)
Expand Down
13 changes: 13 additions & 0 deletions lisp/output.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(in-package #:mahogany)

(defstruct (mahogany-output (:constructor make-mahogany-output (hrt-output)))
(hrt-output cffi:null-pointer :type cffi:foreign-pointer :read-only t))

(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*)))

(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))))
6 changes: 6 additions & 0 deletions lisp/state.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
(keybindings :type list
:initform nil
:reader mahogany-state-keybindings)
(outputs :type vector
:initform (make-array 0
:element-type 'mahogany-output
:adjustable t
:fill-pointer t)
:accessor mahogany-state-outputs)
(views :type list
:initform nil
:reader mahogany-state-views)))
Expand Down
1 change: 1 addition & 0 deletions mahogany.asd
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
(:file "frame" :depends-on ("tree-interface"))
(:file "view" :depends-on ("tree-interface"))))
(:file "state" :depends-on ("package"))
(:file "output" :depends-on ("package" "bindings"))
(:file "view" :depends-on ("package" "bindings"))
(:file "input" :depends-on ("state" "keyboard"))
(:file "globals" :depends-on ("state" "system"))
Expand Down

0 comments on commit dbad1ce

Please sign in to comment.