@native-sdk/cli 0.6.0 → 0.6.2
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.
- package/build.zig +58 -33
- package/native-sdk.d.ts +16 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/src/app_runner/root.zig +19 -0
- package/src/platform/linux/gtk_host.c +167 -8
- package/src/platform/linux/gtk_host.h +3 -2
- package/src/platform/linux/root.zig +198 -9
- package/src/platform/macos/appkit_host.h +2 -2
- package/src/platform/macos/appkit_host.m +186 -36
- package/src/platform/macos/cef_host.mm +46 -11
- package/src/platform/macos/root.zig +143 -5
- package/src/platform/null_platform.zig +32 -4
- package/src/platform/types.zig +29 -4
- package/src/platform/windows/root.zig +220 -10
- package/src/platform/windows/webview2_host.cpp +330 -31
- package/src/primitives/app_manifest/comptime_scene.zig +4 -0
- package/src/primitives/app_manifest/types.zig +16 -0
- package/src/primitives/canvas/widget_render.zig +21 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +51 -0
- package/src/runtime/api.zig +6 -5
- package/src/runtime/bridge_payload.zig +9 -0
- package/src/runtime/bridge_responses.zig +2 -0
- package/src/runtime/builtin_bridge.zig +10 -0
- package/src/runtime/canvas_widget_events.zig +28 -2
- package/src/runtime/canvas_widget_floating_tests.zig +3 -3
- package/src/runtime/effects.zig +5 -6
- package/src/runtime/flow.zig +45 -7
- package/src/runtime/gpu_surface_events.zig +10 -3
- package/src/runtime/runtime_event_tests.zig +9 -6
- package/src/runtime/session_tests.zig +5 -4
- package/src/runtime/shell_layout.zig +25 -11
- package/src/runtime/shell_layout_tests.zig +184 -0
- package/src/runtime/shell_view_tests.zig +9 -7
- package/src/runtime/state.zig +6 -0
- package/src/runtime/ui_app.zig +66 -18
- package/src/runtime/ui_app_window_tests.zig +107 -2
- package/src/runtime/window_command_bridge_tests.zig +82 -6
- package/src/runtime/window_storage.zig +14 -3
- package/src/runtime/window_views.zig +12 -11
- package/src/tooling/manifest.zig +38 -2
- package/src/tooling/raw_manifest.zig +8 -0
- package/src/tooling/templates.zig +17 -0
|
@@ -209,7 +209,11 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
209
209
|
const paint_widget = widgetWithFrame(widget, pixelSnapGeometryRect(tokens, widget.frame));
|
|
210
210
|
try emitWidgetBackdropBlur(builder, paint_widget, tokens);
|
|
211
211
|
switch (paint_widget.kind) {
|
|
212
|
-
.stack, .row, .column
|
|
212
|
+
.stack, .row, .column => {
|
|
213
|
+
try emitLayoutContainerBackground(builder, paint_widget);
|
|
214
|
+
try emitWidgetClippedChildren(builder, paint_widget, tokens, depth);
|
|
215
|
+
},
|
|
216
|
+
.grid, .list, .breadcrumb, .pagination, .radio_group, .toggle_group, .split, .tree => try emitWidgetClippedChildren(builder, paint_widget, tokens, depth),
|
|
213
217
|
.button_group => try emitButtonGroupWidget(builder, paint_widget, tokens, depth),
|
|
214
218
|
.table, .data_grid => {
|
|
215
219
|
try emitWidgetClippedChildren(builder, paint_widget, tokens, depth);
|
|
@@ -488,7 +492,8 @@ fn emitWidgetLayoutNodeContent(
|
|
|
488
492
|
const paint_widget = widgetWithFrame(widget, pixelSnapGeometryRect(tokens, widget.frame));
|
|
489
493
|
try emitWidgetBackdropBlur(builder, paint_widget, tokens);
|
|
490
494
|
switch (paint_widget.kind) {
|
|
491
|
-
.stack, .row, .column
|
|
495
|
+
.stack, .row, .column => try emitLayoutContainerBackground(builder, paint_widget),
|
|
496
|
+
.breadcrumb, .button_group, .pagination, .radio_group, .toggle_group, .split, .tree => {},
|
|
492
497
|
.data_row => try emitDataRowWidgetWash(builder, paint_widget, tokens),
|
|
493
498
|
.tabs => try widget_render_surfaces.emitTabsListWidgetChrome(builder, paint_widget, tokens),
|
|
494
499
|
.table, .data_grid => {
|
|
@@ -623,6 +628,20 @@ fn emitWidgetLayoutNodeContent(
|
|
|
623
628
|
try emitWidgetLayoutClippedChildren(builder, layout, node_index, tokens, state, paint_widget);
|
|
624
629
|
}
|
|
625
630
|
|
|
631
|
+
/// Flow and stacking containers have no implicit surface treatment, but
|
|
632
|
+
/// an author background is real chrome: it fills the laid-out frame
|
|
633
|
+
/// before any children, with the same optional radius accepted by the
|
|
634
|
+
/// builder and markup grammar.
|
|
635
|
+
fn emitLayoutContainerBackground(builder: *Builder, widget: Widget) Error!void {
|
|
636
|
+
const background = widget.style.background orelse return;
|
|
637
|
+
try builder.fillRoundedRect(.{
|
|
638
|
+
.id = widgetPartId(widget.id, 1),
|
|
639
|
+
.rect = widget.frame,
|
|
640
|
+
.radius = Radius.all(nonNegative(widget.style.radius orelse 0)),
|
|
641
|
+
.fill = colorFill(background),
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
|
|
626
645
|
fn emitWidgetLayoutScrollableChildren(
|
|
627
646
|
builder: *Builder,
|
|
628
647
|
layout: anytype,
|
|
@@ -1352,6 +1352,57 @@ test "widget tree emits panel button text and progress commands" {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
1354
|
|
|
1355
|
+
test "stack row and column backgrounds paint in tree and layout emission" {
|
|
1356
|
+
const kinds = [_]WidgetKind{ .stack, .row, .column };
|
|
1357
|
+
const frame = geometry.RectF.init(10, 12, 140, 72);
|
|
1358
|
+
const background = Color.rgb8(18, 52, 86);
|
|
1359
|
+
|
|
1360
|
+
for (kinds, 0..) |kind, index| {
|
|
1361
|
+
const id: ObjectId = @intCast(index + 1);
|
|
1362
|
+
const widget = Widget{
|
|
1363
|
+
.id = id,
|
|
1364
|
+
.kind = kind,
|
|
1365
|
+
.frame = frame,
|
|
1366
|
+
.style = .{
|
|
1367
|
+
.background = background,
|
|
1368
|
+
.radius = 7,
|
|
1369
|
+
},
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
var tree_commands: [1]CanvasCommand = undefined;
|
|
1373
|
+
var tree_builder = Builder.init(&tree_commands);
|
|
1374
|
+
try emitWidgetTree(&tree_builder, widget, .{});
|
|
1375
|
+
const tree_display_list = tree_builder.displayList();
|
|
1376
|
+
try std.testing.expectEqual(@as(usize, 1), tree_display_list.commandCount());
|
|
1377
|
+
switch (tree_display_list.commands[0]) {
|
|
1378
|
+
.fill_rounded_rect => |fill| {
|
|
1379
|
+
try std.testing.expectEqual(widgetPartId(id, 1), fill.id);
|
|
1380
|
+
try expectRect(frame, fill.rect);
|
|
1381
|
+
try std.testing.expectEqualDeep(Radius.all(7), fill.radius);
|
|
1382
|
+
try expectFillColor(background, fill.fill);
|
|
1383
|
+
},
|
|
1384
|
+
else => return error.TestUnexpectedResult,
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1388
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1389
|
+
var layout_commands: [1]CanvasCommand = undefined;
|
|
1390
|
+
var layout_builder = Builder.init(&layout_commands);
|
|
1391
|
+
try emitWidgetLayout(&layout_builder, layout, .{});
|
|
1392
|
+
const layout_display_list = layout_builder.displayList();
|
|
1393
|
+
try std.testing.expectEqual(@as(usize, 1), layout_display_list.commandCount());
|
|
1394
|
+
switch (layout_display_list.commands[0]) {
|
|
1395
|
+
.fill_rounded_rect => |fill| {
|
|
1396
|
+
try std.testing.expectEqual(widgetPartId(id, 1), fill.id);
|
|
1397
|
+
try expectRect(frame, fill.rect);
|
|
1398
|
+
try std.testing.expectEqualDeep(Radius.all(7), fill.radius);
|
|
1399
|
+
try expectFillColor(background, fill.fill);
|
|
1400
|
+
},
|
|
1401
|
+
else => return error.TestUnexpectedResult,
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1355
1406
|
test "widget tree emits backdrop blur before widget content" {
|
|
1356
1407
|
const children = [_]Widget{.{
|
|
1357
1408
|
.id = 2,
|
package/src/runtime/api.zig
CHANGED
|
@@ -65,11 +65,12 @@ pub const CanvasWidgetPointerEvent = struct {
|
|
|
65
65
|
/// cursor, and text selection stay on `target`.
|
|
66
66
|
press_target: ?canvas.WidgetHit = null,
|
|
67
67
|
route: []const canvas.WidgetEventRouteEntry = &.{},
|
|
68
|
-
/// A text edit this pointer gesture performed on `target` (
|
|
69
|
-
///
|
|
70
|
-
///
|
|
71
|
-
///
|
|
72
|
-
///
|
|
68
|
+
/// A text edit this pointer gesture performed on `target` (an
|
|
69
|
+
/// editable field's caret/selection move, or the search field's
|
|
70
|
+
/// built-in clear affordance). The runtime already applied it (the
|
|
71
|
+
/// optimistic echo; the source tree is truth on the next rebuild);
|
|
72
|
+
/// `UiApp` maps it through the tree's handler table to the field's
|
|
73
|
+
/// `on_input` Msg so a model-owned buffer stays in lockstep too.
|
|
73
74
|
edit: ?canvas.TextInputEvent = null,
|
|
74
75
|
};
|
|
75
76
|
|
|
@@ -36,6 +36,15 @@ pub fn viewKindFromString(value: []const u8) ?platform.ViewKind {
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
pub fn windowTitlebarStyleFromString(value: []const u8) ?platform.WindowTitlebarStyle {
|
|
40
|
+
inline for (@typeInfo(platform.WindowTitlebarStyle).@"enum".fields) |field| {
|
|
41
|
+
if (std.mem.eql(u8, value, field.name)) return @field(platform.WindowTitlebarStyle, field.name);
|
|
42
|
+
}
|
|
43
|
+
if (std.mem.eql(u8, value, "hiddenInset")) return .hidden_inset;
|
|
44
|
+
if (std.mem.eql(u8, value, "hiddenInsetTall")) return .hidden_inset_tall;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
pub fn gpuSurfaceOptionsFromJson(payload: []const u8, storage: *json.StringStorage) !platform.GpuSurfaceOptions {
|
|
40
49
|
var options = platform.GpuSurfaceOptions{};
|
|
41
50
|
if (jsonStringField(payload, "gpuBackend", storage) orelse jsonStringField(payload, "gpu_backend", storage)) |value| {
|
|
@@ -293,6 +293,7 @@ pub fn writeWindowJsonToWriter(window: platform.WindowInfo, writer: anytype) !vo
|
|
|
293
293
|
pub fn builtinBridgeErrorMessage(err: anyerror) []const u8 {
|
|
294
294
|
return switch (err) {
|
|
295
295
|
error.UnsupportedService => "Native service is not available on this platform",
|
|
296
|
+
error.UnsupportedWindowTransparency => "This backend cannot make window content transparent",
|
|
296
297
|
error.WindowNotFound => "Window was not found",
|
|
297
298
|
error.WindowLimitReached => "Window limit reached",
|
|
298
299
|
error.DuplicateWindowLabel => "Window id or label already exists",
|
|
@@ -361,6 +362,7 @@ pub fn builtinBridgeErrorMessage(err: anyerror) []const u8 {
|
|
|
361
362
|
pub fn builtinBridgeErrorCode(err: anyerror) bridge.ErrorCode {
|
|
362
363
|
return switch (err) {
|
|
363
364
|
error.UnsupportedService,
|
|
365
|
+
error.UnsupportedWindowTransparency,
|
|
364
366
|
error.InvalidWindowOptions,
|
|
365
367
|
error.WindowNotFound,
|
|
366
368
|
error.WindowLimitReached,
|
|
@@ -22,6 +22,7 @@ const jsonBoolField = bridge_payload.jsonBoolField;
|
|
|
22
22
|
const webViewWindowIdFromJson = bridge_payload.webViewWindowIdFromJson;
|
|
23
23
|
const viewWindowIdFromJson = bridge_payload.viewWindowIdFromJson;
|
|
24
24
|
const viewKindFromString = bridge_payload.viewKindFromString;
|
|
25
|
+
const windowTitlebarStyleFromString = bridge_payload.windowTitlebarStyleFromString;
|
|
25
26
|
const gpuSurfaceOptionsFromJson = bridge_payload.gpuSurfaceOptionsFromJson;
|
|
26
27
|
const viewFrameFromJson = bridge_payload.viewFrameFromJson;
|
|
27
28
|
const viewLayerFromJson = bridge_payload.viewLayerFromJson;
|
|
@@ -236,11 +237,20 @@ pub fn RuntimeBuiltinBridge(comptime Runtime: type) type {
|
|
|
236
237
|
const x = jsonNumberField(payload, "x") orelse 0;
|
|
237
238
|
const y = jsonNumberField(payload, "y") orelse 0;
|
|
238
239
|
const source = if (jsonStringField(payload, "url", &storage)) |url| platform.WebViewSource.url(url) else null;
|
|
240
|
+
const titlebar = if (jsonStringField(payload, "titlebar", &storage)) |value|
|
|
241
|
+
windowTitlebarStyleFromString(value) orelse return error.InvalidWindowOptions
|
|
242
|
+
else
|
|
243
|
+
.standard;
|
|
239
244
|
const info = try self.createWindow(.{
|
|
240
245
|
.label = label,
|
|
241
246
|
.title = title,
|
|
242
247
|
.default_frame = geometry.RectF.init(x, y, width, height),
|
|
243
248
|
.restore_state = jsonBoolField(payload, "restoreState") orelse true,
|
|
249
|
+
.titlebar = titlebar,
|
|
250
|
+
.transparent = jsonBoolField(payload, "transparent") orelse false,
|
|
251
|
+
.always_on_top = jsonBoolField(payload, "alwaysOnTop") orelse false,
|
|
252
|
+
.click_through = jsonBoolField(payload, "clickThrough") orelse false,
|
|
253
|
+
.activate_on_show = jsonBoolField(payload, "activateOnShow") orelse true,
|
|
244
254
|
.source = source,
|
|
245
255
|
});
|
|
246
256
|
return writeWindowJson(info, output);
|
|
@@ -2080,6 +2080,11 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2080
2080
|
}
|
|
2081
2081
|
}
|
|
2082
2082
|
if (target_id == 0) return;
|
|
2083
|
+
const target_index = self.views[index].canvasWidgetNodeIndexById(target_id) orelse return;
|
|
2084
|
+
const target_widget = self.views[index].widget_layout_nodes[target_index].widget;
|
|
2085
|
+
const mirrors_editable_selection =
|
|
2086
|
+
canvas_widget_runtime.canvasWidgetEditableTextKind(target_widget.kind) and
|
|
2087
|
+
!target_widget.state.disabled;
|
|
2083
2088
|
|
|
2084
2089
|
// The search field's built-in clear affordance: a press
|
|
2085
2090
|
// inside the trailing clear region clears through the
|
|
@@ -2098,8 +2103,29 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2098
2103
|
pointer_event.pointer.point,
|
|
2099
2104
|
pointer_event.pointer.phase == .move,
|
|
2100
2105
|
pointer_event.pointer.click_count,
|
|
2101
|
-
)
|
|
2102
|
-
|
|
2106
|
+
);
|
|
2107
|
+
// Pointer placement lives first in the retained editor, but a
|
|
2108
|
+
// controlled field's model owns the TextBuffer that the next
|
|
2109
|
+
// keyboard edit will reduce. Stamp the resulting selection
|
|
2110
|
+
// onto the SAME pointer event so `UiApp` delivers
|
|
2111
|
+
// `.set_selection` through `on_input` before a later delete,
|
|
2112
|
+
// insert, or IME edit reaches that model. Without this echo,
|
|
2113
|
+
// the highlight was honest only in the runtime: selecting a
|
|
2114
|
+
// middle span and pressing Backspace let the model delete at
|
|
2115
|
+
// its stale end caret, and its rebuild overwrote the runtime's
|
|
2116
|
+
// correct optimistic edit.
|
|
2117
|
+
//
|
|
2118
|
+
// Stamp even when the retained state did not change. This is
|
|
2119
|
+
// the pointer counterpart of keyboard clear's resync rule: a
|
|
2120
|
+
// divergent model mirror must still hear the selection the
|
|
2121
|
+
// user established.
|
|
2122
|
+
if (mirrors_editable_selection) {
|
|
2123
|
+
const edited_widget = self.views[index].widget_layout_nodes[target_index].widget;
|
|
2124
|
+
const selection = edited_widget.text_selection orelse canvas.TextSelection.collapsed(edited_widget.text.len);
|
|
2125
|
+
pointer_event.edit = .{ .set_selection = selection };
|
|
2126
|
+
}
|
|
2127
|
+
const dirty_bounds = dirty orelse return;
|
|
2128
|
+
if (canvasDirtyRegionForView(self.views[index].frame, dirty_bounds)) |dirty_region| {
|
|
2103
2129
|
self.invalidateFor(.state, dirty_region);
|
|
2104
2130
|
} else {
|
|
2105
2131
|
self.invalidateFor(.state, self.views[index].frame);
|
|
@@ -3214,7 +3214,7 @@ test "window key-loss hides tooltips in that window's views only, re-key reveals
|
|
|
3214
3214
|
const toolbar = try installTooltipToolbar(harness, app, arena.allocator());
|
|
3215
3215
|
|
|
3216
3216
|
// A second window with its own canvas view and a delay-0 tooltip.
|
|
3217
|
-
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools" });
|
|
3217
|
+
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools", .activate_on_show = false });
|
|
3218
3218
|
_ = try harness.runtime.createView(.{
|
|
3219
3219
|
.window_id = second.id,
|
|
3220
3220
|
.label = "canvas",
|
|
@@ -3287,7 +3287,7 @@ test "window key-loss announced loss-first (Windows/GTK ordering) hides the tool
|
|
|
3287
3287
|
|
|
3288
3288
|
// A second window with its own canvas view and a delay-0 tooltip,
|
|
3289
3289
|
// exactly like the gain-only key-loss test above.
|
|
3290
|
-
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools" });
|
|
3290
|
+
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools", .activate_on_show = false });
|
|
3291
3291
|
_ = try harness.runtime.createView(.{
|
|
3292
3292
|
.window_id = second.id,
|
|
3293
3293
|
.label = "canvas",
|
|
@@ -3452,7 +3452,7 @@ test "a tooltip mounting beneath a non-key window's hovered trigger reveals and
|
|
|
3452
3452
|
|
|
3453
3453
|
// A second window with its own canvas view and a bare trigger; the
|
|
3454
3454
|
// startup window keeps key throughout the mount.
|
|
3455
|
-
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools" });
|
|
3455
|
+
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools", .activate_on_show = false });
|
|
3456
3456
|
_ = try harness.runtime.createView(.{
|
|
3457
3457
|
.window_id = second.id,
|
|
3458
3458
|
.label = "canvas",
|
package/src/runtime/effects.zig
CHANGED
|
@@ -7775,12 +7775,11 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
7775
7775
|
_ = binding.minimize_fn(binding.context, window_label);
|
|
7776
7776
|
}
|
|
7777
7777
|
|
|
7778
|
-
/// Show a window by its declared label: unhide +
|
|
7779
|
-
///
|
|
7780
|
-
///
|
|
7781
|
-
///
|
|
7782
|
-
///
|
|
7783
|
-
/// merely backgrounded window. Fire-and-forget, same contract
|
|
7778
|
+
/// Show a window by its declared label: unhide + order front,
|
|
7779
|
+
/// activating by default and remaining passive for an
|
|
7780
|
+
/// `activate_on_show = false` overlay. It is the counterpart to
|
|
7781
|
+
/// a `close_policy = .hide` hide and also brings back a minimized
|
|
7782
|
+
/// or merely backgrounded window. Fire-and-forget, same contract
|
|
7784
7783
|
/// as `closeWindow`: no event echoes beyond the window's own
|
|
7785
7784
|
/// frame event, an unknown label is a no-op, and the fake
|
|
7786
7785
|
/// executor only records the request in the mirror.
|
package/src/runtime/flow.zig
CHANGED
|
@@ -10,6 +10,7 @@ const runtime_automation_widget_dispatch = @import("automation_widget_dispatch.z
|
|
|
10
10
|
const automation_commands = @import("automation_commands.zig");
|
|
11
11
|
const launch_timing = @import("launch_timing.zig");
|
|
12
12
|
const runtime_clock = @import("clock.zig");
|
|
13
|
+
const runtime_state = @import("state.zig");
|
|
13
14
|
const shell_layout = @import("shell_layout.zig");
|
|
14
15
|
const runtime_builtin_bridge = @import("builtin_bridge.zig");
|
|
15
16
|
const runtime_canvas_widget_events = @import("canvas_widget_events.zig");
|
|
@@ -28,6 +29,8 @@ const security = @import("../security/root.zig");
|
|
|
28
29
|
|
|
29
30
|
const validateCommandName = validation.validateCommandName;
|
|
30
31
|
const sceneNeedsMainWebView = shell_layout.sceneNeedsMainWebView;
|
|
32
|
+
const shellWindowNeedsMainWebView = shell_layout.shellWindowNeedsMainWebView;
|
|
33
|
+
const shellWindowUsesSourcelessCanvas = shell_layout.shellWindowUsesSourcelessCanvas;
|
|
31
34
|
const nowNanoseconds = runtime_clock.nowNanoseconds;
|
|
32
35
|
const canvasWidgetAccessibilityActionKindFromPlatform = widget_bridge.canvasWidgetAccessibilityActionKindFromPlatform;
|
|
33
36
|
const parseAutomationCommandName = automation_commands.parseAutomationCommandName;
|
|
@@ -179,7 +182,10 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
179
182
|
const window = app_info.resolvedStartupWindow(0);
|
|
180
183
|
if (WindowViewMethods().findWindowIndexById(self, window.id) != null) return;
|
|
181
184
|
|
|
182
|
-
const runtime_index = try WindowViewMethods().reserveWindow(self, window.id, window.label, window.resolvedTitle(app_info.app_name), null, true);
|
|
185
|
+
const runtime_index = try WindowViewMethods().reserveWindow(self, window.id, window.label, window.resolvedTitle(app_info.app_name), null, true, .allow_source_less);
|
|
186
|
+
self.windows[runtime_index].activate_on_show = window.activate_on_show;
|
|
187
|
+
self.windows[runtime_index].info.focused = window.activate_on_show and window.show == .immediate;
|
|
188
|
+
self.windows[runtime_index].main_focused = self.windows[runtime_index].info.focused;
|
|
183
189
|
self.windows[runtime_index].info.frame = window.default_frame;
|
|
184
190
|
self.windows[runtime_index].main_frame = geometry.RectF.init(0, 0, window.default_frame.width, window.default_frame.height);
|
|
185
191
|
self.next_window_id = @max(self.next_window_id, window.id + 1);
|
|
@@ -630,14 +636,18 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
630
636
|
const window = app_info.resolvedStartupWindow(index);
|
|
631
637
|
const runtime_index = if (WindowViewMethods().findWindowIndexById(self, window.id)) |runtime_index| blk: {
|
|
632
638
|
self.windows[runtime_index].source = try WindowViewMethods().copySource(self, runtime_index, source);
|
|
639
|
+
self.windows[runtime_index].source_policy = .require_source;
|
|
633
640
|
break :blk runtime_index;
|
|
634
641
|
} else blk: {
|
|
635
|
-
const runtime_index = try WindowViewMethods().reserveWindow(self, window.id, window.label, window.resolvedTitle(app_info.app_name), source, true);
|
|
642
|
+
const runtime_index = try WindowViewMethods().reserveWindow(self, window.id, window.label, window.resolvedTitle(app_info.app_name), source, true, .require_source);
|
|
636
643
|
self.windows[runtime_index].info.frame = window.default_frame;
|
|
637
644
|
self.windows[runtime_index].main_frame = geometry.RectF.init(0, 0, window.default_frame.width, window.default_frame.height);
|
|
638
645
|
break :blk runtime_index;
|
|
639
646
|
};
|
|
640
647
|
self.windows[runtime_index].source_reloads_from_app = true;
|
|
648
|
+
self.windows[runtime_index].activate_on_show = window.activate_on_show;
|
|
649
|
+
self.windows[runtime_index].info.focused = index == 0 and window.activate_on_show and window.show == .immediate;
|
|
650
|
+
self.windows[runtime_index].main_focused = self.windows[runtime_index].info.focused;
|
|
641
651
|
if (index > 0) {
|
|
642
652
|
// The same `.hide` gate as the runtime create path
|
|
643
653
|
// (window_storage): secondary startup windows reach
|
|
@@ -656,7 +666,8 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
656
666
|
if (window.close_policy == .hide and !self.options.platform.supports(.window_hide_on_close)) {
|
|
657
667
|
return error.UnsupportedWindowClosePolicy;
|
|
658
668
|
}
|
|
659
|
-
|
|
669
|
+
const native_info = try self.options.platform.services.createWindow(window);
|
|
670
|
+
try WindowViewMethods().applyNativeInfo(self, runtime_index, native_info);
|
|
660
671
|
}
|
|
661
672
|
try self.options.platform.services.loadWindowWebView(window.id, self.windows[runtime_index].source.?);
|
|
662
673
|
try applyMainWebViewState(self, window.id);
|
|
@@ -675,16 +686,27 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
675
686
|
return;
|
|
676
687
|
}
|
|
677
688
|
|
|
678
|
-
const
|
|
689
|
+
const uses_default_empty_source = appUsesDefaultEmptyWebViewSource(App, app);
|
|
690
|
+
const source = if (sceneNeedsMainWebView(scene) or !uses_default_empty_source)
|
|
679
691
|
try WindowViewMethods().copyLoadedSource(self, try app.webViewSource())
|
|
680
692
|
else
|
|
681
693
|
null;
|
|
682
694
|
if (source != null and !self.options.web_layer) return error.WebViewLayerNotBuilt;
|
|
683
695
|
self.loaded_source = source;
|
|
684
696
|
|
|
685
|
-
|
|
697
|
+
const startup_uses_source = sceneWindowUsesAppSource(scene.windows[0], uses_default_empty_source);
|
|
698
|
+
try loadStartupSceneWindow(
|
|
699
|
+
self,
|
|
700
|
+
scene.windows[0],
|
|
701
|
+
if (startup_uses_source) source else null,
|
|
702
|
+
if (startup_uses_source) .allow_source_less else .never_source,
|
|
703
|
+
);
|
|
686
704
|
for (scene.windows[1..]) |window| {
|
|
687
|
-
|
|
705
|
+
if (sceneWindowUsesAppSource(window, uses_default_empty_source)) {
|
|
706
|
+
_ = try WindowViewMethods().createShellWindowWithSourceMode(self, window, source, source != null);
|
|
707
|
+
} else {
|
|
708
|
+
_ = try WindowViewMethods().createSourcelessShellWindow(self, window);
|
|
709
|
+
}
|
|
688
710
|
}
|
|
689
711
|
|
|
690
712
|
log(self, "scene.load", "loaded app scene", &.{
|
|
@@ -693,7 +715,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
693
715
|
});
|
|
694
716
|
}
|
|
695
717
|
|
|
696
|
-
fn loadStartupSceneWindow(self: *Runtime, shell_window: app_manifest.ShellWindow, source: ?platform.WebViewSource) anyerror!void {
|
|
718
|
+
fn loadStartupSceneWindow(self: *Runtime, shell_window: app_manifest.ShellWindow, source: ?platform.WebViewSource, source_policy: runtime_state.WindowSourcePolicy) anyerror!void {
|
|
697
719
|
const app_info = self.options.platform.app_info;
|
|
698
720
|
const startup_window = app_info.resolvedStartupWindow(0);
|
|
699
721
|
const window_id = startup_window.id;
|
|
@@ -712,6 +734,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
712
734
|
shell_window.title orelse app_info.resolvedWindowTitle(),
|
|
713
735
|
null,
|
|
714
736
|
true,
|
|
737
|
+
source_policy,
|
|
715
738
|
);
|
|
716
739
|
if (WindowViewMethods().findWindowIndexByLabel(self, shell_window.label)) |label_index| {
|
|
717
740
|
if (label_index != runtime_index) return error.DuplicateWindowLabel;
|
|
@@ -722,6 +745,14 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
722
745
|
self.windows[runtime_index].info.frame = startup_frame;
|
|
723
746
|
self.windows[runtime_index].source = if (source) |source_value| try WindowViewMethods().copySource(self, runtime_index, source_value) else null;
|
|
724
747
|
self.windows[runtime_index].source_reloads_from_app = source != null;
|
|
748
|
+
self.windows[runtime_index].source_policy = source_policy;
|
|
749
|
+
// The host created this startup window from AppInfo before
|
|
750
|
+
// the scene loaded. Overlay presentation is immutable host
|
|
751
|
+
// state, so runtime bookkeeping must retain that same source
|
|
752
|
+
// of truth even when the scene descriptor differs.
|
|
753
|
+
self.windows[runtime_index].activate_on_show = startup_window.activate_on_show;
|
|
754
|
+
self.windows[runtime_index].info.focused = startup_window.activate_on_show and startup_window.show == .immediate;
|
|
755
|
+
self.windows[runtime_index].main_focused = self.windows[runtime_index].info.focused;
|
|
725
756
|
if (!self.windows[runtime_index].main_frame_set) {
|
|
726
757
|
self.windows[runtime_index].main_frame = geometry.RectF.init(0, 0, startup_frame.width, startup_frame.height);
|
|
727
758
|
}
|
|
@@ -766,6 +797,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
766
797
|
return;
|
|
767
798
|
}
|
|
768
799
|
for (self.windows[0..self.window_count], 0..) |*window, index| {
|
|
800
|
+
if (window.source_policy == .never_source) continue;
|
|
769
801
|
if (window.source == null or window.source_reloads_from_app) {
|
|
770
802
|
window.source = try WindowViewMethods().copySource(self, index, source);
|
|
771
803
|
}
|
|
@@ -1269,3 +1301,9 @@ fn appUsesDefaultEmptyWebViewSource(comptime App: type, app: App) bool {
|
|
|
1269
1301
|
app.source.bytes.len == 0 and
|
|
1270
1302
|
app.source.asset_options == null;
|
|
1271
1303
|
}
|
|
1304
|
+
|
|
1305
|
+
fn sceneWindowUsesAppSource(shell_window: app_manifest.ShellWindow, app_uses_default_empty_source: bool) bool {
|
|
1306
|
+
if (shellWindowNeedsMainWebView(shell_window)) return true;
|
|
1307
|
+
if (shellWindowUsesSourcelessCanvas(shell_window)) return false;
|
|
1308
|
+
return !app_uses_default_empty_source;
|
|
1309
|
+
}
|
|
@@ -106,7 +106,6 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
106
106
|
self.views[index].gpu_backend = frame_event.backend;
|
|
107
107
|
self.views[index].gpu_pixel_format = frame_event.pixel_format;
|
|
108
108
|
self.views[index].gpu_present_mode = frame_event.present_mode;
|
|
109
|
-
self.views[index].gpu_alpha_mode = frame_event.alpha_mode;
|
|
110
109
|
self.views[index].gpu_color_space = frame_event.color_space;
|
|
111
110
|
self.views[index].gpu_vsync = frame_event.vsync;
|
|
112
111
|
self.views[index].gpu_status = frame_event.status;
|
|
@@ -119,6 +118,14 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
119
118
|
// the rebuild so the app sees it honestly.
|
|
120
119
|
enriched_frame_event.occluded = frame_event.occluded;
|
|
121
120
|
}
|
|
121
|
+
// Alpha mode is immutable surface configuration, not a
|
|
122
|
+
// completion-time measurement. The desktop ABIs predate
|
|
123
|
+
// premultiplied surfaces and stamp their legacy opaque
|
|
124
|
+
// default on every completion, while their actual pixel
|
|
125
|
+
// presenters already preserve/premultiply alpha. Keep the
|
|
126
|
+
// create-time mode authoritative and normalize the event
|
|
127
|
+
// delivered to the app in both diagnostics tiers.
|
|
128
|
+
enriched_frame_event.alpha_mode = self.views[index].gpu_alpha_mode;
|
|
122
129
|
// Native scroll drivers reconcile against live host state
|
|
123
130
|
// on every presented frame (the relayout-stomp lesson: a
|
|
124
131
|
// one-shot frame patch races shell relayout): frames,
|
|
@@ -313,8 +320,8 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
313
320
|
} else {
|
|
314
321
|
try CanvasWidgetEventMethods().updateCanvasWidgetControlFromPointer(self, pointer_event.*);
|
|
315
322
|
try CanvasWidgetEventMethods().updateCanvasWidgetInteractionFromPointer(self, pointer_event.*);
|
|
316
|
-
// The text pass may stamp a
|
|
317
|
-
// event for the app dispatch below.
|
|
323
|
+
// The text pass may stamp a caret/selection or clear
|
|
324
|
+
// edit onto the event for the app dispatch below.
|
|
318
325
|
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromPointer(self, pointer_event);
|
|
319
326
|
try CanvasWidgetEventMethods().updateCanvasWidgetScrollFromPointer(self, pointer_event.*);
|
|
320
327
|
try CanvasWidgetEventMethods().updateCanvasWidgetFocusFromPointer(self, pointer_event.*);
|
|
@@ -309,20 +309,21 @@ test "runtime dispatches GPU surface events" {
|
|
|
309
309
|
.label = "canvas",
|
|
310
310
|
.kind = .gpu_surface,
|
|
311
311
|
.frame = geometry.RectF.init(0, 0, 640, 360),
|
|
312
|
+
.gpu_surface = .{ .alpha_mode = .premultiplied },
|
|
312
313
|
});
|
|
313
314
|
const initial_frame = try harness.runtime.gpuSurfaceFrame(1, "canvas");
|
|
314
315
|
try std.testing.expectEqual(created.id, initial_frame.surface_id);
|
|
315
316
|
try std.testing.expectEqual(platform.GpuSurfaceBackend.metal, created.gpu_backend);
|
|
316
317
|
try std.testing.expectEqual(platform.GpuSurfacePixelFormat.bgra8_unorm, created.gpu_pixel_format);
|
|
317
318
|
try std.testing.expectEqual(platform.GpuSurfacePresentMode.timer, created.gpu_present_mode);
|
|
318
|
-
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode
|
|
319
|
+
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode.premultiplied, created.gpu_alpha_mode);
|
|
319
320
|
try std.testing.expectEqual(platform.GpuSurfaceColorSpace.srgb, created.gpu_color_space);
|
|
320
321
|
try std.testing.expect(created.gpu_vsync);
|
|
321
322
|
try std.testing.expectEqual(platform.GpuSurfaceStatus.ready, created.gpu_status);
|
|
322
323
|
try std.testing.expectEqual(platform.GpuSurfaceBackend.metal, initial_frame.backend);
|
|
323
324
|
try std.testing.expectEqual(platform.GpuSurfacePixelFormat.bgra8_unorm, initial_frame.pixel_format);
|
|
324
325
|
try std.testing.expectEqual(platform.GpuSurfacePresentMode.timer, initial_frame.present_mode);
|
|
325
|
-
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode
|
|
326
|
+
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode.premultiplied, initial_frame.alpha_mode);
|
|
326
327
|
try std.testing.expectEqual(platform.GpuSurfaceColorSpace.srgb, initial_frame.color_space);
|
|
327
328
|
try std.testing.expect(initial_frame.vsync);
|
|
328
329
|
try std.testing.expectEqual(platform.GpuSurfaceStatus.ready, initial_frame.status);
|
|
@@ -389,7 +390,9 @@ test "runtime dispatches GPU surface events" {
|
|
|
389
390
|
try std.testing.expectEqual(platform.GpuSurfaceBackend.metal, app_state.last_gpu_backend);
|
|
390
391
|
try std.testing.expectEqual(platform.GpuSurfacePixelFormat.bgra8_unorm, app_state.last_gpu_pixel_format);
|
|
391
392
|
try std.testing.expectEqual(platform.GpuSurfacePresentMode.timer, app_state.last_gpu_present_mode);
|
|
392
|
-
|
|
393
|
+
// Desktop hosts still stamp their legacy opaque completion value;
|
|
394
|
+
// runtime delivery preserves the surface's create-time contract.
|
|
395
|
+
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode.premultiplied, app_state.last_gpu_alpha_mode);
|
|
393
396
|
try std.testing.expectEqual(platform.GpuSurfaceColorSpace.srgb, app_state.last_gpu_color_space);
|
|
394
397
|
try std.testing.expect(app_state.last_gpu_vsync);
|
|
395
398
|
try std.testing.expectEqual(platform.GpuSurfaceStatus.ready, app_state.last_gpu_status);
|
|
@@ -444,7 +447,7 @@ test "runtime dispatches GPU surface events" {
|
|
|
444
447
|
try std.testing.expectEqual(platform.GpuSurfaceBackend.metal, frame.backend);
|
|
445
448
|
try std.testing.expectEqual(platform.GpuSurfacePixelFormat.bgra8_unorm, frame.pixel_format);
|
|
446
449
|
try std.testing.expectEqual(platform.GpuSurfacePresentMode.timer, frame.present_mode);
|
|
447
|
-
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode
|
|
450
|
+
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode.premultiplied, frame.alpha_mode);
|
|
448
451
|
try std.testing.expectEqual(platform.GpuSurfaceColorSpace.srgb, frame.color_space);
|
|
449
452
|
try std.testing.expect(frame.vsync);
|
|
450
453
|
try std.testing.expectEqual(platform.GpuSurfaceStatus.ready, frame.status);
|
|
@@ -515,7 +518,7 @@ test "runtime dispatches GPU surface events" {
|
|
|
515
518
|
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuBackend\":\"metal\"") != null);
|
|
516
519
|
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuPixelFormat\":\"bgra8_unorm\"") != null);
|
|
517
520
|
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuPresentMode\":\"timer\"") != null);
|
|
518
|
-
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuAlphaMode\":\"
|
|
521
|
+
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuAlphaMode\":\"premultiplied\"") != null);
|
|
519
522
|
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuColorSpace\":\"srgb\"") != null);
|
|
520
523
|
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuVsync\":true") != null);
|
|
521
524
|
try std.testing.expect(std.mem.indexOf(u8, view_json, "\"gpuStatus\":\"ready\"") != null);
|
|
@@ -586,7 +589,7 @@ test "runtime dispatches GPU surface events" {
|
|
|
586
589
|
try std.testing.expectEqual(platform.GpuSurfaceBackend.metal, preview_frame.backend);
|
|
587
590
|
try std.testing.expectEqual(platform.GpuSurfacePixelFormat.bgra8_unorm, preview_frame.pixel_format);
|
|
588
591
|
try std.testing.expectEqual(platform.GpuSurfacePresentMode.timer, preview_frame.present_mode);
|
|
589
|
-
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode
|
|
592
|
+
try std.testing.expectEqual(platform.GpuSurfaceAlphaMode.premultiplied, preview_frame.alpha_mode);
|
|
590
593
|
try std.testing.expectEqual(platform.GpuSurfaceColorSpace.srgb, preview_frame.color_space);
|
|
591
594
|
try std.testing.expect(preview_frame.vsync);
|
|
592
595
|
try std.testing.expectEqual(platform.GpuSurfaceStatus.ready, preview_frame.status);
|
|
@@ -582,10 +582,11 @@ test "a recorded session replays to identical model state and fingerprints" {
|
|
|
582
582
|
try std.testing.expect(recorded.model.stamp_ms != 0);
|
|
583
583
|
try std.testing.expectEqual(@as(u32, 1), recorded.model.spectrum_count);
|
|
584
584
|
try std.testing.expect(recorded.model.band_checksum != 0);
|
|
585
|
-
//
|
|
586
|
-
// multi-line paste all reached the
|
|
587
|
-
//
|
|
588
|
-
|
|
585
|
+
// Both pointer caret placements, the typed insert, the DERIVED
|
|
586
|
+
// Escape-clear, and the sanitized multi-line paste all reached the
|
|
587
|
+
// model's `on_input` mirror — five edits total, with the paste
|
|
588
|
+
// landing STRIPPED of its line breaks (single-line rule).
|
|
589
|
+
try std.testing.expectEqual(@as(u32, 5), recorded.model.query_edits);
|
|
589
590
|
try std.testing.expectEqualStrings("line oneline two", recorded.model.queryText());
|
|
590
591
|
// Both pinch gestures reached the model: the raw stream's product
|
|
591
592
|
// (1.25 * 0.75 = 0.9375) times the verb's exact 1.5.
|
|
@@ -239,19 +239,33 @@ pub fn shellWindowShowMode(shell_window: app_manifest.ShellWindow) platform.Wind
|
|
|
239
239
|
return .immediate;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
/// Whether
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
242
|
+
/// Whether this window declares the app source as its `main` WebView.
|
|
243
|
+
pub fn shellWindowNeedsMainWebView(window: app_manifest.ShellWindow) bool {
|
|
244
|
+
for (window.views) |view| {
|
|
245
|
+
if (view.kind == .webview and validation.isMainWebViewLabel(view.label)) return true;
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/// A canvas-owned window has no WebView content of its own. It must stay
|
|
251
|
+
/// sourceless even when another scene window loads the app source: otherwise
|
|
252
|
+
/// the source silently materializes a full-window main WebView behind the
|
|
253
|
+
/// canvas (and transparent Windows windows reject creation altogether).
|
|
254
|
+
pub fn shellWindowUsesSourcelessCanvas(window: app_manifest.ShellWindow) bool {
|
|
255
|
+
var has_gpu_surface = false;
|
|
256
|
+
for (window.views) |view| {
|
|
257
|
+
if (view.kind == .webview) return false;
|
|
258
|
+
if (view.kind == .gpu_surface) has_gpu_surface = true;
|
|
259
|
+
}
|
|
260
|
+
return has_gpu_surface;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// Whether loading this scene must copy the app's WebView source at all.
|
|
264
|
+
/// Per-window routing happens in `loadScene`: a scene may need the source
|
|
265
|
+
/// for one WebView window while keeping a canvas overlay sourceless.
|
|
250
266
|
pub fn sceneNeedsMainWebView(scene: app_manifest.ShellConfig) bool {
|
|
251
267
|
for (scene.windows) |window| {
|
|
252
|
-
|
|
253
|
-
if (view.kind == .webview and validation.isMainWebViewLabel(view.label)) return true;
|
|
254
|
-
}
|
|
268
|
+
if (shellWindowNeedsMainWebView(window)) return true;
|
|
255
269
|
}
|
|
256
270
|
return false;
|
|
257
271
|
}
|