Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
/ alloy Public archive

Commit ce2cdf8

Browse files
committed
Bla
1 parent 2c0585e commit ce2cdf8

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

examples/toolkit.lisp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
`(progn (defun ,name (,@(rest args))
3030
(flet ((,thunk (,(first args))
3131
,@body))
32-
(unless *screen*
33-
(setf *screen* (make-instance 'screen)))
34-
(,thunk *screen*)))
32+
(if (boundp '*screen*)
33+
(,thunk *screen*)
34+
(framebuffers:with-screen (*screen* 'screen)
35+
(thunk *screen*)))))
3536
(pushnew ',name *examples*))))

renderers/framebuffers/package.lisp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#:cursor
1515
#:monitor
1616
#:screen
17-
#:window))
17+
#:window
18+
#:with-screen))
1819

1920
(push :alloy-framebuffers *features*)

renderers/framebuffers/windowing.lisp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@
2525
(defmethod (setf alloy:cursor) (value (screen screen))
2626
value)
2727

28-
(defmethod make-window ((screen screen) &rest args &key &allow-other-keys)
28+
(defmethod window:make-window ((screen screen) &rest args &key &allow-other-keys)
2929
(apply #'make-instance 'window :screen screen args))
3030

3131
(defmethod process-events ((screen screen) &key timeout)
3232
(fb:process-events (windows screen) :timeout timeout)
3333
(setf (windows screen) (remove-if #'fb:close-requested-p (windows screen)))
3434
screen)
3535

36+
(defmacro with-screen ((screen &optional (type ''screen) &rest initargs) &body body)
37+
(let ((thunk (gensym "THUNK")))
38+
`(let ((,screen (make-instance ,type ,@initargs)))
39+
(locally ,@body)
40+
(loop while (windows ,screen)
41+
do (dolist (window (windows ,screen))
42+
(alloy:maybe-render ,screen window))
43+
(process-events ,screen :timeout T)))))
44+
3645
(defclass cursor (window:cursor)
3746
((native :initarg :native :accessor native)
3847
(icon :initform :default :accessor icon :reader window:icon)))
@@ -46,7 +55,8 @@
4655
(symbol icon)))
4756
(setf (icon cursor) icon))
4857

49-
(defclass window (alloy:ui fb:event-handler
58+
(defclass window (window:window
59+
fb:event-handler
5060
org.shirakumo.alloy.renderers.simple.presentations::default-look-and-feel)
5161
((native :accessor native)
5262
(screen :initarg :screen :reader window:screen)
@@ -55,6 +65,7 @@
5565
(cursor :reader window:cursor)))
5666

5767
(defmethod initialize-instance :after ((window window) &key)
68+
#++
5869
(setf (slot-value window 'cursor) (make-instance 'cursor :window native)))
5970

6071
(defmethod alloy:render ((screen screen) (window window))

0 commit comments

Comments
 (0)