aboutsummaryrefslogtreecommitdiffhomepage
path: root/wheelwork.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'wheelwork.lisp')
-rw-r--r--wheelwork.lisp15
1 files changed, 14 insertions, 1 deletions
diff --git a/wheelwork.lisp b/wheelwork.lisp
index 0fdfdf4..6cebb66 100644
--- a/wheelwork.lisp
+++ b/wheelwork.lisp
@@ -437,11 +437,20 @@ give focus to whatever was clicked."
(when-let (handler (get-handler-for target 'mousedown))
(funcall handler target x y clicks button wx wy)))))
+(defun eventloop-mousebuttonup (app wx wy clicks button)
+ (when (should-listen-for-p 'mouseup app)
+ (destructuring-bind (x y) (screen-to-world wx wy)
+ (when-let* ((target (or (unit-under app x y)
+ app))
+ (handler (get-handler-for target 'mouseup)))
+ (funcall handler target x y clicks button wx wy)))))
+
(defun eventloop-mousemotion (app wx wy wxrel wyrel state)
(when (should-listen-for-p 'mousemotion app)
(destructuring-bind (x y) (screen-to-world wx wy)
(destructuring-bind (xrel yrel) (screen-to-world wxrel wyrel)
- (when-let* ((target (unit-under app x y))
+ (when-let* ((target (or (unit-under app x y)
+ app))
(handler (get-handler-for target 'mousemotion)))
(funcall handler target x y xrel yrel state wx wy wxrel wyrel))))))
@@ -451,6 +460,7 @@ give focus to whatever was clicked."
(handler (get-handler-for focus 'mousewheel)))
(funcall handler focus wx wy dir))))
+
(defun eventloop (app)
(sdl2:with-event-loop (:method :poll)
(:mousebuttondown
@@ -459,6 +469,9 @@ give focus to whatever was clicked."
(:mousemotion
(:x x :y y :xrel xrel :yrel yrel :state state)
(eventloop-mousemotion app x y xrel yrel state))
+ (:mousebuttonup
+ (:x x :y y :clicks clicks :button button)
+ (eventloop-mousebuttonup app x y clicks button))
(:keydown
(:keysym keysym)
(eventloop-keydown app keysym))