@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
|
@@ -13,6 +13,7 @@ pub const Error = error{
|
|
|
13
13
|
CreateFailed,
|
|
14
14
|
FocusFailed,
|
|
15
15
|
CloseFailed,
|
|
16
|
+
UnsupportedWindowTransparency,
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const AppKitHost = opaque {};
|
|
@@ -155,7 +156,7 @@ const shortcut_modifier_control: u32 = 1 << 2;
|
|
|
155
156
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
156
157
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
157
158
|
|
|
158
|
-
extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, display_name: [*]const u8, display_name_len: usize, version: [*]const u8, version_len: usize, about_description: [*]const u8, about_description_len: usize, has_web_content: c_int, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int) ?*AppKitHost;
|
|
159
|
+
extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, display_name: [*]const u8, display_name_len: usize, version: [*]const u8, version_len: usize, about_description: [*]const u8, about_description_len: usize, has_web_content: c_int, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int, window_flags: u32) ?*AppKitHost;
|
|
159
160
|
extern fn native_sdk_appkit_destroy(host: *AppKitHost) void;
|
|
160
161
|
extern fn native_sdk_appkit_set_dock_icon_rgba(host: *AppKitHost, pixels: [*]const u8, width: usize, height: usize) void;
|
|
161
162
|
extern fn native_sdk_appkit_set_dock_icon_file(host: *AppKitHost, path: [*]const u8, path_len: usize) void;
|
|
@@ -173,7 +174,7 @@ extern fn native_sdk_appkit_set_security_policy(host: *AppKitHost, allowed_origi
|
|
|
173
174
|
extern fn native_sdk_appkit_set_menus(host: *AppKitHost, menu_titles: [*]const [*]const u8, menu_title_lens: [*]const usize, menu_count: usize, item_menu_indices: [*]const u32, item_labels: [*]const [*]const u8, item_label_lens: [*]const usize, item_commands: [*]const [*]const u8, item_command_lens: [*]const usize, item_keys: [*]const [*]const u8, item_key_lens: [*]const usize, item_modifiers: [*]const u32, item_separators: [*]const c_int, item_enabled: [*]const c_int, item_checked: [*]const c_int, item_count: usize) void;
|
|
174
175
|
extern fn native_sdk_appkit_set_shortcuts(host: *AppKitHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
175
176
|
extern fn native_sdk_appkit_request_frame(host: *AppKitHost) void;
|
|
176
|
-
extern fn native_sdk_appkit_create_window(host: *AppKitHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int) c_int;
|
|
177
|
+
extern fn native_sdk_appkit_create_window(host: *AppKitHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int, window_flags: u32) c_int;
|
|
177
178
|
extern fn native_sdk_appkit_set_window_content_min_size(host: *AppKitHost, window_id: u64, min_width: f64, min_height: f64) c_int;
|
|
178
179
|
extern fn native_sdk_appkit_focus_window(host: *AppKitHost, window_id: u64) c_int;
|
|
179
180
|
extern fn native_sdk_appkit_close_window(host: *AppKitHost, window_id: u64) c_int;
|
|
@@ -595,6 +596,7 @@ pub const MacPlatform = struct {
|
|
|
595
596
|
|
|
596
597
|
pub fn initWithOptions(size: geometry.SizeF, web_engine: platform_mod.WebEngine, app_info: platform_mod.AppInfo) Error!MacPlatform {
|
|
597
598
|
const window_options = app_info.resolvedMainWindow();
|
|
599
|
+
try refuseUnsupportedTransparentWindow(web_engine, window_options);
|
|
598
600
|
const window_title = window_options.resolvedTitle(app_info.app_name);
|
|
599
601
|
const frame = window_options.default_frame;
|
|
600
602
|
const display_name = app_info.resolvedDisplayName();
|
|
@@ -610,7 +612,7 @@ pub const MacPlatform = struct {
|
|
|
610
612
|
// the classic load byte-for-byte.
|
|
611
613
|
const dock_icon = planDockIcon(app_info.icon_path);
|
|
612
614
|
const icon_path = if (dock_icon == .host_file) app_info.icon_path else "";
|
|
613
|
-
const host = native_sdk_appkit_create(app_info.app_name.ptr, app_info.app_name.len, display_name.ptr, display_name.len, app_info.version.ptr, app_info.version.len, app_info.description.ptr, app_info.description.len, if (app_info.has_web_content) 1 else 0, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, icon_path.ptr, icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), showModeInt(window_options.show)) orelse return error.CreateFailed;
|
|
615
|
+
const host = native_sdk_appkit_create(app_info.app_name.ptr, app_info.app_name.len, display_name.ptr, display_name.len, app_info.version.ptr, app_info.version.len, app_info.description.ptr, app_info.description.len, if (app_info.has_web_content) 1 else 0, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, icon_path.ptr, icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
614
616
|
switch (dock_icon) {
|
|
615
617
|
.host_file => {},
|
|
616
618
|
.masked_render => spawnDevDockIconRender(host, app_info.icon_path),
|
|
@@ -1220,6 +1222,19 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
1220
1222
|
};
|
|
1221
1223
|
}
|
|
1222
1224
|
|
|
1225
|
+
fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
1226
|
+
var flags: u32 = 0;
|
|
1227
|
+
if (options.transparent) flags |= 1 << 0;
|
|
1228
|
+
if (options.always_on_top) flags |= 1 << 1;
|
|
1229
|
+
if (options.click_through) flags |= 1 << 2;
|
|
1230
|
+
if (!options.activate_on_show) flags |= 1 << 3;
|
|
1231
|
+
return flags;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
fn refuseUnsupportedTransparentWindow(web_engine: platform_mod.WebEngine, options: platform_mod.WindowOptions) Error!void {
|
|
1235
|
+
if (web_engine == .chromium and options.transparent) return error.UnsupportedWindowTransparency;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1223
1238
|
fn closePolicyInt(policy: platform_mod.WindowClosePolicy) c_int {
|
|
1224
1239
|
return switch (policy) {
|
|
1225
1240
|
.quit => 0,
|
|
@@ -1249,9 +1264,10 @@ fn applyWindowContentMinSize(host: *AppKitHost, window_id: u64, min_width: f32,
|
|
|
1249
1264
|
|
|
1250
1265
|
fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyerror!platform_mod.WindowInfo {
|
|
1251
1266
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1267
|
+
try refuseUnsupportedTransparentWindow(self.web_engine, options);
|
|
1252
1268
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
1253
1269
|
const frame = options.default_frame;
|
|
1254
|
-
if (native_sdk_appkit_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), showModeInt(options.show)) == 0) return error.CreateFailed;
|
|
1270
|
+
if (native_sdk_appkit_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
1255
1271
|
applyWindowContentMinSize(self.host, options.id, options.min_width, options.min_height);
|
|
1256
1272
|
applyWindowClosePolicy(self.host, options.id, options.close_policy);
|
|
1257
1273
|
return .{
|
|
@@ -1261,7 +1277,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
1261
1277
|
.frame = frame,
|
|
1262
1278
|
.scale_factor = 1,
|
|
1263
1279
|
.open = true,
|
|
1264
|
-
.focused =
|
|
1280
|
+
.focused = options.activate_on_show and options.show == .immediate,
|
|
1265
1281
|
};
|
|
1266
1282
|
}
|
|
1267
1283
|
|
|
@@ -2252,6 +2268,22 @@ test "macos chromium reports unsupported native surfaces" {
|
|
|
2252
2268
|
try std.testing.expect(!MacPlatform.supportsFeature(&chromium, .view_surface_adoption));
|
|
2253
2269
|
}
|
|
2254
2270
|
|
|
2271
|
+
test "macos chromium refuses transparent windows" {
|
|
2272
|
+
try refuseUnsupportedTransparentWindow(.system, .{ .transparent = true });
|
|
2273
|
+
try refuseUnsupportedTransparentWindow(.chromium, .{});
|
|
2274
|
+
try std.testing.expectError(
|
|
2275
|
+
error.UnsupportedWindowTransparency,
|
|
2276
|
+
refuseUnsupportedTransparentWindow(.chromium, .{ .transparent = true }),
|
|
2277
|
+
);
|
|
2278
|
+
|
|
2279
|
+
const host_source = @embedFile("cef_host.mm");
|
|
2280
|
+
try std.testing.expect(std.mem.count(
|
|
2281
|
+
u8,
|
|
2282
|
+
host_source,
|
|
2283
|
+
"if ((window_flags & (1u << 0)) != 0) return",
|
|
2284
|
+
) >= 2);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2255
2287
|
fn testPlatformWithEngine(web_engine: platform_mod.WebEngine) MacPlatform {
|
|
2256
2288
|
return .{
|
|
2257
2289
|
.host = undefined,
|
|
@@ -2423,6 +2455,112 @@ test "mac webview presses report the focused child label" {
|
|
|
2423
2455
|
try std.testing.expect(std.mem.indexOf(u8, host_source, ".view_label = label") != null);
|
|
2424
2456
|
}
|
|
2425
2457
|
|
|
2458
|
+
test "mac active implicit show activates before making the window key" {
|
|
2459
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2460
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source,
|
|
2461
|
+
\\ if ([self.passiveShowWindows containsObject:@(windowId)]) {
|
|
2462
|
+
\\ [window orderFront:nil];
|
|
2463
|
+
\\ } else {
|
|
2464
|
+
\\ [NSApp activate];
|
|
2465
|
+
\\ [window makeKeyAndOrderFront:nil];
|
|
2466
|
+
\\ }
|
|
2467
|
+
) != null);
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
test "mac explicit focus activates before making the window key" {
|
|
2471
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2472
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source,
|
|
2473
|
+
\\- (void)focusWindowWithId:(uint64_t)windowId {
|
|
2474
|
+
\\ NSWindow *window = self.windows[@(windowId)];
|
|
2475
|
+
\\ if (!window) return;
|
|
2476
|
+
\\ // An explicit focus overrides a pending present-before-show defer:
|
|
2477
|
+
\\ // the runtime asked for the window NOW.
|
|
2478
|
+
\\ [self.deferredShowWindows removeObjectForKey:@(windowId)];
|
|
2479
|
+
\\ [NSApp activate];
|
|
2480
|
+
\\ [window makeKeyAndOrderFront:nil];
|
|
2481
|
+
) != null);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
2485
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2486
|
+
const helper_at = std.mem.indexOf(
|
|
2487
|
+
u8,
|
|
2488
|
+
host_source,
|
|
2489
|
+
"static void NativeSdkPremultiplyStraightRgba8",
|
|
2490
|
+
) orelse return error.TestExpectedEqual;
|
|
2491
|
+
const present_at = std.mem.indexOfPos(
|
|
2492
|
+
u8,
|
|
2493
|
+
host_source,
|
|
2494
|
+
helper_at,
|
|
2495
|
+
"- (BOOL)presentPixelsWithWidth:",
|
|
2496
|
+
) orelse return error.TestExpectedEqual;
|
|
2497
|
+
const present_tail = host_source[present_at..];
|
|
2498
|
+
|
|
2499
|
+
try std.testing.expect(helper_at < present_at);
|
|
2500
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2501
|
+
u8,
|
|
2502
|
+
present_tail,
|
|
2503
|
+
"if (self.window && !self.window.opaque && !sourceIsPremultiplied)",
|
|
2504
|
+
) != null);
|
|
2505
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2506
|
+
u8,
|
|
2507
|
+
present_tail,
|
|
2508
|
+
"NativeSdkPremultiplyStraightRgba8(",
|
|
2509
|
+
) != null);
|
|
2510
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2511
|
+
u8,
|
|
2512
|
+
present_tail,
|
|
2513
|
+
"sourceIsPremultiplied:YES rgba8:(const uint8_t *)pixels.bytes",
|
|
2514
|
+
) != null);
|
|
2515
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2516
|
+
u8,
|
|
2517
|
+
present_tail,
|
|
2518
|
+
"sourceIsPremultiplied:NO rgba8:rgba8",
|
|
2519
|
+
) != null);
|
|
2520
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2521
|
+
u8,
|
|
2522
|
+
present_tail,
|
|
2523
|
+
"const uint8_t *uploadBytes = presentBytes +",
|
|
2524
|
+
) != null);
|
|
2525
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2526
|
+
u8,
|
|
2527
|
+
present_tail,
|
|
2528
|
+
"memcpy(backingBytes, presentBytes, byteLength);",
|
|
2529
|
+
) != null);
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
test "mac transparent gpu surfaces clear missing canvas content to transparent" {
|
|
2533
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2534
|
+
const render_at = std.mem.indexOf(
|
|
2535
|
+
u8,
|
|
2536
|
+
host_source,
|
|
2537
|
+
"- (void)renderFrame {",
|
|
2538
|
+
) orelse return error.TestExpectedEqual;
|
|
2539
|
+
const render_end = std.mem.indexOfPos(
|
|
2540
|
+
u8,
|
|
2541
|
+
host_source,
|
|
2542
|
+
render_at,
|
|
2543
|
+
"- (BOOL)acceptsFirstResponder",
|
|
2544
|
+
) orelse return error.TestExpectedEqual;
|
|
2545
|
+
const render_source = host_source[render_at..render_end];
|
|
2546
|
+
|
|
2547
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2548
|
+
u8,
|
|
2549
|
+
render_source,
|
|
2550
|
+
"const BOOL transparentWindow = window != nil && !window.opaque;",
|
|
2551
|
+
) != null);
|
|
2552
|
+
try std.testing.expect(std.mem.indexOf(u8, render_source,
|
|
2553
|
+
\\descriptor.colorAttachments[0].clearColor = transparentWindow
|
|
2554
|
+
\\ ? MTLClearColorMake(0.0, 0.0, 0.0, 0.0)
|
|
2555
|
+
\\ : MTLClearColorMake(red, green, blue, 1.0);
|
|
2556
|
+
) != null);
|
|
2557
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2558
|
+
u8,
|
|
2559
|
+
render_source,
|
|
2560
|
+
"if (self.hasCanvasTexture && canvasTextureMatchesDrawable",
|
|
2561
|
+
) != null);
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2426
2564
|
test "mac Chromium webview focus reports the focused child label" {
|
|
2427
2565
|
// CEF's focus handler is the engine-level ownership edge: it covers
|
|
2428
2566
|
// pointer, keyboard, and programmatic focus without predicting from
|
|
@@ -328,6 +328,10 @@ pub const NullPlatform = struct {
|
|
|
328
328
|
/// like `windows` — same seam-regression purpose as
|
|
329
329
|
/// `window_resizable` (the startup create used to hardcode it).
|
|
330
330
|
window_titlebar: [max_windows]WindowTitlebarStyle = [_]WindowTitlebarStyle{.standard} ** max_windows,
|
|
331
|
+
window_transparent: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
332
|
+
window_always_on_top: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
333
|
+
window_click_through: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
334
|
+
window_activate_on_show: [max_windows]bool = [_]bool{true} ** max_windows,
|
|
331
335
|
/// Minimize calls per window (`minimize_window_fn`), indexed like
|
|
332
336
|
/// `windows`: the observable seam for app-drawn minimize controls —
|
|
333
337
|
/// the null platform has no Dock to genie into, so the count IS the
|
|
@@ -937,7 +941,7 @@ pub const NullPlatform = struct {
|
|
|
937
941
|
.frame = window.default_frame,
|
|
938
942
|
.scale_factor = self.surface_value.scale_factor,
|
|
939
943
|
.open = true,
|
|
940
|
-
.focused = index == 0,
|
|
944
|
+
.focused = index == 0 and window.activate_on_show and window.show == .immediate,
|
|
941
945
|
} });
|
|
942
946
|
}
|
|
943
947
|
var frame: u32 = 0;
|
|
@@ -1037,6 +1041,10 @@ pub const NullPlatform = struct {
|
|
|
1037
1041
|
if (window.id == options.id) return error.DuplicateWindowId;
|
|
1038
1042
|
if (std.mem.eql(u8, window.label, options.label)) return error.DuplicateWindowLabel;
|
|
1039
1043
|
}
|
|
1044
|
+
const focused = options.activate_on_show and options.show == .immediate;
|
|
1045
|
+
if (focused) {
|
|
1046
|
+
for (self.windows[0..self.window_count]) |*window| window.focused = false;
|
|
1047
|
+
}
|
|
1040
1048
|
const info: WindowInfo = .{
|
|
1041
1049
|
.id = options.id,
|
|
1042
1050
|
.label = options.label,
|
|
@@ -1044,11 +1052,15 @@ pub const NullPlatform = struct {
|
|
|
1044
1052
|
.frame = options.default_frame,
|
|
1045
1053
|
.scale_factor = self.surface_value.scale_factor,
|
|
1046
1054
|
.open = true,
|
|
1047
|
-
.focused =
|
|
1055
|
+
.focused = focused,
|
|
1048
1056
|
};
|
|
1049
1057
|
self.windows[self.window_count] = info;
|
|
1050
1058
|
self.window_resizable[self.window_count] = options.resizable;
|
|
1051
1059
|
self.window_titlebar[self.window_count] = options.titlebar;
|
|
1060
|
+
self.window_transparent[self.window_count] = options.transparent;
|
|
1061
|
+
self.window_always_on_top[self.window_count] = options.always_on_top;
|
|
1062
|
+
self.window_click_through[self.window_count] = options.click_through;
|
|
1063
|
+
self.window_activate_on_show[self.window_count] = options.activate_on_show;
|
|
1052
1064
|
self.window_show[self.window_count] = options.show;
|
|
1053
1065
|
self.window_close_policy[self.window_count] = options.close_policy;
|
|
1054
1066
|
self.window_min_width[self.window_count] = options.min_width;
|
|
@@ -1081,6 +1093,11 @@ pub const NullPlatform = struct {
|
|
|
1081
1093
|
self.window_visible[index] = true;
|
|
1082
1094
|
self.show_op_seq += 1;
|
|
1083
1095
|
self.window_shown_seq[index] = self.show_op_seq;
|
|
1096
|
+
if (self.window_activate_on_show[index]) {
|
|
1097
|
+
for (self.windows[0..self.window_count], 0..) |*window, cursor| {
|
|
1098
|
+
window.focused = cursor == index;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1084
1101
|
}
|
|
1085
1102
|
}
|
|
1086
1103
|
|
|
@@ -1175,8 +1192,10 @@ pub const NullPlatform = struct {
|
|
|
1175
1192
|
// present-before-show alike.
|
|
1176
1193
|
self.windows[index].hidden = false;
|
|
1177
1194
|
self.window_occluded[index] = false;
|
|
1178
|
-
|
|
1179
|
-
|
|
1195
|
+
if (self.window_activate_on_show[index]) {
|
|
1196
|
+
for (self.windows[0..self.window_count], 0..) |*window, cursor| {
|
|
1197
|
+
window.focused = cursor == index;
|
|
1198
|
+
}
|
|
1180
1199
|
}
|
|
1181
1200
|
if (!self.window_visible[index]) {
|
|
1182
1201
|
self.window_visible[index] = true;
|
|
@@ -2591,6 +2610,15 @@ pub const NullPlatform = struct {
|
|
|
2591
2610
|
while (cursor + 1 < self.window_count) : (cursor += 1) {
|
|
2592
2611
|
self.windows[cursor] = self.windows[cursor + 1];
|
|
2593
2612
|
self.window_resizable[cursor] = self.window_resizable[cursor + 1];
|
|
2613
|
+
self.window_titlebar[cursor] = self.window_titlebar[cursor + 1];
|
|
2614
|
+
self.window_transparent[cursor] = self.window_transparent[cursor + 1];
|
|
2615
|
+
self.window_always_on_top[cursor] = self.window_always_on_top[cursor + 1];
|
|
2616
|
+
self.window_click_through[cursor] = self.window_click_through[cursor + 1];
|
|
2617
|
+
self.window_activate_on_show[cursor] = self.window_activate_on_show[cursor + 1];
|
|
2618
|
+
self.window_show[cursor] = self.window_show[cursor + 1];
|
|
2619
|
+
self.window_visible[cursor] = self.window_visible[cursor + 1];
|
|
2620
|
+
self.window_first_present_seq[cursor] = self.window_first_present_seq[cursor + 1];
|
|
2621
|
+
self.window_shown_seq[cursor] = self.window_shown_seq[cursor + 1];
|
|
2594
2622
|
self.window_min_width[cursor] = self.window_min_width[cursor + 1];
|
|
2595
2623
|
self.window_min_height[cursor] = self.window_min_height[cursor + 1];
|
|
2596
2624
|
self.window_minimize_count[cursor] = self.window_minimize_count[cursor + 1];
|
package/src/platform/types.zig
CHANGED
|
@@ -8,6 +8,7 @@ pub const default_gpu_first_frame_latency_budget_ns: u64 = 150_000_000;
|
|
|
8
8
|
|
|
9
9
|
pub const Error = error{
|
|
10
10
|
UnsupportedService,
|
|
11
|
+
UnsupportedWindowTransparency,
|
|
11
12
|
WindowNotFound,
|
|
12
13
|
WindowLimitReached,
|
|
13
14
|
DuplicateWindowId,
|
|
@@ -594,6 +595,22 @@ pub const WindowOptions = struct {
|
|
|
594
595
|
restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
|
|
595
596
|
titlebar: WindowTitlebarStyle = .standard,
|
|
596
597
|
show: WindowShowMode = .immediate,
|
|
598
|
+
/// Make the top-level window and its rendering surface alpha-capable.
|
|
599
|
+
/// The app must also render alpha (for canvas views, select a
|
|
600
|
+
/// non-opaque gpu alpha mode); otherwise opaque content still covers
|
|
601
|
+
/// the desktop normally. Backends that cannot provide an alpha-capable
|
|
602
|
+
/// render surface reject creation with `UnsupportedWindowTransparency`.
|
|
603
|
+
transparent: bool = false,
|
|
604
|
+
/// Keep the window above ordinary application windows using the
|
|
605
|
+
/// platform's floating/topmost window level.
|
|
606
|
+
always_on_top: bool = false,
|
|
607
|
+
/// Ignore pointer hit testing for the whole top-level window so
|
|
608
|
+
/// clicks, motion, and scrolling reach the window underneath.
|
|
609
|
+
click_through: bool = false,
|
|
610
|
+
/// Whether an implicit show (initial creation, first-present reveal,
|
|
611
|
+
/// or `showWindow`) activates the app and takes keyboard focus.
|
|
612
|
+
/// Explicit `focusWindow` remains an activation request either way.
|
|
613
|
+
activate_on_show: bool = true,
|
|
597
614
|
/// Content min-size floor the WINDOW enforces (macOS
|
|
598
615
|
/// `contentMinSize`): the user cannot resize below it, so declared
|
|
599
616
|
/// layout floors stop clamping/clipping panes instead of stopping
|
|
@@ -667,6 +684,10 @@ pub const WindowCreateOptions = struct {
|
|
|
667
684
|
restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
|
|
668
685
|
titlebar: WindowTitlebarStyle = .standard,
|
|
669
686
|
show: WindowShowMode = .immediate,
|
|
687
|
+
transparent: bool = false,
|
|
688
|
+
always_on_top: bool = false,
|
|
689
|
+
click_through: bool = false,
|
|
690
|
+
activate_on_show: bool = true,
|
|
670
691
|
/// Window-enforced content min-size floor (see
|
|
671
692
|
/// `WindowOptions.min_width`/`min_height`); 0 = no floor.
|
|
672
693
|
min_width: f32 = 0,
|
|
@@ -686,6 +707,10 @@ pub const WindowCreateOptions = struct {
|
|
|
686
707
|
.restore_policy = self.restore_policy,
|
|
687
708
|
.titlebar = self.titlebar,
|
|
688
709
|
.show = self.show,
|
|
710
|
+
.transparent = self.transparent,
|
|
711
|
+
.always_on_top = self.always_on_top,
|
|
712
|
+
.click_through = self.click_through,
|
|
713
|
+
.activate_on_show = self.activate_on_show,
|
|
689
714
|
.min_width = self.min_width,
|
|
690
715
|
.min_height = self.min_height,
|
|
691
716
|
.close_policy = self.close_policy,
|
|
@@ -853,7 +878,7 @@ pub const GpuSurfaceOptions = struct {
|
|
|
853
878
|
return (self.backend == .metal or self.backend == .software) and
|
|
854
879
|
self.pixel_format == .bgra8_unorm and
|
|
855
880
|
self.present_mode == .timer and
|
|
856
|
-
self.alpha_mode == .@"opaque" and
|
|
881
|
+
(self.alpha_mode == .@"opaque" or self.alpha_mode == .premultiplied) and
|
|
857
882
|
self.color_space == .srgb and
|
|
858
883
|
self.vsync;
|
|
859
884
|
}
|
|
@@ -2303,9 +2328,9 @@ pub const PlatformServices = struct {
|
|
|
2303
2328
|
/// controls — chromeless windows have no system button to click.
|
|
2304
2329
|
/// Platforms without the concept leave this null.
|
|
2305
2330
|
minimize_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
|
|
2306
|
-
/// The real OS show verb: unhide +
|
|
2307
|
-
///
|
|
2308
|
-
///
|
|
2331
|
+
/// The real OS show verb: unhide + order front. It activates by
|
|
2332
|
+
/// default; windows created with `activate_on_show = false` use the
|
|
2333
|
+
/// platform's passive variant. This is the counterpart to a
|
|
2309
2334
|
/// `close_policy = .hide` hide, and the tray "Open" consequence.
|
|
2310
2335
|
/// Platforms without the concept leave this null.
|
|
2311
2336
|
show_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
|