Android: clamp safe margins values to max of the reported insets

In some cases during resize events after an orientation change, it
can happen that the subtraction logic to figure out the remaining
value to leave the non-safe area, might compare a transcient/old
geometry, and end with big values in the reported safe margin. To
avoid that clamp the value to insets reported by the system.

Pick-to: 6.9 6.10 6.10.0
Change-Id: Ia7b39e1ef3969dca0cdc998368290646ab6d2b6d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Assam Boudjelthia 2025-09-08 20:19:46 +03:00
parent 13a1cf98e6
commit 74a3746617
1 changed files with 4 additions and 4 deletions

View File

@ -204,10 +204,10 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
// Find the remaining minimum safe margins
Insets safeInsets = getSafeInsets(this, insets);
int left = safeInsets.left > 0 ? Math.max(0, safeInsets.left - leftOffset) : 0;
int top = safeInsets.top > 0 ? Math.max(0, safeInsets.top - topOffset) : 0;
int right = safeInsets.right > 0 ? Math.max(0, safeInsets.right - rightOffset) : 0;
int bottom = safeInsets.bottom > 0 ? Math.max(0, safeInsets.bottom - bottomOffset) : 0;
int left = Math.max(0, Math.min(safeInsets.left, safeInsets.left - leftOffset));
int top = Math.max(0, Math.min(safeInsets.top, safeInsets.top - topOffset));
int right = Math.max(0, Math.min(safeInsets.right, safeInsets.right - rightOffset));
int bottom = Math.max(0, Math.min(safeInsets.bottom, safeInsets.bottom - bottomOffset));
safeAreaMarginsChanged(Insets.of(left, top, right, bottom), id);
}