nandi/jolt-nativepublic Fork 0
99fabc1
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Answer screen-size with numbers before there is a window

A client asks this while it is starting. frq computes its layout from
(long (second (screen-size))) on its first tick, which runs before the
window opens, so nil was a NullPointerException in the caller rather than
a small first frame -- found by running frq against this backend, not by
reading it.

window-width already answered 0 for the same reason. A layout computed
against zero for one frame is a layout nobody saw; the value is right on
the next tick.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandi committed 2026-09-10T05:59:17-07:00 Browse files
99fabc1 parent: c7dc288
modified jvui/src/jvui/host.clj +12 -2
@@ -59,9 +59,19 @@
5959 (or (first (window-size)) 0))
6060
6161 (defn screen-size
62- "[w h] of the display this window is on, or nil with no window."
62+ "[w h] of the display this window is on. [0 0] before there is one.
63+
64+ NUMBERS, not nil, and that is the whole point of the zero. A client asks
65+ this while it is starting — frq computes its layout from
66+ `(long (second (screen-size)))` on the first tick, which is before the
67+ window opens — and nil there is a NullPointerException in the caller
68+ rather than a small first frame. `window-width` already answers 0 for the
69+ same reason; this matches it.
70+
71+ The value is right on the next tick, and a layout computed against zero
72+ for one frame is a layout nobody saw."
6373 []
64- (when-let [w @win] (sdl/display-bounds w)))
74+ (or (when-let [w @win] (sdl/display-bounds w)) [0 0]))
6575
6676 ;; --- the world outside -------------------------------------------------------
6777
@@ -59,9 +59,19 @@
59 (or (first (window-size)) 0))59 (or (first (window-size)) 0))
60 60
61 (defn screen-size61 (defn screen-size
62- "[w h] of the display this window is on, or nil with no window."62+ "[w h] of the display this window is on. [0 0] before there is one.
63+
64+ NUMBERS, not nil, and that is the whole point of the zero. A client asks
65+ this while it is starting — frq computes its layout from
66+ `(long (second (screen-size)))` on the first tick, which is before the
67+ window opens — and nil there is a NullPointerException in the caller
68+ rather than a small first frame. `window-width` already answers 0 for the
69+ same reason; this matches it.
70+
71+ The value is right on the next tick, and a layout computed against zero
72+ for one frame is a layout nobody saw."
63 []73 []
64- (when-let [w @win] (sdl/display-bounds w)))74+ (or (when-let [w @win] (sdl/display-bounds w)) [0 0]))
65 75
66 ;; --- the world outside -------------------------------------------------------76 ;; --- the world outside -------------------------------------------------------
67 77
modified jvui/test/jvui/host_check.clj +4 -1
@@ -15,7 +15,10 @@
1515 ck! (fn [n ok?] (swap! out conj [n (boolean ok?)]))
1616 seen (atom 0)]
1717 ;; Before any window: everything must answer harmlessly rather than throw.
18- (ck! "no window: screen-size is nil" (nil? (host/screen-size)))
18+ ;; Numbers and not nil: a client that asks before the window is open
19+ ;; does arithmetic on the answer. frq does exactly that on its first
20+ ;; tick, and nil there was a NullPointerException in the caller.
21+ (ck! "no window: screen-size is [0 0]" (= [0 0] (host/screen-size)))
1922 (ck! "no window: window-width is 0" (zero? (host/window-width)))
2023 (ck! "no window: set-title! is quiet" (nil? (host/set-title! "x")))
2124 (ck! "no window: no clipboard picture" (false? (host/clipboard-image-png! "/tmp/nope.png")))
@@ -15,7 +15,10 @@
15 ck! (fn [n ok?] (swap! out conj [n (boolean ok?)]))15 ck! (fn [n ok?] (swap! out conj [n (boolean ok?)]))
16 seen (atom 0)]16 seen (atom 0)]
17 ;; Before any window: everything must answer harmlessly rather than throw.17 ;; Before any window: everything must answer harmlessly rather than throw.
18- (ck! "no window: screen-size is nil" (nil? (host/screen-size)))18+ ;; Numbers and not nil: a client that asks before the window is open
19+ ;; does arithmetic on the answer. frq does exactly that on its first
20+ ;; tick, and nil there was a NullPointerException in the caller.
21+ (ck! "no window: screen-size is [0 0]" (= [0 0] (host/screen-size)))
19 (ck! "no window: window-width is 0" (zero? (host/window-width)))22 (ck! "no window: window-width is 0" (zero? (host/window-width)))
20 (ck! "no window: set-title! is quiet" (nil? (host/set-title! "x")))23 (ck! "no window: set-title! is quiet" (nil? (host/set-title! "x")))
21 (ck! "no window: no clipboard picture" (false? (host/clipboard-image-png! "/tmp/nope.png")))24 (ck! "no window: no clipboard picture" (false? (host/clipboard-image-png! "/tmp/nope.png")))