@windowkit/appkit 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ waits on the UI thread (`test/threaded-verbs.js` covers each row):
|
|
|
125
125
|
|
|
126
126
|
| from a worker | verbs |
|
|
127
127
|
| --- | --- |
|
|
128
|
-
| unchanged, on the calling thread | surfaces and video surfaces, every `ctx*` (`ctxDrawSymbol` included), layouts and fonts, `symbolSize`, `pasteboardTypeForMIME`, `pasteboardTypeInfo`, `contentTypeFor`, `colorSpace` |
|
|
128
|
+
| unchanged, on the calling thread | surfaces and video surfaces, every `ctx*` (`ctxDrawSymbol` included), layouts and fonts, `symbolSize`, `pasteboardTypeForMIME`, `pasteboardTypeInfo`, `contentTypeFor`, `colorSpace`, `lastInputMs` |
|
|
129
129
|
| a command, answering nothing | `initApp`, `setActivationPolicy`, `setAppName`, `activateApp`, `showWindow`, `hideWindow`, `setWindowFrame`, `setWindowTitle`, `setWindowMinMax`, `setWindowIgnoresMouseEvents`, `invalidateWindowShadow`, `destroyWindow2`, `setCursor`, `setMainMenu`, `setDockMenu`, `setDockBadge`, `cancelUserAttention`, `setStatusItem`, `setStatusItemMenu`, `removeStatusItem`, `registerDropTypes`, `setDropResponse`, `pasteboardWriteText`, `pasteboardWrite`, `pasteboardClear`, `cancelPanel`, `cancelPopUpMenu`; the test posts `postMouseEvent`, `postKeyEvent`, `postAppleEvent`, `postAccessibilityDisplayChange` |
|
|
130
130
|
| a handle at the call | `createWindow2`, followed by `window-created { handle, windowNumber }`; every event about the window, input included, carries `handle`, so `ev.handle === win` |
|
|
131
131
|
| | `windowRootLayer`, allocated with the window |
|
|
@@ -1599,6 +1599,23 @@ Mechanism only: what to do with `reduceMotion` is the renderer's (react-x11: loo
|
|
|
1599
1599
|
so the observer path can be exercised without touching the user's settings — test-only, like
|
|
1600
1600
|
`postAppleEvent`; `test/accessibility-display.js` is the check.
|
|
1601
1601
|
|
|
1602
|
+
## Idle time (an empty desk)
|
|
1603
|
+
|
|
1604
|
+
How long the user has been away from the keyboard and pointer, across the whole session and
|
|
1605
|
+
every app — the clock a screen saver keys off (react-x11's `useIdle`,
|
|
1606
|
+
[react-x11#951](https://github.com/sidorares/react-x11/pull/951)):
|
|
1607
|
+
|
|
1608
|
+
```js
|
|
1609
|
+
native.lastInputMs(); // -> 41250.3: ms since the last keyboard, mouse, trackpad or tablet event
|
|
1610
|
+
```
|
|
1611
|
+
|
|
1612
|
+
It is `CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateCombinedSessionState,
|
|
1613
|
+
kCGAnyInputEventType)`, in milliseconds. There is no event: poll it. It asks nothing of AppKit and
|
|
1614
|
+
needs no permission, so it answers synchronously on whichever thread calls it — before
|
|
1615
|
+
`initApp`, in pump mode, and from a worker with the main thread parked in `runMain`. It is not
|
|
1616
|
+
`ioreg`'s `HIDIdleTime`: the two are kept apart, and while they agree at a desk, on CI's VMs this
|
|
1617
|
+
one ran 3–5 s longer. `test/last-input.js` is the check.
|
|
1618
|
+
|
|
1602
1619
|
## Mapping to a React reconciler
|
|
1603
1620
|
|
|
1604
1621
|
The shape of a host config on top of this:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windowkit/appkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "Retained-mode AppKit backend for Node.js: Core Animation (CALayer) layer trees, CoreText layout and drawing, IOSurface presentation, NSMenu, and native control bezels — the macOS half of react-x11.",
|
|
5
5
|
"author": "Andrey Sidorov <andrey.sidorov@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"install": "node scripts/install.js",
|
|
44
44
|
"build": "node-gyp rebuild",
|
|
45
45
|
"demo": "node demo/demo.js",
|
|
46
|
-
"test": "node test/app-lifecycle.js && node test/animation.js && node test/layer-transform.js && node test/contents-gravity.js && node test/contents-center.js && node test/accessibility-display.js && node test/ignores-mouse-events.js && node test/popup-menu.js && node test/pasteboard-write.js && node test/surface-blit.js && node test/surface-faded.js && node test/image-smoothing.js && node test/surface-colorspace.js && node test/video-surface.js && node test/player.js && node test/round-rect-xy.js && node test/clip-rule.js && node test/radial-gradient.js && node test/control-bezels.js && node test/text-features.js && node test/font-from-data.js && node test/text-coverage.js && node test/text-typesetter.js && node test/text-line-height.js && node test/text-line-width.js && node test/text-justify.js && node test/text-scale.js && node test/symbols.js && node test/eventkit-permissions.js && node test/calendars.js && node test/calendar-writes.js && node test/screencolor.js && node test/notifications.js && node test/threaded.js && node test/threaded-verbs.js && node test/threaded-frames.js && node test/threaded-resize.js && node test/ending-worker.js && node test/live-resize.js && node test/activation-policy.js"
|
|
46
|
+
"test": "node test/app-lifecycle.js && node test/animation.js && node test/layer-transform.js && node test/contents-gravity.js && node test/contents-center.js && node test/accessibility-display.js && node test/ignores-mouse-events.js && node test/popup-menu.js && node test/pasteboard-write.js && node test/surface-blit.js && node test/surface-faded.js && node test/image-smoothing.js && node test/surface-colorspace.js && node test/video-surface.js && node test/player.js && node test/round-rect-xy.js && node test/clip-rule.js && node test/radial-gradient.js && node test/control-bezels.js && node test/text-features.js && node test/font-from-data.js && node test/text-coverage.js && node test/text-typesetter.js && node test/text-line-height.js && node test/text-line-width.js && node test/text-justify.js && node test/text-scale.js && node test/symbols.js && node test/eventkit-permissions.js && node test/calendars.js && node test/calendar-writes.js && node test/screencolor.js && node test/notifications.js && node test/threaded.js && node test/threaded-verbs.js && node test/threaded-frames.js && node test/threaded-resize.js && node test/ending-worker.js && node test/live-resize.js && node test/activation-policy.js && node test/last-input.js"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"node-addon-api": "^8.3.0"
|
|
Binary file
|
|
Binary file
|
package/src/backend.mm
CHANGED
|
@@ -6929,6 +6929,22 @@ static Napi::Value PbChangeCountFn(const Napi::CallbackInfo& info) {
|
|
|
6929
6929
|
(double)NSPasteboard.generalPasteboard.changeCount);
|
|
6930
6930
|
}
|
|
6931
6931
|
|
|
6932
|
+
// ---------------------------------------------------------------------------
|
|
6933
|
+
// idle time
|
|
6934
|
+
// ---------------------------------------------------------------------------
|
|
6935
|
+
|
|
6936
|
+
// lastInputMs() -> number: milliseconds since the last input event of any
|
|
6937
|
+
// kind in the login session — keyboard, mouse, trackpad, tablet — from any
|
|
6938
|
+
// app, the clock a screen saver keys off. CGEventSource keeps it per session,
|
|
6939
|
+
// so it asks nothing of AppKit or the window server's event stream and needs
|
|
6940
|
+
// no permission; it answers on whichever thread calls it, before initApp
|
|
6941
|
+
// and from a worker alike.
|
|
6942
|
+
static Napi::Value LastInputMsFn(const Napi::CallbackInfo& info) {
|
|
6943
|
+
CFTimeInterval s = CGEventSourceSecondsSinceLastEventType(
|
|
6944
|
+
kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType);
|
|
6945
|
+
return Napi::Number::New(info.Env(), s * 1000.0);
|
|
6946
|
+
}
|
|
6947
|
+
|
|
6932
6948
|
// ---------------------------------------------------------------------------
|
|
6933
6949
|
// screens + cursors + appearance
|
|
6934
6950
|
// ---------------------------------------------------------------------------
|
|
@@ -8060,6 +8076,7 @@ void InitBackend(Napi::Env env, Napi::Object exports) {
|
|
|
8060
8076
|
BFN("pasteboardReadText", PbReadTextFn);
|
|
8061
8077
|
BFN("pasteboardClear", PbClearFn);
|
|
8062
8078
|
BFN("pasteboardChangeCount", PbChangeCountFn);
|
|
8079
|
+
BFN("lastInputMs", LastInputMsFn);
|
|
8063
8080
|
BFN("setMainMenu", SetMainMenuFn);
|
|
8064
8081
|
BFN("mainMenuInfo", MainMenuInfoFn);
|
|
8065
8082
|
BFN("activateMenuItem", ActivateMenuItemFn);
|