# Deterministic display-scale override

`<Xm/Display.h>` now exposes an additive test/developer hook for simulating a display scale without changing the caller's X resource database:

```c
XmSetDisplayScaleOverride(display, 2.0);
/* create or update widgets at a deterministic 2x default scale */
XmClearDisplayScaleOverride(display);
```

`XmGetDisplayScaleOverride` reports whether an override is active. The setter accepts only finite, positive values; invalid values leave the current value untouched. Overrides are stored per `Display`, are process-local, and are removed when cleared or when the Motif display object is destroyed. They do not call `XrmPutStringResource`, alter `Xft.dpi`, or rewrite an application's resource database.

The override is consulted before the optional XLibre output-DPI adapter and the existing global `Xft.dpi` fallback. A changed value is delivered through the same UI-thread transaction boundary used by the XLibre observer. The transaction first lets registered widgets update toolkit-owned derived defaults, then invokes the normal same-size resize path. Widget identity, callbacks, focus, selections, and application-owned pixel resources are not replaced by the transaction. Only toolkit-owned defaults that already participate in the DPI contract are affected.

This increment provides live relayout for the registered scale-aware subset; it does not claim that every historical Motif metric reflows or that a real multi-output server has been qualified. Those remain separate work-package gates with stronger geometry and XLibre evidence requirements.

Automatic `XmScrolledWindow`, `XmScrollBar`, and `XmScale` defaults now participate in the same contract across classic, high-contrast, and modern profiles. `XmScrolledWindow`'s toolkit-owned 100-pixel width and height, `XmScrollBar`'s toolkit-owned 11-pixel inner thickness (`2 * (highlight + shadow) + scaled(11)`), minimum slider thumb extent, and slider marks (`XmTHUMB_MARK` / `XmROUND_MARK`), and `XmScale`'s classic 15-pixel minor / 100-pixel major extents are scaled at construction and reflow live on a display-scale transaction while preserving explicit application or resource-database dimensions. In `XmScrolledWindow` (including `XmCreateScrolledList` and `XmCreateScrolledText`), child scrollbar thickness updates reflow the viewport inside existing constrained outer bounds without enlarging the outer `XmScrolledWindow`. The installed `tests/automated/run-display-scale-scrolled.py` and `tests/automated/run-display-scale-override.py` fixtures verify 1x/1.5x/2x/3x construction, live expansion, reversible reset, and explicit-size preservation.

Classic and high-contrast profiles also scale the following control metrics:
- `XmPanedWindow` and `XmPaned` scale their default sash width and height and update the existing sash children. Explicit `sashWidth` and `sashHeight` remain device dimensions.
- `XmArrowButton` and `XmArrowButtonGadget` scale the 15-pixel default interior. An axis set to zero resumes automatic sizing.
- Default cascade pixmaps have a DPI-scaled arrow size floor. Menu entries retain application-supplied `cascadePixmap` values. Tear-off controls scale their dash lengths and the minimum automatic height used by menu layout.
- `XmNotebook` scales its default binding width, back-page size, frame shadow thickness, inner margins, and tab spacing, and reflows its managed page scrollers and major/minor tab controls live.
- `XmMainWindow` scales its toolkit-owned `mainWindowMarginWidth` and `mainWindowMarginHeight` defaults and redistributes menu bar, command window, message window, and work-area regions in bottom-up order so nested scrollbars and command lists grow cleanly without clipping.
- `XmCommand`, `XmSelectionBox`, `XmMessageBox`, and nested `XmFileSelectionBox` chrome reflow their children with scaled default margins while preserving `XmCommand`'s configured `XmNhistoryVisibleItemCount` across intermediate resize passes. Explicit allocations remain in effect during the transaction.
- On multi-head RandR 1.5 servers (`XLibre` or `_MOTIF_RANDR_OUTPUT_DPI`), `_XmXlibreDpiInstallShell` synchronizes shells constructed on non-`1x` CRTCs with their resolved output `DPI` immediately upon registration and updates per-shell metrics across live cross-monitor moves and per-output `DPI` property changes (`tests/automated/run-xlibre-multihead.py` and `tests/automated/run-historical-scale-shaping.py`).

The installed matrix checks both profiles on Xvfb, including the sash child geometry, cascade pixmap dimensions, rendered tear-off dashes, Notebook page selection, dialog editor contents, and restoration at 1x. It supplies explicit dimensions through both Xt arguments and Xrm.

The installed consumer fixture is `tests/automated/run-display-scale-override.py`. It checks invalid values, per-display retention, resource-database identity, default indicator scaling, explicit pixel-resource preservation, and reversible cleanup against the selected installed `libXm`.

The transaction rollback fixture is `tests/automated/run-display-scale-rollback.py`. It injects a deterministic callback-snapshot allocation failure and verifies that both a failed set and a failed clear retain the previous override. Three repeated installed AArch64 `uconsole` runs pass against the current prefix; this fault-injection check is separate from the normal no-fault scale matrix.

Scale callbacks cannot start a second display-scale transaction while the outer transaction is dispatching. `tests/automated/run-display-scale-reentrant.py` registers a callback that attempts a nested override and verifies rejection, outer-value precedence and reversible cleanup. This prevents a callback from observing or replacing a partially applied derived-metric update.

## Qualification evidence

The first qualification ran on the AArch64 `uconsole` Linux host from a fresh Clang/Xft/Unicode/AT-SPI installed prefix. The current installed `libXm.so.8.0.0` fingerprint is `db1cb5845391519431410918d11dbc2e64daf8e4a18c13318151b20c52319d99`; the fixture source fingerprint is `30f791c20513b62d4fc1d6000e036cb310cdb4ad3b9ff0d07eaa5e50da72dda5`. Three independent Xvfb runs passed in `/tmp/ckmotif-scale-20261025/results/scale-override-r6/`, `-r7/` and `-r8/`. A consumer-only ASan/UBSan run with leak detection enabled also passed; its output is retained in `/tmp/ckmotif-scale-20261025/results/scale-override-asan-r2/`. The expanded precedence fixture was rerun in `scale-override-r9/`, `-r10/` and `-r11/`, with a separate strict run in `scale-override-asan-r3/`. The live-transaction fixture was then rebuilt against the updated library and passed in `fixture-r5/`, `-r6/` and `-r7/`, with a consumer-only strict ASan/UBSan run in `asan-r4/`; the installed library fingerprint for that run is `bdd7689d479646e4f7d03f297626c713194bd7128b2e27961959104922ef30a3`. The SpinBox live-default extension was subsequently rebuilt and passed in `fixture-spin-r3-4/`, `-5/` and `-6/`, with a consumer-only strict ASan/UBSan run in `fixture-spin-asan-r3/`. That installed `libXm.so.8.0.0` is `3dc9b995cb71894e66c40d013ec0bac242f6e9633d0d60e343ac4c2ff8b74b45`, and the fixture source is `2001413c96751c6bab59f6794ed54c0b9ea66a256880ef1b0b8d36e029c8fb66`. The same installed prefix then qualified ProgressRing preferred-size reflow in `fixture-ring-r1-2/`, `-3/` and `-4/`, with a consumer-only strict ASan/UBSan run in `fixture-ring-asan-r1/`. The fixture source for that combined cohort is `5cb2a55003cab57222f4f06cf1a934a68492c3c8338a526c56db1ee9c3dfd106`. After correcting inherited Primitive geometry ownership, the 96/144/192/288 matrix passed in `fixture-matrix-final-1/`, `-2/` and `-3/`, with a strict consumer ASan/UBSan run in `fixture-matrix-asan-final/`. The resulting installed library fingerprint is `99b423d62c5ae79097401b1ecbbf1cf4353a4157905947d3e3a5e95bd1051d17`, and the fixture source is `65fed9c30ad5f67458638cea744402fcddfe94131d97beec9c25b29b96c327b9`. The C23 configure probe was separately run with GCC 14 and reported the C11 atomic capability as available. The expanded fixture evidence qualifies the same-thread transaction, default indicator reflow, explicit-size preservation, toggle-state preservation, SpinBox and ProgressRing default reflow, and reversible cleanup; full historical-widget coverage and live appearance transactions remain open.

The reentrancy guard was rebuilt on AArch64 `uconsole` from 14:08:35 through 14:11:38 UTC on 2026-10-25 (clean build, 3:03 elapsed). Three fresh installed `run-display-scale-reentrant.py` runs and two existing display-scale override runs passed; a consumer ASan/UBSan reentrancy run with leak detection disabled also passed. The installed `libXm.so.8.0.0` fingerprint was `8bcba14d8924a0283037a66f7547eca74d38da4d40d4792ad77feccc549e80a8`; receipts are retained under `/tmp/ckmotif-scale-reentrant-20261025/`.
