Skip to content

Commit

Permalink
skitter: ignore resize events when inside a viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
azimut committed Nov 5, 2024
1 parent 343ad10 commit 72fcd21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/skitter.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@
(window-listener (first args)))

(defun window-listener (dim &aux (width (x dim)) (height (y dim)))
(let* ((w (if (> height width) width (* height (/ 16 9f0))))
(h (if (> width height) height (* width (/ 9 16f0)))))
;; Ignores dynamic resizes when working on non-default viewports
(let ((default-viewport
(cepl.context::%cepl-context-default-viewport
(cepl-context))))
(when (not (equal default-viewport (current-viewport)))
(return-from window-listener)))
;; Otherwise resize
(let* ((w (if (> height width) width (* height (/ 16 9f0))))
(h (if (> width height) height (* width (/ 9 16f0)))))
;; FIXME: this ^ forces a 16/9 aspect ratio
(setf (resolution (current-viewport)) (v! w h))
(when (scenes *state*)
(issue (current-scene)
Expand Down

0 comments on commit 72fcd21

Please sign in to comment.