Skip to content

Commit

Permalink
Don't :use mahogany/core package
Browse files Browse the repository at this point in the history
  • Loading branch information
sdilts committed Nov 2, 2024
1 parent 17842f9 commit 6f29001
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
48 changes: 24 additions & 24 deletions lisp/main.lisp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(in-package #:mahogany)

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

(cffi:defcallback keyboard-callback :bool
((seat (:pointer (:struct hrt-seat)))
(info (:pointer (:struct hrt-keypress-info))))
(cffi:with-foreign-slots ((keysyms modifiers keysyms-len) info (:struct hrt-keypress-info))
(dotimes (i keysyms-len)
(let ((key (make-key (cffi:mem-aref keysyms :uint32 i) modifiers)))
((seat (:pointer (:struct hrt:hrt-seat)))
(info (:pointer (:struct hrt:hrt-keypress-info))))
(cffi:with-foreign-slots ((hrt:keysyms hrt:modifiers hrt:keysyms-len) info (:struct hrt:hrt-keypress-info))
(dotimes (i hrt:keysyms-len)
(let ((key (make-key (cffi:mem-aref hrt:keysyms :uint32 i) hrt:modifiers)))
(handle-key-event key seat)))))

(defmacro init-callback-struct (variable type &body sets)
Expand All @@ -19,37 +19,37 @@
append (list (car pair) `(cffi:callback ,(cadr pair))))))))

(defun init-view-callbacks (view-callbacks)
(init-callback-struct view-callbacks (:struct hrt-view-callbacks)
(new-view handle-new-view-event)
(view-destroyed handle-view-destroyed-event)))
(init-callback-struct view-callbacks (:struct hrt:hrt-view-callbacks)
(hrt:new-view handle-new-view-event)
(hrt:view-destroyed handle-view-destroyed-event)))

(defun run-server ()
(disable-fpu-exceptions)
(hrt:load-foreign-libraries)
(log-init :level :trace)
(enable-debugger)
(cffi:with-foreign-objects ((output-callbacks '(:struct hrt-output-callbacks))
(seat-callbacks '(:struct hrt-seat-callbacks))
(view-callbacks '(:struct hrt-view-callbacks))
(server '(:struct hrt-server)))
(init-callback-struct output-callbacks (:struct hrt-output-callbacks)
(output-added handle-new-output)
(output-removed handle-output-removed)
(output-layout-changed handle-output-layout-change))
(init-callback-struct seat-callbacks (:struct hrt-seat-callbacks)
(button-event cursor-callback)
(wheel-event cursor-callback)
(keyboard-keypress-event keyboard-callback))
(cffi:with-foreign-objects ((output-callbacks '(:struct hrt:hrt-output-callbacks))
(seat-callbacks '(:struct hrt:hrt-seat-callbacks))
(view-callbacks '(:struct hrt:hrt-view-callbacks))
(server '(:struct hrt:hrt-server)))
(init-callback-struct output-callbacks (:struct hrt:hrt-output-callbacks)
(hrt:output-added handle-new-output)
(hrt:output-removed handle-output-removed)
(hrt:output-layout-changed handle-output-layout-change))
(init-callback-struct seat-callbacks (:struct hrt:hrt-seat-callbacks)
(hrt:button-event cursor-callback)
(hrt:wheel-event cursor-callback)
(hrt:keyboard-keypress-event keyboard-callback))
(init-view-callbacks view-callbacks)

(setf (mahogany-state-server *compositor-state*) server)
(log-string :debug "Initialized mahogany state")
(hrt-server-init server output-callbacks seat-callbacks view-callbacks 3)
(hrt:hrt-server-init server output-callbacks seat-callbacks view-callbacks 3)
(log-string :debug "Initialized heart state")
(unwind-protect
(hrt-server-start server)
(hrt:hrt-server-start server)
(log-string :debug "Cleaning up...")
(server-stop *compositor-state*)
(hrt-server-finish server)
(hrt:hrt-server-finish server)
(server-state-reset *compositor-state*)
(log-string :debug "Shutdown reached."))))
12 changes: 6 additions & 6 deletions lisp/output.lisp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(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)))
(let ((make (hrt:hrt-output-make hrt-output))
(name (hrt:hrt-output-name hrt-output))
(serial (hrt:hrt-output-serial hrt-output))
(model (hrt:hrt-output-model hrt-output)))
(concatenate 'string
(or name "")
(or make "")
Expand All @@ -15,11 +15,11 @@
(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))))
(cffi:defcallback handle-new-output :void ((output (:pointer (:struct hrt:hrt-output))))
(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))))
(cffi:defcallback handle-output-removed :void ((output (:pointer (:struct hrt:hrt-output))))
(mahogany-state-output-remove *compositor-state* output))

(cffi:defcallback handle-output-layout-change :void ()
Expand Down
1 change: 0 additions & 1 deletion lisp/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
#:mahogany/log
#:mahogany/wm-interface
#:mahogany/util
#:mahogany/core
#:mahogany/keyboard)
(:local-nicknames (#:tree #:mahogany/tree)))
2 changes: 1 addition & 1 deletion lisp/state.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
(current-group mahogany-current-group)
(server mahogany-state-server))
state
(let ((new-view (hrt:view-init view-ptr (hrt-server-scene-tree server))))
(let ((new-view (hrt:view-init view-ptr (hrt:hrt-server-scene-tree server))))
(setf (gethash (cffi:pointer-address view-ptr) view-tbl) new-view)
(group-add-view current-group new-view))))

Expand Down
4 changes: 2 additions & 2 deletions lisp/view.lisp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(in-package #:mahogany)

(cffi:defcallback handle-new-view-event :void
((view (:pointer (:struct hrt-view))))
((view (:pointer (:struct hrt:hrt-view))))
(log-string :trace "New view callback called!")
(mahogany-state-view-add *compositor-state* view))

(cffi:defcallback handle-view-destroyed-event :void
((view (:pointer (:struct hrt-view))))
((view (:pointer (:struct hrt:hrt-view))))
(log-string :trace "View destroyed callback called!")
(mahogany-state-view-remove *compositor-state* view))

0 comments on commit 6f29001

Please sign in to comment.