nandi/jolt-nativepublic Fork 0
5adddc7
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.

Let the window be renamed after it opens

A title was whatever `vidya_open` was handed, and nothing could say
otherwise afterwards — so an app whose title has something to report
(who is signed in, which document is open, what a second window of the
same app is for) had only what it knew before the window existed, which
for a name that arrives with a connection is nothing.

`vidya_set_title` writes the winit window and `Handler.title` both. The
handler's copy is not a cache: on Android the window is taken away and
rebuilt whenever the activity leaves the foreground, and `Gl::create`
names the new one from that field — a title set only on the window would
be the launch title again after a resume.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandi committed 2026-08-30T18:49:47-07:00 Browse files
5adddc7 parent: a20c5b9
modified crates/jolt-vidya/src/app.rs +13 -0
@@ -621,6 +621,19 @@ impl App {
621621 vidya_core::apply(&self.handler.egui_ctx, &self.handler.theme);
622622 }
623623
624+ /// Rename the open window.
625+ ///
626+ /// Onto the handler as well as the window: on Android the window is taken
627+ /// away and rebuilt whenever the activity leaves the foreground, and
628+ /// `Gl::create` names the new one from `self.title`. A title set once and
629+ /// only on the window would be the launch title again after a resume.
630+ pub fn set_title(&mut self, title: &str) {
631+ self.handler.title = title.to_owned();
632+ if let Some(gl) = self.handler.gl.as_ref() {
633+ gl.window.set_title(title);
634+ }
635+ }
636+
624637 pub fn set_target_fps(&mut self, fps: i32) {
625638 self.frame_budget = match fps {
626639 f if f > 0 => Duration::from_secs_f64(1.0 / f as f64),
@@ -621,6 +621,19 @@ impl App {
621 vidya_core::apply(&self.handler.egui_ctx, &self.handler.theme);621 vidya_core::apply(&self.handler.egui_ctx, &self.handler.theme);
622 }622 }
623 623
624+ /// Rename the open window.
625+ ///
626+ /// Onto the handler as well as the window: on Android the window is taken
627+ /// away and rebuilt whenever the activity leaves the foreground, and
628+ /// `Gl::create` names the new one from `self.title`. A title set once and
629+ /// only on the window would be the launch title again after a resume.
630+ pub fn set_title(&mut self, title: &str) {
631+ self.handler.title = title.to_owned();
632+ if let Some(gl) = self.handler.gl.as_ref() {
633+ gl.window.set_title(title);
634+ }
635+ }
636+
624 pub fn set_target_fps(&mut self, fps: i32) {637 pub fn set_target_fps(&mut self, fps: i32) {
625 self.frame_budget = match fps {638 self.frame_budget = match fps {
626 f if f > 0 => Duration::from_secs_f64(1.0 / f as f64),639 f if f > 0 => Duration::from_secs_f64(1.0 / f as f64),
modified crates/jolt-vidya/src/lib.rs +8 -0
@@ -130,6 +130,14 @@ pub extern "C" fn vidya_should_close() -> c_int {
130130 with_app(1, |app| app.should_close() as c_int)
131131 }
132132
133+/// # Safety
134+/// `title` is null or a NUL-terminated UTF-8 string.
135+#[no_mangle]
136+pub unsafe extern "C" fn vidya_set_title(title: *const c_char) {
137+ let title = borrowed_str(title);
138+ with_app((), |app| app.set_title(&title));
139+}
140+
133141 #[no_mangle]
134142 pub extern "C" fn vidya_set_target_fps(fps: c_int) {
135143 with_app((), |app| app.set_target_fps(fps));
@@ -130,6 +130,14 @@ pub extern "C" fn vidya_should_close() -> c_int {
130 with_app(1, |app| app.should_close() as c_int)130 with_app(1, |app| app.should_close() as c_int)
131 }131 }
132 132
133+/// # Safety
134+/// `title` is null or a NUL-terminated UTF-8 string.
135+#[no_mangle]
136+pub unsafe extern "C" fn vidya_set_title(title: *const c_char) {
137+ let title = borrowed_str(title);
138+ with_app((), |app| app.set_title(&title));
139+}
140+
133 #[no_mangle]141 #[no_mangle]
134 pub extern "C" fn vidya_set_target_fps(fps: c_int) {142 pub extern "C" fn vidya_set_target_fps(fps: c_int) {
135 with_app((), |app| app.set_target_fps(fps));143 with_app((), |app| app.set_target_fps(fps));
modified jolt/glimmer-vidya/src/glimmer_vidya/core.jolt +10 -0
@@ -242,6 +242,16 @@
242242 (forget-dead-handlers!)
243243 nil)
244244
245+(defn set-title!
246+ "Rename the open window. `run` names it once at startup; this is for a title
247+ that has something to say later — who is signed in, which document is open,
248+ what a second window of the same app is for.
249+
250+ A no-op before the window exists and after it closes."
251+ [title]
252+ (ffi/set-title! (str title))
253+ nil)
254+
245255 (defn window-width
246256 "The width in points of the window's content area, as the last painted frame
247257 measured it. 0 before the first frame.
@@ -242,6 +242,16 @@
242 (forget-dead-handlers!)242 (forget-dead-handlers!)
243 nil)243 nil)
244 244
245+(defn set-title!
246+ "Rename the open window. `run` names it once at startup; this is for a title
247+ that has something to say later — who is signed in, which document is open,
248+ what a second window of the same app is for.
249+
250+ A no-op before the window exists and after it closes."
251+ [title]
252+ (ffi/set-title! (str title))
253+ nil)
254+
245 (defn window-width255 (defn window-width
246 "The width in points of the window's content area, as the last painted frame256 "The width in points of the window's content area, as the last painted frame
247 measured it. 0 before the first frame.257 measured it. 0 before the first frame.
modified jolt/glimmer-vidya/src/glimmer_vidya/ffi.jolt +1 -0
@@ -23,6 +23,7 @@
2323 (ffi/defcfn raw-open "vidya_open" [:int :int :string] :int)
2424 (ffi/defcfn close! "vidya_close" [] :void)
2525 (ffi/defcfn raw-should-close "vidya_should_close" [] :int)
26+(ffi/defcfn set-title! "vidya_set_title" [:string] :void)
2627 (ffi/defcfn set-target-fps! "vidya_set_target_fps" [:int] :void)
2728 (ffi/defcfn set-mode! "vidya_set_mode" [:int] :void)
2829 (ffi/defcfn raw-load-font "vidya_load_font" [:string :int] :int)
@@ -23,6 +23,7 @@
23 (ffi/defcfn raw-open "vidya_open" [:int :int :string] :int)23 (ffi/defcfn raw-open "vidya_open" [:int :int :string] :int)
24 (ffi/defcfn close! "vidya_close" [] :void)24 (ffi/defcfn close! "vidya_close" [] :void)
25 (ffi/defcfn raw-should-close "vidya_should_close" [] :int)25 (ffi/defcfn raw-should-close "vidya_should_close" [] :int)
26+(ffi/defcfn set-title! "vidya_set_title" [:string] :void)
26 (ffi/defcfn set-target-fps! "vidya_set_target_fps" [:int] :void)27 (ffi/defcfn set-target-fps! "vidya_set_target_fps" [:int] :void)
27 (ffi/defcfn set-mode! "vidya_set_mode" [:int] :void)28 (ffi/defcfn set-mode! "vidya_set_mode" [:int] :void)
28 (ffi/defcfn raw-load-font "vidya_load_font" [:string :int] :int)29 (ffi/defcfn raw-load-font "vidya_load_font" [:string :int] :int)