@geastack/apple 0.2.33 → 0.2.34
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/package.json +6 -6
- package/targets/macos/README.md +178 -6
- package/targets/macos/build-macos.sh +22 -3
- package/targets/macos/main/font_registry.h +8 -1
- package/targets/macos/main/font_registry.mm +42 -17
- package/targets/macos/main/macos_content_view.h +20 -0
- package/targets/macos/main/macos_main.mm +233 -34
- package/targets/macos/main/macos_microphone.mm +134 -0
- package/targets/macos/main/macos_native_shell.h +12 -0
- package/targets/macos/main/macos_native_shell.mm +102 -3
- package/targets/macos/main/macos_renderer.h +40 -0
- package/targets/macos/main/macos_renderer.mm +681 -12
- package/targets/macos/main/macos_windows.h +46 -0
- package/targets/macos/main/macos_windows.mm +704 -0
- package/targets/macos/window-config.mjs +9 -4
- package/targets/shared/apple_audio.mm +121 -2
- package/targets/shared/apple_audio_selftest.mm +74 -2
|
@@ -76,6 +76,18 @@ void firePressForElementId(const std::string &elementId)
|
|
|
76
76
|
fire(PointerEventType::Click);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
// The click a toolbar item with no data-action sends to its own element, so
|
|
80
|
+
// `<toolbar-item onClick={...}>` works like any other element.
|
|
81
|
+
void fireClickAt(int nodeId)
|
|
82
|
+
{
|
|
83
|
+
Tree &tree = Tree::instance();
|
|
84
|
+
if (nodeId < 0 || nodeId >= tree.nodeCount()) return;
|
|
85
|
+
gea::framework::events::PointerEvent ev;
|
|
86
|
+
ev.type = gea::framework::events::PointerEventType::Click;
|
|
87
|
+
ev.targetId = nodeId;
|
|
88
|
+
tree.dispatchEvent(ev);
|
|
89
|
+
}
|
|
90
|
+
|
|
79
91
|
// The `<glass-split>` at or below `nodeId`, or -1. Bounded: the shell element is
|
|
80
92
|
// an app's OUTERMOST element, so it sits directly under the `#app` mount root
|
|
81
93
|
// (or under a wrapper or two a component added). Walking a few levels of the
|
|
@@ -84,6 +96,8 @@ int findGlassSplit(int nodeId, int depth = 0)
|
|
|
84
96
|
{
|
|
85
97
|
if (nodeId < 0 || depth > 4) return -1;
|
|
86
98
|
if (tagIs(nodeId, "glass-split")) return nodeId;
|
|
99
|
+
// A `<window>` below is its own window, with its own shell (macos_windows.mm).
|
|
100
|
+
if (depth > 0 && Tree::instance().isDetachedRoot(nodeId)) return -1;
|
|
87
101
|
for (int child = firstChild(nodeId); child >= 0; child = nextSibling(child)) {
|
|
88
102
|
const int found = findGlassSplit(child, depth + 1);
|
|
89
103
|
if (found >= 0) return found;
|
|
@@ -92,6 +106,7 @@ int findGlassSplit(int nodeId, int depth = 0)
|
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
struct PaneInfo {
|
|
109
|
+
int paneNodeId; // the <glass-pane>
|
|
95
110
|
int contentNodeId; // the gea subtree root rendered into this pane
|
|
96
111
|
NSView *container; // the split item's view (full height, behind toolbar)
|
|
97
112
|
NSView *content; // inner view inset to the safe area (below the toolbar)
|
|
@@ -102,7 +117,8 @@ struct ToolbarItemInfo {
|
|
|
102
117
|
std::string identifier;
|
|
103
118
|
std::string symbol; // SF Symbol name
|
|
104
119
|
std::string label;
|
|
105
|
-
std::string actionId; // element id to press on click ("" =
|
|
120
|
+
std::string actionId; // element id to press on click ("" = the item's own element)
|
|
121
|
+
int nodeId = -1; // the <toolbar-item> / <toolbar-search> element
|
|
106
122
|
bool isSearch = false;
|
|
107
123
|
bool isSpace = false; // flexible space
|
|
108
124
|
bool isSidebarToggle = false;
|
|
@@ -198,7 +214,7 @@ struct ToolbarItemInfo {
|
|
|
198
214
|
container.layer.backgroundColor = [[NSColor colorWithSRGBRed:0.114 green:0.114 blue:0.122 alpha:1.0] CGColor];
|
|
199
215
|
}
|
|
200
216
|
[svc addSplitViewItem:item];
|
|
201
|
-
shell.panes->push_back({contentNode, container, contentView});
|
|
217
|
+
shell.panes->push_back({child, contentNode, container, contentView});
|
|
202
218
|
}
|
|
203
219
|
|
|
204
220
|
if (shell.panes->empty()) {
|
|
@@ -227,6 +243,7 @@ struct ToolbarItemInfo {
|
|
|
227
243
|
{
|
|
228
244
|
for (int item = firstChild(toolbarNode); item >= 0; item = nextSibling(item)) {
|
|
229
245
|
ToolbarItemInfo info;
|
|
246
|
+
info.nodeId = item;
|
|
230
247
|
if (tagIs(item, "toolbar-search")) {
|
|
231
248
|
info.isSearch = true;
|
|
232
249
|
info.identifier = "gea.search";
|
|
@@ -313,6 +330,68 @@ struct ToolbarItemInfo {
|
|
|
313
330
|
gea::macos::MacosRenderer::instance().syncPanes(paneViews, rootIds.data());
|
|
314
331
|
}
|
|
315
332
|
|
|
333
|
+
- (BOOL)updatePaneFrames
|
|
334
|
+
{
|
|
335
|
+
if (!_panes || _panes->empty()) return NO;
|
|
336
|
+
NSWindow *window = nil;
|
|
337
|
+
for (const PaneInfo &pane : *_panes) {
|
|
338
|
+
if (pane.container.window) { window = pane.container.window; break; }
|
|
339
|
+
}
|
|
340
|
+
NSView *windowContent = window.contentView;
|
|
341
|
+
const NSRect belowToolbar = window ? window.contentLayoutRect : NSZeroRect;
|
|
342
|
+
BOOL changed = NO;
|
|
343
|
+
for (PaneInfo &pane : *_panes) {
|
|
344
|
+
NSView *container = pane.container;
|
|
345
|
+
NSRect inContainer = windowContent ? [container convertRect:belowToolbar fromView:windowContent] : container.bounds;
|
|
346
|
+
NSRect contentFrame = NSIntersectionRect(inContainer, container.bounds);
|
|
347
|
+
if (NSIsEmptyRect(contentFrame)) contentFrame = container.bounds;
|
|
348
|
+
if (NSEqualRects(contentFrame, pane.lastFrame)) continue;
|
|
349
|
+
pane.content.frame = contentFrame;
|
|
350
|
+
pane.lastFrame = contentFrame;
|
|
351
|
+
changed = YES;
|
|
352
|
+
}
|
|
353
|
+
return changed;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
- (void)layoutPanes
|
|
357
|
+
{
|
|
358
|
+
if (!_panes) return;
|
|
359
|
+
Tree &tree = Tree::instance();
|
|
360
|
+
for (PaneInfo &pane : *_panes) {
|
|
361
|
+
// The pane is laid out as the root, and each of its in-flow children
|
|
362
|
+
// fills it -- the pane's content may be a conditional (`{a ? <X/> :
|
|
363
|
+
// <Y/>}`), whose element is not always the pane's first child.
|
|
364
|
+
pane.contentNodeId = firstChild(pane.paneNodeId);
|
|
365
|
+
const int w = static_cast<int>(pane.lastFrame.size.width);
|
|
366
|
+
const int h = static_cast<int>(pane.lastFrame.size.height);
|
|
367
|
+
const int paneNode = pane.paneNodeId;
|
|
368
|
+
if (w <= 0 || h <= 0 || paneNode < 0 || paneNode >= tree.nodeCount()) continue;
|
|
369
|
+
NodeHandle(paneNode).style().width(w);
|
|
370
|
+
NodeHandle(paneNode).style().height(h);
|
|
371
|
+
for (int child = firstChild(paneNode); child >= 0; child = nextSibling(child)) {
|
|
372
|
+
const auto &node = tree.node(child);
|
|
373
|
+
if (gea::embedded::ui::isLayoutExcluded(node) || gea::embedded::ui::isOutOfFlowPosition(node.computedStyle().position)) continue;
|
|
374
|
+
NodeHandle(child).style().width(w);
|
|
375
|
+
NodeHandle(child).style().height(h);
|
|
376
|
+
}
|
|
377
|
+
tree.computeLayout(paneNode, w, h);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
- (void)appendSyncRoots:(void *)roots
|
|
382
|
+
{
|
|
383
|
+
if (!_panes) return;
|
|
384
|
+
auto &out = *static_cast<std::vector<gea::macos::SyncRoot> *>(roots);
|
|
385
|
+
Tree &tree = Tree::instance();
|
|
386
|
+
for (const PaneInfo &pane : *_panes) {
|
|
387
|
+
const int paneNode = pane.paneNodeId;
|
|
388
|
+
if (paneNode < 0 || paneNode >= tree.nodeCount() || pane.lastFrame.size.width <= 0 || pane.lastFrame.size.height <= 0) continue;
|
|
389
|
+
const auto &layout = tree.node(paneNode).layout;
|
|
390
|
+
for (int child = firstChild(paneNode); child >= 0; child = nextSibling(child))
|
|
391
|
+
out.push_back({pane.content, child, static_cast<int>(layout.x), static_cast<int>(layout.y), -1});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
316
395
|
#pragma mark NSToolbarDelegate
|
|
317
396
|
|
|
318
397
|
- (NSArray<NSToolbarItemIdentifier> *)toolbarItemIdentifiers
|
|
@@ -345,6 +424,11 @@ struct ToolbarItemInfo {
|
|
|
345
424
|
if (info.isSearch) {
|
|
346
425
|
NSSearchToolbarItem *search = [[NSSearchToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
|
|
347
426
|
search.resignsFirstResponderWithCancel = YES;
|
|
427
|
+
// Each edit lands on the <toolbar-search> element as its `value` plus
|
|
428
|
+
// an `input` event, so `onInput={e => ...e.target.value}` filters.
|
|
429
|
+
search.searchField.sendsSearchStringImmediately = YES;
|
|
430
|
+
search.searchField.target = self;
|
|
431
|
+
search.searchField.action = @selector(searchChanged:);
|
|
348
432
|
return search;
|
|
349
433
|
}
|
|
350
434
|
NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
|
|
@@ -387,10 +471,25 @@ struct ToolbarItemInfo {
|
|
|
387
471
|
const std::string ident = sender.itemIdentifier.UTF8String;
|
|
388
472
|
for (const ToolbarItemInfo &info : *_toolbarItems) {
|
|
389
473
|
if (info.identifier == ident) {
|
|
390
|
-
|
|
474
|
+
if (info.actionId.empty()) fireClickAt(info.nodeId);
|
|
475
|
+
else firePressForElementId(info.actionId);
|
|
391
476
|
return;
|
|
392
477
|
}
|
|
393
478
|
}
|
|
394
479
|
}
|
|
395
480
|
|
|
481
|
+
- (void)searchChanged:(NSSearchField *)sender
|
|
482
|
+
{
|
|
483
|
+
Tree &tree = Tree::instance();
|
|
484
|
+
for (const ToolbarItemInfo &info : *_toolbarItems) {
|
|
485
|
+
if (!info.isSearch || info.nodeId < 0 || info.nodeId >= tree.nodeCount()) continue;
|
|
486
|
+
tree.setAttribute(info.nodeId, "value", sender.stringValue.UTF8String ?: "");
|
|
487
|
+
gea::framework::events::PointerEvent ev;
|
|
488
|
+
ev.type = gea::framework::events::PointerEventType::Input;
|
|
489
|
+
ev.targetId = info.nodeId;
|
|
490
|
+
tree.dispatchEvent(ev);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
396
495
|
@end
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
#ifdef __OBJC__
|
|
4
4
|
@class NSView;
|
|
5
5
|
@class NSArray;
|
|
6
|
+
@class NSEvent;
|
|
7
|
+
@class NSWindow;
|
|
6
8
|
#else
|
|
7
9
|
struct NSView;
|
|
8
10
|
struct NSArray;
|
|
11
|
+
struct NSEvent;
|
|
12
|
+
struct NSWindow;
|
|
9
13
|
#endif
|
|
14
|
+
#include <CoreGraphics/CGGeometry.h>
|
|
10
15
|
|
|
11
16
|
namespace gea::macos {
|
|
12
17
|
|
|
@@ -14,6 +19,34 @@ namespace gea::macos {
|
|
|
14
19
|
void publishControlEventBounds(int nodeId);
|
|
15
20
|
// Called only after AppKit accepts the actual root responder transition.
|
|
16
21
|
void nativeRootFocusChanged(NSView*view,bool focused,int nodeId);
|
|
22
|
+
// Dispatches a scroll-wheel NSEvent as a DOM `wheel` event to the Gea node
|
|
23
|
+
// under `locationInWindow` (window base coordinates) in `window`, and returns
|
|
24
|
+
// true when a listener called preventDefault() -- the caller then drops the
|
|
25
|
+
// event so the enclosing NSScrollView does not scroll. Returns false (forward
|
|
26
|
+
// the event unchanged) when nothing listens for `wheel` or no Gea view is hit.
|
|
27
|
+
// The app-wide local scroll monitor calls this with the event's own window and
|
|
28
|
+
// location; the replay harness passes them for its synthesized event.
|
|
29
|
+
bool dispatchWheelEvent(NSEvent *event, NSWindow *window, CGPoint locationInWindow);
|
|
30
|
+
|
|
31
|
+
// The Gea node under `locationInWindow` (window base coordinates) in `window`,
|
|
32
|
+
// or -1, with the point in that node's tree coordinates -- the space the root
|
|
33
|
+
// press bridge reports presses in (a pane's or a `<window>`'s own space).
|
|
34
|
+
int nodeAtWindowPoint(NSWindow *window, CGPoint locationInWindow, int *treeX, int *treeY);
|
|
35
|
+
|
|
36
|
+
#ifdef __OBJC__
|
|
37
|
+
// One laid-out subtree rendered into `view`. `originX`/`originY` are the tree
|
|
38
|
+
// coordinates of the view's top-left corner; `focusRoot` (>= 0) makes the view
|
|
39
|
+
// the keyboard root for that subtree, as the main window's content view is.
|
|
40
|
+
struct SyncRoot {
|
|
41
|
+
__unsafe_unretained NSView *view;
|
|
42
|
+
int node;
|
|
43
|
+
int originX;
|
|
44
|
+
int originY;
|
|
45
|
+
int focusRoot;
|
|
46
|
+
// Unchanged since the last sync: not walked, and its views are kept.
|
|
47
|
+
bool keep = false;
|
|
48
|
+
};
|
|
49
|
+
#endif
|
|
17
50
|
|
|
18
51
|
class MacosRenderer {
|
|
19
52
|
public:
|
|
@@ -33,6 +66,13 @@ public:
|
|
|
33
66
|
// sweeps every map entry it didn't touch).
|
|
34
67
|
void syncPanes(NSArray *paneViews, const int *rootNodeIds);
|
|
35
68
|
|
|
69
|
+
#ifdef __OBJC__
|
|
70
|
+
// Every root shown this frame, in one pass with one stale-view sweep: the
|
|
71
|
+
// main window (flat or split panes) and each `<window>`'s content. Any
|
|
72
|
+
// separate sync() would evict the views of the roots it did not visit.
|
|
73
|
+
void syncRoots(const SyncRoot *roots, unsigned long count);
|
|
74
|
+
#endif
|
|
75
|
+
|
|
36
76
|
// Drop all NSView associations and detach them from their parents.
|
|
37
77
|
// Called on app teardown / tree clear.
|
|
38
78
|
void teardown();
|