react-x11 2.12.0 → 2.13.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/package.json +3 -2
- package/src/Reconciler.js +4 -14
- package/src/appcontext.js +59 -30
- package/src/cocoa/app.js +11 -0
- package/src/cocoa/glarea.js +4 -2
- package/src/cocoa/overlay.js +159 -0
- package/src/cocoa/promotion.js +13 -0
- package/src/embedding.js +31 -0
- package/src/events.js +72 -12
- package/src/foreignnodes.js +56 -3
- package/src/glnodes.js +171 -40
- package/src/gloverlay.js +383 -0
- package/src/host.d.ts +0 -1
- package/src/index.d.ts +14 -1
- package/src/node.d.ts +12 -1
- package/src/nodes/window/flush.js +35 -0
- package/src/nodes/window/window.js +9 -0
- package/src/types/elements.d.ts +15 -13
package/src/index.d.ts
CHANGED
|
@@ -163,8 +163,21 @@ export function useClipboard(): Clipboard;
|
|
|
163
163
|
* branches on it through the theme's `controls: 'auto'` policy; this is for
|
|
164
164
|
* application code composing its own controls to sit beside native ones. It
|
|
165
165
|
* is a property of the backend and never changes over the app's life.
|
|
166
|
+
*
|
|
167
|
+
* `'embedding'` is whether this connection can take another process's window
|
|
168
|
+
* into its own — X11, never Cocoa or the headless mock. Ask it before
|
|
169
|
+
* rendering a `<foreign>`, which refuses with one `onError` where it is
|
|
170
|
+
* false. Also a property of the backend, and it never changes either.
|
|
171
|
+
*
|
|
172
|
+
* `'glOverlay'` is whether the children of a `<glarea>` are drawn above its
|
|
173
|
+
* GL surface — laid out in its box, painted on panes stacked over it, hit
|
|
174
|
+
* before it. Both backends draw them; translucency is the difference,
|
|
175
|
+
* composited by Core Animation on Cocoa and opaque on X11, where what a
|
|
176
|
+
* child leaves unpainted shows the surface's `clearColor` (docs/elements.md).
|
|
177
|
+
* Ask it before handing a surface its HUD. A property of the backend.
|
|
166
178
|
*/
|
|
167
|
-
export type SupportsFeature =
|
|
179
|
+
export type SupportsFeature =
|
|
180
|
+
'transparency' | 'shaders' | 'nativeControls' | 'embedding' | 'glOverlay';
|
|
168
181
|
|
|
169
182
|
/**
|
|
170
183
|
* Can this **display** do something? `'transparency'` is true when the
|
package/src/node.d.ts
CHANGED
|
@@ -820,5 +820,16 @@ export declare class WindowNode extends Node {}
|
|
|
820
820
|
export declare class PopupNode extends WindowNode {}
|
|
821
821
|
/** The precedents for an element owning a real child X window — a surface of
|
|
822
822
|
* its own, and one holding somebody else's window. */
|
|
823
|
-
export declare class GlAreaNode extends Node {
|
|
823
|
+
export declare class GlAreaNode extends Node {
|
|
824
|
+
/**
|
|
825
|
+
* `true`: the pointer over the surface is dispatched through the owning
|
|
826
|
+
* window's event manager, at this node, on this backend. So an element
|
|
827
|
+
* built on `<glarea>` must not listen for the pointer on `node.window` —
|
|
828
|
+
* on X11 that selects the event on the surface's own window, and X then
|
|
829
|
+
* delivers it there instead of to the tree. Readable without rendering,
|
|
830
|
+
* as `GlAreaNode.prototype.forwardsPointer`; absent on a core that does
|
|
831
|
+
* not deliver it.
|
|
832
|
+
*/
|
|
833
|
+
readonly forwardsPointer: true;
|
|
834
|
+
}
|
|
824
835
|
export declare class ForeignNode extends Node {}
|
|
@@ -84,6 +84,29 @@ export class WindowFlush {
|
|
|
84
84
|
this._pacer.charge(ms);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Panes for the children of every `<glarea>` here, where this frame's
|
|
89
|
+
* layout put them (src/gloverlay.js). True when one was made, resized or
|
|
90
|
+
* dropped, which the frame then owes a paint for.
|
|
91
|
+
*/
|
|
92
|
+
_syncOverlays() {
|
|
93
|
+
let changed = false;
|
|
94
|
+
for (const area of this._overlaid) {
|
|
95
|
+
if (area.destroyed || area.root !== this) {
|
|
96
|
+
this._overlaid.delete(area);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (area._syncOverlay()) changed = true;
|
|
100
|
+
}
|
|
101
|
+
return changed;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** …and their paint, with the frame's own damage: a claim inside a
|
|
105
|
+
* `<glarea>`'s children is in that list like any other. */
|
|
106
|
+
_paintOverlays(damage) {
|
|
107
|
+
for (const area of this._overlaid) area._paintOverlay(damage);
|
|
108
|
+
}
|
|
109
|
+
|
|
87
110
|
/**
|
|
88
111
|
* A frame: layout if owed, then the paint passes — or the presenter's
|
|
89
112
|
* frame — then the backend's word. Runs on the window's clock through
|
|
@@ -254,6 +277,12 @@ export class WindowFlush {
|
|
|
254
277
|
// …and the next commit's claims name the arrangement this frame leaves
|
|
255
278
|
// behind again, from before whatever scroll comes with them
|
|
256
279
|
this._laidOut = false;
|
|
280
|
+
// The children of a `<glarea>` get panes where they are now: after
|
|
281
|
+
// layout and the scroll's shift, before the damage is taken, so a pane
|
|
282
|
+
// made or resized in this frame is painted in it, whole
|
|
283
|
+
if (this._overlaid.size !== 0 && this._syncOverlays()) {
|
|
284
|
+
this.needsPaint = true;
|
|
285
|
+
}
|
|
257
286
|
if (!this.needsPaint) return false;
|
|
258
287
|
this.needsPaint = false;
|
|
259
288
|
const damage = this._takeDamage(width, height);
|
|
@@ -276,6 +305,8 @@ export class WindowFlush {
|
|
|
276
305
|
// list was still taken (its bookkeeping is what keeps the two paths one
|
|
277
306
|
// code) and is simply not consumed; the presenter diffs at the layer.
|
|
278
307
|
if (typeof this.window.presentFrame === 'function') {
|
|
308
|
+
// the panes are no presenter's: they paint from the damage either way
|
|
309
|
+
if (this._overlaid.size !== 0) this._paintOverlays(damage);
|
|
279
310
|
this.window.presentFrame(this, damage);
|
|
280
311
|
this.app._reactX11Startup?.painted();
|
|
281
312
|
return true;
|
|
@@ -297,6 +328,10 @@ export class WindowFlush {
|
|
|
297
328
|
for (const rect of damage ?? [null]) {
|
|
298
329
|
this._paintRegion(ctx, rect, width, height);
|
|
299
330
|
}
|
|
331
|
+
// …and the panes over the surfaces, with the same damage: a claim from
|
|
332
|
+
// a `<glarea>`'s children is theirs to repaint — the window's pass under
|
|
333
|
+
// the surface is one nobody sees. Inside the cache's frame, like a pass.
|
|
334
|
+
if (this._overlaid.size !== 0) this._paintOverlays(damage);
|
|
300
335
|
// after every region: an entry drawn in one damage rect must not be
|
|
301
336
|
// evicted before the next rect of the same frame asks for it
|
|
302
337
|
this._paintCache?.endFrame();
|
|
@@ -191,6 +191,15 @@ export class WindowNode extends Scrollable(Node) {
|
|
|
191
191
|
// behind one `size` read on the motion path, and a tree that never asked
|
|
192
192
|
// for attention must not pay a property walk to find that out.
|
|
193
193
|
this._attentionNodes = new Set();
|
|
194
|
+
// The GL surfaces in this window, bottom to top: `<glarea>`s, stacked
|
|
195
|
+
// above everything 2D here, which the hit test therefore asks before the
|
|
196
|
+
// tree (`EventManager._surfaceAt`). A surface joins when its window is
|
|
197
|
+
// made and leaves when it goes (src/glnodes.js).
|
|
198
|
+
this._surfaces = [];
|
|
199
|
+
// …and the ones with children, whose panes each frame syncs after layout
|
|
200
|
+
// and paints with its damage (nodes/window/flush.js, src/gloverlay.js).
|
|
201
|
+
// Empty is one `size` read a frame.
|
|
202
|
+
this._overlaid = new Set();
|
|
194
203
|
this.events = new EventManager(this);
|
|
195
204
|
// ids of the child windows in the order the *server* stacks them,
|
|
196
205
|
// bottom to top — see _restackWindowChildren
|
package/src/types/elements.d.ts
CHANGED
|
@@ -915,6 +915,16 @@ export interface SvgProps extends DrawnProps<DrawnNode> {
|
|
|
915
915
|
|
|
916
916
|
export type FrameLoop = 'demand' | 'always';
|
|
917
917
|
|
|
918
|
+
/**
|
|
919
|
+
* `<glarea>`: a GL surface in the layout. Its **children** are 2D content
|
|
920
|
+
* drawn above the surface — laid out in its box like a `<box>`'s and cut to
|
|
921
|
+
* it, painted over the GL frame, hit before it — composited on the Cocoa
|
|
922
|
+
* backend and opaque on X11 (docs/elements.md); `useSupports('glOverlay')`
|
|
923
|
+
* asks whether they will be. The pointer over it is the tree's, as over any
|
|
924
|
+
* node: the handlers it inherits (`onMouseDown`, `onClick`, `onWheel`, …)
|
|
925
|
+
* fire at the child under the pointer or the `<glarea>` and bubble, on both
|
|
926
|
+
* backends, and `GlAreaNode.forwardsPointer` says so at run time.
|
|
927
|
+
*/
|
|
918
928
|
export interface GlAreaProps extends DrawnProps<DrawnNode> {
|
|
919
929
|
/** CSS colour, or `[r, g, b, a]` floats. Default black. */
|
|
920
930
|
clearColor?: Color | [number, number, number, number];
|
|
@@ -937,17 +947,6 @@ export interface GlAreaProps extends DrawnProps<DrawnNode> {
|
|
|
937
947
|
onDraw?: (gl: any, info: DrawInfo) => void;
|
|
938
948
|
/** No GL surface — no GLX, or no matching visual. */
|
|
939
949
|
onError?: (err: Error) => void;
|
|
940
|
-
/**
|
|
941
|
-
* The wheel over the surface. Inherited from `EventHandlers` like every
|
|
942
|
-
* other element's, and listed here because it is the **only** pointer
|
|
943
|
-
* event a `<glarea>` currently reports: the surface owns its own X window,
|
|
944
|
-
* so it selects the wheel there and hands it to the window's event manager
|
|
945
|
-
* (see docs/elements.md). Deltas are pixels, `preventDefault()` takes the
|
|
946
|
-
* default scroll action back, and it bubbles from this node.
|
|
947
|
-
*/
|
|
948
|
-
onWheel?: (ev: WheelEvent<DrawnNode>) => void;
|
|
949
|
-
/** A click inside the surface that hit no mesh. */
|
|
950
|
-
onPointerMissed?: (ev: MouseEvent<DrawnNode>) => void;
|
|
951
950
|
}
|
|
952
951
|
|
|
953
952
|
// --- embedding -------------------------------------------------------------
|
|
@@ -973,7 +972,9 @@ export interface ForeignProps extends DrawnProps<DrawnNode> {
|
|
|
973
972
|
*/
|
|
974
973
|
windowId?: number;
|
|
975
974
|
/** The container window's id, offered as soon as it exists, so a program
|
|
976
|
-
* can be spawned into it. Fires before there is anything embedded
|
|
975
|
+
* can be spawned into it. Fires before there is anything embedded — and
|
|
976
|
+
* never on a backend with no embedding (`useSupports('embedding')`), so the
|
|
977
|
+
* id is always a real window's. */
|
|
977
978
|
onReady?: (info: { windowId: number; node: DrawnNode }) => void;
|
|
978
979
|
/** A client is in. */
|
|
979
980
|
onEmbedded?: (info: EmbeddedInfo) => void;
|
|
@@ -982,7 +983,8 @@ export interface ForeignProps extends DrawnProps<DrawnNode> {
|
|
|
982
983
|
/** `XEMBED_REQUEST_FOCUS`: the client wants the focus. It is given through
|
|
983
984
|
* the focus manager unless a handler prevents it by focusing elsewhere. */
|
|
984
985
|
onRequestFocus?: (info: { node: DrawnNode }) => void;
|
|
985
|
-
/** The embed failed — no such window, or it went away mid-handshake
|
|
986
|
+
/** The embed failed — no such window, or it went away mid-handshake — or
|
|
987
|
+
* this backend cannot embed at all, which is reported once, at mount.
|
|
986
988
|
* Without a handler the failure is a console warning. */
|
|
987
989
|
onError?: (err: Error) => void;
|
|
988
990
|
}
|