[gnome-shell] switcherPopups: Correct selection with arrows and scrolling using RTL



commit 5423179844bc5c4b30603323c6be2ae3c7c46e57
Author: Leleat <atule pm me>
Date:   Fri May 7 13:26:21 2021 +0200

    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>

 js/ui/altTab.js | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 2ae7b6b232..bc8b17fac3 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]