@native-sdk/cli 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/build.zig +8 -0
  2. package/native-sdk.d.ts +16 -0
  3. package/package.json +9 -9
  4. package/packages/core/package-lock.json +2 -2
  5. package/packages/core/package.json +1 -1
  6. package/packages/core/sdk/text.ts +62 -21
  7. package/src/app_runner/root.zig +19 -0
  8. package/src/platform/linux/gtk_host.c +167 -8
  9. package/src/platform/linux/gtk_host.h +3 -2
  10. package/src/platform/linux/root.zig +198 -9
  11. package/src/platform/macos/appkit_host.h +4 -2
  12. package/src/platform/macos/appkit_host.m +137 -38
  13. package/src/platform/macos/cef_host.mm +46 -11
  14. package/src/platform/macos/root.zig +150 -6
  15. package/src/platform/null_platform.zig +32 -4
  16. package/src/platform/types.zig +31 -4
  17. package/src/platform/windows/root.zig +220 -10
  18. package/src/platform/windows/webview2_host.cpp +330 -31
  19. package/src/primitives/app_manifest/comptime_scene.zig +4 -0
  20. package/src/primitives/app_manifest/types.zig +16 -0
  21. package/src/primitives/canvas/equality.zig +3 -1
  22. package/src/primitives/canvas/events.zig +4 -0
  23. package/src/primitives/canvas/root.zig +11 -0
  24. package/src/primitives/canvas/text.zig +10 -0
  25. package/src/primitives/canvas/text_interaction.zig +164 -22
  26. package/src/primitives/canvas/text_layout.zig +107 -21
  27. package/src/primitives/canvas/text_tests.zig +86 -0
  28. package/src/primitives/canvas/ui.zig +21 -16
  29. package/src/primitives/canvas/ui_markup_reflect.zig +20 -3
  30. package/src/primitives/canvas/ui_markup_view_tests.zig +16 -0
  31. package/src/primitives/canvas/ui_tests.zig +6 -0
  32. package/src/primitives/canvas/widget_render.zig +21 -2
  33. package/src/primitives/canvas/widget_runtime.zig +1 -0
  34. package/src/primitives/canvas/widget_runtime_tests.zig +51 -0
  35. package/src/primitives/canvas/widget_text_input.zig +23 -11
  36. package/src/runtime/api.zig +9 -0
  37. package/src/runtime/bridge_payload.zig +9 -0
  38. package/src/runtime/bridge_responses.zig +2 -0
  39. package/src/runtime/builtin_bridge.zig +10 -0
  40. package/src/runtime/canvas_frame_helpers.zig +1 -0
  41. package/src/runtime/canvas_limits.zig +7 -0
  42. package/src/runtime/canvas_widget_accessibility_tests.zig +27 -1
  43. package/src/runtime/canvas_widget_clipboard_tests.zig +16 -0
  44. package/src/runtime/canvas_widget_display.zig +15 -1
  45. package/src/runtime/canvas_widget_events.zig +43 -19
  46. package/src/runtime/canvas_widget_floating_tests.zig +3 -3
  47. package/src/runtime/canvas_widget_runtime.zig +67 -10
  48. package/src/runtime/canvas_widget_state.zig +1 -0
  49. package/src/runtime/canvas_widget_text_tests.zig +1878 -70
  50. package/src/runtime/effects.zig +5 -6
  51. package/src/runtime/flow.zig +45 -7
  52. package/src/runtime/gpu_surface_events.zig +46 -1
  53. package/src/runtime/runtime_event_tests.zig +9 -6
  54. package/src/runtime/shell_layout.zig +25 -11
  55. package/src/runtime/shell_layout_tests.zig +184 -0
  56. package/src/runtime/shell_view_tests.zig +9 -7
  57. package/src/runtime/state.zig +6 -0
  58. package/src/runtime/ui_app.zig +61 -14
  59. package/src/runtime/ui_app_window_tests.zig +107 -2
  60. package/src/runtime/view.zig +30 -0
  61. package/src/runtime/view_widget_text.zig +1048 -10
  62. package/src/runtime/view_widget_tree.zig +2 -0
  63. package/src/runtime/window_command_bridge_tests.zig +82 -6
  64. package/src/runtime/window_storage.zig +14 -3
  65. package/src/runtime/window_views.zig +12 -11
  66. package/src/tooling/manifest.zig +38 -2
  67. package/src/tooling/raw_manifest.zig +8 -0
  68. package/src/tooling/templates.zig +17 -0
@@ -321,6 +321,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
321
321
  /// titlebar-control channel's scope, not this field's.
322
322
  /// Platforms without the concept keep standard chrome.
323
323
  titlebar: app_manifest.WindowTitlebarStyle = .standard,
324
+ /// Creation-time overlay presentation. These mirror
325
+ /// `app_manifest.ShellWindow` and are immutable for the life
326
+ /// of the declared window.
327
+ transparent: bool = false,
328
+ always_on_top: bool = false,
329
+ click_through: bool = false,
330
+ activate_on_show: bool = true,
324
331
  /// Msg dispatched when the USER closes the window (never for
325
332
  /// a reconcile close the model itself initiated). The
326
333
  /// dismissal precedent: the window is already gone as an
@@ -742,6 +749,11 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
742
749
  canvas_label_len: usize = 0,
743
750
  window_id: platform.WindowId = 0,
744
751
  on_close: ?MsgT = null,
752
+ /// The descriptor's top-level alpha contract also controls
753
+ /// this slot's gpu alpha mode and frame clear. Without both,
754
+ /// an alpha-capable native window still receives an opaque
755
+ /// canvas inherited from the main scene.
756
+ transparent: bool = false,
745
757
  installed: bool = false,
746
758
  /// This slot's handler-tree currency (the per-slot half of
747
759
  /// `main_tree_current`): false only between handing the
@@ -895,6 +907,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
895
907
  /// these.
896
908
  pixel_buffer: []u8 = &.{},
897
909
  pixel_scratch: []u8 = &.{},
910
+ /// Window whose retained image currently occupies
911
+ /// `pixel_buffer`. Software presenters consume the entire shared
912
+ /// buffer even for an incremental frame, so a handoff between
913
+ /// UiApp surfaces must repaint fully once; consecutive frames for
914
+ /// the same surface may retain and idle normally.
915
+ pixel_buffer_window_id: ?platform.WindowId = null,
898
916
  /// Worker threads, completion queue, and spawn slots for the
899
917
  /// effect system. Fixed-capacity; lives with the app struct
900
918
  /// (heap-allocated like the rest of it).
@@ -1297,6 +1315,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1297
1315
  if (self.pixel_scratch.len > 0) self.backing.free(self.pixel_scratch);
1298
1316
  self.pixel_buffer = &.{};
1299
1317
  self.pixel_scratch = &.{};
1318
+ self.pixel_buffer_window_id = null;
1300
1319
  }
1301
1320
 
1302
1321
  pub fn app(self: *Self) App {
@@ -2618,6 +2637,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2618
2637
  .y = descriptor.y,
2619
2638
  .resizable = descriptor.resizable,
2620
2639
  .titlebar = descriptor.titlebar,
2640
+ .transparent = descriptor.transparent,
2641
+ .always_on_top = descriptor.always_on_top,
2642
+ .click_through = descriptor.click_through,
2643
+ .activate_on_show = descriptor.activate_on_show,
2621
2644
  .min_width = descriptor.min_width,
2622
2645
  .min_height = descriptor.min_height,
2623
2646
  // Deterministic reopen: the descriptor is the geometry
@@ -2636,6 +2659,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2636
2659
  @memcpy(slot.canvas_label_storage[0..descriptor.canvas_label.len], descriptor.canvas_label);
2637
2660
  slot.window_id = info.id;
2638
2661
  slot.on_close = descriptor.on_close;
2662
+ slot.transparent = descriptor.transparent;
2639
2663
  slot.installed = false;
2640
2664
  slot.canvas_size = .{ .width = descriptor.width, .height = descriptor.height };
2641
2665
  // Until this window's first frame reports its real density,
@@ -2658,7 +2682,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2658
2682
  .kind = .gpu_surface,
2659
2683
  .fill = true,
2660
2684
  };
2661
- for (self.options.scene.windows) |window| {
2685
+ scene: for (self.options.scene.windows) |window| {
2662
2686
  for (window.views) |scene_view| {
2663
2687
  if (scene_view.kind != .gpu_surface) continue;
2664
2688
  if (!std.mem.eql(u8, scene_view.label, self.options.canvas_label)) continue;
@@ -2668,9 +2692,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2668
2692
  view.gpu_alpha_mode = scene_view.gpu_alpha_mode;
2669
2693
  view.gpu_color_space = scene_view.gpu_color_space;
2670
2694
  view.gpu_vsync = scene_view.gpu_vsync;
2671
- return view;
2695
+ break :scene;
2672
2696
  }
2673
2697
  }
2698
+ // The top-level alpha flag is sufficient for UiApp windows:
2699
+ // do not inherit the main canvas's ordinary opaque alpha
2700
+ // mode and accidentally erase the desktop behind the slot.
2701
+ if (descriptor.transparent) view.gpu_alpha_mode = .premultiplied;
2674
2702
  return view;
2675
2703
  }
2676
2704
 
@@ -4208,7 +4236,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4208
4236
  if (comptime terminal_session.enabled) {
4209
4237
  _ = self.terminal_sessions.flushPending();
4210
4238
  }
4211
- try self.presentFrame(runtime, frame_event, self.options.canvas_label, installing);
4239
+ try self.presentFrame(
4240
+ runtime,
4241
+ frame_event,
4242
+ self.options.canvas_label,
4243
+ installing,
4244
+ self.effectiveTokens().colors.background,
4245
+ );
4212
4246
  if (installing) return;
4213
4247
  const on_frame = self.options.on_frame orelse return;
4214
4248
  const gpu_frame = runtime.gpuSurfaceFrame(frame_event.window_id, self.options.canvas_label) catch return;
@@ -4262,7 +4296,14 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4262
4296
  // lands first re-measures all of them.
4263
4297
  try self.rebuildForRegisteredFonts(runtime);
4264
4298
  }
4265
- try self.presentFrame(runtime, frame_event, slot.canvasLabel(), installing);
4299
+ var clear_color = self.slotEffectiveTokens(slot).colors.background;
4300
+ if (slot.transparent) clear_color.a = 0;
4301
+ // Packet hosts retain each surface independently. The CPU
4302
+ // fallback shares one UiApp pixel buffer, whose ownership is
4303
+ // handled inside `presentFrame`: a surface handoff repaints
4304
+ // fully once, while an idle completion for the current owner
4305
+ // is allowed to skip.
4306
+ try self.presentFrame(runtime, frame_event, slot.canvasLabel(), installing, clear_color);
4266
4307
  }
4267
4308
 
4268
4309
  /// A face joined the runtime's font registry after this app's
@@ -4293,13 +4334,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4293
4334
  /// reports `UnsupportedService` at present time also falls back to
4294
4335
  /// pixels; that attempt forces a full repaint because the failed
4295
4336
  /// packet plan already recorded the frame's presented summary.
4296
- fn presentFrame(self: *Self, runtime: *Runtime, frame_event: platform.GpuSurfaceFrameEvent, canvas_label: []const u8, installing: bool) anyerror!void {
4297
- // The installing frame must paint unconditionally: on software
4298
- // platforms with no window-manager-driven resizes, nothing else
4299
- // invalidates before the first present, and the surface would
4300
- // stay blank until the first input arrives.
4337
+ fn presentFrame(self: *Self, runtime: *Runtime, frame_event: platform.GpuSurfaceFrameEvent, canvas_label: []const u8, force_full_repaint: bool, clear_color: canvas.Color) anyerror!void {
4338
+ // A forced frame must paint unconditionally: the installing
4339
+ // frame has no earlier glass to retain. Software-buffer
4340
+ // ownership below independently forces the first frame after
4341
+ // a surface handoff.
4301
4342
  const services = runtime.options.platform.services;
4302
- const clear_color = self.effectiveTokens().colors.background;
4303
4343
  var packet_attempted = false;
4304
4344
  if (services.present_gpu_surface_packet_fn != null or services.present_gpu_surface_packet_binary_fn != null) {
4305
4345
  packet_attempted = true;
@@ -4312,7 +4352,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4312
4352
  .timestamp_ns = frame_event.timestamp_ns,
4313
4353
  .surface_size = frame_event.size,
4314
4354
  .scale = frame_event.scale_factor,
4315
- .full_repaint = frame_event.canvas_frame_full_repaint or installing,
4355
+ .full_repaint = frame_event.canvas_frame_full_repaint or force_full_repaint,
4316
4356
  },
4317
4357
  runtime.canvasFrameScratchStorage(),
4318
4358
  clear_color,
@@ -4329,7 +4369,9 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4329
4369
  }
4330
4370
  if (services.present_gpu_surface_pixels_fn == null) return;
4331
4371
  self.ensurePixelBuffers(frame_event.size, frame_event.scale_factor) catch return;
4332
- _ = runtime.presentNextCanvasFramePixels(
4372
+ const pixel_buffer_owned = self.pixel_buffer_window_id != null and
4373
+ self.pixel_buffer_window_id.? == frame_event.window_id;
4374
+ const pixel_frame = runtime.presentNextCanvasFramePixels(
4333
4375
  frame_event.window_id,
4334
4376
  canvas_label,
4335
4377
  .{
@@ -4337,16 +4379,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4337
4379
  .timestamp_ns = frame_event.timestamp_ns,
4338
4380
  .surface_size = frame_event.size,
4339
4381
  .scale = frame_event.scale_factor,
4340
- .full_repaint = frame_event.canvas_frame_full_repaint or packet_attempted or installing,
4382
+ .full_repaint = frame_event.canvas_frame_full_repaint or
4383
+ packet_attempted or
4384
+ force_full_repaint or
4385
+ !pixel_buffer_owned,
4341
4386
  },
4342
4387
  runtime.canvasFrameScratchStorage(),
4343
4388
  self.pixel_buffer,
4344
4389
  self.pixel_scratch,
4345
4390
  clear_color,
4346
4391
  ) catch |err| switch (err) {
4347
- error.UnsupportedService, error.UnsupportedViewKind => {},
4392
+ error.UnsupportedService, error.UnsupportedViewKind => return,
4348
4393
  else => return err,
4349
4394
  };
4395
+ if (pixel_frame.requiresRender()) self.pixel_buffer_window_id = frame_event.window_id;
4350
4396
  }
4351
4397
 
4352
4398
  /// Grow the heap pixel buffers to hold the surface at the given
@@ -4354,6 +4400,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4354
4400
  fn ensurePixelBuffers(self: *Self, surface_size: geometry.SizeF, scale_factor: f32) anyerror!void {
4355
4401
  const pixel_size = try canvas_frame.canvasSurfacePixelSize(surface_size, scale_factor);
4356
4402
  if (self.pixel_buffer.len < pixel_size.byte_len) {
4403
+ self.pixel_buffer_window_id = null;
4357
4404
  if (self.pixel_buffer.len > 0) self.backing.free(self.pixel_buffer);
4358
4405
  self.pixel_buffer = &.{};
4359
4406
  self.pixel_buffer = try self.backing.alloc(u8, pixel_size.byte_len);
@@ -20,6 +20,7 @@ const settings_window_label = "settings";
20
20
 
21
21
  const PanelModel = struct {
22
22
  settings_open: bool = false,
23
+ transparent_settings: bool = false,
23
24
  bumps: u32 = 0,
24
25
  user_closes: u32 = 0,
25
26
  };
@@ -61,6 +62,8 @@ fn panelWindows(model: *const PanelModel, scratch: *PanelApp.WindowsScratch) []c
61
62
  .height = 240,
62
63
  .min_width = 280,
63
64
  .min_height = 200,
65
+ .titlebar = if (model.transparent_settings) .chromeless else .standard,
66
+ .transparent = model.transparent_settings,
64
67
  .on_close = .settings_closed,
65
68
  };
66
69
  count += 1;
@@ -143,13 +146,17 @@ const Fixture = struct {
143
146
 
144
147
  /// Deliver the settings window's installing gpu frame.
145
148
  fn installSettingsCanvas(self: Fixture, window_id: support.platform.WindowId) !void {
149
+ try self.dispatchSettingsCanvasFrame(window_id, 1, 2_000_000);
150
+ }
151
+
152
+ fn dispatchSettingsCanvasFrame(self: Fixture, window_id: support.platform.WindowId, frame_index: u64, timestamp_ns: u64) !void {
146
153
  try self.harness.runtime.dispatchPlatformEvent(self.app, .{ .gpu_surface_frame = .{
147
154
  .window_id = window_id,
148
155
  .label = settings_canvas_label,
149
156
  .size = geometry.SizeF.init(320, 240),
150
157
  .scale_factor = 2,
151
- .frame_index = 1,
152
- .timestamp_ns = 2_000_000,
158
+ .frame_index = frame_index,
159
+ .timestamp_ns = timestamp_ns,
153
160
  .nonblank = true,
154
161
  } });
155
162
  }
@@ -226,6 +233,80 @@ test "a Msg declares the settings window, its canvas installs, and automation dr
226
233
  try std.testing.expect(reopened.open);
227
234
  }
228
235
 
236
+ test "a transparent descriptor selects premultiplied canvas alpha and an alpha-zero clear" {
237
+ const fixture = try Fixture.create();
238
+ defer fixture.destroy();
239
+
240
+ fixture.app_state.model.transparent_settings = true;
241
+ try fixture.clickSettingsButton();
242
+ const info = fixture.settingsWindowInfo() orelse return error.TestUnexpectedResult;
243
+
244
+ const index = for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count], 0..) |window, i| {
245
+ if (window.id == info.id) break i;
246
+ } else return error.WindowNotFound;
247
+ try std.testing.expect(fixture.harness.null_platform.window_transparent[index]);
248
+ try std.testing.expectEqual(support.platform.WindowTitlebarStyle.chromeless, fixture.harness.null_platform.window_titlebar[index]);
249
+
250
+ var views_buffer: [4]support.platform.ViewInfo = undefined;
251
+ const views = fixture.harness.runtime.listViews(info.id, &views_buffer);
252
+ try std.testing.expectEqual(@as(usize, 1), views.len);
253
+ try std.testing.expectEqualStrings(settings_canvas_label, views[0].label);
254
+ try std.testing.expectEqual(support.platform.GpuSurfaceAlphaMode.premultiplied, views[0].gpu_alpha_mode);
255
+
256
+ // A packet present's completion with no invalidation must idle. Real
257
+ // hosts schedule this event after every successful present; presenting
258
+ // it again would create a self-sustaining display-rate loop.
259
+ try fixture.installSettingsCanvas(info.id);
260
+ const packet_present_count = fixture.harness.null_platform.gpu_surface_packet_present_count;
261
+ try fixture.dispatchSettingsCanvasFrame(info.id, 2, 3_000_000);
262
+ try std.testing.expectEqual(packet_present_count, fixture.harness.null_platform.gpu_surface_packet_present_count);
263
+
264
+ // Exercise the pixels-only shape used by Windows' layered-window
265
+ // compositor after the packet-path idle check.
266
+ fixture.harness.runtime.options.platform.services.present_gpu_surface_packet_fn = null;
267
+ fixture.harness.runtime.options.platform.services.present_gpu_surface_packet_binary_fn = null;
268
+ try fixture.dispatchSettingsCanvasFrame(info.id, 3, 4_000_000);
269
+ try std.testing.expectEqual(info.id, fixture.harness.null_platform.gpu_surface_present_window_id);
270
+ try std.testing.expectEqual(@as(u8, 0), fixture.harness.null_platform.gpu_surface_present_sample_rgba[3]);
271
+ try std.testing.expect(std.mem.indexOfScalar(u8, fixture.app_state.pixel_buffer, 255) != null);
272
+
273
+ // The current software-buffer owner also idles after its completion.
274
+ const idle_pixel_present_count = fixture.harness.null_platform.gpu_surface_present_count;
275
+ try fixture.dispatchSettingsCanvasFrame(info.id, 4, 5_000_000);
276
+ try std.testing.expectEqual(idle_pixel_present_count, fixture.harness.null_platform.gpu_surface_present_count);
277
+
278
+ // Hand the shared UiApp pixel buffer to the main canvas. Invalidating
279
+ // only that view models a host/resource full repaint without changing
280
+ // the secondary canvas's retained summary.
281
+ fixture.harness.runtime.views[0].presented_canvas_valid = false;
282
+ try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, .{ .gpu_surface_frame = .{
283
+ .window_id = 1,
284
+ .label = canvas_label,
285
+ .size = geometry.SizeF.init(400, 300),
286
+ .scale_factor = 2,
287
+ .frame_index = 2,
288
+ .timestamp_ns = 6_000_000,
289
+ .nonblank = true,
290
+ } });
291
+ try std.testing.expectEqual(@as(support.platform.WindowId, 1), fixture.harness.null_platform.gpu_surface_present_window_id);
292
+
293
+ // The next transparent-slot completion must repaint once after that
294
+ // ownership handoff, restoring a complete alpha image instead of
295
+ // presenting the main surface's bytes.
296
+ @memset(fixture.app_state.pixel_buffer, 0);
297
+ const handoff_present_count = fixture.harness.null_platform.gpu_surface_present_count;
298
+ try fixture.dispatchSettingsCanvasFrame(info.id, 5, 7_000_000);
299
+ try std.testing.expectEqual(handoff_present_count + 1, fixture.harness.null_platform.gpu_surface_present_count);
300
+ try std.testing.expectEqual(info.id, fixture.harness.null_platform.gpu_surface_present_window_id);
301
+ try std.testing.expect(std.mem.indexOfScalar(u8, fixture.app_state.pixel_buffer, 255) != null);
302
+
303
+ // That one corrective present must not re-arm another present when
304
+ // the following completion carries no invalidation.
305
+ const corrected_present_count = fixture.harness.null_platform.gpu_surface_present_count;
306
+ try fixture.dispatchSettingsCanvasFrame(info.id, 6, 8_000_000);
307
+ try std.testing.expectEqual(corrected_present_count, fixture.harness.null_platform.gpu_surface_present_count);
308
+ }
309
+
229
310
  test "a user close dispatches on_close and the model owns the consequence" {
230
311
  const fixture = try Fixture.create();
231
312
  defer fixture.destroy();
@@ -1184,6 +1265,30 @@ test "close_policy .hide on a secondary startup window is refused loudly at star
1184
1265
  }
1185
1266
  }
1186
1267
 
1268
+ test "active immediate secondary startup window becomes the runtime focus owner" {
1269
+ const SourceApp = struct {
1270
+ fn app(self: *@This()) support.App {
1271
+ return .{ .context = self, .name = "startup-focus", .source = support.platform.WebViewSource.html("<p>Startup</p>") };
1272
+ }
1273
+ };
1274
+ const startup_windows = [_]support.platform.WindowOptions{
1275
+ .{ .id = 1, .label = "main", .title = "Main" },
1276
+ .{ .id = 2, .label = "panel", .title = "Panel" },
1277
+ };
1278
+
1279
+ const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
1280
+ defer harness.destroy(std.testing.allocator);
1281
+ harness.runtime.options.platform.app_info.windows = &startup_windows;
1282
+ var app_state: SourceApp = .{};
1283
+ try harness.start(app_state.app());
1284
+
1285
+ var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
1286
+ const windows = harness.runtime.listWindows(&buffer);
1287
+ try std.testing.expectEqual(@as(usize, 2), windows.len);
1288
+ try std.testing.expect(!windows[0].focused);
1289
+ try std.testing.expect(windows[1].focused);
1290
+ }
1291
+
1187
1292
  // --------------------- context-menu pin across the window lifecycle
1188
1293
 
1189
1294
  const MenuWinModel = struct {
@@ -31,6 +31,8 @@ const max_canvas_widget_nodes_per_view = canvas_limits.max_canvas_widget_nodes_p
31
31
  const max_canvas_widget_semantics_per_view = canvas_limits.max_canvas_widget_semantics_per_view;
32
32
  const max_canvas_widget_text_bytes_per_view = canvas_limits.max_canvas_widget_text_bytes_per_view;
33
33
  const max_canvas_widget_source_text_entries_per_view = canvas_limits.max_canvas_widget_source_text_entries_per_view;
34
+ const max_canvas_widget_text_history_bytes_per_view = canvas_limits.max_canvas_widget_text_history_bytes_per_view;
35
+ const max_canvas_widget_text_history_entries_per_view = canvas_limits.max_canvas_widget_text_history_entries_per_view;
34
36
 
35
37
  const CanvasWidgetSourceTextEntry = canvas_widget_runtime.CanvasWidgetSourceTextEntry;
36
38
  const CanvasWidgetSourceScrollEntry = canvas_widget_runtime.CanvasWidgetSourceScrollEntry;
@@ -750,10 +752,38 @@ pub const RuntimeView = struct {
750
752
  accessibility_label_storage: [platform.max_view_accessibility_label_bytes]u8 = undefined,
751
753
  text_storage: [platform.max_view_text_bytes]u8 = undefined,
752
754
  command_storage: [platform.max_view_command_bytes]u8 = undefined,
755
+ /// Per-view, per-widget undo/redo deltas. Kept at the tail so adding
756
+ /// editor history does not move the established hot render/layout
757
+ /// fields inside RuntimeView. Text bytes are shared across entries, so
758
+ /// ordinary typing costs one byte per step rather than a full document
759
+ /// snapshot.
760
+ canvas_widget_text_history_entries: [max_canvas_widget_text_history_entries_per_view]view_widget_text.CanvasWidgetTextHistoryEntry = undefined,
761
+ canvas_widget_text_history_entry_count: usize = 0,
762
+ canvas_widget_text_history_bytes: [max_canvas_widget_text_history_bytes_per_view]u8 = undefined,
763
+ canvas_widget_text_history_byte_count: usize = 0,
764
+ canvas_widget_text_history_next_serial: u64 = 1,
765
+ /// Native textarea Up/Down retains its painted x coordinate while a
766
+ /// consecutive vertical-navigation run crosses shorter visual lines.
767
+ canvas_widget_text_vertical_goal_id: canvas.ObjectId = 0,
768
+ /// Preferred x in widget-local coordinates, so moving a textarea does
769
+ /// not move the logical column with respect to its text container.
770
+ canvas_widget_text_vertical_goal_x: f32 = 0,
771
+ canvas_widget_text_vertical_goal_text_len: usize = 0,
772
+ canvas_widget_text_vertical_goal_text_hash: u64 = 0,
773
+ canvas_widget_text_vertical_goal_focus: usize = 0,
774
+ canvas_widget_text_vertical_goal_affinity: canvas.TextCaretAffinity = .upstream,
775
+ canvas_widget_text_vertical_goal_frame: geometry.RectF = .{},
753
776
 
754
777
  const CanvasWidgetTextMethods = view_widget_text.RuntimeViewCanvasWidgetText(RuntimeView);
755
778
  pub const applyCanvasWidgetTextEdit = CanvasWidgetTextMethods.applyCanvasWidgetTextEdit;
779
+ pub const applyCanvasWidgetTextEditWithoutHistory = CanvasWidgetTextMethods.applyCanvasWidgetTextEditWithoutHistory;
756
780
  pub const canvasWidgetKeyboardTextEdit = CanvasWidgetTextMethods.canvasWidgetKeyboardTextEdit;
781
+ pub const canvasWidgetTextHistoryShortcut = CanvasWidgetTextMethods.canvasWidgetTextHistoryShortcut;
782
+ pub const canvasWidgetTextHistoryAvailability = CanvasWidgetTextMethods.canvasWidgetTextHistoryAvailability;
783
+ pub const canvasWidgetTextHistoryReplayNext = CanvasWidgetTextMethods.canvasWidgetTextHistoryReplayNext;
784
+ pub const commitCanvasWidgetTextHistoryReplayIfComplete = CanvasWidgetTextMethods.commitCanvasWidgetTextHistoryReplayIfComplete;
785
+ pub const pruneCanvasWidgetTextHistory = CanvasWidgetTextMethods.pruneCanvasWidgetTextHistory;
786
+ pub const clearCanvasWidgetTextVerticalGoal = CanvasWidgetTextMethods.clearCanvasWidgetTextVerticalGoal;
757
787
  pub const canEditCanvasWidgetText = CanvasWidgetTextMethods.canEditCanvasWidgetText;
758
788
  pub const applyCanvasWidgetTextPointer = CanvasWidgetTextMethods.applyCanvasWidgetTextPointer;
759
789
  pub const clearCanvasWidgetStaticTextSelection = CanvasWidgetTextMethods.clearCanvasWidgetStaticTextSelection;