switcherPopups: Correct selection with arrows and scrolling using RTL

The switcherPopups use _next() and _previous() to get the items
in the text direction. I. e. with LTR _next() gets the right item;
on RTL it gets the left item. This doesn't work well with RTL when using
the arrow keys since the text direction doesn't matter in those cases.
Pressing Left Arrow should still move left regardless of text direction.
So use the opposite methods.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2547

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1835>
This commit is contained in:
Leleat 2021-05-07 13:26:21 +02:00 committed by Marge Bot
parent 019229c40e
commit 5423179844

View File

@ -164,6 +164,7 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
}
_keyPressHandler(keysym, action) {
const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
if (action == Meta.KeyBindingAction.SWITCH_GROUP) {
if (!this._thumbnailsFocused)
this._select(this._selectedIndex, 0);
@ -179,9 +180,9 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
this._quitApplication(this._selectedIndex);
} else if (this._thumbnailsFocused) {
if (keysym === Clutter.KEY_Left)
this._select(this._selectedIndex, this._previousWindow());
this._select(this._selectedIndex, rtl ? this._nextWindow() : this._previousWindow());
else if (keysym === Clutter.KEY_Right)
this._select(this._selectedIndex, this._nextWindow());
this._select(this._selectedIndex, rtl ? this._previousWindow() : this._nextWindow());
else if (keysym === Clutter.KEY_Up)
this._select(this._selectedIndex, null, true);
else if (keysym === Clutter.KEY_w || keysym === Clutter.KEY_W || keysym === Clutter.KEY_F4)
@ -189,9 +190,9 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
else
return Clutter.EVENT_PROPAGATE;
} else if (keysym == Clutter.KEY_Left) {
this._select(this._previous());
this._select(rtl ? this._next() : this._previous());
} else if (keysym == Clutter.KEY_Right) {
this._select(this._next());
this._select(rtl ? this._previous() : this._next());
} else if (keysym == Clutter.KEY_Down) {
this._select(this._selectedIndex, 0);
} else {
@ -589,14 +590,15 @@ class WindowSwitcherPopup extends SwitcherPopup.SwitcherPopup {
}
_keyPressHandler(keysym, action) {
const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)
this._select(this._next());
else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD)
this._select(this._previous());
else if (keysym == Clutter.KEY_Left)
this._select(this._previous());
this._select(rtl ? this._next() : this._previous());
else if (keysym == Clutter.KEY_Right)
this._select(this._next());
this._select(rtl ? this._previous() : this._next());
else if (keysym === Clutter.KEY_w || keysym === Clutter.KEY_W || keysym === Clutter.KEY_F4)
this._closeWindow(this._selectedIndex);
else