react-x11 2.17.1 → 2.18.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 +1 -1
- package/src/events.js +3 -1
- package/src/glnodes.js +10 -3
- package/src/nodes/hittest.js +5 -2
- package/src/types/style.d.ts +8 -1
package/package.json
CHANGED
package/src/events.js
CHANGED
|
@@ -1270,7 +1270,9 @@ export class EventManager {
|
|
|
1270
1270
|
// arrive
|
|
1271
1271
|
if (!rect?.width || !rect.height) continue;
|
|
1272
1272
|
if (node.hidden || node.style.display === 'none') continue;
|
|
1273
|
-
|
|
1273
|
+
// neither value lets the pointer arrive at the node itself
|
|
1274
|
+
const pe = node.style.pointerEvents;
|
|
1275
|
+
if (pe === 'none' || pe === 'box-none') continue;
|
|
1274
1276
|
const eta =
|
|
1275
1277
|
speed < ATTENTION_MIN_SPEED
|
|
1276
1278
|
? attentionEta(native.x, native.y, 0, 0, rect)
|
package/src/glnodes.js
CHANGED
|
@@ -418,8 +418,9 @@ export class GlAreaNode extends Node {
|
|
|
418
418
|
const { width, height } = this.rect;
|
|
419
419
|
// x/y are where the node's origin sits in the drawable being drawn
|
|
420
420
|
// into (DrawInfo's contract) — a <glarea> draws into its own X window,
|
|
421
|
-
// so that is the origin.
|
|
422
|
-
|
|
421
|
+
// so that is the origin. width/height are device pixels; `scale` takes
|
|
422
|
+
// them back to logical ones.
|
|
423
|
+
const info = { width, height, x: 0, y: 0, scale: this.scale, node: this };
|
|
423
424
|
if (!this._created) {
|
|
424
425
|
this._created = true;
|
|
425
426
|
this.props.onCreated?.(gl, info);
|
|
@@ -481,7 +482,9 @@ export class GlAreaNode extends Node {
|
|
|
481
482
|
* by those. With no GL surface — not made yet, or given up after
|
|
482
483
|
* `onError` — only the children answer, and a point between them is the
|
|
483
484
|
* tree's. Hidden, or `pointerEvents: 'none'` here or above, lets the
|
|
484
|
-
* pointer through to what the tree has behind, as it does for any node
|
|
485
|
+
* pointer through to what the tree has behind, as it does for any node;
|
|
486
|
+
* `'box-none'` here does the same for the surface alone and still lets
|
|
487
|
+
* its children take the pointer.
|
|
485
488
|
*/
|
|
486
489
|
hitSurface(x, y) {
|
|
487
490
|
const panes = this._overlay?.panes.length ?? 0;
|
|
@@ -510,6 +513,10 @@ export class GlAreaNode extends Node {
|
|
|
510
513
|
if (hit) return hit;
|
|
511
514
|
}
|
|
512
515
|
}
|
|
516
|
+
// `box-none`: the children above answered for themselves, and the
|
|
517
|
+
// surface between them is not a target — the point goes on to the tree
|
|
518
|
+
// behind, as it does for any node with that value
|
|
519
|
+
if (this.style?.pointerEvents === 'box-none') return null;
|
|
513
520
|
return this.window ? this : null;
|
|
514
521
|
}
|
|
515
522
|
|
package/src/nodes/hittest.js
CHANGED
|
@@ -170,16 +170,19 @@ export class NodeHitTest {
|
|
|
170
170
|
return null;
|
|
171
171
|
}
|
|
172
172
|
const inside = this.containsPoint(x, y);
|
|
173
|
+
// `box-none`: the children are targets and this node is not — a point
|
|
174
|
+
// over its own area goes to whatever is behind it
|
|
175
|
+
const self = this.style.pointerEvents !== 'box-none';
|
|
173
176
|
// the children are culled on the strict rect — slop grows this node's
|
|
174
177
|
// target, not the region its clip lets through
|
|
175
178
|
if (!inside && this.clipsChildren()) {
|
|
176
|
-
return this.containsPointWithSlop(x, y) ? this : null;
|
|
179
|
+
return self && this.containsPointWithSlop(x, y) ? this : null;
|
|
177
180
|
}
|
|
178
181
|
const order = this.paintOrder();
|
|
179
182
|
for (let i = order.length - 1; i >= 0; i--) {
|
|
180
183
|
const hit = order[i].hitTest(x, y);
|
|
181
184
|
if (hit) return hit;
|
|
182
185
|
}
|
|
183
|
-
return inside || this.containsPointWithSlop(x, y) ? this : null;
|
|
186
|
+
return self && (inside || this.containsPointWithSlop(x, y)) ? this : null;
|
|
184
187
|
}
|
|
185
188
|
}
|
package/src/types/style.d.ts
CHANGED
|
@@ -72,7 +72,14 @@ export type JustifyItems = 'flex-start' | 'center' | 'flex-end' | 'stretch';
|
|
|
72
72
|
export type JustifySelf = 'auto' | JustifyItems;
|
|
73
73
|
export type Overflow = 'visible' | 'hidden' | 'scroll';
|
|
74
74
|
export type BorderStyle = 'solid' | 'dashed';
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Whether the pointer can land on a node. `'none'`: not on it nor anything
|
|
77
|
+
* inside it. `'box-none'` (React Native's): not on the node itself, but on
|
|
78
|
+
* its children — a press on the node's own area goes through to what is
|
|
79
|
+
* behind it. The shape an overlay wants when it holds controls but must not
|
|
80
|
+
* swallow the clicks between them, `<glarea>` included.
|
|
81
|
+
*/
|
|
82
|
+
export type PointerEvents = 'auto' | 'none' | 'box-none';
|
|
76
83
|
export type TextAlign = 'left' | 'right' | 'center' | 'start' | 'end';
|
|
77
84
|
export type FontStyle = 'normal' | 'italic' | 'oblique';
|
|
78
85
|
export type FontWeight = number | 'normal' | 'bold';
|