react-x11 2.47.2 → 2.47.3
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
CHANGED
|
@@ -175,6 +175,11 @@ export class WindowFlush {
|
|
|
175
175
|
// so a frame whose first pass is the floors' own collects once.
|
|
176
176
|
this._floorsCollectOwed = true;
|
|
177
177
|
this._refit();
|
|
178
|
+
// An `'auto'` window waiting for the size its content just asked for
|
|
179
|
+
// lays out when the echo brings it, not at the size it still has
|
|
180
|
+
// (`_holdForRefit`). Nothing here is cleared, so that frame owes
|
|
181
|
+
// everything this one did.
|
|
182
|
+
if (this._refitHolding()) return false;
|
|
178
183
|
}
|
|
179
184
|
const width = this.window.width ?? this._requestedSize?.width ?? 0;
|
|
180
185
|
const height = this.window.height ?? this._requestedSize?.height ?? 0;
|
|
@@ -47,8 +47,10 @@ export class WindowListeners {
|
|
|
47
47
|
// the first re-fit — and against all of them still in flight, not
|
|
48
48
|
// only the latest, because a move echo or an earlier re-fit's can land
|
|
49
49
|
// after the record moved on (#929, `_ownSize`).
|
|
50
|
-
if (this._requestedSize
|
|
51
|
-
|
|
50
|
+
if (this._requestedSize) {
|
|
51
|
+
const own = this._ownSize(ev);
|
|
52
|
+
if (!own) this._userSized = true;
|
|
53
|
+
this._settleRefitHold(ev, own);
|
|
52
54
|
}
|
|
53
55
|
// Where the window sits on screen decides where popups anchored to it
|
|
54
56
|
// belong — and finding that out is a server round trip
|
package/src/nodes/window/size.js
CHANGED
|
@@ -51,6 +51,16 @@ const NO_UNREAD_WIDTHS = process.env.REACT_X11_NO_UNREAD_WIDTHS === '1';
|
|
|
51
51
|
// is a handful at most.
|
|
52
52
|
const SIZES_IN_FLIGHT = 8;
|
|
53
53
|
|
|
54
|
+
// How long an `'auto'` window's frames wait for the size a re-fit asked for
|
|
55
|
+
// (`_holdForRefit`). A round trip is well under it locally and on a LAN; a
|
|
56
|
+
// slower link runs past it into the frame at the old size, which is the
|
|
57
|
+
// behaviour without the hold. The bound is there for a request answered
|
|
58
|
+
// with no new size at all — a window manager refusing it — where the
|
|
59
|
+
// content would otherwise wait for good.
|
|
60
|
+
const REFIT_HOLD_MS = 150;
|
|
61
|
+
// …and off, for A/B measurement and as first aid.
|
|
62
|
+
const NO_REFIT_HOLD = process.env.REACT_X11_NO_REFIT_HOLD === '1';
|
|
63
|
+
|
|
54
64
|
/** Take a node's extents off, as `collectFloorStale` does a dirty child's:
|
|
55
65
|
* both are measured again, and the minimum yoga holds may no longer be
|
|
56
66
|
* the one the floors wrote. */
|
|
@@ -879,6 +889,20 @@ export class WindowSize {
|
|
|
879
889
|
// tree holding the max-content one would hand `flush()` a stale
|
|
880
890
|
// arrangement.
|
|
881
891
|
yoga.calculateLayout(width, needH ? undefined : props.height, dir);
|
|
892
|
+
// **A height floor is a height for a width**, and the ones on hand
|
|
893
|
+
// were measured at the width the window was last laid out at — which
|
|
894
|
+
// is not this one whenever the content asked for a new width. A label
|
|
895
|
+
// that wrapped at the old width carries the two-line floor it earned
|
|
896
|
+
// there, and read back here it is a window two lines tall at a width
|
|
897
|
+
// that fits it on one: the window grew, and shrank again a frame
|
|
898
|
+
// later once the real pass had re-measured (#929). The same probe the
|
|
899
|
+
// real pass asks (`_applyContentFloors`): whether any leaf's height at
|
|
900
|
+
// this width differs from the one its floor was taken at, and only
|
|
901
|
+
// then the measurement and one more pass.
|
|
902
|
+
if (needH && this._probeHeightFloors().owed) {
|
|
903
|
+
measuringExactly(() => this._measureHeightFloors(width, false));
|
|
904
|
+
yoga.calculateLayout(width, undefined, dir);
|
|
905
|
+
}
|
|
882
906
|
const naturalH = needH
|
|
883
907
|
? clampExtent(yoga.getComputedHeight(), undefined, availH)
|
|
884
908
|
: undefined;
|
|
@@ -1001,18 +1025,26 @@ export class WindowSize {
|
|
|
1001
1025
|
}
|
|
1002
1026
|
this._askSize({ width: next.width, height: next.height });
|
|
1003
1027
|
// Asked for, not assumed. `window.width` stays what the server last said
|
|
1004
|
-
// until the ConfigureNotify lands
|
|
1005
|
-
// — the
|
|
1006
|
-
//
|
|
1007
|
-
//
|
|
1008
|
-
//
|
|
1009
|
-
// backing pixmap from the resize event, so a frame painted at a size the
|
|
1010
|
-
// pixmap has not reached yet is a frame clipped to the old one.
|
|
1028
|
+
// until the ConfigureNotify lands — on X11; Cocoa takes a size on the
|
|
1029
|
+
// call — and writing the new size onto the window here would be worse
|
|
1030
|
+
// than waiting: ntk allocates the backing pixmap from the resize event,
|
|
1031
|
+
// so a frame painted at a size the pixmap has not reached yet is a frame
|
|
1032
|
+
// clipped to the old one.
|
|
1011
1033
|
if (typeof wnd.setState === 'function') {
|
|
1012
1034
|
wnd.setState({ width: next.width, height: next.height });
|
|
1013
1035
|
} else {
|
|
1014
1036
|
wnd.resize?.(next.width, next.height);
|
|
1015
1037
|
}
|
|
1038
|
+
// …and laying this frame out at the size the window still has would be
|
|
1039
|
+
// worse again: content that changed *because* it needs more room is
|
|
1040
|
+
// content that does not fit the old size — a label one word longer
|
|
1041
|
+
// wraps, and is cut off at the bottom of a window one line tall — and
|
|
1042
|
+
// that frame went up, for a round trip, before the echo laid it out
|
|
1043
|
+
// again (#929). So the frame waits for the echo (`_holdForRefit`); the
|
|
1044
|
+
// old pixels stay up meanwhile, which is the last thing that was right.
|
|
1045
|
+
if (wnd.width !== next.width || wnd.height !== next.height) {
|
|
1046
|
+
this._holdForRefit(next);
|
|
1047
|
+
}
|
|
1016
1048
|
// A window that grew is a window whose *placement* moved with it, and
|
|
1017
1049
|
// the anchored ones have to be told: a completion list that gains a row
|
|
1018
1050
|
// near the bottom of the screen is one that now flips above the caret.
|
|
@@ -1042,6 +1074,65 @@ export class WindowSize {
|
|
|
1042
1074
|
);
|
|
1043
1075
|
}
|
|
1044
1076
|
|
|
1077
|
+
/**
|
|
1078
|
+
* Hold this window's frames until the backend reports the size `_refit`
|
|
1079
|
+
* just asked for, so the content that asked for it is laid out once, at
|
|
1080
|
+
* that size, and never at the old one. The echo releases the hold (the
|
|
1081
|
+
* 'resize' listener, `_settleRefitHold`), and so does somebody else's size
|
|
1082
|
+
* arriving instead — the user's or a window manager's. A request that is
|
|
1083
|
+
* never answered with a new size is the one case left: a window manager
|
|
1084
|
+
* may refuse it, and its answer then carries the old size, which a move
|
|
1085
|
+
* echo also does. So a timer ends the hold too, and the frame goes up at
|
|
1086
|
+
* whatever size the window has — what every frame did before the hold.
|
|
1087
|
+
*/
|
|
1088
|
+
_holdForRefit(size) {
|
|
1089
|
+
if (NO_REFIT_HOLD) return;
|
|
1090
|
+
clearTimeout(this._refitHeld?.timer);
|
|
1091
|
+
const timer = setTimeout(() => {
|
|
1092
|
+
if (this._refitHeld?.timer !== timer) return;
|
|
1093
|
+
this._releaseRefitHold();
|
|
1094
|
+
}, REFIT_HOLD_MS);
|
|
1095
|
+
timer.unref?.();
|
|
1096
|
+
this._refitHeld = { width: size.width, height: size.height, timer };
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/** Whether this frame waits for the size `_refit` asked for: held, and
|
|
1100
|
+
* the window not that size yet. */
|
|
1101
|
+
_refitHolding() {
|
|
1102
|
+
const held = this._refitHeld;
|
|
1103
|
+
if (!held) return false;
|
|
1104
|
+
const wnd = this.window;
|
|
1105
|
+
if (wnd && (wnd.width !== held.width || wnd.height !== held.height)) {
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
this._releaseRefitHold(false);
|
|
1109
|
+
return false;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* What a resize event does to a hold: the size it was waiting for, or a
|
|
1114
|
+
* size that is not ours (`own` false), ends it. A move echo at the old
|
|
1115
|
+
* size, or the echo of an earlier re-fit still in flight, does not —
|
|
1116
|
+
* those are exactly the frames the hold is there to skip.
|
|
1117
|
+
*/
|
|
1118
|
+
_settleRefitHold(ev, own) {
|
|
1119
|
+
const held = this._refitHeld;
|
|
1120
|
+
if (!held) return;
|
|
1121
|
+
if (!own || (ev.width === held.width && ev.height === held.height)) {
|
|
1122
|
+
this._releaseRefitHold();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/** End a hold, and run the frame it held back unless that is the caller's
|
|
1127
|
+
* own (`schedule` false). */
|
|
1128
|
+
_releaseRefitHold(schedule = true) {
|
|
1129
|
+
const held = this._refitHeld;
|
|
1130
|
+
if (!held) return;
|
|
1131
|
+
clearTimeout(held.timer);
|
|
1132
|
+
this._refitHeld = null;
|
|
1133
|
+
if (schedule && !this.destroyed && this.needsLayout) this._scheduleFrame();
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1045
1136
|
/**
|
|
1046
1137
|
* Record a size this window has asked the backend for. `_requestedSize`
|
|
1047
1138
|
* is the latest, which `_refit()` compares against to ask only once; the
|
|
@@ -275,6 +275,9 @@ export class WindowNode extends Scrollable(Node) {
|
|
|
275
275
|
// has not echoed yet: both are ours when an echo carries them (_ownSize)
|
|
276
276
|
this._confirmedSize = null;
|
|
277
277
|
this._sizesInFlight = [];
|
|
278
|
+
// the size `_refit` is waiting for before it lays out again, and the
|
|
279
|
+
// timer that gives up on it (_holdForRefit)
|
|
280
|
+
this._refitHeld = null;
|
|
278
281
|
// the last `WM_NORMAL_HINTS` struct written and the size it was written
|
|
279
282
|
// at, so that a bound measured every frame is only *sent* on the frames
|
|
280
283
|
// it moves (see _sendSizeHints for why the size is part of it)
|