aboutsummaryrefslogtreecommitdiffhomepage
path: root/wheelwork.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-06-24 07:16:30 -0500
committerColin Okay <colin@cicadas.surf>2022-06-24 07:16:30 -0500
commit2d25da70272cc226d7e24bc9f3ad8c61fb85c2d9 (patch)
treea6d94092a0d1223edb47ff90dd427243a16f3fd5 /wheelwork.lisp
parent278d81508d56a4b44e6b24e036661a6a159126c4 (diff)
[add] focus & blur logic in slot-value-using-class for application
Diffstat (limited to 'wheelwork.lisp')
-rw-r--r--wheelwork.lisp40
1 files changed, 24 insertions, 16 deletions
diff --git a/wheelwork.lisp b/wheelwork.lisp
index d23cd7f..6de9d6b 100644
--- a/wheelwork.lisp
+++ b/wheelwork.lisp
@@ -115,15 +115,30 @@ order). Makes sure to remove the unit from its current container if necessary."
(set-projection app)
(setf (listener app) (make-instance 'listener)))
+(defun fire-blur-event-on (thing)
+ (when-let (blur-handler (and thing (get-handler-for thing 'blur)))
+ (funcall blur-handler thing)))
+
+(defun fire-focus-event-on (thing)
+ (when-let (focus-handler (and thing (get-handler-for thing 'focus)))
+ (funcall focus-handler thing)))
+
+(defmethod (setf closer-mop:slot-value-using-class ) :before
+ (new-value class (app application) slot)
+ (case (closer-mop:slot-definition-name slot)
+ (focus
+ (when (slot-boundp app 'focus)
+ (unless (eq new-value (slot-value app 'focus))
+ (fire-blur-event-on (slot-value app 'focus))
+ (fire-focus-event-on new-value))))))
+
(defmethod (setf closer-mop:slot-value-using-class) :after
(new-value class (app application) slot)
- (let ((slot-name
- (closer-mop:slot-definition-name slot)))
- (cond
- ((member slot-name '(scale width height))
- (set-projection app))
- ((eql slot-name 'fps)
- (setf (slot-value app 'frame-wait) (/ 1.0 new-value))))))
+ (case (closer-mop:slot-definition-name slot)
+ ((scale width height)
+ (set-projection app))
+ (fps
+ (setf (slot-value app 'frame-wait) (/ 1.0 new-value)))))
(defgeneric boot (app)
@@ -316,16 +331,9 @@ order). Makes sure to remove the unit from its current container if necessary."
are keyed by UNIT and hold Event-Handler instances."))
-
-
(defun refocus-on (target &optional (app *application*))
- "Handles changing application focus, calling appropriate blur and focus handlers."
- (when-let (blur-handler (and (application-focus app)
- (get-handler-for (application-focus app) 'blur)))
- (funcall blur-handler (application-focus app)))
- (setf (application-focus app) target)
- (when-let (focus-handler (get-handler-for target 'focus))
- (funcall focus-handler target)))
+ "Sets focus of application to target"
+ (setf (application-focus app) target))
(defun get-focus (&optional (app *application*))
(or (application-focus app) app))