[gnome-shell/wip/carlosg/magnifier-improvements: 5/11] magnifier: Ignore repeated a11y events



commit 6b58dfdbfaef9cd45256507018f9b2199b808d43
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 6 10:56:44 2020 +0100

    magnifier: Ignore repeated a11y events
    
    We may get several a11y events setting the caret on the same
    coordinates it previously was. Make focus tracking ignore those,
    as we're jumping to the same coordinates again during eg. mouse
    operation.

 js/ui/magnifier.js | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index 4978196409..2154effc92 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -799,9 +799,13 @@ var ZoomRegion = class ZoomRegion {
             return;
         }
 
-        [this._xFocus, this._yFocus] = [extents.x + (extents.width / 2),
-                                        extents.y + (extents.height / 2)];
-        this._centerFromFocusPosition();
+        let [xFocus, yFocus] = [extents.x + (extents.width / 2),
+                                extents.y + (extents.height / 2)];
+
+        if (this._xFocus != xFocus || this._yFocus != yFocus) {
+            [this._xFocus, this._yFocus] = [xFocus, yFocus];
+            this._centerFromFocusPosition();
+        }
     }
 
     _updateCaret(caller, event) {
@@ -816,8 +820,12 @@ var ZoomRegion = class ZoomRegion {
             return;
         }
 
-        [this._xCaret, this._yCaret] = [extents.x, extents.y];
-        this._centerFromCaretPosition();
+        let [xCaret, yCaret] = [extents.x, extents.y];
+
+        if (this._xCaret != xCaret || this._yCaret != yCaret) {
+            [this._xCaret, this._yCaret] = [xCaret, yCaret];
+            this._centerFromCaretPosition();
+        }
     }
 
     /**


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