slider: Consider text direction when handling arrow keys

Currently the right arrow key always increases the slider value,
even in RTL locales where the slider itself increases leftwards.

Fix that, so that the arrow keys always correspond to the
direction of the slider.

Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7963

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3500>
This commit is contained in:
Sundeep Mediratta
2024-10-09 13:17:30 -04:00
parent ab46e89171
commit 5309f747fa

View File

@ -193,7 +193,9 @@ export const Slider = GObject.registerClass({
vfunc_key_press_event(event) {
let key = event.get_key_symbol();
if (key === Clutter.KEY_Right || key === Clutter.KEY_Left) {
let delta = key === Clutter.KEY_Right ? 0.1 : -0.1;
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
const increaseKey = rtl ? Clutter.KEY_Left : Clutter.KEY_Right;
const delta = key === increaseKey ? 0.1 : -0.1;
this.value = Math.max(0, Math.min(this._value + delta, this._maxValue));
return Clutter.EVENT_STOP;
}