protocol.lisp (1256B)
1 (uiop:define-package #:net.entf.graphics/window/protocol 2 (:use #:cl) 3 (:import-from #:bordeaux-threads) 4 (:export 5 #:backend 6 #:start-event-loop 7 #:stop-event-loop 8 #:window 9 #:window-title 10 #:window-app-id 11 #:window-size 12 #:make-window)) 13 (in-package #:net.entf.graphics/window/protocol) 14 15 (defclass backend () 16 ((event-loop-thread 17 :accessor event-loop-thread))) 18 19 (defgeneric start-event-loop (backend &key blocking?)) 20 21 (defmethod start-event-loop :around ((backend backend) &key blocking?) 22 (if blocking? 23 (prog1 24 (setf (event-loop-thread backend) (bt2:current-thread)) 25 (call-next-method backend :blocking? blocking?)) 26 (bt2:make-thread (lambda () 27 (start-event-loop backend :blocking? t)) 28 :name (format nil "net.entf.graphics/window event loop for ~A" backend)))) 29 30 (defgeneric stop-event-loop (backend)) 31 32 (defclass window () 33 ((title 34 :initarg :title 35 :accessor window-title) 36 (app-id 37 :initarg :app-id 38 :accessor window-app-id) 39 (size 40 :initarg :size 41 :accessor window-size))) 42 43 (defgeneric make-window (backend &key title app-id size &allow-other-keys)) 44 45 (defgeneric window-minimize (window)) 46 (defgeneric window-maximize (window))