Fix arrow-key navigation in default keyboard style


When navigating vertically with arrow keys, the scan position could land
in a sub-pixel gap between keys, causing the navigation to skip the
entire target row, wrap around, and highlight an unexpected key. The gap
is a side effect of pixel-grid snapping in Qt Quick Layouts: a key with
Layout.fillWidth set to false is clamped to its fractional preferred
width (e.g. functionKeyWidth, which ends in .5 whenever the normal key
width is odd) while its cell boundary is rounded up to the next integer.
This leaves a dead strip of up to 0.5 px inside the cell where no key is
hit. Since functionKeyWidth equals the center x coordinate of a normal
key in the row above, and vertical navigation scans at the center x of
the current key, the scan could aim exactly at this gap. This also
explains why the bug depended on the display size and style: it only
occurred when the resulting key widths produced a fractional
functionKeyWidth.

Fix this by flooring the horizontal scan position. The snapped key
geometry always starts at an integer x coordinate, so a gap never
contains an integer x and the floored position always hits a key in a
fully tiled row.

Fixes: QTBUG-146018
Pick-to: 6.12 6.11
Change-Id: I1b6afc9c544c67888184eb450179da2799564c7b
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
commitde2610fb6d1d0cf57a718904b0be656f3f987c8d
parentf72f8c3e51e26b6c38438d33370ecccfd958f805
authorLiu Zheng <liuzheng@uniontech.com>
committerLiu Zheng <liuzheng@uniontech.com>
commit timeWed, 17 Jun 2026 00:49:10 +0000