@native-sdk/cli 0.5.4 → 0.6.1
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 +50 -1
- package/build.zig +588 -32
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +280 -8
- package/packages/core/sdk/core.ts +481 -2
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1368 -74
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +16 -0
- package/src/runtime/api.zig +76 -6
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +1 -0
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +268 -26
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -4
- package/src/runtime/gpu_surface_events.zig +475 -15
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +114 -19
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2338 -67
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +268 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
|
@@ -43,11 +43,14 @@ static void *NativeSdkAppKitAppearanceObservationContext = &NativeSdkAppKitAppea
|
|
|
43
43
|
* is not paused, but no audio comes out until bytes arrive). */
|
|
44
44
|
static void *NativeSdkAppKitAudioItemStatusContext = &NativeSdkAppKitAudioItemStatusContext;
|
|
45
45
|
static void *NativeSdkAppKitAudioTimeControlContext = &NativeSdkAppKitAudioTimeControlContext;
|
|
46
|
+
static void *NativeSdkAppKitVideoItemStatusContext = &NativeSdkAppKitVideoItemStatusContext;
|
|
47
|
+
static void *NativeSdkAppKitVideoTimeControlContext = &NativeSdkAppKitVideoTimeControlContext;
|
|
46
48
|
/* Render-thread ring state for the spectrum tap; defined with the rest
|
|
47
49
|
* of the spectrum machinery in the audio section below. */
|
|
48
50
|
typedef struct native_sdk_spectrum_tap_state native_sdk_spectrum_tap_state_t;
|
|
49
51
|
static NSRect constrainFrame(NSRect frame);
|
|
50
52
|
static NSString *NativeSdkAppKitBridgeScript(void);
|
|
53
|
+
static NSString *NativeSdkMenuKeyEquivalent(NSString *key);
|
|
51
54
|
static NSString *NativeSdkMimeTypeForPath(NSString *path);
|
|
52
55
|
static NSString *NativeSdkResolvedAssetRoot(NSString *rootPath);
|
|
53
56
|
static void NativeSdkRegisterBundledFonts(void);
|
|
@@ -57,6 +60,7 @@ static NSArray<NSString *> *NativeSdkPolicyListFromBytes(const char *bytes, size
|
|
|
57
60
|
static NSString *NativeSdkOriginForURL(NSURL *url);
|
|
58
61
|
static BOOL NativeSdkPolicyListMatches(NSArray<NSString *> *values, NSURL *url);
|
|
59
62
|
static NSString *NativeSdkShortcutKeyForEvent(NSEvent *event);
|
|
63
|
+
static BOOL NativeSdkTextNavigationNeedsRawKeyEvent(NSEvent *event);
|
|
60
64
|
static BOOL NativeSdkShortcutUsesImplicitShift(NSString *key, NSEvent *event);
|
|
61
65
|
static BOOL NativeSdkShortcutModifiersMatch(uint32_t shortcutModifiers, NSEventModifierFlags eventModifiers, BOOL allowImplicitShift);
|
|
62
66
|
static NSEventModifierFlags NativeSdkMenuModifierFlags(uint32_t modifiers);
|
|
@@ -316,6 +320,7 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
316
320
|
@property(nonatomic, strong) NSArray<NSValue *> *coveredMouseRects;
|
|
317
321
|
@property(nonatomic, assign) NativeSdkAppKitHost *host;
|
|
318
322
|
@property(nonatomic, assign) uint64_t windowId;
|
|
323
|
+
@property(nonatomic, strong) NSString *viewLabel;
|
|
319
324
|
@end
|
|
320
325
|
|
|
321
326
|
@interface NativeSdkBridgeScriptHandler : NSObject <WKScriptMessageHandler>
|
|
@@ -340,6 +345,16 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
340
345
|
* overlay knob stays grabbable). */
|
|
341
346
|
@interface NativeSdkScrollDriverView : NSScrollView
|
|
342
347
|
@property(nonatomic, assign) uint64_t driverId;
|
|
348
|
+
@property(nonatomic, assign) uint64_t parentDriverId;
|
|
349
|
+
/* Bit i set = occluder i of the surface's occluder array hit-blocks
|
|
350
|
+
* this region at points it contains. */
|
|
351
|
+
@property(nonatomic, assign) uint32_t occluderMask;
|
|
352
|
+
/* The region's axis grants (the runtime's widgetScrollsAxis), pushed on
|
|
353
|
+
* every reconcile: the wheel winner-resolution's fallback rule needs
|
|
354
|
+
* grants, not range — a granted axis with short content still owns a
|
|
355
|
+
* bounce, an ungranted one owns nothing. */
|
|
356
|
+
@property(nonatomic, assign) BOOL grantsX;
|
|
357
|
+
@property(nonatomic, assign) BOOL grantsY;
|
|
343
358
|
@end
|
|
344
359
|
|
|
345
360
|
/* Captures the selected item id of a context-menu popUp; NSMenuItem
|
|
@@ -566,6 +581,13 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
566
581
|
@property(nonatomic, assign) uint64_t lastPacketDecodeNs;
|
|
567
582
|
@property(nonatomic, assign) uint64_t lastPacketDrawNs;
|
|
568
583
|
@property(nonatomic, strong) NSCursor *surfaceCursor;
|
|
584
|
+
/* Higher-layer sibling views covering this surface, in surface
|
|
585
|
+
* coordinates. AppKit cursor rects are geometric rather than hit-test
|
|
586
|
+
* aware: one full-bounds rect here would keep winning over an embedded
|
|
587
|
+
* WKWebView layered above the canvas (the workbench's browser pane), so
|
|
588
|
+
* resetCursorRects subtracts these occluders before registering the
|
|
589
|
+
* retained widget cursor. */
|
|
590
|
+
@property(nonatomic, strong) NSArray<NSValue *> *coveredMouseRects;
|
|
569
591
|
@property(nonatomic, strong) NSTrackingArea *surfaceTrackingArea;
|
|
570
592
|
@property(nonatomic, copy) NSString *markedText;
|
|
571
593
|
@property(nonatomic, assign) NSRange markedTextRange;
|
|
@@ -573,10 +595,28 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
573
595
|
@property(nonatomic, assign) BOOL interpretedKeyEventEmittedInput;
|
|
574
596
|
@property(nonatomic, strong) NSArray<NSAccessibilityElement *> *widgetAccessibilityElements;
|
|
575
597
|
@property(nonatomic, strong) NSMutableArray<NativeSdkScrollDriverView *> *scrollDrivers;
|
|
576
|
-
@property(nonatomic,
|
|
598
|
+
@property(nonatomic, assign) NSPoint wheelGesturePoint;
|
|
599
|
+
@property(nonatomic, assign) BOOL wheelGestureActive;
|
|
600
|
+
/* The last phase-less wheel's timestamp: discrete streams have no
|
|
601
|
+
* gesture phases, so a quiet gap IS the gesture boundary. */
|
|
602
|
+
@property(nonatomic, assign) uint64_t lastLegacyWheelTimestampNs;
|
|
603
|
+
/* The gesture's most recent native recipient: zero-delta phase events
|
|
604
|
+
* (begins, the terminal Ended/Cancelled) resolve no owner but still
|
|
605
|
+
* carry the bookkeeping the scroller's overscroll recovery keys off,
|
|
606
|
+
* so they forward here. */
|
|
607
|
+
@property(nonatomic, weak) NativeSdkScrollDriverView *lastNativeWheelDriver;
|
|
608
|
+
/* Driver ids the WIRE has scrolled during this gesture: once the engine
|
|
609
|
+
* applies relative deltas to a region, later ABSOLUTE native reports
|
|
610
|
+
* from the same region would erase them, so a wire-scrolled region
|
|
611
|
+
* never becomes the native recipient again until the gesture ends. */
|
|
612
|
+
@property(nonatomic, strong) NSMutableSet *wireBoundDriverIds;
|
|
613
|
+
/* Occluder rects (view space): floating surfaces and modal catchers
|
|
614
|
+
* that hit-block scroll regions beneath them. */
|
|
615
|
+
@property(nonatomic, strong) NSArray *scrollOccluderRects;
|
|
577
616
|
@property(nonatomic, assign) BOOL applyingScrollDriverOffset;
|
|
578
617
|
@property(nonatomic, assign) BOOL scrollDriverEventPending;
|
|
579
618
|
@property(nonatomic, assign) uint64_t pendingScrollDriverId;
|
|
619
|
+
@property(nonatomic, assign) double pendingScrollDriverOffsetX;
|
|
580
620
|
@property(nonatomic, assign) double pendingScrollDriverOffsetY;
|
|
581
621
|
@property(nonatomic, assign) uint64_t scrollDriverEventLastEmitNs;
|
|
582
622
|
@property(nonatomic, assign) BOOL controlClickActive;
|
|
@@ -623,7 +663,7 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
623
663
|
- (void)emitInputEventWithKind:(NSInteger)kind event:(NSEvent *)event button:(NSInteger)button deltaX:(double)deltaX deltaY:(double)deltaY;
|
|
624
664
|
- (void)queuePointerMotionInputEvent:(NSEvent *)event kind:(NSInteger)kind button:(NSInteger)button;
|
|
625
665
|
- (void)emitQueuedPointerMotionInputEvent;
|
|
626
|
-
- (void)queueScrollInputEvent:(NSEvent *)event deltaX:(double)deltaX deltaY:(double)deltaY;
|
|
666
|
+
- (void)queueScrollInputEvent:(NSEvent *)event atPoint:(NSPoint)point deltaX:(double)deltaX deltaY:(double)deltaY;
|
|
627
667
|
- (void)emitQueuedScrollInputEvent;
|
|
628
668
|
- (void)emitPinchInputEventWithKind:(NSInteger)kind event:(NSEvent *)event magnification:(double)magnification;
|
|
629
669
|
- (void)emitPinchChangeForEvent:(NSEvent *)event;
|
|
@@ -636,7 +676,7 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
636
676
|
- (BOOL)emitWidgetAccessibilityActionWithId:(uint64_t)widgetId action:(NSInteger)action;
|
|
637
677
|
- (BOOL)emitWidgetAccessibilityActionWithId:(uint64_t)widgetId action:(NSInteger)action text:(NSString *)text selectedRange:(NSRange)selectedRange hasSelectedRange:(BOOL)hasSelectedRange;
|
|
638
678
|
- (void)setSurfaceCursor:(NSCursor *)cursor;
|
|
639
|
-
- (void)setScrollDrivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count;
|
|
679
|
+
- (void)setScrollDrivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count occluders:(const native_sdk_appkit_scroll_occluder_t *)occluders occluderCount:(NSUInteger)occluderCount;
|
|
640
680
|
@end
|
|
641
681
|
|
|
642
682
|
@interface NativeSdkAssetSchemeHandler : NSObject <WKURLSchemeHandler>
|
|
@@ -760,6 +800,69 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
760
800
|
* when a new load replaces the stream; orphaned (left to finish) when
|
|
761
801
|
* the stream completes naturally. */
|
|
762
802
|
@property(nonatomic, strong) NSURLSessionDownloadTask *audioCacheDownload;
|
|
803
|
+
/* The app's single video player and its two timers. One player is the
|
|
804
|
+
* whole surface, exactly like audio: a video app shows one stream at a
|
|
805
|
+
* time, and a second concurrent decode would be compositor design the
|
|
806
|
+
* platform seam has not earned. The position tick runs only while
|
|
807
|
+
* playing, at the audio tier's coarse honest cadence — position is a
|
|
808
|
+
* readout, not a frame clock; the FRAME timer (1/60 s, the
|
|
809
|
+
* scheduleFrame cadence) is the clock that actually paces decoded
|
|
810
|
+
* pixels into the sink, armed with the transport plus one-shot polls
|
|
811
|
+
* after seek/pause so a paused scrub still shows its frame. */
|
|
812
|
+
@property(nonatomic, strong) AVPlayer *videoPlayer;
|
|
813
|
+
@property(nonatomic, strong) AVPlayerItem *videoItem;
|
|
814
|
+
/* The frame tap: created at readyToPlay (the presentation size is only
|
|
815
|
+
* decoded then), sized to FIT the sink's per-frame pixel budget. */
|
|
816
|
+
@property(nonatomic, strong) AVPlayerItemVideoOutput *videoOutput;
|
|
817
|
+
@property(nonatomic, strong) NSTimer *videoPositionTimer;
|
|
818
|
+
@property(nonatomic, strong) NSTimer *videoFrameTimer;
|
|
819
|
+
/* Where decoded frames go: the C push trampoline and its context,
|
|
820
|
+
* installed by the load entries. Every timer callback runs on the main
|
|
821
|
+
* run loop, so no locking guards the pair. */
|
|
822
|
+
@property(nonatomic, assign) native_sdk_appkit_video_sink_push_t videoSinkPush;
|
|
823
|
+
@property(nonatomic, assign) void *videoSinkContext;
|
|
824
|
+
/* The reusable RGBA conversion target: malloc'd once per load to the
|
|
825
|
+
* output's max frame size, freed on stop/replace. Frames are converted
|
|
826
|
+
* BGRA -> tightly packed straight-alpha RGBA8 into it before the push. */
|
|
827
|
+
@property(nonatomic, assign) uint8_t *videoFrameBuffer;
|
|
828
|
+
@property(nonatomic, assign) size_t videoFrameBufferLen;
|
|
829
|
+
/* The STREAM's decoded pixel dimensions (presentationSize, falling back
|
|
830
|
+
* to the track's transformed naturalSize) — what LOADED reports, even
|
|
831
|
+
* when the output texture is fitted smaller. */
|
|
832
|
+
@property(nonatomic, assign) uint64_t videoStreamWidth;
|
|
833
|
+
@property(nonatomic, assign) uint64_t videoStreamHeight;
|
|
834
|
+
/* The poster-frame hunt: a load that acknowledges LOADED while paused
|
|
835
|
+
* (autoplay = false, "the poster-frame shape") still owes the surface
|
|
836
|
+
* its first decoded frame — the frame timer normally runs only while
|
|
837
|
+
* playing. Set on LOADED; the pump clears it at the first delivered
|
|
838
|
+
* frame (stopping the timer if still paused), and the tick counter
|
|
839
|
+
* bounds the hunt so an output that never yields a frame cannot poll
|
|
840
|
+
* at 60 Hz forever. */
|
|
841
|
+
@property(nonatomic, assign) BOOL videoPosterPending;
|
|
842
|
+
@property(nonatomic, assign) int videoPosterTicks;
|
|
843
|
+
/* The engine-minted token of the CURRENT load, echoed in every video
|
|
844
|
+
* event (see the header's video_token) so a replaced playback's queued
|
|
845
|
+
* straggler can never be attributed to the replacement. */
|
|
846
|
+
@property(nonatomic, assign) uint64_t videoToken;
|
|
847
|
+
/* Whether the loaded source is a local file: local sources never
|
|
848
|
+
* report buffering. */
|
|
849
|
+
@property(nonatomic, assign) BOOL videoSourceIsLocal;
|
|
850
|
+
/* NSNotificationCenter block-observer tokens for the item's natural
|
|
851
|
+
* end and mid-flight failure; removed on teardown. */
|
|
852
|
+
@property(nonatomic, strong) id videoEndObserver;
|
|
853
|
+
@property(nonatomic, strong) id videoFailObserver;
|
|
854
|
+
/* KVO registration flag so teardown removes observers exactly once. */
|
|
855
|
+
@property(nonatomic, assign) BOOL videoObservingStatus;
|
|
856
|
+
/* The LOADED acknowledgment fires once per load (item status can
|
|
857
|
+
* bounce through readyToPlay again after a stall). */
|
|
858
|
+
@property(nonatomic, assign) BOOL videoLoadedEmitted;
|
|
859
|
+
/* The honest buffering mirror emitted with every video event: YES from
|
|
860
|
+
* stream start (no bytes yet) until the player reports it is actually
|
|
861
|
+
* rolling, then follows timeControlStatus. Never set for local files. */
|
|
862
|
+
@property(nonatomic, assign) BOOL videoBuffering;
|
|
863
|
+
/* Loop intent: a looping player wraps from the natural end back to
|
|
864
|
+
* zero and keeps playing — no COMPLETED, because it never ends. */
|
|
865
|
+
@property(nonatomic, assign) BOOL videoLooping;
|
|
763
866
|
@property(nonatomic, strong) NSString *appName;
|
|
764
867
|
/* The human-facing app name (app.zon display_name, falling back through
|
|
765
868
|
* the window title to the binary name). Everything the OS labels the
|
|
@@ -798,6 +901,7 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
798
901
|
@property(nonatomic, assign) BOOL observesAppearanceChanges;
|
|
799
902
|
@property(nonatomic, assign) NSInteger bridgeFrameKeepalive;
|
|
800
903
|
@property(nonatomic, strong) id shortcutEventMonitor;
|
|
904
|
+
@property(nonatomic, strong) id viewFocusEventMonitor;
|
|
801
905
|
@property(nonatomic, strong) id willTerminateObserver;
|
|
802
906
|
@property(nonatomic, strong) dispatch_source_t sigtermSource;
|
|
803
907
|
@property(nonatomic, strong) NSArray<NativeSdkShortcut *> *shortcuts;
|
|
@@ -840,7 +944,7 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
840
944
|
- (NSInteger)presentGpuSurfacePacketBinaryInWindow:(uint64_t)windowId label:(NSString *)label surfaceWidth:(CGFloat)surfaceWidth height:(CGFloat)surfaceHeight scale:(CGFloat)scale clearR:(uint8_t)clearR clearG:(uint8_t)clearG clearB:(uint8_t)clearB clearA:(uint8_t)clearA requiresRender:(BOOL)requiresRender commandCount:(NSUInteger)commandCount unsupportedCommandCount:(NSUInteger)unsupportedCommandCount representable:(BOOL)representable packet:(const uint8_t *)packet byteLength:(NSUInteger)byteLength;
|
|
841
945
|
- (BOOL)requestGpuSurfaceFrameInWindow:(uint64_t)windowId label:(NSString *)label;
|
|
842
946
|
- (BOOL)noteGpuSurfaceInputInWindow:(uint64_t)windowId label:(NSString *)label;
|
|
843
|
-
- (BOOL)setGpuSurfaceScrollDriversInWindow:(uint64_t)windowId label:(NSString *)label drivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count;
|
|
947
|
+
- (BOOL)setGpuSurfaceScrollDriversInWindow:(uint64_t)windowId label:(NSString *)label drivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count occluders:(const native_sdk_appkit_scroll_occluder_t *)occluders occluderCount:(NSUInteger)occluderCount;
|
|
844
948
|
- (BOOL)showContextMenuInWindow:(uint64_t)windowId label:(NSString *)label x:(double)x y:(double)y token:(uint64_t)token items:(const native_sdk_appkit_context_menu_item_t *)items count:(NSUInteger)count;
|
|
845
949
|
- (BOOL)uploadGpuSurfaceImageWithId:(uint64_t)imageId width:(NSUInteger)width height:(NSUInteger)height rgba8:(const uint8_t *)rgba8 byteLength:(NSUInteger)byteLength;
|
|
846
950
|
- (BOOL)removeGpuSurfaceImageWithId:(uint64_t)imageId;
|
|
@@ -918,6 +1022,29 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
|
|
|
918
1022
|
- (void)stopAudioSpectrumTimer;
|
|
919
1023
|
- (BOOL)anyHostWindowVisibleOnGlass;
|
|
920
1024
|
- (void)audioSpectrumTimerFired:(NSTimer *)timer;
|
|
1025
|
+
- (int)videoLoadPath:(NSString *)path token:(uint64_t)token pushFn:(native_sdk_appkit_video_sink_push_t)pushFn pushContext:(void *)pushContext;
|
|
1026
|
+
- (int)videoLoadURL:(NSString *)urlString token:(uint64_t)token pushFn:(native_sdk_appkit_video_sink_push_t)pushFn pushContext:(void *)pushContext;
|
|
1027
|
+
- (void)videoInstallItem:(AVPlayerItem *)item localSource:(BOOL)localSource pushFn:(native_sdk_appkit_video_sink_push_t)pushFn pushContext:(void *)pushContext;
|
|
1028
|
+
- (BOOL)videoAttachOutputForItem:(AVPlayerItem *)item;
|
|
1029
|
+
- (void)videoTearDownPlayer;
|
|
1030
|
+
- (void)videoItemStatusChanged;
|
|
1031
|
+
- (void)videoTimeControlChanged;
|
|
1032
|
+
- (void)videoDidPlayToEnd;
|
|
1033
|
+
- (void)videoDidFail;
|
|
1034
|
+
- (int)videoPlay;
|
|
1035
|
+
- (int)videoPause;
|
|
1036
|
+
- (int)videoStop;
|
|
1037
|
+
- (int)videoSeekToMs:(uint64_t)positionMs;
|
|
1038
|
+
- (int)videoSetVolume:(double)volume;
|
|
1039
|
+
- (int)videoSetMuted:(BOOL)muted;
|
|
1040
|
+
- (int)videoSetLoop:(BOOL)loop;
|
|
1041
|
+
- (void)emitVideoEventOfKind:(int)kind;
|
|
1042
|
+
- (void)stopVideoPositionTimer;
|
|
1043
|
+
- (void)videoPositionTimerFired:(NSTimer *)timer;
|
|
1044
|
+
- (void)startVideoFrameTimer;
|
|
1045
|
+
- (void)stopVideoFrameTimer;
|
|
1046
|
+
- (void)videoFrameTimerFired:(NSTimer *)timer;
|
|
1047
|
+
- (void)videoPumpFrame;
|
|
921
1048
|
- (void)wakeFromAnyThread;
|
|
922
1049
|
- (void)scheduleBridgeFrames;
|
|
923
1050
|
- (void)emitFrame;
|
|
@@ -3345,15 +3472,28 @@ static NSDictionary *NativeSdkPacketDictionaryFromBinary(const uint8_t *bytes, N
|
|
|
3345
3472
|
@implementation NativeSdkScrollDriverView
|
|
3346
3473
|
|
|
3347
3474
|
- (NSView *)hitTest:(NSPoint)point {
|
|
3348
|
-
//
|
|
3349
|
-
//
|
|
3350
|
-
//
|
|
3351
|
-
//
|
|
3352
|
-
// the
|
|
3475
|
+
// Wheel events deliberately do NOT hit the driver: they fall
|
|
3476
|
+
// through to the surface, whose scrollWheel: resolves the gesture's
|
|
3477
|
+
// dominant axis against every driver under the pointer, locks the
|
|
3478
|
+
// gesture, forwards it to the winner, and splits any residual axis
|
|
3479
|
+
// to the engine wire — per-axis routing that direct NSScrollView
|
|
3480
|
+
// delivery cannot perform (NSScrollView consumes whole events, so a
|
|
3481
|
+
// diagonal gesture over a nested vertical list would swallow the
|
|
3482
|
+
// horizontal component its ancestor owns). The forwarded event
|
|
3483
|
+
// skips AppKit's concurrent responsive-scrolling fast path, but the
|
|
3484
|
+
// scroller still owns feel — momentum, rubber-band, and the overlay
|
|
3485
|
+
// scroller all run from forwarded events (the responder-chain
|
|
3486
|
+
// fallback always relied on exactly that). Everything else passes
|
|
3487
|
+
// through to the canvas beneath, except the overlay scrollers
|
|
3488
|
+
// themselves (the knob stays grabbable).
|
|
3353
3489
|
NSView *hit = [super hitTest:point];
|
|
3354
3490
|
if (!hit) return nil;
|
|
3491
|
+
// Wheel events never hit-test into the driver — not even over a
|
|
3492
|
+
// visible overlay scroller: a wheel over the knob still needs the
|
|
3493
|
+
// splitter, or its cross-axis component would be swallowed. Only
|
|
3494
|
+
// pointer interaction keeps the knob grabbable.
|
|
3355
3495
|
NSEvent *current = NSApp.currentEvent;
|
|
3356
|
-
if (current && current.type == NSEventTypeScrollWheel) return
|
|
3496
|
+
if (current && current.type == NSEventTypeScrollWheel) return nil;
|
|
3357
3497
|
NSView *candidate = hit;
|
|
3358
3498
|
while (candidate && candidate != self) {
|
|
3359
3499
|
if ([candidate isKindOfClass:[NSScroller class]]) return hit;
|
|
@@ -5775,13 +5915,74 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
|
|
|
5775
5915
|
|
|
5776
5916
|
- (void)resetCursorRects {
|
|
5777
5917
|
[super resetCursorRects];
|
|
5778
|
-
|
|
5918
|
+
// Cursor rects do not honor sibling occlusion. Register the canvas
|
|
5919
|
+
// cursor only on the visible fragments left after higher-layer
|
|
5920
|
+
// native/web views are subtracted, so an overlaid WKWebView keeps
|
|
5921
|
+
// authority over its own link/text CSS cursors.
|
|
5922
|
+
NSMutableArray<NSValue *> *visibleCursorRects = [NSMutableArray arrayWithObject:[NSValue valueWithRect:self.bounds]];
|
|
5923
|
+
for (NSValue *coveredValue in self.coveredMouseRects) {
|
|
5924
|
+
NSRect covered = coveredValue.rectValue;
|
|
5925
|
+
NSMutableArray<NSValue *> *nextVisibleRects = [[NSMutableArray alloc] init];
|
|
5926
|
+
for (NSValue *visibleValue in visibleCursorRects) {
|
|
5927
|
+
NSRect visible = visibleValue.rectValue;
|
|
5928
|
+
NSRect intersection = NSIntersectionRect(visible, covered);
|
|
5929
|
+
if (NSIsEmptyRect(intersection)) {
|
|
5930
|
+
[nextVisibleRects addObject:visibleValue];
|
|
5931
|
+
continue;
|
|
5932
|
+
}
|
|
5933
|
+
|
|
5934
|
+
const CGFloat visibleMinX = NSMinX(visible);
|
|
5935
|
+
const CGFloat visibleMaxX = NSMaxX(visible);
|
|
5936
|
+
const CGFloat visibleMinY = NSMinY(visible);
|
|
5937
|
+
const CGFloat visibleMaxY = NSMaxY(visible);
|
|
5938
|
+
const CGFloat coveredMinX = NSMinX(intersection);
|
|
5939
|
+
const CGFloat coveredMaxX = NSMaxX(intersection);
|
|
5940
|
+
const CGFloat coveredMinY = NSMinY(intersection);
|
|
5941
|
+
const CGFloat coveredMaxY = NSMaxY(intersection);
|
|
5942
|
+
|
|
5943
|
+
if (coveredMinY > visibleMinY) {
|
|
5944
|
+
[nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
|
|
5945
|
+
visibleMinX, visibleMinY, visible.size.width, coveredMinY - visibleMinY)]];
|
|
5946
|
+
}
|
|
5947
|
+
if (coveredMaxY < visibleMaxY) {
|
|
5948
|
+
[nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
|
|
5949
|
+
visibleMinX, coveredMaxY, visible.size.width, visibleMaxY - coveredMaxY)]];
|
|
5950
|
+
}
|
|
5951
|
+
if (coveredMinX > visibleMinX) {
|
|
5952
|
+
[nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
|
|
5953
|
+
visibleMinX, coveredMinY, coveredMinX - visibleMinX, intersection.size.height)]];
|
|
5954
|
+
}
|
|
5955
|
+
if (coveredMaxX < visibleMaxX) {
|
|
5956
|
+
[nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
|
|
5957
|
+
coveredMaxX, coveredMinY, visibleMaxX - coveredMaxX, intersection.size.height)]];
|
|
5958
|
+
}
|
|
5959
|
+
}
|
|
5960
|
+
visibleCursorRects = nextVisibleRects;
|
|
5961
|
+
}
|
|
5962
|
+
|
|
5963
|
+
NSCursor *cursor = self.surfaceCursor ?: [NSCursor arrowCursor];
|
|
5964
|
+
for (NSValue *visibleValue in visibleCursorRects) {
|
|
5965
|
+
[self addCursorRect:visibleValue.rectValue cursor:cursor];
|
|
5966
|
+
}
|
|
5779
5967
|
}
|
|
5780
5968
|
|
|
5781
5969
|
- (void)setSurfaceCursor:(NSCursor *)cursor {
|
|
5782
5970
|
_surfaceCursor = cursor ?: [NSCursor arrowCursor];
|
|
5783
5971
|
[self.window invalidateCursorRectsForView:self];
|
|
5784
|
-
|
|
5972
|
+
// The runtime changes cursor intent from mouseMoved:. Its tracking
|
|
5973
|
+
// area spans the geometric surface even where a sibling webview is
|
|
5974
|
+
// layered above it, so never let that immediate update clobber the
|
|
5975
|
+
// higher view's cursor. The visible cursor rect takes over again as
|
|
5976
|
+
// soon as the pointer returns to the canvas.
|
|
5977
|
+
NSPoint mousePoint = [self convertPoint:self.window.mouseLocationOutsideOfEventStream fromView:nil];
|
|
5978
|
+
BOOL covered = NO;
|
|
5979
|
+
for (NSValue *coveredValue in self.coveredMouseRects) {
|
|
5980
|
+
if (NSPointInRect(mousePoint, coveredValue.rectValue)) {
|
|
5981
|
+
covered = YES;
|
|
5982
|
+
break;
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5985
|
+
if (!covered && NSPointInRect(mousePoint, self.bounds)) [_surfaceCursor set];
|
|
5785
5986
|
}
|
|
5786
5987
|
|
|
5787
5988
|
- (void)mouseDown:(NSEvent *)event {
|
|
@@ -5851,15 +6052,96 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
|
|
|
5851
6052
|
}
|
|
5852
6053
|
|
|
5853
6054
|
- (void)scrollWheel:(NSEvent *)event {
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
// The OS scroller owns input + physics for this region (momentum,
|
|
5857
|
-
// rubber-band, overlay scroller); the resulting contentOffset
|
|
5858
|
-
// flows back through the clip-view bounds-change notification.
|
|
5859
|
-
[driver scrollWheel:event];
|
|
6055
|
+
if (self.scrollDrivers.count == 0) {
|
|
6056
|
+
[self queueScrollInputEvent:event atPoint:[self convertPoint:event.locationInWindow fromView:nil] deltaX:-event.scrollingDeltaX deltaY:-event.scrollingDeltaY];
|
|
5860
6057
|
return;
|
|
5861
6058
|
}
|
|
5862
|
-
|
|
6059
|
+
// Gesture anchoring: owners resolve at the point where the GESTURE
|
|
6060
|
+
// began (so momentum and wire hand-offs keep working the same
|
|
6061
|
+
// regions after the pointer wanders), re-evaluated EVERY event
|
|
6062
|
+
// against the drivers' live offsets — which is what hands an axis
|
|
6063
|
+
// to the ancestor the moment the inner region saturates, mirroring
|
|
6064
|
+
// the engine's per-event walk. Legacy wheels (no phases) resolve at
|
|
6065
|
+
// the live pointer; a quiet gap is their gesture boundary.
|
|
6066
|
+
const BOOL legacy = event.phase == NSEventPhaseNone && event.momentumPhase == NSEventPhaseNone;
|
|
6067
|
+
NSPoint point;
|
|
6068
|
+
if (legacy) {
|
|
6069
|
+
point = [self convertPoint:event.locationInWindow fromView:nil];
|
|
6070
|
+
const uint64_t now = NativeSdkTimestampNanoseconds();
|
|
6071
|
+
const BOOL freshBurst = self.lastLegacyWheelTimestampNs == 0 ||
|
|
6072
|
+
now - self.lastLegacyWheelTimestampNs > 250000000ull;
|
|
6073
|
+
self.lastLegacyWheelTimestampNs = now;
|
|
6074
|
+
if (freshBurst) {
|
|
6075
|
+
[self.wireBoundDriverIds removeAllObjects];
|
|
6076
|
+
self.lastNativeWheelDriver = nil;
|
|
6077
|
+
}
|
|
6078
|
+
} else {
|
|
6079
|
+
if (event.phase == NSEventPhaseBegan || event.phase == NSEventPhaseMayBegin) {
|
|
6080
|
+
self.wheelGesturePoint = [self convertPoint:event.locationInWindow fromView:nil];
|
|
6081
|
+
self.wheelGestureActive = YES;
|
|
6082
|
+
[self.wireBoundDriverIds removeAllObjects];
|
|
6083
|
+
self.lastLegacyWheelTimestampNs = 0;
|
|
6084
|
+
self.lastNativeWheelDriver = nil;
|
|
6085
|
+
}
|
|
6086
|
+
point = self.wheelGestureActive ? self.wheelGesturePoint : [self convertPoint:event.locationInWindow fromView:nil];
|
|
6087
|
+
if (event.momentumPhase == NSEventPhaseEnded || event.momentumPhase == NSEventPhaseCancelled) {
|
|
6088
|
+
self.wheelGestureActive = NO;
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
if (!self.wireBoundDriverIds) self.wireBoundDriverIds = [[NSMutableSet alloc] init];
|
|
6092
|
+
|
|
6093
|
+
const double canvasDx = -event.scrollingDeltaX;
|
|
6094
|
+
const double canvasDy = -event.scrollingDeltaY;
|
|
6095
|
+
|
|
6096
|
+
// Zero-delta phase events (begins, the terminal Ended/Cancelled)
|
|
6097
|
+
// resolve no owner but still carry the bookkeeping the scroller's
|
|
6098
|
+
// overscroll recovery keys off — they forward to the gesture's last
|
|
6099
|
+
// native recipient and nowhere else.
|
|
6100
|
+
if (canvasDx == 0 && canvasDy == 0) {
|
|
6101
|
+
if (!legacy && self.lastNativeWheelDriver) {
|
|
6102
|
+
[self.lastNativeWheelDriver scrollWheel:event];
|
|
6103
|
+
}
|
|
6104
|
+
return;
|
|
6105
|
+
}
|
|
6106
|
+
|
|
6107
|
+
NSArray *chain = [self wheelCandidateChainAtPoint:point];
|
|
6108
|
+
NativeSdkScrollDriverView *ownerX = nil;
|
|
6109
|
+
NativeSdkScrollDriverView *ownerY = nil;
|
|
6110
|
+
[self resolveWheelOwnersInChain:chain canvasDx:canvasDx canvasDy:canvasDy ownerX:&ownerX ownerY:&ownerY];
|
|
6111
|
+
|
|
6112
|
+
// ONE owner takes the whole event natively; everything ambiguous
|
|
6113
|
+
// rides the wire, where the engine's real routing decides:
|
|
6114
|
+
// - no owner at all (dead axes, an overlay over the anchor);
|
|
6115
|
+
// - the two axes owned by DIFFERENT regions (one NSScrollView
|
|
6116
|
+
// cannot keep the axes apart — the engine applies each axis to
|
|
6117
|
+
// its own region and the set-offset flags sync the scrollers);
|
|
6118
|
+
// - an owner the wire already scrolled this gesture (the engine
|
|
6119
|
+
// applied relative deltas its next ABSOLUTE report would
|
|
6120
|
+
// erase).
|
|
6121
|
+
// A partially consumable delta stays NATIVE and clamps at the edge
|
|
6122
|
+
// — exactly the engine's rule (the region that can move consumes
|
|
6123
|
+
// the whole event; the remainder dies), so native and engine-only
|
|
6124
|
+
// execution agree.
|
|
6125
|
+
const BOOL dominantVertical = fabs(canvasDy) >= fabs(canvasDx);
|
|
6126
|
+
NativeSdkScrollDriverView *native = dominantVertical ? (ownerY ?: ownerX) : (ownerX ?: ownerY);
|
|
6127
|
+
const BOOL splitOwners = ownerX && ownerY && ownerX != ownerY;
|
|
6128
|
+
const BOOL nativeWireBound = native && [self.wireBoundDriverIds containsObject:@(native.driverId)];
|
|
6129
|
+
if (!native || splitOwners || nativeWireBound) {
|
|
6130
|
+
if (ownerX) [self.wireBoundDriverIds addObject:@(ownerX.driverId)];
|
|
6131
|
+
if (ownerY) [self.wireBoundDriverIds addObject:@(ownerY.driverId)];
|
|
6132
|
+
// Offsets first (one clock): the wire routing consults the
|
|
6133
|
+
// runtime's offsets, so any coalesced driver report must land
|
|
6134
|
+
// before the deltas that depend on it.
|
|
6135
|
+
[self emitQueuedScrollDriverEvent];
|
|
6136
|
+
[self queueScrollInputEvent:event atPoint:point deltaX:canvasDx deltaY:canvasDy];
|
|
6137
|
+
return;
|
|
6138
|
+
}
|
|
6139
|
+
|
|
6140
|
+
// The OS scroller owns input + physics for this event (momentum,
|
|
6141
|
+
// rubber-band, overlay scroller); the resulting contentOffset flows
|
|
6142
|
+
// back through the clip-view bounds-change notification.
|
|
6143
|
+
self.lastNativeWheelDriver = native;
|
|
6144
|
+
[native scrollWheel:event];
|
|
5863
6145
|
}
|
|
5864
6146
|
|
|
5865
6147
|
- (void)magnifyWithEvent:(NSEvent *)event {
|
|
@@ -5938,6 +6220,17 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
|
|
|
5938
6220
|
|
|
5939
6221
|
- (void)keyDown:(NSEvent *)event {
|
|
5940
6222
|
if ([self focusedTextAccessibilityElement]) {
|
|
6223
|
+
// The shared canvas editor already maps Command/Option+Left/Right
|
|
6224
|
+
// (including Shift variants) onto line/word navigation. Preserve
|
|
6225
|
+
// those physical keys instead of letting interpretKeyEvents turn
|
|
6226
|
+
// Command+Left/Right into modifier-less Home/End selectors. A
|
|
6227
|
+
// focused terminal needs the modifiers even more: its emulator
|
|
6228
|
+
// translates the natural macOS gestures to shell bindings, and
|
|
6229
|
+
// negotiated key protocols must see every other combined chord.
|
|
6230
|
+
if (NativeSdkTextNavigationNeedsRawKeyEvent(event)) {
|
|
6231
|
+
[self emitInputEventWithKind:NATIVE_SDK_APPKIT_GPU_INPUT_KEY_DOWN event:event button:0 deltaX:0 deltaY:0];
|
|
6232
|
+
return;
|
|
6233
|
+
}
|
|
5941
6234
|
self.interpretedKeyEventEmittedInput = NO;
|
|
5942
6235
|
[self interpretKeyEvents:@[event]];
|
|
5943
6236
|
if (!self.interpretedKeyEventEmittedInput) {
|
|
@@ -6066,10 +6359,13 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
|
|
|
6066
6359
|
deltaY:0];
|
|
6067
6360
|
}
|
|
6068
6361
|
|
|
6069
|
-
|
|
6362
|
+
// The POINT is caller-supplied: driver hand-offs pass the gesture's
|
|
6363
|
+
// anchor so residual and saturated-momentum deltas route to the same
|
|
6364
|
+
// regions the native side resolved, however far the pointer wandered.
|
|
6365
|
+
- (void)queueScrollInputEvent:(NSEvent *)event atPoint:(NSPoint)point deltaX:(double)deltaX deltaY:(double)deltaY {
|
|
6070
6366
|
if (!self.host || self.surfaceLabel.length == 0 || !event) return;
|
|
6071
6367
|
if (deltaX == 0 && deltaY == 0) return;
|
|
6072
|
-
self.pendingScrollPoint =
|
|
6368
|
+
self.pendingScrollPoint = point;
|
|
6073
6369
|
self.pendingScrollDeltaX += deltaX;
|
|
6074
6370
|
self.pendingScrollDeltaY += deltaY;
|
|
6075
6371
|
self.pendingScrollModifiers = NativeSdkModifierFlagsForEvent(event);
|
|
@@ -6178,8 +6474,18 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6178
6474
|
// IS the canvas scroll offset, reported back per frame interval through
|
|
6179
6475
|
// GPU_SURFACE_SCROLL_DRIVER events.
|
|
6180
6476
|
|
|
6181
|
-
- (void)setScrollDrivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count {
|
|
6477
|
+
- (void)setScrollDrivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count occluders:(const native_sdk_appkit_scroll_occluder_t *)occluders occluderCount:(NSUInteger)occluderCount {
|
|
6182
6478
|
if (!self.scrollDrivers) self.scrollDrivers = [[NSMutableArray alloc] init];
|
|
6479
|
+
// Occluder rects arrive in canvas coordinates (top-left origin,
|
|
6480
|
+
// y-down); store them flipped into this view's space, like the
|
|
6481
|
+
// driver frames.
|
|
6482
|
+
NSMutableArray *occluderRects = [[NSMutableArray alloc] initWithCapacity:occluderCount];
|
|
6483
|
+
for (NSUInteger index = 0; index < occluderCount; index += 1) {
|
|
6484
|
+
const native_sdk_appkit_scroll_occluder_t occluder = occluders[index];
|
|
6485
|
+
const NSRect rect = NSMakeRect(occluder.x, self.bounds.size.height - occluder.y - occluder.height, occluder.width, occluder.height);
|
|
6486
|
+
[occluderRects addObject:[NSValue valueWithRect:rect]];
|
|
6487
|
+
}
|
|
6488
|
+
self.scrollOccluderRects = occluderRects;
|
|
6183
6489
|
for (NSInteger index = (NSInteger)self.scrollDrivers.count - 1; index >= 0; index -= 1) {
|
|
6184
6490
|
NativeSdkScrollDriverView *driver = self.scrollDrivers[(NSUInteger)index];
|
|
6185
6491
|
BOOL present = NO;
|
|
@@ -6194,6 +6500,11 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6194
6500
|
[driver removeFromSuperview];
|
|
6195
6501
|
[self.scrollDrivers removeObjectAtIndex:(NSUInteger)index];
|
|
6196
6502
|
}
|
|
6503
|
+
// Rebuilt in SPEC order every push: the specs ride layout pre-order
|
|
6504
|
+
// (outermost first, deepest last), and the wheel selection walk
|
|
6505
|
+
// depends on that order — a keyed reorder that keeps ids must not
|
|
6506
|
+
// leave a stale creation order deciding which region is "deepest".
|
|
6507
|
+
NSMutableArray *ordered = [[NSMutableArray alloc] initWithCapacity:count];
|
|
6197
6508
|
for (NSUInteger spec = 0; spec < count; spec += 1) {
|
|
6198
6509
|
const native_sdk_appkit_scroll_driver_t desired = drivers[spec];
|
|
6199
6510
|
NativeSdkScrollDriverView *driver = nil;
|
|
@@ -6210,10 +6521,14 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6210
6521
|
driver.driverId = desired.driver_id;
|
|
6211
6522
|
driver.drawsBackground = NO;
|
|
6212
6523
|
driver.hasVerticalScroller = YES;
|
|
6213
|
-
|
|
6524
|
+
// The horizontal scroller engages only when the driver's
|
|
6525
|
+
// content is wider than its frame — the runtime pins
|
|
6526
|
+
// content_width to the frame width on regions without a
|
|
6527
|
+
// horizontal axis grant, so vertical-only regions never
|
|
6528
|
+
// grow one.
|
|
6529
|
+
driver.hasHorizontalScroller = YES;
|
|
6214
6530
|
driver.scrollerStyle = NSScrollerStyleOverlay;
|
|
6215
6531
|
driver.autohidesScrollers = YES;
|
|
6216
|
-
driver.horizontalScrollElasticity = NSScrollElasticityNone;
|
|
6217
6532
|
driver.automaticallyAdjustsContentInsets = NO;
|
|
6218
6533
|
NativeSdkScrollDriverDocumentView *document = [[NativeSdkScrollDriverDocumentView alloc] initWithFrame:NSMakeRect(0, 0, MAX(desired.content_width, 1), MAX(desired.content_height, 1))];
|
|
6219
6534
|
driver.documentView = document;
|
|
@@ -6226,52 +6541,159 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6226
6541
|
// against anything but the actual frame races with relayout.
|
|
6227
6542
|
// Elasticity rides the same reconcile: a region's edge behavior
|
|
6228
6543
|
// (pin at the edges vs bounce past them) is per-region state the
|
|
6229
|
-
// runtime owns
|
|
6230
|
-
|
|
6231
|
-
|
|
6544
|
+
// runtime owns, armed ONLY on axes the region grants — an
|
|
6545
|
+
// ungranted axis must never bounce or report a native offset the
|
|
6546
|
+
// runtime would ignore and fight back.
|
|
6547
|
+
NSScrollElasticity verticalElasticity = (desired.rubber_band && desired.scrolls_y) ? NSScrollElasticityAllowed : NSScrollElasticityNone;
|
|
6548
|
+
if (driver.verticalScrollElasticity != verticalElasticity) driver.verticalScrollElasticity = verticalElasticity;
|
|
6549
|
+
NSScrollElasticity horizontalElasticity = (desired.rubber_band && desired.scrolls_x) ? NSScrollElasticityAllowed : NSScrollElasticityNone;
|
|
6550
|
+
if (driver.horizontalScrollElasticity != horizontalElasticity) driver.horizontalScrollElasticity = horizontalElasticity;
|
|
6551
|
+
// Scroller chrome follows the grants the same way, and the
|
|
6552
|
+
// grants themselves ride the view for the wheel winner walk.
|
|
6553
|
+
if (driver.hasVerticalScroller != (desired.scrolls_y != 0)) driver.hasVerticalScroller = desired.scrolls_y != 0;
|
|
6554
|
+
if (driver.hasHorizontalScroller != (desired.scrolls_x != 0)) driver.hasHorizontalScroller = desired.scrolls_x != 0;
|
|
6555
|
+
driver.grantsX = desired.scrolls_x != 0;
|
|
6556
|
+
driver.grantsY = desired.scrolls_y != 0;
|
|
6557
|
+
driver.parentDriverId = desired.parent_driver_id;
|
|
6558
|
+
driver.occluderMask = desired.occluder_mask;
|
|
6232
6559
|
NSRect target = NSMakeRect(desired.x, self.bounds.size.height - desired.y - desired.height, desired.width, desired.height);
|
|
6233
6560
|
if (!NSEqualRects(driver.frame, target)) driver.frame = target;
|
|
6234
6561
|
NSSize contentSize = NSMakeSize(MAX(desired.content_width, 1), MAX(desired.content_height, 1));
|
|
6235
6562
|
if (driver.documentView && !NSEqualSizes(driver.documentView.frame.size, contentSize)) {
|
|
6236
6563
|
[driver.documentView setFrameSize:contentSize];
|
|
6237
6564
|
}
|
|
6238
|
-
if (created || desired.
|
|
6565
|
+
if (created || desired.set_offset_x || desired.set_offset_y) {
|
|
6566
|
+
[self applyScrollDriverOffset:driver
|
|
6567
|
+
offsetX:desired.offset_x
|
|
6568
|
+
setX:(created || desired.set_offset_x)
|
|
6569
|
+
offsetY:desired.offset_y
|
|
6570
|
+
setY:(created || desired.set_offset_y)];
|
|
6571
|
+
}
|
|
6572
|
+
[ordered addObject:driver];
|
|
6239
6573
|
}
|
|
6574
|
+
self.scrollDrivers = ordered;
|
|
6240
6575
|
}
|
|
6241
6576
|
|
|
6242
|
-
-
|
|
6577
|
+
// Per-axis programmatic offset write: an axis the runtime did not move
|
|
6578
|
+
// keeps the native scroller's CURRENT origin, so a vertical write can
|
|
6579
|
+
// never drag a stale horizontal offset over native motion whose
|
|
6580
|
+
// coalesced report is still in flight (and vice versa).
|
|
6581
|
+
- (void)applyScrollDriverOffset:(NativeSdkScrollDriverView *)driver offsetX:(double)offsetX setX:(BOOL)setX offsetY:(double)offsetY setY:(BOOL)setY {
|
|
6582
|
+
const NSPoint current = driver.contentView.bounds.origin;
|
|
6243
6583
|
self.applyingScrollDriverOffset = YES;
|
|
6244
|
-
[driver.contentView setBoundsOrigin:NSMakePoint(
|
|
6584
|
+
[driver.contentView setBoundsOrigin:NSMakePoint(setX ? offsetX : current.x, setY ? offsetY : current.y)];
|
|
6245
6585
|
[driver reflectScrolledClipView:driver.contentView];
|
|
6246
6586
|
self.applyingScrollDriverOffset = NO;
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
//
|
|
6251
|
-
|
|
6252
|
-
|
|
6587
|
+
// A queued (frame-coalesced) report for THIS driver predates the
|
|
6588
|
+
// programmatic write: rewrite it to the offsets the clip view
|
|
6589
|
+
// actually settled on, so the stale pair can never re-land and
|
|
6590
|
+
// yank the region back after the runtime moved it.
|
|
6591
|
+
if (self.scrollDriverEventPending && self.pendingScrollDriverId == driver.driverId) {
|
|
6592
|
+
self.pendingScrollDriverOffsetX = driver.contentView.bounds.origin.x;
|
|
6593
|
+
self.pendingScrollDriverOffsetY = driver.contentView.bounds.origin.y;
|
|
6594
|
+
}
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
// Direction-aware consumption, the engine's nested-handoff predicate
|
|
6598
|
+
// (`canvasWidgetScrollCanConsumeAxis`) restated against the native
|
|
6599
|
+
// scroller with the engine's EXACT bounds (no edge tolerance — the
|
|
6600
|
+
// engine compares exactly, and a half-point slack would hand an
|
|
6601
|
+
// almost-home inner region's delta to its ancestor where the engine
|
|
6602
|
+
// still moves the inner one): a driver consumes a delta on an axis
|
|
6603
|
+
// only while its offset can still move in that direction, so a
|
|
6604
|
+
// saturated inner region hands an outward swipe to its ancestor
|
|
6605
|
+
// exactly like the engine walk does.
|
|
6606
|
+
static BOOL NativeSdkScrollDriverCanConsumeVertically(NativeSdkScrollDriverView *driver, double canvasDelta) {
|
|
6607
|
+
if (canvasDelta == 0) return NO;
|
|
6608
|
+
const double offset = driver.contentView.bounds.origin.y;
|
|
6609
|
+
const double maxOffset = driver.documentView.frame.size.height - driver.contentView.bounds.size.height;
|
|
6610
|
+
return canvasDelta > 0 ? offset < maxOffset : offset > 0;
|
|
6611
|
+
}
|
|
6612
|
+
|
|
6613
|
+
static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverView *driver, double canvasDelta) {
|
|
6614
|
+
if (canvasDelta == 0) return NO;
|
|
6615
|
+
const double offset = driver.contentView.bounds.origin.x;
|
|
6616
|
+
const double maxOffset = driver.documentView.frame.size.width - driver.contentView.bounds.size.width;
|
|
6617
|
+
return canvasDelta > 0 ? offset < maxOffset : offset > 0;
|
|
6618
|
+
}
|
|
6619
|
+
|
|
6620
|
+
// The wheel CANDIDATE CHAIN at a point: the deepest driver under the
|
|
6621
|
+
// point (specs ride layout pre-order, so the last containing entry is
|
|
6622
|
+
// the hit region) plus its ancestors by parent id — the widget-tree
|
|
6623
|
+
// containment chain the engine's route walks. Restricting owner
|
|
6624
|
+
// resolution to this chain keeps a geometrically overlapping but
|
|
6625
|
+
// UNRELATED region (a background scroller behind a floating surface)
|
|
6626
|
+
// from stealing an axis the engine would never give it. Ordered
|
|
6627
|
+
// outermost first, like the spec array.
|
|
6628
|
+
- (NSArray *)wheelCandidateChainAtPoint:(NSPoint)viewPoint {
|
|
6629
|
+
// Occluders first: an overlay containing the point hit-blocks every
|
|
6630
|
+
// region beneath it (bit set in the region's mask), exactly where
|
|
6631
|
+
// the engine's hit test would give the point to the overlay's
|
|
6632
|
+
// branch. Blocked drivers decline outright — the wheel then rides
|
|
6633
|
+
// the wire, where real hit-testing decides.
|
|
6634
|
+
uint32_t blockedBits = 0;
|
|
6635
|
+
NSUInteger occluderIndex = 0;
|
|
6636
|
+
for (NSValue *value in self.scrollOccluderRects) {
|
|
6637
|
+
if (NSPointInRect(viewPoint, value.rectValue)) blockedBits |= (uint32_t)1 << occluderIndex;
|
|
6638
|
+
occluderIndex += 1;
|
|
6639
|
+
}
|
|
6640
|
+
NativeSdkScrollDriverView *hit = nil;
|
|
6253
6641
|
for (NativeSdkScrollDriverView *driver in self.scrollDrivers) {
|
|
6254
|
-
if (
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
}
|
|
6274
|
-
return
|
|
6642
|
+
if ((driver.occluderMask & blockedBits) != 0) continue;
|
|
6643
|
+
if (NSPointInRect(viewPoint, driver.frame)) hit = driver;
|
|
6644
|
+
}
|
|
6645
|
+
if (!hit) return @[];
|
|
6646
|
+
NSMutableArray *chain = [[NSMutableArray alloc] init];
|
|
6647
|
+
NativeSdkScrollDriverView *current = hit;
|
|
6648
|
+
while (current) {
|
|
6649
|
+
if ((current.occluderMask & blockedBits) == 0) [chain insertObject:current atIndex:0];
|
|
6650
|
+
uint64_t parentId = current.parentDriverId;
|
|
6651
|
+
NativeSdkScrollDriverView *parent = nil;
|
|
6652
|
+
if (parentId != 0) {
|
|
6653
|
+
for (NativeSdkScrollDriverView *candidate in self.scrollDrivers) {
|
|
6654
|
+
if (candidate.driverId == parentId) {
|
|
6655
|
+
parent = candidate;
|
|
6656
|
+
break;
|
|
6657
|
+
}
|
|
6658
|
+
}
|
|
6659
|
+
}
|
|
6660
|
+
current = parent;
|
|
6661
|
+
}
|
|
6662
|
+
return chain;
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6665
|
+
// Resolve each axis's OWNER independently over the candidate chain —
|
|
6666
|
+
// the engine's per-axis walk restated over the native drivers: an axis
|
|
6667
|
+
// routes to the DEEPEST chain region that can consume its delta right
|
|
6668
|
+
// now (direction-aware, so a saturated inner region hands an outward
|
|
6669
|
+
// swipe to its ancestor), falling back to the OUTERMOST region granted
|
|
6670
|
+
// that axis — which bounces if elastic (rubber-band needs no range,
|
|
6671
|
+
// short content included) and clamps into a harmless no-op if not,
|
|
6672
|
+
// exactly the engine's outermost-applies rule. Nil means no native
|
|
6673
|
+
// region owns the axis. Elastic-take deliberately never outranks a
|
|
6674
|
+
// consumer: an elastic inner list that saturates while its parent still
|
|
6675
|
+
// has range hands the axis over instead of bouncing forever.
|
|
6676
|
+
- (void)resolveWheelOwnersInChain:(NSArray *)chain
|
|
6677
|
+
canvasDx:(double)canvasDx
|
|
6678
|
+
canvasDy:(double)canvasDy
|
|
6679
|
+
ownerX:(NativeSdkScrollDriverView **)ownerX
|
|
6680
|
+
ownerY:(NativeSdkScrollDriverView **)ownerY {
|
|
6681
|
+
NativeSdkScrollDriverView *consumerX = nil;
|
|
6682
|
+
NativeSdkScrollDriverView *fallbackX = nil;
|
|
6683
|
+
NativeSdkScrollDriverView *consumerY = nil;
|
|
6684
|
+
NativeSdkScrollDriverView *fallbackY = nil;
|
|
6685
|
+
for (NativeSdkScrollDriverView *driver in chain) {
|
|
6686
|
+
if (canvasDx != 0 && driver.grantsX) {
|
|
6687
|
+
if (NativeSdkScrollDriverCanConsumeHorizontally(driver, canvasDx)) consumerX = driver;
|
|
6688
|
+
if (!fallbackX) fallbackX = driver;
|
|
6689
|
+
}
|
|
6690
|
+
if (canvasDy != 0 && driver.grantsY) {
|
|
6691
|
+
if (NativeSdkScrollDriverCanConsumeVertically(driver, canvasDy)) consumerY = driver;
|
|
6692
|
+
if (!fallbackY) fallbackY = driver;
|
|
6693
|
+
}
|
|
6694
|
+
}
|
|
6695
|
+
*ownerX = consumerX ?: fallbackX;
|
|
6696
|
+
*ownerY = consumerY ?: fallbackY;
|
|
6275
6697
|
}
|
|
6276
6698
|
|
|
6277
6699
|
- (void)scrollDriverBoundsDidChange:(NSNotification *)note {
|
|
@@ -6279,17 +6701,18 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6279
6701
|
NSClipView *clipView = note.object;
|
|
6280
6702
|
for (NativeSdkScrollDriverView *driver in self.scrollDrivers) {
|
|
6281
6703
|
if (driver.contentView != clipView) continue;
|
|
6282
|
-
[self queueScrollDriverEventWithId:driver.driverId offsetY:clipView.bounds.origin.y];
|
|
6704
|
+
[self queueScrollDriverEventWithId:driver.driverId offsetX:clipView.bounds.origin.x offsetY:clipView.bounds.origin.y];
|
|
6283
6705
|
return;
|
|
6284
6706
|
}
|
|
6285
6707
|
}
|
|
6286
6708
|
|
|
6287
|
-
- (void)queueScrollDriverEventWithId:(uint64_t)driverId offsetY:(double)offsetY {
|
|
6709
|
+
- (void)queueScrollDriverEventWithId:(uint64_t)driverId offsetX:(double)offsetX offsetY:(double)offsetY {
|
|
6288
6710
|
if (!self.host || self.surfaceLabel.length == 0) return;
|
|
6289
6711
|
if (self.scrollDriverEventPending && self.pendingScrollDriverId != driverId) {
|
|
6290
6712
|
[self emitQueuedScrollDriverEvent];
|
|
6291
6713
|
}
|
|
6292
6714
|
self.pendingScrollDriverId = driverId;
|
|
6715
|
+
self.pendingScrollDriverOffsetX = offsetX;
|
|
6293
6716
|
self.pendingScrollDriverOffsetY = offsetY;
|
|
6294
6717
|
if (self.scrollDriverEventPending) return;
|
|
6295
6718
|
self.scrollDriverEventPending = YES;
|
|
@@ -6311,6 +6734,7 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6311
6734
|
- (void)emitQueuedScrollDriverEvent {
|
|
6312
6735
|
if (!self.scrollDriverEventPending) return;
|
|
6313
6736
|
const uint64_t driverId = self.pendingScrollDriverId;
|
|
6737
|
+
const double offsetX = self.pendingScrollDriverOffsetX;
|
|
6314
6738
|
const double offsetY = self.pendingScrollDriverOffsetY;
|
|
6315
6739
|
self.scrollDriverEventPending = NO;
|
|
6316
6740
|
if (!self.host || self.surfaceLabel.length == 0) return;
|
|
@@ -6323,6 +6747,7 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6323
6747
|
.view_label_len = [self.surfaceLabel lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
|
|
6324
6748
|
.timestamp_ns = NativeSdkTimestampNanoseconds(),
|
|
6325
6749
|
.widget_id = driverId,
|
|
6750
|
+
.scroll_driver_offset_x = offsetX,
|
|
6326
6751
|
.scroll_driver_offset_y = offsetY,
|
|
6327
6752
|
}];
|
|
6328
6753
|
}
|
|
@@ -6933,6 +7358,7 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6933
7358
|
- (void)dealloc {
|
|
6934
7359
|
[self invalidateAppTimers];
|
|
6935
7360
|
[self audioStop];
|
|
7361
|
+
[self videoStop];
|
|
6936
7362
|
/* The vDSP plan outlives individual playbacks (created lazily
|
|
6937
7363
|
* once); the host's end is where it retires. */
|
|
6938
7364
|
if (self.audioSpectrumFft) {
|
|
@@ -6944,6 +7370,10 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
6944
7370
|
[NSEvent removeMonitor:self.shortcutEventMonitor];
|
|
6945
7371
|
self.shortcutEventMonitor = nil;
|
|
6946
7372
|
}
|
|
7373
|
+
if (self.viewFocusEventMonitor) {
|
|
7374
|
+
[NSEvent removeMonitor:self.viewFocusEventMonitor];
|
|
7375
|
+
self.viewFocusEventMonitor = nil;
|
|
7376
|
+
}
|
|
6947
7377
|
[self removeAllChildBridgeHandlers];
|
|
6948
7378
|
for (WKWebView *webView in self.webViews.allValues) {
|
|
6949
7379
|
[webView.configuration.userContentController removeScriptMessageHandlerForName:@"nativeSdkBridge"];
|
|
@@ -7162,6 +7592,7 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
7162
7592
|
WKWebView *webView = [[NativeSdkWebView alloc] initWithFrame:container.bounds configuration:configuration];
|
|
7163
7593
|
((NativeSdkWebView *)webView).host = self;
|
|
7164
7594
|
((NativeSdkWebView *)webView).windowId = windowId;
|
|
7595
|
+
((NativeSdkWebView *)webView).viewLabel = @"main";
|
|
7165
7596
|
[webView registerForDraggedTypes:@[NSPasteboardTypeFileURL]];
|
|
7166
7597
|
webView.wantsLayer = YES;
|
|
7167
7598
|
webView.layer.zPosition = 0;
|
|
@@ -7594,11 +8025,11 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
7594
8025
|
return YES;
|
|
7595
8026
|
}
|
|
7596
8027
|
|
|
7597
|
-
- (BOOL)setGpuSurfaceScrollDriversInWindow:(uint64_t)windowId label:(NSString *)label drivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count {
|
|
8028
|
+
- (BOOL)setGpuSurfaceScrollDriversInWindow:(uint64_t)windowId label:(NSString *)label drivers:(const native_sdk_appkit_scroll_driver_t *)drivers count:(NSUInteger)count occluders:(const native_sdk_appkit_scroll_occluder_t *)occluders occluderCount:(NSUInteger)occluderCount {
|
|
7598
8029
|
NSString *key = [self nativeViewKeyForWindow:windowId label:label];
|
|
7599
8030
|
NSView *view = self.nativeViews[key];
|
|
7600
8031
|
if (![view isKindOfClass:[NativeSdkMetalSurfaceView class]]) return NO;
|
|
7601
|
-
[(NativeSdkMetalSurfaceView *)view setScrollDrivers:drivers count:count];
|
|
8032
|
+
[(NativeSdkMetalSurfaceView *)view setScrollDrivers:drivers count:count occluders:occluders occluderCount:occluderCount];
|
|
7602
8033
|
return YES;
|
|
7603
8034
|
}
|
|
7604
8035
|
|
|
@@ -7844,6 +8275,7 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
7844
8275
|
WKWebView *webview = [[NativeSdkWebView alloc] initWithFrame:[self webViewFrameForWindow:window x:x y:y width:width height:height] configuration:configuration];
|
|
7845
8276
|
((NativeSdkWebView *)webview).host = self;
|
|
7846
8277
|
((NativeSdkWebView *)webview).windowId = windowId;
|
|
8278
|
+
((NativeSdkWebView *)webview).viewLabel = label;
|
|
7847
8279
|
[webview registerForDraggedTypes:@[NSPasteboardTypeFileURL]];
|
|
7848
8280
|
webview.wantsLayer = YES;
|
|
7849
8281
|
webview.layer.zPosition = layer;
|
|
@@ -8048,18 +8480,27 @@ static double NativeSdkClampedPinchMagnification(double magnification) {
|
|
|
8048
8480
|
}];
|
|
8049
8481
|
|
|
8050
8482
|
for (NSUInteger index = 0; index < views.count; index++) {
|
|
8051
|
-
|
|
8052
|
-
|
|
8483
|
+
NSView *coveredView = views[index];
|
|
8484
|
+
const BOOL isWebView = [coveredView isKindOfClass:[NativeSdkWebView class]];
|
|
8485
|
+
const BOOL isMetalSurface = [coveredView isKindOfClass:[NativeSdkMetalSurfaceView class]];
|
|
8486
|
+
if (!isWebView && !isMetalSurface) continue;
|
|
8053
8487
|
NSMutableArray<NSValue *> *coveredRects = [[NSMutableArray alloc] init];
|
|
8054
8488
|
for (NSUInteger coverIndex = index + 1; coverIndex < views.count; coverIndex++) {
|
|
8055
8489
|
NSView *coveringView = views[coverIndex];
|
|
8056
8490
|
if (coveringView.hidden) continue;
|
|
8057
|
-
NSRect intersection = NSIntersectionRect(
|
|
8491
|
+
NSRect intersection = NSIntersectionRect(coveredView.frame, coveringView.frame);
|
|
8058
8492
|
if (NSIsEmptyRect(intersection)) continue;
|
|
8059
|
-
[coveredRects addObject:[NSValue valueWithRect:[
|
|
8493
|
+
[coveredRects addObject:[NSValue valueWithRect:[coveredView convertRect:intersection fromView:contentView]]];
|
|
8494
|
+
}
|
|
8495
|
+
if (isWebView) {
|
|
8496
|
+
NativeSdkWebView *webView = (NativeSdkWebView *)coveredView;
|
|
8497
|
+
webView.coveredMouseRects = coveredRects;
|
|
8498
|
+
[self applyCoveredMouseRects:coveredRects toWebView:webView];
|
|
8499
|
+
} else {
|
|
8500
|
+
NativeSdkMetalSurfaceView *surfaceView = (NativeSdkMetalSurfaceView *)coveredView;
|
|
8501
|
+
surfaceView.coveredMouseRects = coveredRects;
|
|
8502
|
+
[surfaceView.window invalidateCursorRectsForView:surfaceView];
|
|
8060
8503
|
}
|
|
8061
|
-
webView.coveredMouseRects = coveredRects;
|
|
8062
|
-
[self applyCoveredMouseRects:coveredRects toWebView:webView];
|
|
8063
8504
|
}
|
|
8064
8505
|
}
|
|
8065
8506
|
|
|
@@ -8545,7 +8986,7 @@ static void NativeSdkApplyProcessDisplayName(NSString *displayName) {
|
|
|
8545
8986
|
}
|
|
8546
8987
|
|
|
8547
8988
|
- (NSMenuItem *)commandMenuItem:(NSString *)title command:(NSString *)command key:(NSString *)key modifiers:(uint32_t)modifiers enabled:(BOOL)enabled checked:(BOOL)checked {
|
|
8548
|
-
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title ?: @"" action:@selector(menuCommandItemClicked:) keyEquivalent:key ?: @""];
|
|
8989
|
+
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title ?: @"" action:@selector(menuCommandItemClicked:) keyEquivalent:NativeSdkMenuKeyEquivalent(key ?: @"")];
|
|
8549
8990
|
item.target = self;
|
|
8550
8991
|
item.enabled = enabled;
|
|
8551
8992
|
item.representedObject = command ?: @"";
|
|
@@ -8639,6 +9080,31 @@ static void NativeSdkApplyProcessDisplayName(NSString *displayName) {
|
|
|
8639
9080
|
return event;
|
|
8640
9081
|
}];
|
|
8641
9082
|
}
|
|
9083
|
+
if (!self.viewFocusEventMonitor) {
|
|
9084
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
9085
|
+
self.viewFocusEventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:
|
|
9086
|
+
(NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown | NSEventMaskOtherMouseDown)
|
|
9087
|
+
handler:^NSEvent *(NSEvent *event) {
|
|
9088
|
+
NativeSdkAppKitHost *strongSelf = weakSelf;
|
|
9089
|
+
NSView *content = event.window.contentView;
|
|
9090
|
+
if (!strongSelf || !content) return event;
|
|
9091
|
+
NSPoint point = [content convertPoint:event.locationInWindow fromView:nil];
|
|
9092
|
+
NSView *hit = [content hitTest:point];
|
|
9093
|
+
while (hit && ![hit isKindOfClass:[NativeSdkWebView class]]) {
|
|
9094
|
+
hit = hit.superview;
|
|
9095
|
+
}
|
|
9096
|
+
if (![hit isKindOfClass:[NativeSdkWebView class]]) return event;
|
|
9097
|
+
NativeSdkWebView *webView = (NativeSdkWebView *)hit;
|
|
9098
|
+
const char *label = webView.viewLabel.UTF8String ?: "";
|
|
9099
|
+
[strongSelf emitEvent:(native_sdk_appkit_event_t){
|
|
9100
|
+
.kind = NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED,
|
|
9101
|
+
.window_id = webView.windowId,
|
|
9102
|
+
.view_label = label,
|
|
9103
|
+
.view_label_len = strlen(label),
|
|
9104
|
+
}];
|
|
9105
|
+
return event;
|
|
9106
|
+
}];
|
|
9107
|
+
}
|
|
8642
9108
|
|
|
8643
9109
|
[self startApplicationActivationObservers];
|
|
8644
9110
|
[self startAppearanceObservers];
|
|
@@ -8725,10 +9191,15 @@ static void NativeSdkApplyProcessDisplayName(NSString *displayName) {
|
|
|
8725
9191
|
self.timer = nil;
|
|
8726
9192
|
[self invalidateAppTimers];
|
|
8727
9193
|
[self audioStop];
|
|
9194
|
+
[self videoStop];
|
|
8728
9195
|
if (self.shortcutEventMonitor) {
|
|
8729
9196
|
[NSEvent removeMonitor:self.shortcutEventMonitor];
|
|
8730
9197
|
self.shortcutEventMonitor = nil;
|
|
8731
9198
|
}
|
|
9199
|
+
if (self.viewFocusEventMonitor) {
|
|
9200
|
+
[NSEvent removeMonitor:self.viewFocusEventMonitor];
|
|
9201
|
+
self.viewFocusEventMonitor = nil;
|
|
9202
|
+
}
|
|
8732
9203
|
[self stopAppearanceObservers];
|
|
8733
9204
|
[self stopApplicationActivationObservers];
|
|
8734
9205
|
[NSApp stop:nil];
|
|
@@ -8849,6 +9320,22 @@ static void NativeSdkApplyProcessDisplayName(NSString *displayName) {
|
|
|
8849
9320
|
});
|
|
8850
9321
|
return;
|
|
8851
9322
|
}
|
|
9323
|
+
/* Same hop for the video player's observers: every video entry
|
|
9324
|
+
* point is loop-thread only too. */
|
|
9325
|
+
if (context == NativeSdkAppKitVideoItemStatusContext) {
|
|
9326
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
9327
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
9328
|
+
[weakSelf videoItemStatusChanged];
|
|
9329
|
+
});
|
|
9330
|
+
return;
|
|
9331
|
+
}
|
|
9332
|
+
if (context == NativeSdkAppKitVideoTimeControlContext) {
|
|
9333
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
9334
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
9335
|
+
[weakSelf videoTimeControlChanged];
|
|
9336
|
+
});
|
|
9337
|
+
return;
|
|
9338
|
+
}
|
|
8852
9339
|
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
8853
9340
|
}
|
|
8854
9341
|
|
|
@@ -9023,7 +9510,12 @@ static double NativeSdkSecondsFromCMTime(CMTime time) {
|
|
|
9023
9510
|
|
|
9024
9511
|
static CMTime NativeSdkCMTimeFromMs(uint64_t ms) {
|
|
9025
9512
|
CMTime time;
|
|
9026
|
-
|
|
9513
|
+
/* The millisecond position arrives as u64; CMTimeValue is signed
|
|
9514
|
+
* 64-bit, so an absurd request past INT64_MAX must clamp rather
|
|
9515
|
+
* than wrap negative. AVPlayer then clamps the (still enormous)
|
|
9516
|
+
* positive time to the item's duration — seek-past-end lands at
|
|
9517
|
+
* the end, per the transport contract. */
|
|
9518
|
+
time.value = (ms > (uint64_t)INT64_MAX) ? INT64_MAX : (CMTimeValue)ms;
|
|
9027
9519
|
time.timescale = 1000;
|
|
9028
9520
|
time.flags = kCMTimeFlags_Valid;
|
|
9029
9521
|
time.epoch = 0;
|
|
@@ -9196,9 +9688,14 @@ static int NativeSdkSpectrumComputeBands(native_sdk_spectrum_tap_state_t *state,
|
|
|
9196
9688
|
double duration = self.audioItem ? NativeSdkSecondsFromCMTime(self.audioItem.duration) : 0.0;
|
|
9197
9689
|
if (position > 0) position_ms = (uint64_t)llround(position * 1000.0);
|
|
9198
9690
|
if (duration > 0) duration_ms = (uint64_t)llround(duration * 1000.0);
|
|
9199
|
-
/* rate > 0 is the transport intent (un-paused)
|
|
9200
|
-
*
|
|
9201
|
-
*
|
|
9691
|
+
/* rate > 0 is the transport intent (un-paused), NOT the
|
|
9692
|
+
* effective rate: a stream stalled in AVPlayer's waiting state
|
|
9693
|
+
* keeps rate at the requested value (see the video twin in
|
|
9694
|
+
* emitVideoEventOfKind for the AVPlayer.h contract), so a
|
|
9695
|
+
* stalled-but-unpaused stream reports playing=1 with the
|
|
9696
|
+
* buffering flag beside it saying whether audio is actually
|
|
9697
|
+
* coming out. Local files never buffer — the flag is
|
|
9698
|
+
* stream-only. */
|
|
9202
9699
|
playing = player.rate > 0 ? 1 : 0;
|
|
9203
9700
|
buffering = (!self.audioSourceIsLocal && self.audioBuffering) ? 1 : 0;
|
|
9204
9701
|
}
|
|
@@ -9732,6 +10229,679 @@ static int NativeSdkSpectrumComputeBands(native_sdk_spectrum_tap_state_t *state,
|
|
|
9732
10229
|
return 1;
|
|
9733
10230
|
}
|
|
9734
10231
|
|
|
10232
|
+
/* ---------------------------------------------------- video player
|
|
10233
|
+
*
|
|
10234
|
+
* The app's single video player: one AVPlayer whose
|
|
10235
|
+
* AVPlayerItemVideoOutput frames feed the sink push handed to the load
|
|
10236
|
+
* entries. The transport, events, and buffering vocabulary mirror the
|
|
10237
|
+
* audio player above; the one addition is the frame pump — a 1/60 s
|
|
10238
|
+
* timer (the scheduleFrame cadence) that polls the output, converts
|
|
10239
|
+
* each new BGRA pixel buffer into the reusable tightly packed RGBA8
|
|
10240
|
+
* buffer, and pushes it through the sink. Pixels never ride events. */
|
|
10241
|
+
|
|
10242
|
+
/* The sink's per-frame ceiling, mirrored from the Zig side
|
|
10243
|
+
* (max_media_surface_pixel_bytes): the output is sized to FIT it. */
|
|
10244
|
+
#define NATIVE_SDK_VIDEO_MAX_FRAME_BYTES (8 * 1024 * 1024)
|
|
10245
|
+
|
|
10246
|
+
/* Fit the stream's natural size to the frame budget: scale DOWN
|
|
10247
|
+
* preserving aspect when width * height * 4 exceeds it (4K fits to
|
|
10248
|
+
* roughly 1867x1050), never up — a small video decodes at its own
|
|
10249
|
+
* size. */
|
|
10250
|
+
static void NativeSdkVideoFittedSize(double naturalWidth, double naturalHeight, size_t *outWidth, size_t *outHeight) {
|
|
10251
|
+
double width = naturalWidth >= 1.0 ? naturalWidth : 1.0;
|
|
10252
|
+
double height = naturalHeight >= 1.0 ? naturalHeight : 1.0;
|
|
10253
|
+
const double budget_pixels = (double)(NATIVE_SDK_VIDEO_MAX_FRAME_BYTES / 4);
|
|
10254
|
+
const double pixels = width * height;
|
|
10255
|
+
if (pixels > budget_pixels) {
|
|
10256
|
+
const double scale = sqrt(budget_pixels / pixels);
|
|
10257
|
+
width = floor(width * scale);
|
|
10258
|
+
height = floor(height * scale);
|
|
10259
|
+
if (width < 1.0) width = 1.0;
|
|
10260
|
+
if (height < 1.0) height = 1.0;
|
|
10261
|
+
}
|
|
10262
|
+
*outWidth = (size_t)width;
|
|
10263
|
+
*outHeight = (size_t)height;
|
|
10264
|
+
}
|
|
10265
|
+
|
|
10266
|
+
/* Emit one video report carrying the live position/duration readout of
|
|
10267
|
+
* the app's single AVPlayer. Runs on the loop thread — every video
|
|
10268
|
+
* entry point is loop-thread only; the player's KVO and notification
|
|
10269
|
+
* handlers hop to the main queue before landing here. */
|
|
10270
|
+
- (void)emitVideoEventOfKind:(int)kind {
|
|
10271
|
+
AVPlayer *player = self.videoPlayer;
|
|
10272
|
+
uint64_t position_ms = 0;
|
|
10273
|
+
uint64_t duration_ms = 0;
|
|
10274
|
+
int playing = 0;
|
|
10275
|
+
int buffering = 0;
|
|
10276
|
+
if (player) {
|
|
10277
|
+
double position = NativeSdkSecondsFromCMTime(player.currentTime);
|
|
10278
|
+
double duration = self.videoItem ? NativeSdkSecondsFromCMTime(self.videoItem.duration) : 0.0;
|
|
10279
|
+
if (position > 0) position_ms = (uint64_t)llround(position * 1000.0);
|
|
10280
|
+
if (duration > 0) duration_ms = (uint64_t)llround(duration * 1000.0);
|
|
10281
|
+
/* rate > 0 is the transport intent (un-paused), NOT the
|
|
10282
|
+
* effective rate: while a stream stalls into
|
|
10283
|
+
* AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate, the
|
|
10284
|
+
* AVPlayer.h contract keeps rate at the requested value ("the
|
|
10285
|
+
* value of the rate property is not currently effective but
|
|
10286
|
+
* instead indicates the rate at which playback will start or
|
|
10287
|
+
* resume"), so a stalled-but-unpaused playback reports
|
|
10288
|
+
* playing=1 with the buffering flag beside it saying whether
|
|
10289
|
+
* frames are actually coming out — the transport control keeps
|
|
10290
|
+
* offering Pause. AVPlayer resets rate to 0.0 on its own only
|
|
10291
|
+
* with waits-to-minimize-stalling disabled (our LOCAL-file
|
|
10292
|
+
* configuration, where a mid-file stall has no bytes to wait
|
|
10293
|
+
* for and playback would not self-resume — reporting paused,
|
|
10294
|
+
* and offering Play, is then the honest affordance). Local
|
|
10295
|
+
* files never buffer — the flag is stream-only. */
|
|
10296
|
+
playing = player.rate > 0 ? 1 : 0;
|
|
10297
|
+
buffering = (!self.videoSourceIsLocal && self.videoBuffering) ? 1 : 0;
|
|
10298
|
+
}
|
|
10299
|
+
native_sdk_appkit_event_t event = {
|
|
10300
|
+
.kind = NATIVE_SDK_APPKIT_EVENT_VIDEO,
|
|
10301
|
+
.video_kind = kind,
|
|
10302
|
+
.video_token = self.videoToken,
|
|
10303
|
+
.video_position_ms = position_ms,
|
|
10304
|
+
.video_duration_ms = duration_ms,
|
|
10305
|
+
.video_playing = playing,
|
|
10306
|
+
.video_buffering = buffering,
|
|
10307
|
+
.timestamp_ns = NativeSdkTimestampNanoseconds(),
|
|
10308
|
+
};
|
|
10309
|
+
if (kind == NATIVE_SDK_APPKIT_VIDEO_EVENT_LOADED) {
|
|
10310
|
+
/* The acknowledgment carries the STREAM's true dimensions —
|
|
10311
|
+
* the honest source geometry, even when the output texture is
|
|
10312
|
+
* fitted smaller to the frame budget. */
|
|
10313
|
+
event.video_width = self.videoStreamWidth;
|
|
10314
|
+
event.video_height = self.videoStreamHeight;
|
|
10315
|
+
}
|
|
10316
|
+
[self emitEvent:event];
|
|
10317
|
+
}
|
|
10318
|
+
|
|
10319
|
+
- (void)stopVideoPositionTimer {
|
|
10320
|
+
[self.videoPositionTimer invalidate];
|
|
10321
|
+
self.videoPositionTimer = nil;
|
|
10322
|
+
}
|
|
10323
|
+
|
|
10324
|
+
- (void)videoPositionTimerFired:(NSTimer *)timer {
|
|
10325
|
+
(void)timer;
|
|
10326
|
+
if (!self.videoPlayer) {
|
|
10327
|
+
[self stopVideoPositionTimer];
|
|
10328
|
+
return;
|
|
10329
|
+
}
|
|
10330
|
+
[self emitVideoEventOfKind:NATIVE_SDK_APPKIT_VIDEO_EVENT_POSITION];
|
|
10331
|
+
}
|
|
10332
|
+
|
|
10333
|
+
- (void)startVideoFrameTimer {
|
|
10334
|
+
if (self.videoFrameTimer) return;
|
|
10335
|
+
/* The pixel clock (1/60 s, the scheduleFrame cadence). Common
|
|
10336
|
+
* modes so frames keep flowing during live resize and menu
|
|
10337
|
+
* tracking (default-mode timers do not fire in tracking
|
|
10338
|
+
* runloops). Block-based with a WEAK host: a target-selector
|
|
10339
|
+
* repeating timer retains its target through the run loop, so a
|
|
10340
|
+
* host destroyed mid-playback could never dealloc — the timer
|
|
10341
|
+
* self-invalidates when the host is gone instead. */
|
|
10342
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
10343
|
+
NSTimer *tick = [NSTimer timerWithTimeInterval:(1.0 / 60.0)
|
|
10344
|
+
repeats:YES
|
|
10345
|
+
block:^(NSTimer *timer) {
|
|
10346
|
+
NativeSdkAppKitHost *strongSelf = weakSelf;
|
|
10347
|
+
if (!strongSelf) {
|
|
10348
|
+
[timer invalidate];
|
|
10349
|
+
return;
|
|
10350
|
+
}
|
|
10351
|
+
[strongSelf videoFrameTimerFired:timer];
|
|
10352
|
+
}];
|
|
10353
|
+
[[NSRunLoop mainRunLoop] addTimer:tick forMode:NSRunLoopCommonModes];
|
|
10354
|
+
self.videoFrameTimer = tick;
|
|
10355
|
+
}
|
|
10356
|
+
|
|
10357
|
+
- (void)stopVideoFrameTimer {
|
|
10358
|
+
[self.videoFrameTimer invalidate];
|
|
10359
|
+
self.videoFrameTimer = nil;
|
|
10360
|
+
}
|
|
10361
|
+
|
|
10362
|
+
- (void)videoFrameTimerFired:(NSTimer *)timer {
|
|
10363
|
+
(void)timer;
|
|
10364
|
+
if (!self.videoPlayer) {
|
|
10365
|
+
[self stopVideoFrameTimer];
|
|
10366
|
+
return;
|
|
10367
|
+
}
|
|
10368
|
+
[self videoPumpFrame];
|
|
10369
|
+
/* The poster hunt's bound: a paused hunt that has not yielded a
|
|
10370
|
+
* frame within ~3s (180 ticks) stops polling — honest surrender,
|
|
10371
|
+
* the placeholder stays. A PLAYING stream never surrenders here;
|
|
10372
|
+
* its timer belongs to playback. */
|
|
10373
|
+
if (self.videoPosterPending &&
|
|
10374
|
+
self.videoPlayer.timeControlStatus != AVPlayerTimeControlStatusPlaying) {
|
|
10375
|
+
self.videoPosterTicks += 1;
|
|
10376
|
+
if (self.videoPosterTicks > 180) {
|
|
10377
|
+
self.videoPosterPending = NO;
|
|
10378
|
+
[self stopVideoFrameTimer];
|
|
10379
|
+
}
|
|
10380
|
+
}
|
|
10381
|
+
}
|
|
10382
|
+
|
|
10383
|
+
/* One poll of the video output: if a new frame is due at the current
|
|
10384
|
+
* host time, convert it and push it through the sink. Also called
|
|
10385
|
+
* one-shot after pause and seek, so a paused scrub still paints the
|
|
10386
|
+
* frame it landed on. Main-thread only, like every video entry. */
|
|
10387
|
+
- (void)videoPumpFrame {
|
|
10388
|
+
AVPlayerItemVideoOutput *output = self.videoOutput;
|
|
10389
|
+
native_sdk_appkit_video_sink_push_t push = self.videoSinkPush;
|
|
10390
|
+
if (!output || !push || !self.videoFrameBuffer) return;
|
|
10391
|
+
CMTime itemTime = [output itemTimeForHostTime:CACurrentMediaTime()];
|
|
10392
|
+
if (![output hasNewPixelBufferForItemTime:itemTime]) return;
|
|
10393
|
+
CVPixelBufferRef pixels = [output copyPixelBufferForItemTime:itemTime itemTimeForDisplay:NULL];
|
|
10394
|
+
if (!pixels) return;
|
|
10395
|
+
const size_t width = CVPixelBufferGetWidth(pixels);
|
|
10396
|
+
const size_t height = CVPixelBufferGetHeight(pixels);
|
|
10397
|
+
const size_t frame_len = width * height * 4;
|
|
10398
|
+
if (frame_len == 0 || frame_len > self.videoFrameBufferLen) {
|
|
10399
|
+
CFRelease(pixels);
|
|
10400
|
+
return;
|
|
10401
|
+
}
|
|
10402
|
+
/* A failed lock never mapped the buffer: the base address would be
|
|
10403
|
+
* garbage and the matching unlock would unbalance the buffer's lock
|
|
10404
|
+
* count. Drop this frame and keep hunting — the poster latch stays
|
|
10405
|
+
* set for the same reason a converted-but-unpushed tick keeps it
|
|
10406
|
+
* (below): only an actual push verdict may end the hunt. */
|
|
10407
|
+
if (CVPixelBufferLockBaseAddress(pixels, kCVPixelBufferLock_ReadOnly) != kCVReturnSuccess) {
|
|
10408
|
+
CFRelease(pixels);
|
|
10409
|
+
return;
|
|
10410
|
+
}
|
|
10411
|
+
void *base = CVPixelBufferGetBaseAddress(pixels);
|
|
10412
|
+
/* -1 = no push happened (NULL base address or a failed channel
|
|
10413
|
+
* permutation). Only an actual push verdict may end the poster
|
|
10414
|
+
* hunt or release the claim below; a converted-but-unpushed tick
|
|
10415
|
+
* must keep hunting, or a paused load's surface stays blank. */
|
|
10416
|
+
int result = -1;
|
|
10417
|
+
if (base) {
|
|
10418
|
+
/* BGRA -> RGBA is one channel permutation; vImage reads the
|
|
10419
|
+
* buffer's bytesPerRow stride and writes the tightly packed
|
|
10420
|
+
* rows the sink contract requires. */
|
|
10421
|
+
vImage_Buffer source = {
|
|
10422
|
+
.data = base,
|
|
10423
|
+
.height = height,
|
|
10424
|
+
.width = width,
|
|
10425
|
+
.rowBytes = CVPixelBufferGetBytesPerRow(pixels),
|
|
10426
|
+
};
|
|
10427
|
+
vImage_Buffer destination = {
|
|
10428
|
+
.data = self.videoFrameBuffer,
|
|
10429
|
+
.height = height,
|
|
10430
|
+
.width = width,
|
|
10431
|
+
.rowBytes = width * 4,
|
|
10432
|
+
};
|
|
10433
|
+
const uint8_t permute[4] = { 2, 1, 0, 3 };
|
|
10434
|
+
if (vImagePermuteChannels_ARGB8888(&source, &destination, permute, kvImageNoFlags) == kvImageNoError) {
|
|
10435
|
+
result = push(self.videoSinkContext, width, height, self.videoFrameBuffer, frame_len);
|
|
10436
|
+
}
|
|
10437
|
+
}
|
|
10438
|
+
CVPixelBufferUnlockBaseAddress(pixels, kCVPixelBufferLock_ReadOnly);
|
|
10439
|
+
CFRelease(pixels);
|
|
10440
|
+
/* The first delivered frame ends the poster hunt: a paused load
|
|
10441
|
+
* has painted its poster, so the timer stops until play; a playing
|
|
10442
|
+
* load keeps its timer, the latch just clears. */
|
|
10443
|
+
if (result == 0 && self.videoPosterPending) {
|
|
10444
|
+
self.videoPosterPending = NO;
|
|
10445
|
+
AVPlayer *player = self.videoPlayer;
|
|
10446
|
+
if (player && player.timeControlStatus != AVPlayerTimeControlStatusPlaying) {
|
|
10447
|
+
[self stopVideoFrameTimer];
|
|
10448
|
+
}
|
|
10449
|
+
}
|
|
10450
|
+
/* 1 says the receiving claim was released (the sink is
|
|
10451
|
+
* latest-wins; a released claim just means stop pushing) — the
|
|
10452
|
+
* frame timer has nothing left to feed. Any other nonzero result
|
|
10453
|
+
* is one dropped frame; the decode keeps rolling. */
|
|
10454
|
+
if (result == 1) {
|
|
10455
|
+
self.videoPosterPending = NO;
|
|
10456
|
+
[self stopVideoFrameTimer];
|
|
10457
|
+
}
|
|
10458
|
+
}
|
|
10459
|
+
|
|
10460
|
+
/* Local files on the app's single video player. Unlike audio there is
|
|
10461
|
+
* no synchronous decode verdict to probe for (AVAudioPlayer's header
|
|
10462
|
+
* decode has no video twin), so the existence check is the only
|
|
10463
|
+
* synchronous refusal — an undecodable file reports asynchronously as
|
|
10464
|
+
* one FAILED event. */
|
|
10465
|
+
- (int)videoLoadPath:(NSString *)path token:(uint64_t)token pushFn:(native_sdk_appkit_video_sink_push_t)pushFn pushContext:(void *)pushContext {
|
|
10466
|
+
[self videoStop];
|
|
10467
|
+
self.videoToken = token;
|
|
10468
|
+
/* Relative paths resolve against the bundle's Resources inside a
|
|
10469
|
+
* packaged .app (where the process cwd is meaningless — `open`
|
|
10470
|
+
* launches at /), and keep their cwd meaning everywhere else. */
|
|
10471
|
+
NSString *resolved = NativeSdkResolvedAssetFilePath(path);
|
|
10472
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:resolved]) return 1;
|
|
10473
|
+
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:resolved] options:nil];
|
|
10474
|
+
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
|
|
10475
|
+
[self videoInstallItem:item localSource:YES pushFn:pushFn pushContext:pushContext];
|
|
10476
|
+
return 0;
|
|
10477
|
+
}
|
|
10478
|
+
|
|
10479
|
+
/* URL sources: a progressive AVPlayer stream — playable as soon as
|
|
10480
|
+
* enough bytes arrive, never download-then-play. No cache layer here
|
|
10481
|
+
* (unlike audio's verified-entry two-step): video bytes are large and
|
|
10482
|
+
* the streaming path alone is the honest slice. Returns 0 for a
|
|
10483
|
+
* started stream, 2 when the URL cannot be parsed; everything
|
|
10484
|
+
* asynchronous — readiness, stalls, natural end, network death —
|
|
10485
|
+
* arrives as EVENT_VIDEO reports. */
|
|
10486
|
+
- (int)videoLoadURL:(NSString *)urlString token:(uint64_t)token pushFn:(native_sdk_appkit_video_sink_push_t)pushFn pushContext:(void *)pushContext {
|
|
10487
|
+
[self videoStop];
|
|
10488
|
+
self.videoToken = token;
|
|
10489
|
+
NSURL *url = [NSURL URLWithString:urlString];
|
|
10490
|
+
if (!url || !url.scheme) return 2;
|
|
10491
|
+
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
|
|
10492
|
+
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
|
|
10493
|
+
[self videoInstallItem:item localSource:NO pushFn:pushFn pushContext:pushContext];
|
|
10494
|
+
return 0;
|
|
10495
|
+
}
|
|
10496
|
+
|
|
10497
|
+
/* Shared install for both sources: the single AVPlayer, its status and
|
|
10498
|
+
* time-control observers, the end/failure notifications, and the sink
|
|
10499
|
+
* destination. The LOADED acknowledgment stays asynchronous by
|
|
10500
|
+
* contract (readyToPlay KVO -> videoItemStatusChanged, which also
|
|
10501
|
+
* attaches the video output — the presentation size is only decoded
|
|
10502
|
+
* then): emitting inside the service call would re-enter the runtime
|
|
10503
|
+
* while it is still dispatching the command that asked for the load. */
|
|
10504
|
+
- (void)videoInstallItem:(AVPlayerItem *)item localSource:(BOOL)localSource pushFn:(native_sdk_appkit_video_sink_push_t)pushFn pushContext:(void *)pushContext {
|
|
10505
|
+
AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
|
|
10506
|
+
/* Stall policy by source: a local file has all its bytes, so
|
|
10507
|
+
* playback starts immediately; a stream keeps the default — start
|
|
10508
|
+
* as soon as sustained playback is likely, roll through short gaps.
|
|
10509
|
+
* Stated explicitly because immediate progressive start is the
|
|
10510
|
+
* contract for streams. */
|
|
10511
|
+
player.automaticallyWaitsToMinimizeStalling = localSource ? NO : YES;
|
|
10512
|
+
self.videoItem = item;
|
|
10513
|
+
self.videoPlayer = player;
|
|
10514
|
+
self.videoSinkPush = pushFn;
|
|
10515
|
+
self.videoSinkContext = pushContext;
|
|
10516
|
+
self.videoSourceIsLocal = localSource;
|
|
10517
|
+
/* Buffering follows timeControlStatus (videoTimeControlChanged):
|
|
10518
|
+
* the moment an un-paused stream needs bytes, the player enters
|
|
10519
|
+
* the waiting state and the observer flips this flag. Presetting
|
|
10520
|
+
* it would make a PAUSED fresh stream read as buffering — a
|
|
10521
|
+
* paused player is paused, not waiting. */
|
|
10522
|
+
self.videoBuffering = NO;
|
|
10523
|
+
self.videoLoadedEmitted = NO;
|
|
10524
|
+
[item addObserver:self
|
|
10525
|
+
forKeyPath:@"status"
|
|
10526
|
+
options:NSKeyValueObservingOptionNew
|
|
10527
|
+
context:NativeSdkAppKitVideoItemStatusContext];
|
|
10528
|
+
[player addObserver:self
|
|
10529
|
+
forKeyPath:@"timeControlStatus"
|
|
10530
|
+
options:NSKeyValueObservingOptionNew
|
|
10531
|
+
context:NativeSdkAppKitVideoTimeControlContext];
|
|
10532
|
+
self.videoObservingStatus = YES;
|
|
10533
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
10534
|
+
/* Both blocks re-check the notification's item against the CURRENT
|
|
10535
|
+
* one: removeObserver (the teardown a replacing load runs) stops
|
|
10536
|
+
* future deliveries, but a notification already enqueued on the
|
|
10537
|
+
* main queue still executes its block — ungated, a replaced item's
|
|
10538
|
+
* terminal would tear down the replacement's player and emit a
|
|
10539
|
+
* false terminal event for the playback that replaced it. */
|
|
10540
|
+
self.videoEndObserver = [[NSNotificationCenter defaultCenter]
|
|
10541
|
+
addObserverForName:AVPlayerItemDidPlayToEndTimeNotification
|
|
10542
|
+
object:item
|
|
10543
|
+
queue:[NSOperationQueue mainQueue]
|
|
10544
|
+
usingBlock:^(NSNotification *note) {
|
|
10545
|
+
NativeSdkAppKitHost *host = weakSelf;
|
|
10546
|
+
if (!host || note.object != host.videoItem) return;
|
|
10547
|
+
[host videoDidPlayToEnd];
|
|
10548
|
+
}];
|
|
10549
|
+
self.videoFailObserver = [[NSNotificationCenter defaultCenter]
|
|
10550
|
+
addObserverForName:AVPlayerItemFailedToPlayToEndTimeNotification
|
|
10551
|
+
object:item
|
|
10552
|
+
queue:[NSOperationQueue mainQueue]
|
|
10553
|
+
usingBlock:^(NSNotification *note) {
|
|
10554
|
+
NativeSdkAppKitHost *host = weakSelf;
|
|
10555
|
+
if (!host || note.object != host.videoItem) return;
|
|
10556
|
+
[host videoDidFail];
|
|
10557
|
+
}];
|
|
10558
|
+
}
|
|
10559
|
+
|
|
10560
|
+
/* Attach the frame tap once the item is ready — presentationSize is
|
|
10561
|
+
* only decoded then. The output's pixel buffers are BGRA fitted to the
|
|
10562
|
+
* frame budget; the STREAM dimensions recorded here are what LOADED
|
|
10563
|
+
* reports. Returns NO when this playback could never paint a frame:
|
|
10564
|
+
* an item with no video geometry at all (an audio-only file loaded as
|
|
10565
|
+
* video — sound over a permanently blank surface is a broken video
|
|
10566
|
+
* playback, and audio-only sources belong to the audio channel), or a
|
|
10567
|
+
* conversion buffer that cannot be allocated after geometry promised
|
|
10568
|
+
* frames. Either way the caller reports the load FAILED instead of
|
|
10569
|
+
* acknowledging a playback that can never paint. */
|
|
10570
|
+
- (BOOL)videoAttachOutputForItem:(AVPlayerItem *)item {
|
|
10571
|
+
/* Rotated media (iPhone portrait: encoded landscape, presented
|
|
10572
|
+
* through a 90-degree track preferredTransform) needs the
|
|
10573
|
+
* transform BAKED into the vended frames: a raw output tap gets
|
|
10574
|
+
* the encoded orientation — sideways and stretched into the
|
|
10575
|
+
* requested attributes — while AVPlayerLayer would have applied
|
|
10576
|
+
* the transform for presentation. A properties-of-asset video
|
|
10577
|
+
* composition renders it in (verified against a portrait-flagged
|
|
10578
|
+
* H.264 asset: the tap vends encoded orientation without it and
|
|
10579
|
+
* display orientation with it). Identity-transform assets skip
|
|
10580
|
+
* the composition's render pass, and track-less items (streams)
|
|
10581
|
+
* have no transform to bake. */
|
|
10582
|
+
NSArray<AVAssetTrack *> *videoTracks = [item.asset tracksWithMediaType:AVMediaTypeVideo];
|
|
10583
|
+
if (videoTracks.count > 0 && !CGAffineTransformIsIdentity(videoTracks.firstObject.preferredTransform)) {
|
|
10584
|
+
#pragma clang diagnostic push
|
|
10585
|
+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
10586
|
+
/* The synchronous variant: this runs at readyToPlay, where the
|
|
10587
|
+
* asset's properties are already loaded, and the completion-
|
|
10588
|
+
* handler replacement is not available on every supported
|
|
10589
|
+
* macOS. */
|
|
10590
|
+
item.videoComposition = [AVMutableVideoComposition videoCompositionWithPropertiesOfAsset:item.asset];
|
|
10591
|
+
#pragma clang diagnostic pop
|
|
10592
|
+
}
|
|
10593
|
+
CGSize natural = item.presentationSize;
|
|
10594
|
+
if (natural.width < 1.0 || natural.height < 1.0) {
|
|
10595
|
+
/* Fallback: the first video track's naturalSize with its
|
|
10596
|
+
* preferredTransform applied (rotated media reports a
|
|
10597
|
+
* transposed natural size). */
|
|
10598
|
+
if (videoTracks.count > 0) {
|
|
10599
|
+
AVAssetTrack *track = videoTracks.firstObject;
|
|
10600
|
+
CGSize transformed = CGSizeApplyAffineTransform(track.naturalSize, track.preferredTransform);
|
|
10601
|
+
natural = CGSizeMake(fabs(transformed.width), fabs(transformed.height));
|
|
10602
|
+
}
|
|
10603
|
+
}
|
|
10604
|
+
if (natural.width < 1.0 || natural.height < 1.0) return NO;
|
|
10605
|
+
self.videoStreamWidth = (uint64_t)llround(natural.width);
|
|
10606
|
+
self.videoStreamHeight = (uint64_t)llround(natural.height);
|
|
10607
|
+
size_t fitted_width = 0;
|
|
10608
|
+
size_t fitted_height = 0;
|
|
10609
|
+
NativeSdkVideoFittedSize(natural.width, natural.height, &fitted_width, &fitted_height);
|
|
10610
|
+
/* The width/height attributes are client REQUIREMENTS on the
|
|
10611
|
+
* vended buffers (AVPlayerItemVideoOutput's pixelBufferAttributes
|
|
10612
|
+
* contract), not hints: the output converts AND scales every frame
|
|
10613
|
+
* to satisfy them, so a 3840x2160 source tapped with fitted
|
|
10614
|
+
* attributes vends fitted-size buffers (verified against a UHD
|
|
10615
|
+
* H.264 asset: requested 1866x1050, vended 1866x1050). The
|
|
10616
|
+
* oversized-frame drop in videoPumpFrame is defense in depth
|
|
10617
|
+
* against a hypothetical host ignoring the attributes, never an
|
|
10618
|
+
* expected path. */
|
|
10619
|
+
AVPlayerItemVideoOutput *output = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:@{
|
|
10620
|
+
(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA),
|
|
10621
|
+
(id)kCVPixelBufferWidthKey: @(fitted_width),
|
|
10622
|
+
(id)kCVPixelBufferHeightKey: @(fitted_height),
|
|
10623
|
+
}];
|
|
10624
|
+
[item addOutput:output];
|
|
10625
|
+
self.videoOutput = output;
|
|
10626
|
+
/* The reusable conversion target: one allocation per load at the
|
|
10627
|
+
* output's max frame size, freed on stop/replace. Allocation
|
|
10628
|
+
* failure is a FAILED load, never a silent zero-frame playback. */
|
|
10629
|
+
if (self.videoFrameBuffer) free(self.videoFrameBuffer);
|
|
10630
|
+
self.videoFrameBufferLen = fitted_width * fitted_height * 4;
|
|
10631
|
+
self.videoFrameBuffer = malloc(self.videoFrameBufferLen);
|
|
10632
|
+
if (!self.videoFrameBuffer) {
|
|
10633
|
+
self.videoFrameBufferLen = 0;
|
|
10634
|
+
return NO;
|
|
10635
|
+
}
|
|
10636
|
+
return YES;
|
|
10637
|
+
}
|
|
10638
|
+
|
|
10639
|
+
/* Release the player, its observers, the frame tap, and the conversion
|
|
10640
|
+
* buffer. The sink destination is cleared with them — a retired
|
|
10641
|
+
* playback must never push another frame. */
|
|
10642
|
+
- (void)videoTearDownPlayer {
|
|
10643
|
+
AVPlayerItem *item = self.videoItem;
|
|
10644
|
+
AVPlayer *player = self.videoPlayer;
|
|
10645
|
+
if (self.videoObservingStatus) {
|
|
10646
|
+
[item removeObserver:self forKeyPath:@"status" context:NativeSdkAppKitVideoItemStatusContext];
|
|
10647
|
+
[player removeObserver:self forKeyPath:@"timeControlStatus" context:NativeSdkAppKitVideoTimeControlContext];
|
|
10648
|
+
self.videoObservingStatus = NO;
|
|
10649
|
+
}
|
|
10650
|
+
if (self.videoEndObserver) {
|
|
10651
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self.videoEndObserver];
|
|
10652
|
+
self.videoEndObserver = nil;
|
|
10653
|
+
}
|
|
10654
|
+
if (self.videoFailObserver) {
|
|
10655
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self.videoFailObserver];
|
|
10656
|
+
self.videoFailObserver = nil;
|
|
10657
|
+
}
|
|
10658
|
+
[player pause];
|
|
10659
|
+
if (self.videoOutput && item) [item removeOutput:self.videoOutput];
|
|
10660
|
+
self.videoOutput = nil;
|
|
10661
|
+
self.videoItem = nil;
|
|
10662
|
+
self.videoPlayer = nil;
|
|
10663
|
+
self.videoSinkPush = NULL;
|
|
10664
|
+
self.videoSinkContext = NULL;
|
|
10665
|
+
self.videoSourceIsLocal = NO;
|
|
10666
|
+
self.videoBuffering = NO;
|
|
10667
|
+
self.videoLoadedEmitted = NO;
|
|
10668
|
+
self.videoLooping = NO;
|
|
10669
|
+
self.videoStreamWidth = 0;
|
|
10670
|
+
self.videoStreamHeight = 0;
|
|
10671
|
+
self.videoPosterPending = NO;
|
|
10672
|
+
self.videoPosterTicks = 0;
|
|
10673
|
+
self.videoToken = 0;
|
|
10674
|
+
if (self.videoFrameBuffer) {
|
|
10675
|
+
free(self.videoFrameBuffer);
|
|
10676
|
+
self.videoFrameBuffer = NULL;
|
|
10677
|
+
self.videoFrameBufferLen = 0;
|
|
10678
|
+
}
|
|
10679
|
+
}
|
|
10680
|
+
|
|
10681
|
+
/* Item status flipped (main queue, hopped from KVO): readyToPlay is
|
|
10682
|
+
* the load's LOADED acknowledgment — the geometry is decoded, the
|
|
10683
|
+
* frame tap attaches, and playback is rolling or about to; failed is
|
|
10684
|
+
* the honest terminal report for an unreachable host or an
|
|
10685
|
+
* undecodable payload. */
|
|
10686
|
+
- (void)videoItemStatusChanged {
|
|
10687
|
+
AVPlayerItem *item = self.videoItem;
|
|
10688
|
+
if (!item) return;
|
|
10689
|
+
if (item.status == AVPlayerItemStatusReadyToPlay) {
|
|
10690
|
+
if (self.videoLoadedEmitted) return;
|
|
10691
|
+
self.videoLoadedEmitted = YES;
|
|
10692
|
+
if (![self videoAttachOutputForItem:item]) {
|
|
10693
|
+
/* No video geometry (an audio-only asset) or no conversion
|
|
10694
|
+
* buffer: acknowledging LOADED would promise frames that
|
|
10695
|
+
* can never arrive, so the load fails honestly. */
|
|
10696
|
+
[self videoDidFail];
|
|
10697
|
+
return;
|
|
10698
|
+
}
|
|
10699
|
+
[self emitVideoEventOfKind:NATIVE_SDK_APPKIT_VIDEO_EVENT_LOADED];
|
|
10700
|
+
/* The poster frame: a paused load (autoplay = false) runs no
|
|
10701
|
+
* frame timer, so start a bounded first-frame hunt — the
|
|
10702
|
+
* output needs a beat past readyToPlay to yield the frame at
|
|
10703
|
+
* position zero. A playing load clears the latch at its first
|
|
10704
|
+
* pumped frame and the timer just keeps rolling. */
|
|
10705
|
+
self.videoPosterPending = YES;
|
|
10706
|
+
self.videoPosterTicks = 0;
|
|
10707
|
+
[self startVideoFrameTimer];
|
|
10708
|
+
return;
|
|
10709
|
+
}
|
|
10710
|
+
if (item.status == AVPlayerItemStatusFailed) {
|
|
10711
|
+
[self videoDidFail];
|
|
10712
|
+
}
|
|
10713
|
+
}
|
|
10714
|
+
|
|
10715
|
+
/* timeControlStatus flipped (main queue, hopped from KVO): waiting to
|
|
10716
|
+
* play at the requested rate IS buffering — for streams. A local file
|
|
10717
|
+
* has all its bytes, so the flag never surfaces for local sources
|
|
10718
|
+
* (waits-to-minimize-stalling is off for them anyway). Emit the
|
|
10719
|
+
* transition immediately as a position report so the UI flips its
|
|
10720
|
+
* buffering state now, not at the next 500ms tick. */
|
|
10721
|
+
- (void)videoTimeControlChanged {
|
|
10722
|
+
AVPlayer *player = self.videoPlayer;
|
|
10723
|
+
if (!player) return;
|
|
10724
|
+
/* Playback actually rolling: make sure the pixel clock runs. The
|
|
10725
|
+
* poster hunt may have stopped the frame timer while the stream
|
|
10726
|
+
* buffered (or surrendered past its bound), and nothing else
|
|
10727
|
+
* restarts it when AVPlayer's waiting phase finally ends —
|
|
10728
|
+
* startVideoFrameTimer is idempotent, so a timer videoPlay already
|
|
10729
|
+
* armed is untouched. */
|
|
10730
|
+
if (player.timeControlStatus == AVPlayerTimeControlStatusPlaying) {
|
|
10731
|
+
[self startVideoFrameTimer];
|
|
10732
|
+
}
|
|
10733
|
+
if (self.videoSourceIsLocal) return;
|
|
10734
|
+
BOOL buffering = player.timeControlStatus == AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate;
|
|
10735
|
+
if (buffering == self.videoBuffering) return;
|
|
10736
|
+
self.videoBuffering = buffering;
|
|
10737
|
+
/* A transition INTO paused is the caller's own pause landing (rate
|
|
10738
|
+
* hit zero): pause emits no acknowledgment by contract — the
|
|
10739
|
+
* engine's command mirror already cleared its buffering flag — and
|
|
10740
|
+
* position reports are for playback in motion, so the flag update
|
|
10741
|
+
* above stays silent. Waiting and playing transitions still emit:
|
|
10742
|
+
* they are the stream's own news. */
|
|
10743
|
+
if (player.timeControlStatus == AVPlayerTimeControlStatusPaused) return;
|
|
10744
|
+
[self emitVideoEventOfKind:NATIVE_SDK_APPKIT_VIDEO_EVENT_POSITION];
|
|
10745
|
+
}
|
|
10746
|
+
|
|
10747
|
+
/* Natural end of the video, both sources. A looping playback wraps to
|
|
10748
|
+
* zero and keeps rolling, emitting NOTHING — a playback that never
|
|
10749
|
+
* ends never completes (the documented contract); position ticks keep
|
|
10750
|
+
* telling the truth on their own cadence. A non-looping end is
|
|
10751
|
+
* retire-before-emit, the audio pattern: the completion Msg routinely
|
|
10752
|
+
* starts the NEXT video from inside its own dispatch, and tearing down
|
|
10753
|
+
* afterwards would destroy the player that load just installed. The
|
|
10754
|
+
* duration is captured first so the event still carries the honest
|
|
10755
|
+
* terminal position. */
|
|
10756
|
+
- (void)videoDidPlayToEnd {
|
|
10757
|
+
if (!self.videoPlayer) return;
|
|
10758
|
+
if (self.videoLooping) {
|
|
10759
|
+
CMTime zero = NativeSdkCMTimeFromMs(0);
|
|
10760
|
+
[self.videoPlayer seekToTime:zero toleranceBefore:zero toleranceAfter:zero];
|
|
10761
|
+
[self.videoPlayer play];
|
|
10762
|
+
return;
|
|
10763
|
+
}
|
|
10764
|
+
[self stopVideoPositionTimer];
|
|
10765
|
+
[self stopVideoFrameTimer];
|
|
10766
|
+
uint64_t duration_ms = 0;
|
|
10767
|
+
if (self.videoItem) {
|
|
10768
|
+
double duration = NativeSdkSecondsFromCMTime(self.videoItem.duration);
|
|
10769
|
+
if (duration > 0) duration_ms = (uint64_t)llround(duration * 1000.0);
|
|
10770
|
+
}
|
|
10771
|
+
const uint64_t token = self.videoToken;
|
|
10772
|
+
[self videoTearDownPlayer];
|
|
10773
|
+
[self emitEvent:(native_sdk_appkit_event_t){
|
|
10774
|
+
.kind = NATIVE_SDK_APPKIT_EVENT_VIDEO,
|
|
10775
|
+
.video_kind = NATIVE_SDK_APPKIT_VIDEO_EVENT_COMPLETED,
|
|
10776
|
+
.video_token = token,
|
|
10777
|
+
.video_position_ms = duration_ms,
|
|
10778
|
+
.video_duration_ms = duration_ms,
|
|
10779
|
+
.video_playing = 0,
|
|
10780
|
+
.video_buffering = 0,
|
|
10781
|
+
.timestamp_ns = NativeSdkTimestampNanoseconds(),
|
|
10782
|
+
}];
|
|
10783
|
+
}
|
|
10784
|
+
|
|
10785
|
+
/* Playback died — a stream lost its network, a local file hit a decode
|
|
10786
|
+
* error mid-file, or an item never became playable (an undecodable
|
|
10787
|
+
* payload, an unreachable host): one FAILED event, player retired
|
|
10788
|
+
* first. */
|
|
10789
|
+
- (void)videoDidFail {
|
|
10790
|
+
if (!self.videoPlayer) return;
|
|
10791
|
+
[self stopVideoPositionTimer];
|
|
10792
|
+
[self stopVideoFrameTimer];
|
|
10793
|
+
const uint64_t token = self.videoToken;
|
|
10794
|
+
[self videoTearDownPlayer];
|
|
10795
|
+
[self emitEvent:(native_sdk_appkit_event_t){
|
|
10796
|
+
.kind = NATIVE_SDK_APPKIT_EVENT_VIDEO,
|
|
10797
|
+
.video_kind = NATIVE_SDK_APPKIT_VIDEO_EVENT_FAILED,
|
|
10798
|
+
.video_token = token,
|
|
10799
|
+
.video_position_ms = 0,
|
|
10800
|
+
.video_duration_ms = 0,
|
|
10801
|
+
.video_playing = 0,
|
|
10802
|
+
.video_buffering = 0,
|
|
10803
|
+
.timestamp_ns = NativeSdkTimestampNanoseconds(),
|
|
10804
|
+
}];
|
|
10805
|
+
}
|
|
10806
|
+
|
|
10807
|
+
- (int)videoPlay {
|
|
10808
|
+
AVPlayer *player = self.videoPlayer;
|
|
10809
|
+
if (!player) return 0;
|
|
10810
|
+
/* AVPlayer's play is asynchronous by nature (it starts when
|
|
10811
|
+
* buffered bytes allow), so play always "applies" — readiness and
|
|
10812
|
+
* stalls report through the event stream. */
|
|
10813
|
+
[player play];
|
|
10814
|
+
if (!self.videoPositionTimer) {
|
|
10815
|
+
/* Common modes for the same reason app timers use them: the
|
|
10816
|
+
* readout must keep ticking while a menu is open or the window
|
|
10817
|
+
* is live-resizing. Weak-host block timer, the pixel clock's
|
|
10818
|
+
* rule: no retain cycle through the run loop. */
|
|
10819
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
10820
|
+
NSTimer *tick = [NSTimer timerWithTimeInterval:0.5
|
|
10821
|
+
repeats:YES
|
|
10822
|
+
block:^(NSTimer *timer) {
|
|
10823
|
+
NativeSdkAppKitHost *strongSelf = weakSelf;
|
|
10824
|
+
if (!strongSelf) {
|
|
10825
|
+
[timer invalidate];
|
|
10826
|
+
return;
|
|
10827
|
+
}
|
|
10828
|
+
[strongSelf videoPositionTimerFired:timer];
|
|
10829
|
+
}];
|
|
10830
|
+
[[NSRunLoop mainRunLoop] addTimer:tick forMode:NSRunLoopCommonModes];
|
|
10831
|
+
self.videoPositionTimer = tick;
|
|
10832
|
+
}
|
|
10833
|
+
[self startVideoFrameTimer];
|
|
10834
|
+
return 1;
|
|
10835
|
+
}
|
|
10836
|
+
|
|
10837
|
+
- (int)videoPause {
|
|
10838
|
+
AVPlayer *player = self.videoPlayer;
|
|
10839
|
+
if (!player) return 0;
|
|
10840
|
+
[player pause];
|
|
10841
|
+
[self stopVideoPositionTimer];
|
|
10842
|
+
[self stopVideoFrameTimer];
|
|
10843
|
+
/* One final poll: the frame the pause landed on may not have been
|
|
10844
|
+
* pumped yet, and a paused surface should hold it. */
|
|
10845
|
+
[self videoPumpFrame];
|
|
10846
|
+
return 1;
|
|
10847
|
+
}
|
|
10848
|
+
|
|
10849
|
+
- (int)videoStop {
|
|
10850
|
+
[self stopVideoPositionTimer];
|
|
10851
|
+
[self stopVideoFrameTimer];
|
|
10852
|
+
if (!self.videoPlayer) return 0;
|
|
10853
|
+
[self videoTearDownPlayer];
|
|
10854
|
+
return 1;
|
|
10855
|
+
}
|
|
10856
|
+
|
|
10857
|
+
- (int)videoSeekToMs:(uint64_t)positionMs {
|
|
10858
|
+
AVPlayer *player = self.videoPlayer;
|
|
10859
|
+
if (!player) return 0;
|
|
10860
|
+
/* AVPlayer clamps to the seekable ranges it has (or fetches the
|
|
10861
|
+
* range it needs); exact tolerance keeps the readout honest
|
|
10862
|
+
* against the requested position. */
|
|
10863
|
+
CMTime zero = NativeSdkCMTimeFromMs(0);
|
|
10864
|
+
__weak NativeSdkAppKitHost *weakSelf = self;
|
|
10865
|
+
[player seekToTime:NativeSdkCMTimeFromMs(positionMs)
|
|
10866
|
+
toleranceBefore:zero
|
|
10867
|
+
toleranceAfter:zero
|
|
10868
|
+
completionHandler:^(BOOL finished) {
|
|
10869
|
+
if (!finished) return;
|
|
10870
|
+
/* One-shot poll on the loop thread so a PAUSED scrub still
|
|
10871
|
+
* paints the sought frame — the frame timer only runs while
|
|
10872
|
+
* playing. */
|
|
10873
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
10874
|
+
[weakSelf videoPumpFrame];
|
|
10875
|
+
});
|
|
10876
|
+
}];
|
|
10877
|
+
return 1;
|
|
10878
|
+
}
|
|
10879
|
+
|
|
10880
|
+
- (int)videoSetVolume:(double)volume {
|
|
10881
|
+
AVPlayer *player = self.videoPlayer;
|
|
10882
|
+
if (!player) return 0;
|
|
10883
|
+
player.volume = (float)volume;
|
|
10884
|
+
return 1;
|
|
10885
|
+
}
|
|
10886
|
+
|
|
10887
|
+
- (int)videoSetMuted:(BOOL)muted {
|
|
10888
|
+
AVPlayer *player = self.videoPlayer;
|
|
10889
|
+
if (!player) return 0;
|
|
10890
|
+
player.muted = muted;
|
|
10891
|
+
return 1;
|
|
10892
|
+
}
|
|
10893
|
+
|
|
10894
|
+
- (int)videoSetLoop:(BOOL)loop {
|
|
10895
|
+
AVPlayer *player = self.videoPlayer;
|
|
10896
|
+
if (!player) return 0;
|
|
10897
|
+
self.videoLooping = loop;
|
|
10898
|
+
/* A looping player must not pause itself at the end notification's
|
|
10899
|
+
* moment — the wrap seek in videoDidPlayToEnd restarts it
|
|
10900
|
+
* seamlessly. */
|
|
10901
|
+
player.actionAtItemEnd = loop ? AVPlayerActionAtItemEndNone : AVPlayerActionAtItemEndPause;
|
|
10902
|
+
return 1;
|
|
10903
|
+
}
|
|
10904
|
+
|
|
9735
10905
|
- (void)scheduleBridgeFrames {
|
|
9736
10906
|
self.bridgeFrameKeepalive = NativeSdkBridgeFrameKeepaliveFrames;
|
|
9737
10907
|
[self scheduleFrame];
|
|
@@ -10094,6 +11264,58 @@ static NSString *NativeSdkOriginForURL(NSURL *url) {
|
|
|
10094
11264
|
return [NSString stringWithFormat:@"%@://%@", scheme, host];
|
|
10095
11265
|
}
|
|
10096
11266
|
|
|
11267
|
+
/* The canonical key name -> NSMenuItem key equivalent. Single characters
|
|
11268
|
+
* pass through; named keys become the character AppKit expects (function
|
|
11269
|
+
* keys and navigation keys are private-use unichars, editing keys their
|
|
11270
|
+
* control characters). An unknown name degrades to no key equivalent
|
|
11271
|
+
* rather than a multi-character string AppKit would misread. */
|
|
11272
|
+
static NSString *NativeSdkMenuKeyEquivalent(NSString *key) {
|
|
11273
|
+
if (key.length == 0) return @"";
|
|
11274
|
+
// Lowercase single characters too (key names validate
|
|
11275
|
+
// case-insensitively): an uppercase key equivalent implies Shift to
|
|
11276
|
+
// AppKit, which the explicit modifier mask already expresses.
|
|
11277
|
+
if (key.length == 1) return key.lowercaseString;
|
|
11278
|
+
static NSDictionary<NSString *, NSString *> *named = nil;
|
|
11279
|
+
static dispatch_once_t once;
|
|
11280
|
+
dispatch_once(&once, ^{
|
|
11281
|
+
named = @{
|
|
11282
|
+
@"escape": [NSString stringWithFormat:@"%C", (unichar)0x1b],
|
|
11283
|
+
@"enter": @"\r",
|
|
11284
|
+
@"tab": @"\t",
|
|
11285
|
+
@"space": @" ",
|
|
11286
|
+
/* The physical Mac Delete/backspace key emits 0x7f (what the
|
|
11287
|
+
* key-event normalizer maps to "backspace"), not the nominal
|
|
11288
|
+
* BS control 0x08 — key equivalents must match what the key
|
|
11289
|
+
* actually produces or the accelerator never fires. */
|
|
11290
|
+
@"backspace": [NSString stringWithFormat:@"%C", (unichar)0x7f],
|
|
11291
|
+
@"arrowup": [NSString stringWithFormat:@"%C", (unichar)NSUpArrowFunctionKey],
|
|
11292
|
+
@"arrowdown": [NSString stringWithFormat:@"%C", (unichar)NSDownArrowFunctionKey],
|
|
11293
|
+
@"arrowleft": [NSString stringWithFormat:@"%C", (unichar)NSLeftArrowFunctionKey],
|
|
11294
|
+
@"arrowright": [NSString stringWithFormat:@"%C", (unichar)NSRightArrowFunctionKey],
|
|
11295
|
+
@"delete": [NSString stringWithFormat:@"%C", (unichar)NSDeleteFunctionKey],
|
|
11296
|
+
@"home": [NSString stringWithFormat:@"%C", (unichar)NSHomeFunctionKey],
|
|
11297
|
+
@"end": [NSString stringWithFormat:@"%C", (unichar)NSEndFunctionKey],
|
|
11298
|
+
@"pageup": [NSString stringWithFormat:@"%C", (unichar)NSPageUpFunctionKey],
|
|
11299
|
+
@"pagedown": [NSString stringWithFormat:@"%C", (unichar)NSPageDownFunctionKey],
|
|
11300
|
+
@"insert": [NSString stringWithFormat:@"%C", (unichar)NSInsertFunctionKey],
|
|
11301
|
+
@"f1": [NSString stringWithFormat:@"%C", (unichar)NSF1FunctionKey],
|
|
11302
|
+
@"f2": [NSString stringWithFormat:@"%C", (unichar)NSF2FunctionKey],
|
|
11303
|
+
@"f3": [NSString stringWithFormat:@"%C", (unichar)NSF3FunctionKey],
|
|
11304
|
+
@"f4": [NSString stringWithFormat:@"%C", (unichar)NSF4FunctionKey],
|
|
11305
|
+
@"f5": [NSString stringWithFormat:@"%C", (unichar)NSF5FunctionKey],
|
|
11306
|
+
@"f6": [NSString stringWithFormat:@"%C", (unichar)NSF6FunctionKey],
|
|
11307
|
+
@"f7": [NSString stringWithFormat:@"%C", (unichar)NSF7FunctionKey],
|
|
11308
|
+
@"f8": [NSString stringWithFormat:@"%C", (unichar)NSF8FunctionKey],
|
|
11309
|
+
@"f9": [NSString stringWithFormat:@"%C", (unichar)NSF9FunctionKey],
|
|
11310
|
+
@"f10": [NSString stringWithFormat:@"%C", (unichar)NSF10FunctionKey],
|
|
11311
|
+
@"f11": [NSString stringWithFormat:@"%C", (unichar)NSF11FunctionKey],
|
|
11312
|
+
@"f12": [NSString stringWithFormat:@"%C", (unichar)NSF12FunctionKey],
|
|
11313
|
+
};
|
|
11314
|
+
});
|
|
11315
|
+
NSString *equivalent = named[key.lowercaseString];
|
|
11316
|
+
return equivalent ?: @"";
|
|
11317
|
+
}
|
|
11318
|
+
|
|
10097
11319
|
static NSString *NativeSdkShortcutKeyForEvent(NSEvent *event) {
|
|
10098
11320
|
NSString *characters = event.charactersIgnoringModifiers ?: @"";
|
|
10099
11321
|
if (characters.length == 0) return @"";
|
|
@@ -10106,6 +11328,21 @@ static NSString *NativeSdkShortcutKeyForEvent(NSEvent *event) {
|
|
|
10106
11328
|
case NSDeleteFunctionKey: return @"delete";
|
|
10107
11329
|
case NSHomeFunctionKey: return @"home";
|
|
10108
11330
|
case NSEndFunctionKey: return @"end";
|
|
11331
|
+
case NSPageUpFunctionKey: return @"pageup";
|
|
11332
|
+
case NSPageDownFunctionKey: return @"pagedown";
|
|
11333
|
+
case NSInsertFunctionKey: return @"insert";
|
|
11334
|
+
case NSF1FunctionKey: return @"f1";
|
|
11335
|
+
case NSF2FunctionKey: return @"f2";
|
|
11336
|
+
case NSF3FunctionKey: return @"f3";
|
|
11337
|
+
case NSF4FunctionKey: return @"f4";
|
|
11338
|
+
case NSF5FunctionKey: return @"f5";
|
|
11339
|
+
case NSF6FunctionKey: return @"f6";
|
|
11340
|
+
case NSF7FunctionKey: return @"f7";
|
|
11341
|
+
case NSF8FunctionKey: return @"f8";
|
|
11342
|
+
case NSF9FunctionKey: return @"f9";
|
|
11343
|
+
case NSF10FunctionKey: return @"f10";
|
|
11344
|
+
case NSF11FunctionKey: return @"f11";
|
|
11345
|
+
case NSF12FunctionKey: return @"f12";
|
|
10109
11346
|
case 0x1b: return @"escape";
|
|
10110
11347
|
case '\r': return @"enter";
|
|
10111
11348
|
case '\t': return @"tab";
|
|
@@ -10137,6 +11374,14 @@ static NSString *NativeSdkShortcutKeyForEvent(NSEvent *event) {
|
|
|
10137
11374
|
}
|
|
10138
11375
|
}
|
|
10139
11376
|
|
|
11377
|
+
static BOOL NativeSdkTextNavigationNeedsRawKeyEvent(NSEvent *event) {
|
|
11378
|
+
if (!event) return NO;
|
|
11379
|
+
NSEventModifierFlags flags = event.modifierFlags & NSEventModifierFlagDeviceIndependentFlagsMask;
|
|
11380
|
+
if ((flags & (NSEventModifierFlagCommand | NSEventModifierFlagOption)) == 0) return NO;
|
|
11381
|
+
NSString *key = NativeSdkShortcutKeyForEvent(event);
|
|
11382
|
+
return [key isEqualToString:@"arrowleft"] || [key isEqualToString:@"arrowright"];
|
|
11383
|
+
}
|
|
11384
|
+
|
|
10140
11385
|
static BOOL NativeSdkShortcutUsesImplicitShift(NSString *key, NSEvent *event) {
|
|
10141
11386
|
if ((event.modifierFlags & NSEventModifierFlagShift) == 0) return NO;
|
|
10142
11387
|
if (key.length != 1) return NO;
|
|
@@ -10321,6 +11566,55 @@ int native_sdk_appkit_audio_set_volume(native_sdk_appkit_host_t *host, double vo
|
|
|
10321
11566
|
return [object audioSetVolume:volume];
|
|
10322
11567
|
}
|
|
10323
11568
|
|
|
11569
|
+
int native_sdk_appkit_video_load(native_sdk_appkit_host_t *host, const char *path, size_t path_len, uint64_t token, native_sdk_appkit_video_sink_push_t push_fn, void *push_context) {
|
|
11570
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11571
|
+
NSString *path_string = [[NSString alloc] initWithBytes:path length:path_len encoding:NSUTF8StringEncoding];
|
|
11572
|
+
if (!path_string) return 1;
|
|
11573
|
+
return [object videoLoadPath:path_string token:token pushFn:push_fn pushContext:push_context];
|
|
11574
|
+
}
|
|
11575
|
+
|
|
11576
|
+
int native_sdk_appkit_video_load_url(native_sdk_appkit_host_t *host, const char *url, size_t url_len, uint64_t token, native_sdk_appkit_video_sink_push_t push_fn, void *push_context) {
|
|
11577
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11578
|
+
NSString *url_string = [[NSString alloc] initWithBytes:url length:url_len encoding:NSUTF8StringEncoding];
|
|
11579
|
+
if (!url_string) return 2;
|
|
11580
|
+
return [object videoLoadURL:url_string token:token pushFn:push_fn pushContext:push_context];
|
|
11581
|
+
}
|
|
11582
|
+
|
|
11583
|
+
int native_sdk_appkit_video_play(native_sdk_appkit_host_t *host) {
|
|
11584
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11585
|
+
return [object videoPlay];
|
|
11586
|
+
}
|
|
11587
|
+
|
|
11588
|
+
int native_sdk_appkit_video_pause(native_sdk_appkit_host_t *host) {
|
|
11589
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11590
|
+
return [object videoPause];
|
|
11591
|
+
}
|
|
11592
|
+
|
|
11593
|
+
int native_sdk_appkit_video_stop(native_sdk_appkit_host_t *host) {
|
|
11594
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11595
|
+
return [object videoStop];
|
|
11596
|
+
}
|
|
11597
|
+
|
|
11598
|
+
int native_sdk_appkit_video_seek(native_sdk_appkit_host_t *host, uint64_t position_ms) {
|
|
11599
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11600
|
+
return [object videoSeekToMs:position_ms];
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11603
|
+
int native_sdk_appkit_video_set_volume(native_sdk_appkit_host_t *host, double volume) {
|
|
11604
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11605
|
+
return [object videoSetVolume:volume];
|
|
11606
|
+
}
|
|
11607
|
+
|
|
11608
|
+
int native_sdk_appkit_video_set_muted(native_sdk_appkit_host_t *host, int muted) {
|
|
11609
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11610
|
+
return [object videoSetMuted:(muted != 0)];
|
|
11611
|
+
}
|
|
11612
|
+
|
|
11613
|
+
int native_sdk_appkit_video_set_loop(native_sdk_appkit_host_t *host, int loop) {
|
|
11614
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
11615
|
+
return [object videoSetLoop:(loop != 0)];
|
|
11616
|
+
}
|
|
11617
|
+
|
|
10324
11618
|
void native_sdk_appkit_wake(native_sdk_appkit_host_t *host) {
|
|
10325
11619
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
10326
11620
|
[object wakeFromAnyThread];
|
|
@@ -10610,10 +11904,10 @@ int native_sdk_appkit_note_gpu_surface_input(native_sdk_appkit_host_t *host, uin
|
|
|
10610
11904
|
return [object noteGpuSurfaceInputInWindow:window_id label:labelString ?: @""] ? 1 : 0;
|
|
10611
11905
|
}
|
|
10612
11906
|
|
|
10613
|
-
int native_sdk_appkit_set_gpu_surface_scroll_drivers(native_sdk_appkit_host_t *host, uint64_t window_id, const char *label, size_t label_len, const native_sdk_appkit_scroll_driver_t *drivers, size_t count) {
|
|
11907
|
+
int native_sdk_appkit_set_gpu_surface_scroll_drivers(native_sdk_appkit_host_t *host, uint64_t window_id, const char *label, size_t label_len, const native_sdk_appkit_scroll_driver_t *drivers, size_t count, const native_sdk_appkit_scroll_occluder_t *occluders, size_t occluder_count) {
|
|
10614
11908
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
10615
11909
|
NSString *labelString = label ? [[NSString alloc] initWithBytes:label length:label_len encoding:NSUTF8StringEncoding] : @"";
|
|
10616
|
-
return [object setGpuSurfaceScrollDriversInWindow:window_id label:labelString ?: @"" drivers:drivers count:count] ? 1 : 0;
|
|
11910
|
+
return [object setGpuSurfaceScrollDriversInWindow:window_id label:labelString ?: @"" drivers:drivers count:count occluders:occluders occluderCount:occluder_count] ? 1 : 0;
|
|
10617
11911
|
}
|
|
10618
11912
|
|
|
10619
11913
|
int native_sdk_appkit_show_context_menu(native_sdk_appkit_host_t *host, uint64_t window_id, const char *label, size_t label_len, double x, double y, uint64_t token, const native_sdk_appkit_context_menu_item_t *items, size_t count) {
|