react-x11 2.18.1 → 2.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cocoa/app.js +25 -10
- package/src/cocoa/glarea.js +2 -1
- package/src/cocoa/panewindow.js +5 -0
- package/src/cocoa/window.js +9 -0
package/package.json
CHANGED
package/src/cocoa/app.js
CHANGED
|
@@ -85,6 +85,17 @@ const SCREEN_POLL_MS = 500;
|
|
|
85
85
|
// have finished moving the window (`_recheckScreens`).
|
|
86
86
|
const SCREEN_RECHECK_MS = 1000;
|
|
87
87
|
|
|
88
|
+
/** One frame callback; a throw is reported, not allowed to end the tick. */
|
|
89
|
+
function runFrame(entry, now) {
|
|
90
|
+
try {
|
|
91
|
+
entry.cb(now);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
queueMicrotask(() => {
|
|
94
|
+
throw err;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
88
99
|
export class CocoaApp {
|
|
89
100
|
constructor(native, options = {}) {
|
|
90
101
|
this._native = native;
|
|
@@ -92,7 +103,7 @@ export class CocoaApp {
|
|
|
92
103
|
// CocoaWindow._key -> CocoaWindow: the number, or on a worker the handle
|
|
93
104
|
this._windows = new Map();
|
|
94
105
|
this._grabWindow = null;
|
|
95
|
-
this._rafQueue = []; // [{ cb, wnd }]
|
|
106
|
+
this._rafQueue = []; // [{ cb, wnd, surface }]
|
|
96
107
|
// the app's own frame clock, for a frame no window owns (a pane's)
|
|
97
108
|
this._rafLast = 0;
|
|
98
109
|
// an explicit interval applies to every window; null means each
|
|
@@ -843,8 +854,8 @@ export class CocoaApp {
|
|
|
843
854
|
* paced claim (src/pacing.js) land at its wait rather than at its wait
|
|
844
855
|
* rounded up to the pump.
|
|
845
856
|
*/
|
|
846
|
-
_requestFrame(cb, wnd = null) {
|
|
847
|
-
this._rafQueue.push({ cb, wnd });
|
|
857
|
+
_requestFrame(cb, wnd = null, surface = false) {
|
|
858
|
+
this._rafQueue.push({ cb, wnd, surface });
|
|
848
859
|
if ((this._pump || this._threaded) && this._rafQueue.length === 1) {
|
|
849
860
|
const now = performance.now();
|
|
850
861
|
this._armFrameTimer(Math.max(1, this._frameWait(wnd ?? this, now)), now);
|
|
@@ -947,6 +958,14 @@ export class CocoaApp {
|
|
|
947
958
|
const queue = this._rafQueue;
|
|
948
959
|
this._rafQueue = [];
|
|
949
960
|
let soonest = Infinity;
|
|
961
|
+
// A `<glarea>`'s frames, due in this tick, run after every window's
|
|
962
|
+
// own: its children are laid out, painted and presented in the window's
|
|
963
|
+
// flush, so a GL frame drawn ahead of that flush reached the screen
|
|
964
|
+
// under the overlay of the frame before — for as long as the flush took,
|
|
965
|
+
// which is more than a display frame when the change costs layout
|
|
966
|
+
// (issue #641). The Wayland backend orders them the same way
|
|
967
|
+
// (`requestSurfaceFrame`).
|
|
968
|
+
const surfaces = [];
|
|
950
969
|
for (const entry of queue) {
|
|
951
970
|
// A window whose last flip has not reached its layer yet (threaded
|
|
952
971
|
// mode's fence, `CocoaWindow.frameInFlight`) waits before
|
|
@@ -974,14 +993,10 @@ export class CocoaApp {
|
|
|
974
993
|
this._rafQueue.push(entry);
|
|
975
994
|
continue;
|
|
976
995
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
} catch (err) {
|
|
980
|
-
queueMicrotask(() => {
|
|
981
|
-
throw err;
|
|
982
|
-
});
|
|
983
|
-
}
|
|
996
|
+
if (entry.surface) surfaces.push(entry);
|
|
997
|
+
else runFrame(entry, now);
|
|
984
998
|
}
|
|
999
|
+
for (const entry of surfaces) runFrame(entry, now);
|
|
985
1000
|
this._armFrameTimer(soonest, now);
|
|
986
1001
|
}
|
|
987
1002
|
|
package/src/cocoa/glarea.js
CHANGED
|
@@ -232,8 +232,9 @@ export class CocoaGLArea {
|
|
|
232
232
|
for (const fn of this._listeners.get(name) ?? []) fn(ev);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
// on the owning window's clock, after its flush in the same tick (#641)
|
|
235
236
|
requestAnimationFrame(cb) {
|
|
236
|
-
return this.parent.
|
|
237
|
+
return this.parent.requestSurfaceFrame(cb);
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
/**
|
package/src/cocoa/panewindow.js
CHANGED
|
@@ -99,6 +99,11 @@ export class CocoaPaneWindow {
|
|
|
99
99
|
return this.app._requestFrame(cb);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/** A `<glarea>`'s frame, after this pane's own (`CocoaWindow`'s). */
|
|
103
|
+
requestSurfaceFrame(cb) {
|
|
104
|
+
return this.app._requestFrame(cb, null, true);
|
|
105
|
+
}
|
|
106
|
+
|
|
102
107
|
/**
|
|
103
108
|
* Whether the host may still be showing the frame before the last one —
|
|
104
109
|
* the gate `flushPendingFrames` (src/frames.js) is written around: a
|
package/src/cocoa/window.js
CHANGED
|
@@ -915,6 +915,15 @@ export class CocoaWindow {
|
|
|
915
915
|
return this.app._requestFrame(cb, this);
|
|
916
916
|
}
|
|
917
917
|
|
|
918
|
+
/**
|
|
919
|
+
* A `<glarea>`'s frame: on this window's clock, and after this window's
|
|
920
|
+
* own frame in the tick that runs both, so the GL frame goes out after
|
|
921
|
+
* the overlay its children were painted on (src/cocoa/glarea.js).
|
|
922
|
+
*/
|
|
923
|
+
requestSurfaceFrame(cb) {
|
|
924
|
+
return this.app._requestFrame(cb, this, true);
|
|
925
|
+
}
|
|
926
|
+
|
|
918
927
|
/**
|
|
919
928
|
* The earliest moment this window's clock will hand out another frame,
|
|
920
929
|
* for a gate of `interval` ms — the display's period by default, which
|