@native-sdk/cli 0.8.4 → 0.9.0
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/app.zig +859 -62
- package/build.zig +543 -13
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +2 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +365 -2
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +149 -0
- package/packages/core/sdk/core.ts +529 -12
- package/packages/core/sdk/events.d.ts +36 -0
- package/packages/core/sdk/events.ts +57 -0
- package/packages/core/src/checker.ts +468 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1847 -16
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +82 -16
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +47 -0
- package/skill-data/ts-core/SKILL.md +80 -31
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +249 -8
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +109 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +119 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +40 -18
- package/src/platform/macos/appkit_host.h +16 -3
- package/src/platform/macos/appkit_host.m +536 -36
- package/src/platform/macos/cef_host.mm +248 -36
- package/src/platform/macos/root.zig +244 -34
- package/src/platform/null_platform.zig +223 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +179 -15
- package/src/platform/windows/root.zig +187 -21
- package/src/platform/windows/webview2_host.cpp +293 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/root.zig +46 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +18 -11
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2295 -113
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +49 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +4 -0
- package/src/runtime/ts_core_host.zig +788 -86
- package/src/runtime/ts_core_host_tests.zig +231 -11
- package/src/runtime/ts_ui_app.zig +499 -1
- package/src/runtime/ui_app.zig +142 -16
- package/src/runtime/ui_app_tests.zig +155 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +9 -0
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +214 -2
- package/src/tooling/package.zig +116 -0
- package/src/tooling/raw_manifest.zig +30 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +161 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +378 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -175,6 +175,10 @@ typedef struct native_sdk_gpu_frame_state {
|
|
|
175
175
|
|
|
176
176
|
void *native_sdk_app_create(void);
|
|
177
177
|
void native_sdk_app_destroy(void *app);
|
|
178
|
+
// Returns 1 when teardown preserved the app because a detached platform
|
|
179
|
+
// callback may still be executing; the shim must preserve that callback's
|
|
180
|
+
// context too. Returns 0 after ordinary complete destruction.
|
|
181
|
+
int native_sdk_app_destroy_with_status(void *app);
|
|
178
182
|
void native_sdk_app_start(void *app);
|
|
179
183
|
void native_sdk_app_activate(void *app);
|
|
180
184
|
void native_sdk_app_deactivate(void *app);
|
|
@@ -226,6 +230,18 @@ typedef struct native_sdk_audio_service {
|
|
|
226
230
|
int (*set_volume)(void *context, double volume);
|
|
227
231
|
} native_sdk_audio_service_t;
|
|
228
232
|
int native_sdk_app_set_audio_service(void *app, const native_sdk_audio_service_t *service, void *context);
|
|
233
|
+
// Secure credential service. Result codes preserve the core effect's closed
|
|
234
|
+
// outcomes: set returns 1 success, -2 locked, -3 denied, 0 I/O failure;
|
|
235
|
+
// get returns a non-negative byte length, -1 miss, -2 locked, -3 denied,
|
|
236
|
+
// -4 output too small, -5 I/O failure; delete returns 1 deleted, 0 miss,
|
|
237
|
+
// -2 locked, -3 denied, -5 I/O failure.
|
|
238
|
+
typedef struct native_sdk_credential_service {
|
|
239
|
+
int (*set)(void *context, const char *service, uintptr_t service_len, const char *account, uintptr_t account_len, const uint8_t *secret, uintptr_t secret_len);
|
|
240
|
+
int64_t (*get)(void *context, const char *service, uintptr_t service_len, const char *account, uintptr_t account_len, uint8_t *output, uintptr_t output_len);
|
|
241
|
+
int (*delete)(void *context, const char *service, uintptr_t service_len, const char *account, uintptr_t account_len);
|
|
242
|
+
} native_sdk_credential_service_t;
|
|
243
|
+
int native_sdk_app_set_credential_service(void *app, const native_sdk_credential_service_t *service, void *context);
|
|
244
|
+
|
|
229
245
|
// One audio player report (kind ordinals above; position/duration in ms).
|
|
230
246
|
// Call between runtime entry points on the loop thread, never from inside
|
|
231
247
|
// an audio service callback.
|
|
@@ -245,6 +261,7 @@ typedef struct native_sdk_image_service {
|
|
|
245
261
|
} native_sdk_image_service_t;
|
|
246
262
|
int native_sdk_app_set_image_service(void *app, const native_sdk_image_service_t *service, void *context);
|
|
247
263
|
int native_sdk_app_set_automation_dir(void *app, const char *path, uintptr_t len);
|
|
264
|
+
int native_sdk_app_set_data_root(void *app, const char *path, uintptr_t len);
|
|
248
265
|
void native_sdk_app_set_asset_root(void *app, const char *path, uintptr_t len);
|
|
249
266
|
uintptr_t native_sdk_app_widget_semantics_count(void *app);
|
|
250
267
|
int native_sdk_app_widget_semantics_at(void *app, uintptr_t index, native_sdk_widget_semantics_t *out);
|
|
@@ -99,13 +99,96 @@
|
|
|
99
99
|
#import <QuartzCore/CAMetalLayer.h>
|
|
100
100
|
#import <AVFoundation/AVFoundation.h>
|
|
101
101
|
#import <ImageIO/ImageIO.h>
|
|
102
|
+
#import <Security/Security.h>
|
|
102
103
|
|
|
103
104
|
#include <dlfcn.h>
|
|
104
105
|
#include <mach-o/dyld.h>
|
|
105
106
|
#include <stdlib.h>
|
|
107
|
+
#include <string.h>
|
|
106
108
|
|
|
107
109
|
#include "native_sdk_app.h"
|
|
108
110
|
|
|
111
|
+
// ----------------------------------------------------------- credentials
|
|
112
|
+
// Generic-password Keychain entries shared by the WebView bridge and core
|
|
113
|
+
// effects through the runtime's one service/account namespace.
|
|
114
|
+
static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
115
|
+
if (status == errSecSuccess) return 1;
|
|
116
|
+
if (status == errSecItemNotFound) return missingCode;
|
|
117
|
+
if (status == errSecInteractionNotAllowed || status == errSecNotAvailable) return -2;
|
|
118
|
+
if (status == errSecAuthFailed || status == errSecUserCanceled || status == errSecMissingEntitlement) return -3;
|
|
119
|
+
return -5;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static NSMutableDictionary *NativeSdkCredentialQuery(const char *service, uintptr_t service_len,
|
|
123
|
+
const char *account, uintptr_t account_len) {
|
|
124
|
+
NSString *serviceString = [[NSString alloc] initWithBytes:service length:service_len encoding:NSUTF8StringEncoding];
|
|
125
|
+
NSString *accountString = [[NSString alloc] initWithBytes:account length:account_len encoding:NSUTF8StringEncoding];
|
|
126
|
+
if (!serviceString || !accountString) return nil;
|
|
127
|
+
return [@{
|
|
128
|
+
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
|
|
129
|
+
(__bridge id)kSecAttrService: serviceString,
|
|
130
|
+
(__bridge id)kSecAttrAccount: accountString,
|
|
131
|
+
} mutableCopy];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static int NativeSdkCredentialSet(void *context,
|
|
135
|
+
const char *service, uintptr_t service_len,
|
|
136
|
+
const char *account, uintptr_t account_len,
|
|
137
|
+
const uint8_t *secret, uintptr_t secret_len) {
|
|
138
|
+
(void)context;
|
|
139
|
+
@autoreleasepool {
|
|
140
|
+
NSMutableDictionary *query = NativeSdkCredentialQuery(service, service_len, account, account_len);
|
|
141
|
+
if (!query) return -5;
|
|
142
|
+
NSData *data = [NSData dataWithBytes:secret length:secret_len];
|
|
143
|
+
NSDictionary *update = @{ (__bridge id)kSecValueData: data };
|
|
144
|
+
OSStatus status = SecItemUpdate((__bridge CFDictionaryRef)query,
|
|
145
|
+
(__bridge CFDictionaryRef)update);
|
|
146
|
+
if (status == errSecItemNotFound) {
|
|
147
|
+
query[(__bridge id)kSecValueData] = data;
|
|
148
|
+
query[(__bridge id)kSecAttrAccessible] = (__bridge id)kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
|
|
149
|
+
status = SecItemAdd((__bridge CFDictionaryRef)query, NULL);
|
|
150
|
+
}
|
|
151
|
+
return status == errSecSuccess ? 1 : NativeSdkCredentialStatus(status, -5);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static int64_t NativeSdkCredentialGet(void *context,
|
|
156
|
+
const char *service, uintptr_t service_len,
|
|
157
|
+
const char *account, uintptr_t account_len,
|
|
158
|
+
uint8_t *output, uintptr_t output_len) {
|
|
159
|
+
(void)context;
|
|
160
|
+
@autoreleasepool {
|
|
161
|
+
NSMutableDictionary *query = NativeSdkCredentialQuery(service, service_len, account, account_len);
|
|
162
|
+
if (!query) return -5;
|
|
163
|
+
query[(__bridge id)kSecReturnData] = @YES;
|
|
164
|
+
query[(__bridge id)kSecMatchLimit] = (__bridge id)kSecMatchLimitOne;
|
|
165
|
+
CFTypeRef raw = NULL;
|
|
166
|
+
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &raw);
|
|
167
|
+
if (status != errSecSuccess) return NativeSdkCredentialStatus(status, -1);
|
|
168
|
+
NSData *data = (__bridge NSData *)raw;
|
|
169
|
+
if (data.length > output_len) {
|
|
170
|
+
CFRelease(raw);
|
|
171
|
+
return -4;
|
|
172
|
+
}
|
|
173
|
+
if (data.length > 0) memcpy(output, data.bytes, data.length);
|
|
174
|
+
int64_t result = (int64_t)data.length;
|
|
175
|
+
CFRelease(raw);
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static int NativeSdkCredentialDelete(void *context,
|
|
181
|
+
const char *service, uintptr_t service_len,
|
|
182
|
+
const char *account, uintptr_t account_len) {
|
|
183
|
+
(void)context;
|
|
184
|
+
@autoreleasepool {
|
|
185
|
+
NSMutableDictionary *query = NativeSdkCredentialQuery(service, service_len, account, account_len);
|
|
186
|
+
if (!query) return -5;
|
|
187
|
+
OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
|
|
188
|
+
return status == errSecSuccess ? 1 : NativeSdkCredentialStatus(status, 0);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
109
192
|
// Zig's std.debug stack-trace symbolication (pulled in by the embed lib's
|
|
110
193
|
// panic path) references `_dyld_get_image_header_containing_address`, which
|
|
111
194
|
// the iOS SDK marks __API_UNAVAILABLE(ios). Provide the documented
|
|
@@ -1665,6 +1748,16 @@ static const CGFloat NativeSdkTouchSlop = 8.0;
|
|
|
1665
1748
|
native_sdk_app_set_audio_service(self.nativeApp, &audioService, (__bridge void *)self.audioEngine);
|
|
1666
1749
|
[self logNativeErrorIfAny:@"audio_service"];
|
|
1667
1750
|
|
|
1751
|
+
// Secure credentials use generic-password Keychain entries. Register
|
|
1752
|
+
// before start so boot effects see the same namespace as the bridge.
|
|
1753
|
+
native_sdk_credential_service_t credentialService = {
|
|
1754
|
+
.set = NativeSdkCredentialSet,
|
|
1755
|
+
.get = NativeSdkCredentialGet,
|
|
1756
|
+
.delete = NativeSdkCredentialDelete,
|
|
1757
|
+
};
|
|
1758
|
+
native_sdk_app_set_credential_service(self.nativeApp, &credentialService, NULL);
|
|
1759
|
+
[self logNativeErrorIfAny:@"credential_service"];
|
|
1760
|
+
|
|
1668
1761
|
// The platform image decoder (registered before start, like the audio
|
|
1669
1762
|
// service, so a boot-effect fx.registerImageBytes already decodes):
|
|
1670
1763
|
// CGImageSource behind the embed image seam, the same ImageIO family
|
|
@@ -1675,6 +1768,28 @@ static const CGFloat NativeSdkTouchSlop = 8.0;
|
|
|
1675
1768
|
native_sdk_app_set_image_service(self.nativeApp, &imageService, NULL);
|
|
1676
1769
|
[self logNativeErrorIfAny:@"image_service"];
|
|
1677
1770
|
|
|
1771
|
+
// Engine-owned durable storage lives in the platform app-data
|
|
1772
|
+
// directory. The ABI accepts this for every app; capability-shed builds
|
|
1773
|
+
// treat it as a no-op, while `store` builds open store.db before start.
|
|
1774
|
+
NSString *dataRoot = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
|
|
1775
|
+
NSUserDomainMask,
|
|
1776
|
+
YES).firstObject;
|
|
1777
|
+
if (dataRoot) {
|
|
1778
|
+
NSError *dataRootError = nil;
|
|
1779
|
+
[NSFileManager.defaultManager createDirectoryAtPath:dataRoot
|
|
1780
|
+
withIntermediateDirectories:YES
|
|
1781
|
+
attributes:nil
|
|
1782
|
+
error:&dataRootError];
|
|
1783
|
+
if (dataRootError) {
|
|
1784
|
+
NSLog(@"native-sdk: app data directory unavailable: %@", dataRootError);
|
|
1785
|
+
} else {
|
|
1786
|
+
native_sdk_app_set_data_root(self.nativeApp,
|
|
1787
|
+
dataRoot.UTF8String,
|
|
1788
|
+
[dataRoot lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
|
1789
|
+
[self logNativeErrorIfAny:@"data_root"];
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1678
1793
|
// Verification harness: with NATIVE_SDK_AUTOMATION set (simctl launch
|
|
1679
1794
|
// exports SIMCTL_CHILD_* into the app) the embedded runtime publishes
|
|
1680
1795
|
// snapshot.txt into the app's data container, same protocol as the
|
|
@@ -531,7 +531,7 @@ size_t native_sdk_gtk_get_credential(Host *host, const char *service, size_t ser
|
|
|
531
531
|
(void)account_len;
|
|
532
532
|
(void)buffer;
|
|
533
533
|
(void)buffer_len;
|
|
534
|
-
return
|
|
534
|
+
return SIZE_MAX - 1;
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
int native_sdk_gtk_delete_credential(Host *host, const char *service, size_t service_len, const char *account, size_t account_len) {
|
|
@@ -358,6 +358,7 @@ typedef struct native_sdk_gtk_window {
|
|
|
358
358
|
int click_through;
|
|
359
359
|
int activate_on_show;
|
|
360
360
|
int show_on_first_present;
|
|
361
|
+
int policy_hidden;
|
|
361
362
|
int shown;
|
|
362
363
|
/* One-second safety reveal for a canvas window whose first present
|
|
363
364
|
* never arrives. Zero once cancelled/fired. */
|
|
@@ -2518,6 +2519,7 @@ static void native_sdk_emit_window_frame(native_sdk_gtk_host_t *host, native_sdk
|
|
|
2518
2519
|
.scale = scale,
|
|
2519
2520
|
.open = open,
|
|
2520
2521
|
.focused = focused,
|
|
2522
|
+
.hidden = open ? win->policy_hidden : 0,
|
|
2521
2523
|
.label = win->label ? win->label : "",
|
|
2522
2524
|
.label_len = win->label ? strlen(win->label) : 0,
|
|
2523
2525
|
.title = win->title ? win->title : "",
|
|
@@ -3076,6 +3078,7 @@ static native_sdk_gtk_window_t *native_sdk_create_window_internal(native_sdk_gtk
|
|
|
3076
3078
|
win->click_through = (window_flags & (1u << 2)) != 0;
|
|
3077
3079
|
win->activate_on_show = (window_flags & (1u << 3)) == 0;
|
|
3078
3080
|
win->show_on_first_present = show_policy == 1;
|
|
3081
|
+
win->policy_hidden = show_policy == 2;
|
|
3079
3082
|
if (!win->label || !win->title) {
|
|
3080
3083
|
free(win->label);
|
|
3081
3084
|
free(win->title);
|
|
@@ -3201,7 +3204,7 @@ static void on_activate(GtkApplication *app, gpointer data) {
|
|
|
3201
3204
|
host->init_show_policy, host->init_window_flags);
|
|
3202
3205
|
if (!win) return;
|
|
3203
3206
|
|
|
3204
|
-
if (!win->show_on_first_present) native_sdk_show_window_implicit(win);
|
|
3207
|
+
if (!win->show_on_first_present && !win->policy_hidden) native_sdk_show_window_implicit(win);
|
|
3205
3208
|
native_sdk_emit_app_active_if_changed(host);
|
|
3206
3209
|
|
|
3207
3210
|
native_sdk_emit(host, (native_sdk_gtk_event_t){ .kind = NATIVE_SDK_GTK_EVENT_START });
|
|
@@ -3772,7 +3775,7 @@ int native_sdk_gtk_create_window(native_sdk_gtk_host_t *host, uint64_t window_id
|
|
|
3772
3775
|
free(label);
|
|
3773
3776
|
if (!win) return 0;
|
|
3774
3777
|
|
|
3775
|
-
if (!win->show_on_first_present) native_sdk_show_window_implicit(win);
|
|
3778
|
+
if (!win->show_on_first_present && !win->policy_hidden) native_sdk_show_window_implicit(win);
|
|
3776
3779
|
return 1;
|
|
3777
3780
|
}
|
|
3778
3781
|
|
|
@@ -3943,6 +3946,7 @@ int native_sdk_gtk_focus_window(native_sdk_gtk_host_t *host, uint64_t window_id)
|
|
|
3943
3946
|
native_sdk_gtk_window_t *win = native_sdk_find_window(host, window_id);
|
|
3944
3947
|
if (!win || !win->gtk_window) return 0;
|
|
3945
3948
|
native_sdk_cancel_deferred_show(win);
|
|
3949
|
+
win->policy_hidden = 0;
|
|
3946
3950
|
gtk_window_present(win->gtk_window);
|
|
3947
3951
|
win->shown = 1;
|
|
3948
3952
|
native_sdk_emit_window_frame(host, win, 1);
|
|
@@ -3953,12 +3957,24 @@ int native_sdk_gtk_show_window(native_sdk_gtk_host_t *host, uint64_t window_id)
|
|
|
3953
3957
|
native_sdk_gtk_window_t *win = native_sdk_find_window(host, window_id);
|
|
3954
3958
|
if (!win || !win->gtk_window) return 0;
|
|
3955
3959
|
native_sdk_cancel_deferred_show(win);
|
|
3960
|
+
win->policy_hidden = 0;
|
|
3956
3961
|
if (!win->activate_on_show) gtk_window_unminimize(win->gtk_window);
|
|
3957
3962
|
native_sdk_show_window_implicit(win);
|
|
3958
3963
|
native_sdk_emit_window_frame(host, win, 1);
|
|
3959
3964
|
return 1;
|
|
3960
3965
|
}
|
|
3961
3966
|
|
|
3967
|
+
int native_sdk_gtk_hide_window(native_sdk_gtk_host_t *host, uint64_t window_id) {
|
|
3968
|
+
native_sdk_gtk_window_t *win = native_sdk_find_window(host, window_id);
|
|
3969
|
+
if (!win || !win->gtk_window) return 0;
|
|
3970
|
+
native_sdk_cancel_deferred_show(win);
|
|
3971
|
+
win->policy_hidden = 1;
|
|
3972
|
+
win->shown = 0;
|
|
3973
|
+
gtk_widget_set_visible(GTK_WIDGET(win->gtk_window), FALSE);
|
|
3974
|
+
native_sdk_emit_window_frame(host, win, 1);
|
|
3975
|
+
return 1;
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3962
3978
|
int native_sdk_gtk_close_window(native_sdk_gtk_host_t *host, uint64_t window_id) {
|
|
3963
3979
|
native_sdk_gtk_window_t *win = native_sdk_find_window(host, window_id);
|
|
3964
3980
|
if (!win || !win->gtk_window) return 0;
|
|
@@ -4381,7 +4397,7 @@ int native_sdk_gtk_present_gpu_surface_pixels(native_sdk_gtk_host_t *host, uint6
|
|
|
4381
4397
|
* placeholder pump — from here on frames exist only on demand. */
|
|
4382
4398
|
const int first_present = !view->gpu_presented;
|
|
4383
4399
|
view->gpu_presented = 1;
|
|
4384
|
-
if (first_present && win && !win->shown) {
|
|
4400
|
+
if (first_present && win && !win->shown && !win->policy_hidden) {
|
|
4385
4401
|
native_sdk_cancel_deferred_show(win);
|
|
4386
4402
|
native_sdk_show_window_implicit(win);
|
|
4387
4403
|
native_sdk_emit_window_frame(host, win, 1);
|
|
@@ -4966,11 +4982,26 @@ static native_sdk_secret_api_t *native_sdk_load_secret_api(void) {
|
|
|
4966
4982
|
return &native_sdk_secret_api;
|
|
4967
4983
|
}
|
|
4968
4984
|
|
|
4969
|
-
static void
|
|
4985
|
+
static void native_sdk_secure_gfree(char *bytes, size_t len) {
|
|
4970
4986
|
if (!bytes) return;
|
|
4971
4987
|
volatile char *cursor = bytes;
|
|
4972
4988
|
for (size_t i = 0; i < len; i++) cursor[i] = 0;
|
|
4973
|
-
|
|
4989
|
+
g_free(bytes);
|
|
4990
|
+
}
|
|
4991
|
+
|
|
4992
|
+
static const char native_sdk_credential_bytes_prefix[] = "native-sdk:bytes:v1:";
|
|
4993
|
+
|
|
4994
|
+
/* libsecret reports a locked collection through GError rather than a
|
|
4995
|
+
* dedicated return value. Keep that condition distinct at the C seam so the
|
|
4996
|
+
* core effect can deliver its closed `locked` outcome instead of flattening
|
|
4997
|
+
* it into `io_failed`. */
|
|
4998
|
+
static int native_sdk_secret_error_locked(const GError *error) {
|
|
4999
|
+
if (!error || !error->message) return 0;
|
|
5000
|
+
char *lower = g_ascii_strdown(error->message, -1);
|
|
5001
|
+
if (!lower) return 0;
|
|
5002
|
+
int locked = strstr(lower, "locked") != NULL;
|
|
5003
|
+
g_free(lower);
|
|
5004
|
+
return locked;
|
|
4974
5005
|
}
|
|
4975
5006
|
|
|
4976
5007
|
int native_sdk_gtk_credentials_available(native_sdk_gtk_host_t *host) {
|
|
@@ -4981,15 +5012,17 @@ int native_sdk_gtk_credentials_available(native_sdk_gtk_host_t *host) {
|
|
|
4981
5012
|
int native_sdk_gtk_set_credential(native_sdk_gtk_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len, const char *secret, size_t secret_len) {
|
|
4982
5013
|
(void)host;
|
|
4983
5014
|
native_sdk_secret_api_t *api = native_sdk_load_secret_api();
|
|
4984
|
-
if (!api || !service || service_len == 0 || !account || account_len == 0 || !secret
|
|
5015
|
+
if (!api || !service || service_len == 0 || !account || account_len == 0 || (!secret && secret_len > 0)) return 0;
|
|
4985
5016
|
|
|
4986
5017
|
char *service_copy = native_sdk_strndup(service, service_len);
|
|
4987
5018
|
char *account_copy = native_sdk_strndup(account, account_len);
|
|
4988
|
-
|
|
5019
|
+
gchar *encoded = g_base64_encode((const guchar *)(secret ? secret : ""), secret_len);
|
|
5020
|
+
char *secret_copy = encoded ? g_strdup_printf("%s%s", native_sdk_credential_bytes_prefix, encoded) : NULL;
|
|
4989
5021
|
if (!service_copy || !account_copy || !secret_copy) {
|
|
4990
5022
|
free(service_copy);
|
|
4991
5023
|
free(account_copy);
|
|
4992
|
-
|
|
5024
|
+
if (encoded) native_sdk_secure_gfree(encoded, strlen(encoded));
|
|
5025
|
+
if (secret_copy) native_sdk_secure_gfree(secret_copy, strlen(secret_copy));
|
|
4993
5026
|
return 0;
|
|
4994
5027
|
}
|
|
4995
5028
|
|
|
@@ -4997,32 +5030,35 @@ int native_sdk_gtk_set_credential(native_sdk_gtk_host_t *host, const char *servi
|
|
|
4997
5030
|
if (!label) {
|
|
4998
5031
|
free(service_copy);
|
|
4999
5032
|
free(account_copy);
|
|
5000
|
-
|
|
5033
|
+
native_sdk_secure_gfree(encoded, strlen(encoded));
|
|
5034
|
+
native_sdk_secure_gfree(secret_copy, strlen(secret_copy));
|
|
5001
5035
|
return 0;
|
|
5002
5036
|
}
|
|
5003
5037
|
|
|
5004
5038
|
GError *error = NULL;
|
|
5005
5039
|
gboolean ok = api->store_sync(&native_sdk_credential_schema, "default", label, secret_copy, NULL, &error, "service", service_copy, "account", account_copy, NULL);
|
|
5040
|
+
int locked = native_sdk_secret_error_locked(error);
|
|
5006
5041
|
if (error) g_error_free(error);
|
|
5007
5042
|
|
|
5008
5043
|
g_free(label);
|
|
5009
5044
|
free(service_copy);
|
|
5010
5045
|
free(account_copy);
|
|
5011
|
-
|
|
5012
|
-
|
|
5046
|
+
native_sdk_secure_gfree(encoded, strlen(encoded));
|
|
5047
|
+
native_sdk_secure_gfree(secret_copy, strlen(secret_copy));
|
|
5048
|
+
return locked ? -2 : (ok ? 1 : 0);
|
|
5013
5049
|
}
|
|
5014
5050
|
|
|
5015
5051
|
size_t native_sdk_gtk_get_credential(native_sdk_gtk_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len, char *buffer, size_t buffer_len) {
|
|
5016
5052
|
(void)host;
|
|
5017
5053
|
native_sdk_secret_api_t *api = native_sdk_load_secret_api();
|
|
5018
|
-
if (!api || !service || service_len == 0 || !account || account_len == 0 || !buffer) return
|
|
5054
|
+
if (!api || !service || service_len == 0 || !account || account_len == 0 || (!buffer && buffer_len > 0)) return SIZE_MAX - 1;
|
|
5019
5055
|
|
|
5020
5056
|
char *service_copy = native_sdk_strndup(service, service_len);
|
|
5021
5057
|
char *account_copy = native_sdk_strndup(account, account_len);
|
|
5022
5058
|
if (!service_copy || !account_copy) {
|
|
5023
5059
|
free(service_copy);
|
|
5024
5060
|
free(account_copy);
|
|
5025
|
-
return
|
|
5061
|
+
return SIZE_MAX - 1;
|
|
5026
5062
|
}
|
|
5027
5063
|
|
|
5028
5064
|
GError *error = NULL;
|
|
@@ -5030,14 +5066,28 @@ size_t native_sdk_gtk_get_credential(native_sdk_gtk_host_t *host, const char *se
|
|
|
5030
5066
|
free(service_copy);
|
|
5031
5067
|
free(account_copy);
|
|
5032
5068
|
if (error) {
|
|
5069
|
+
int locked = native_sdk_secret_error_locked(error);
|
|
5033
5070
|
g_error_free(error);
|
|
5034
|
-
return
|
|
5071
|
+
return locked ? SIZE_MAX - 2 : SIZE_MAX - 1;
|
|
5035
5072
|
}
|
|
5036
|
-
if (!password) return
|
|
5073
|
+
if (!password) return SIZE_MAX;
|
|
5037
5074
|
|
|
5038
5075
|
size_t password_len = strlen(password);
|
|
5076
|
+
const size_t prefix_len = sizeof(native_sdk_credential_bytes_prefix) - 1;
|
|
5077
|
+
if (password_len >= prefix_len && memcmp(password, native_sdk_credential_bytes_prefix, prefix_len) == 0) {
|
|
5078
|
+
gsize decoded_len = 0;
|
|
5079
|
+
guchar *decoded = g_base64_decode(password + prefix_len, &decoded_len);
|
|
5080
|
+
if (!decoded && decoded_len != 0) {
|
|
5081
|
+
native_sdk_secure_gfree(password, password_len);
|
|
5082
|
+
return SIZE_MAX - 1;
|
|
5083
|
+
}
|
|
5084
|
+
if (decoded_len <= buffer_len && decoded_len > 0) memcpy(buffer, decoded, decoded_len);
|
|
5085
|
+
if (decoded) native_sdk_secure_gfree((char *)decoded, decoded_len);
|
|
5086
|
+
native_sdk_secure_gfree(password, password_len);
|
|
5087
|
+
return decoded_len;
|
|
5088
|
+
}
|
|
5039
5089
|
if (password_len <= buffer_len && password_len > 0) memcpy(buffer, password, password_len);
|
|
5040
|
-
|
|
5090
|
+
native_sdk_secure_gfree(password, password_len);
|
|
5041
5091
|
return password_len;
|
|
5042
5092
|
}
|
|
5043
5093
|
|
|
@@ -5059,12 +5109,34 @@ int native_sdk_gtk_delete_credential(native_sdk_gtk_host_t *host, const char *se
|
|
|
5059
5109
|
free(service_copy);
|
|
5060
5110
|
free(account_copy);
|
|
5061
5111
|
if (error) {
|
|
5112
|
+
int locked = native_sdk_secret_error_locked(error);
|
|
5062
5113
|
g_error_free(error);
|
|
5063
|
-
return -1;
|
|
5114
|
+
return locked ? -2 : -1;
|
|
5064
5115
|
}
|
|
5065
5116
|
return ok ? 1 : 0;
|
|
5066
5117
|
}
|
|
5067
5118
|
|
|
5119
|
+
size_t native_sdk_gtk_format_local_time(native_sdk_gtk_host_t *host, int64_t timestamp_ms, int style, char *buffer, size_t buffer_len) {
|
|
5120
|
+
(void)host;
|
|
5121
|
+
if (!buffer || buffer_len == 0 || style < 0 || style > 2) return 0;
|
|
5122
|
+
gint64 seconds = timestamp_ms / 1000;
|
|
5123
|
+
if (timestamp_ms < 0 && timestamp_ms % 1000 != 0) seconds -= 1;
|
|
5124
|
+
GDateTime *date = g_date_time_new_from_unix_local(seconds);
|
|
5125
|
+
if (!date) return 0;
|
|
5126
|
+
const char *pattern = style == 0 ? "%x" : (style == 1 ? "%X" : "%x %X");
|
|
5127
|
+
char *text = g_date_time_format(date, pattern);
|
|
5128
|
+
g_date_time_unref(date);
|
|
5129
|
+
if (!text) return 0;
|
|
5130
|
+
size_t len = strlen(text);
|
|
5131
|
+
if (len == 0 || len > buffer_len) {
|
|
5132
|
+
g_free(text);
|
|
5133
|
+
return 0;
|
|
5134
|
+
}
|
|
5135
|
+
memcpy(buffer, text, len);
|
|
5136
|
+
g_free(text);
|
|
5137
|
+
return len;
|
|
5138
|
+
}
|
|
5139
|
+
|
|
5068
5140
|
/* ---------------------------------------------------------------- audio
|
|
5069
5141
|
*
|
|
5070
5142
|
* Backend: the GStreamer PLAYBIN pipeline (gst-1.0). One in-box element
|
|
@@ -43,6 +43,7 @@ typedef struct {
|
|
|
43
43
|
double y;
|
|
44
44
|
int open;
|
|
45
45
|
int focused;
|
|
46
|
+
int hidden;
|
|
46
47
|
const char *label;
|
|
47
48
|
size_t label_len;
|
|
48
49
|
const char *title;
|
|
@@ -217,6 +218,7 @@ void native_sdk_gtk_start_timer(native_sdk_gtk_host_t *host, uint64_t timer_id,
|
|
|
217
218
|
void native_sdk_gtk_cancel_timer(native_sdk_gtk_host_t *host, uint64_t timer_id);
|
|
218
219
|
int native_sdk_gtk_focus_window(native_sdk_gtk_host_t *host, uint64_t window_id);
|
|
219
220
|
int native_sdk_gtk_show_window(native_sdk_gtk_host_t *host, uint64_t window_id);
|
|
221
|
+
int native_sdk_gtk_hide_window(native_sdk_gtk_host_t *host, uint64_t window_id);
|
|
220
222
|
int native_sdk_gtk_close_window(native_sdk_gtk_host_t *host, uint64_t window_id);
|
|
221
223
|
/* The real OS minimize verb (gtk_window_minimize), for app-drawn window
|
|
222
224
|
* controls on chromeless windows. Returns 0 when the window id is
|
|
@@ -253,6 +255,7 @@ int native_sdk_gtk_credentials_available(native_sdk_gtk_host_t *host);
|
|
|
253
255
|
int native_sdk_gtk_set_credential(native_sdk_gtk_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len, const char *secret, size_t secret_len);
|
|
254
256
|
size_t native_sdk_gtk_get_credential(native_sdk_gtk_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len, char *buffer, size_t buffer_len);
|
|
255
257
|
int native_sdk_gtk_delete_credential(native_sdk_gtk_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len);
|
|
258
|
+
size_t native_sdk_gtk_format_local_time(native_sdk_gtk_host_t *host, int64_t timestamp_ms, int style, char *buffer, size_t buffer_len);
|
|
256
259
|
/* Audio playback (GStreamer playbin, runtime-loaded like libsecret).
|
|
257
260
|
* native_sdk_gtk_audio_available answers whether the library resolved
|
|
258
261
|
* at runtime; when it did not, every load below answers 3 (no backend)
|
|
@@ -47,6 +47,7 @@ const GtkEvent = extern struct {
|
|
|
47
47
|
y: f64,
|
|
48
48
|
open: c_int,
|
|
49
49
|
focused: c_int,
|
|
50
|
+
hidden: c_int,
|
|
50
51
|
label: [*]const u8,
|
|
51
52
|
label_len: usize,
|
|
52
53
|
title: [*]const u8,
|
|
@@ -136,6 +137,7 @@ extern fn native_sdk_gtk_start_timer(host: *GtkHost, timer_id: u64, interval_ns:
|
|
|
136
137
|
extern fn native_sdk_gtk_cancel_timer(host: *GtkHost, timer_id: u64) void;
|
|
137
138
|
extern fn native_sdk_gtk_focus_window(host: *GtkHost, window_id: u64) c_int;
|
|
138
139
|
extern fn native_sdk_gtk_show_window(host: *GtkHost, window_id: u64) c_int;
|
|
140
|
+
extern fn native_sdk_gtk_hide_window(host: *GtkHost, window_id: u64) c_int;
|
|
139
141
|
extern fn native_sdk_gtk_close_window(host: *GtkHost, window_id: u64) c_int;
|
|
140
142
|
extern fn native_sdk_gtk_minimize_window(host: *GtkHost, window_id: u64) c_int;
|
|
141
143
|
extern fn native_sdk_gtk_create_view(host: *GtkHost, window_id: u64, label: [*]const u8, label_len: usize, kind: c_int, parent: [*]const u8, parent_len: usize, x: f64, y: f64, width: f64, height: f64, layer: c_int, visible: c_int, enabled: c_int, role: [*]const u8, role_len: usize, accessibility_label: [*]const u8, accessibility_label_len: usize, text: [*]const u8, text_len: usize, command: [*]const u8, command_len: usize) c_int;
|
|
@@ -161,6 +163,7 @@ extern fn native_sdk_gtk_credentials_available(host: *GtkHost) c_int;
|
|
|
161
163
|
extern fn native_sdk_gtk_set_credential(host: *GtkHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, secret: [*]const u8, secret_len: usize) c_int;
|
|
162
164
|
extern fn native_sdk_gtk_get_credential(host: *GtkHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
163
165
|
extern fn native_sdk_gtk_delete_credential(host: *GtkHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize) c_int;
|
|
166
|
+
extern fn native_sdk_gtk_format_local_time(host: *GtkHost, timestamp_ms: i64, style: c_int, buffer: [*]u8, buffer_len: usize) usize;
|
|
164
167
|
extern fn native_sdk_gtk_audio_available(host: *GtkHost) c_int;
|
|
165
168
|
extern fn native_sdk_gtk_audio_spectrum_available(host: *GtkHost) c_int;
|
|
166
169
|
extern fn native_sdk_gtk_audio_load(host: *GtkHost, path: [*]const u8, path_len: usize) c_int;
|
|
@@ -254,9 +257,8 @@ pub const LinuxPlatform = struct {
|
|
|
254
257
|
app_info: platform_mod.AppInfo,
|
|
255
258
|
surface_value: platform_mod.Surface,
|
|
256
259
|
state: RunState = .{},
|
|
257
|
-
/// Latched when
|
|
258
|
-
///
|
|
259
|
-
/// `PlatformServices.note_channel_wake_abandoned_fn`): the stale
|
|
260
|
+
/// Latched when effects teardown abandons an in-flight platform call
|
|
261
|
+
/// (a channel wake or blocking credential operation): the stale
|
|
260
262
|
/// call still holds this platform as its context and may execute
|
|
261
263
|
/// into it at any later time, so `deinit` must skip destruction
|
|
262
264
|
/// and leak the host, process-lived — and the wrapper struct the
|
|
@@ -329,13 +331,13 @@ pub const LinuxPlatform = struct {
|
|
|
329
331
|
}
|
|
330
332
|
|
|
331
333
|
pub fn deinit(self: *LinuxPlatform) void {
|
|
332
|
-
// An abandoned
|
|
334
|
+
// An abandoned platform call may still enter this host at
|
|
333
335
|
// any later time (see `channel_wake_abandoned`): destroying it
|
|
334
336
|
// would turn that stale call into a use-after-free, so the
|
|
335
337
|
// host is deliberately leaked, process-lived — the
|
|
336
338
|
// abandoned-worker idiom, applied to the platform itself.
|
|
337
339
|
if (self.channel_wake_abandoned.load(.seq_cst)) {
|
|
338
|
-
std.debug.print("linux platform teardown: an abandoned
|
|
340
|
+
std.debug.print("linux platform teardown: an abandoned platform call may still enter this host; skipping destruction and leaking it (and the wrapper it enters through), process-lived, so the stale call stays safe\n", .{});
|
|
339
341
|
return;
|
|
340
342
|
}
|
|
341
343
|
native_sdk_gtk_destroy(self.host);
|
|
@@ -363,6 +365,7 @@ pub const LinuxPlatform = struct {
|
|
|
363
365
|
.focus_window_fn = focusWindow,
|
|
364
366
|
.close_window_fn = closeWindow,
|
|
365
367
|
.minimize_window_fn = minimizeWindow,
|
|
368
|
+
.hide_window_fn = hideWindow,
|
|
366
369
|
.show_window_fn = showWindow,
|
|
367
370
|
.quit_app_fn = quitApp,
|
|
368
371
|
.start_window_drag_fn = startWindowDrag,
|
|
@@ -394,6 +397,8 @@ pub const LinuxPlatform = struct {
|
|
|
394
397
|
.set_credential_fn = setCredential,
|
|
395
398
|
.get_credential_fn = getCredential,
|
|
396
399
|
.delete_credential_fn = deleteCredential,
|
|
400
|
+
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
401
|
+
.format_local_time_fn = formatLocalTime,
|
|
397
402
|
.audio_load_fn = audioLoad,
|
|
398
403
|
.audio_load_url_fn = audioLoadUrl,
|
|
399
404
|
.audio_play_fn = audioPlay,
|
|
@@ -444,7 +449,7 @@ pub const LinuxPlatform = struct {
|
|
|
444
449
|
.app_activation_events,
|
|
445
450
|
.gpu_surfaces,
|
|
446
451
|
=> self.web_engine == .system,
|
|
447
|
-
.credentials =>
|
|
452
|
+
.credentials => credentialsAvailable(self.host),
|
|
448
453
|
// Audio rides GStreamer (playbin), runtime-loaded like
|
|
449
454
|
// libsecret: the report is a live probe, so a host without
|
|
450
455
|
// the library honestly answers false and playback degrades
|
|
@@ -572,6 +577,7 @@ fn gtkCallback(context: ?*anyopaque, event: *const GtkEvent) callconv(.c) void {
|
|
|
572
577
|
.scale_factor = @floatCast(event.scale),
|
|
573
578
|
.open = event.open != 0,
|
|
574
579
|
.focused = event.focused != 0,
|
|
580
|
+
.hidden = event.hidden != 0,
|
|
575
581
|
} });
|
|
576
582
|
},
|
|
577
583
|
.view_focused => state.emit(.{ .view_focused = .{
|
|
@@ -854,6 +860,7 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
854
860
|
return switch (mode) {
|
|
855
861
|
.immediate => 0,
|
|
856
862
|
.on_first_present => 1,
|
|
863
|
+
.hidden => 2,
|
|
857
864
|
};
|
|
858
865
|
}
|
|
859
866
|
|
|
@@ -863,6 +870,7 @@ fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
|
863
870
|
if (options.always_on_top) flags |= 1 << 1;
|
|
864
871
|
if (options.click_through) flags |= 1 << 2;
|
|
865
872
|
if (!options.activate_on_show) flags |= 1 << 3;
|
|
873
|
+
if (!options.allows_fullscreen) flags |= 1 << 4;
|
|
866
874
|
return flags;
|
|
867
875
|
}
|
|
868
876
|
|
|
@@ -885,6 +893,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
885
893
|
.scale_factor = 1,
|
|
886
894
|
.open = true,
|
|
887
895
|
.focused = options.activate_on_show and options.show == .immediate,
|
|
896
|
+
.hidden = options.show == .hidden,
|
|
888
897
|
};
|
|
889
898
|
}
|
|
890
899
|
|
|
@@ -903,6 +912,11 @@ fn minimizeWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerr
|
|
|
903
912
|
if (native_sdk_gtk_minimize_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
904
913
|
}
|
|
905
914
|
|
|
915
|
+
fn hideWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
916
|
+
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
917
|
+
if (native_sdk_gtk_hide_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
918
|
+
}
|
|
919
|
+
|
|
906
920
|
/// GTK has no hide-on-close, but show is still distinct from explicit
|
|
907
921
|
/// focus for passive overlay windows.
|
|
908
922
|
fn showWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
@@ -1333,9 +1347,8 @@ fn clearRecentDocuments(context: ?*anyopaque) anyerror!void {
|
|
|
1333
1347
|
|
|
1334
1348
|
fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anyerror!void {
|
|
1335
1349
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1336
|
-
if (self.
|
|
1337
|
-
|
|
1338
|
-
if (native_sdk_gtk_set_credential(
|
|
1350
|
+
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.CredentialStoreLocked;
|
|
1351
|
+
const result = native_sdk_gtk_set_credential(
|
|
1339
1352
|
self.host,
|
|
1340
1353
|
credential.service.ptr,
|
|
1341
1354
|
credential.service.len,
|
|
@@ -1343,13 +1356,14 @@ fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anye
|
|
|
1343
1356
|
credential.account.len,
|
|
1344
1357
|
credential.secret.ptr,
|
|
1345
1358
|
credential.secret.len,
|
|
1346
|
-
)
|
|
1359
|
+
);
|
|
1360
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
1361
|
+
if (result <= 0) return error.CredentialStoreFailed;
|
|
1347
1362
|
}
|
|
1348
1363
|
|
|
1349
1364
|
fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer: []u8) anyerror![]const u8 {
|
|
1350
1365
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1351
|
-
if (self.
|
|
1352
|
-
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.UnsupportedService;
|
|
1366
|
+
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.CredentialStoreLocked;
|
|
1353
1367
|
const len = native_sdk_gtk_get_credential(
|
|
1354
1368
|
self.host,
|
|
1355
1369
|
key.service.ptr,
|
|
@@ -1359,16 +1373,16 @@ fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer:
|
|
|
1359
1373
|
buffer.ptr,
|
|
1360
1374
|
buffer.len,
|
|
1361
1375
|
);
|
|
1362
|
-
if (len == std.math.maxInt(usize)) return error.
|
|
1363
|
-
if (len ==
|
|
1376
|
+
if (len == std.math.maxInt(usize)) return error.CredentialNotFound;
|
|
1377
|
+
if (len == std.math.maxInt(usize) - 2) return error.CredentialStoreLocked;
|
|
1378
|
+
if (len == std.math.maxInt(usize) - 1) return error.CredentialStoreFailed;
|
|
1364
1379
|
if (len > buffer.len) return error.NoSpaceLeft;
|
|
1365
1380
|
return buffer[0..len];
|
|
1366
1381
|
}
|
|
1367
1382
|
|
|
1368
1383
|
fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyerror!void {
|
|
1369
1384
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1370
|
-
if (self.
|
|
1371
|
-
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.UnsupportedService;
|
|
1385
|
+
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.CredentialStoreLocked;
|
|
1372
1386
|
const result = native_sdk_gtk_delete_credential(
|
|
1373
1387
|
self.host,
|
|
1374
1388
|
key.service.ptr,
|
|
@@ -1376,10 +1390,18 @@ fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyer
|
|
|
1376
1390
|
key.account.ptr,
|
|
1377
1391
|
key.account.len,
|
|
1378
1392
|
);
|
|
1379
|
-
if (result
|
|
1393
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
1394
|
+
if (result < 0) return error.CredentialStoreFailed;
|
|
1380
1395
|
if (result == 0) return error.CredentialNotFound;
|
|
1381
1396
|
}
|
|
1382
1397
|
|
|
1398
|
+
fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: platform_mod.LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
|
|
1399
|
+
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1400
|
+
const len = native_sdk_gtk_format_local_time(self.host, timestamp_ms, @intFromEnum(style), buffer.ptr, buffer.len);
|
|
1401
|
+
if (len == 0 or len > buffer.len) return error.LocalTimeFormatFailed;
|
|
1402
|
+
return buffer[0..len];
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1383
1405
|
/// Map the audio host's synchronous load result: 0 loading (the
|
|
1384
1406
|
/// asynchronous `.loaded` acknowledgment with the decoded duration
|
|
1385
1407
|
/// follows on the main loop), 1 the file is missing, 2 an unusable
|
|
@@ -2017,7 +2039,7 @@ test "linux first-present windows stay unmapped until present with a cancellable
|
|
|
2017
2039
|
const first_present_at = std.mem.indexOf(
|
|
2018
2040
|
u8,
|
|
2019
2041
|
host_source,
|
|
2020
|
-
"if (first_present && win && !win->shown)",
|
|
2042
|
+
"if (first_present && win && !win->shown && !win->policy_hidden)",
|
|
2021
2043
|
) orelse return error.TestExpectedEqual;
|
|
2022
2044
|
const first_present_tail = host_source[first_present_at..];
|
|
2023
2045
|
const cancel_at = std.mem.indexOf(
|