[gnome-shell/wip/fix-screen-shield-motion-handler-leak: 1/2] screenShield: Use identity operator when matching for motion events




commit 2b44fa893f990f0f611d4b9d60c171649ec5cfc8
Author: Ray Strode <rstrode redhat com>
Date:   Thu Oct 8 09:36:30 2020 -0400

    screenShield: Use identity operator when matching for motion events
    
    The screen shield watches for motion events to know to display
    the pointer when the user wiggles their mouse.
    
    It checks for motion events by looking at the event type and
    seeing if it is of type `Clutter.EventType.MOTION`.  To do this
    comparison it uses the equality operator (==).  Using the equality
    operator isn't considered best practice, because it can returns true
    when comparing disparate types, if those types happen to be equivalent
    after coersion.
    
    From a code resiliance point of view, it's better to use the
    identity operator (===), which requires both sides of the comparison
    to be of the same type.
    
    As a policy, any legacy code that gets changed or moved should be
    switched away from the equality operator to the identity operator, if
    appropriate.
    
    This commit makes that change as prep work for a fix to that part of
    the code.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1459

 js/ui/screenShield.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index b368162ce8..9beece6465 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -436,7 +436,7 @@ var ScreenShield = class {
 
     _lockScreenShown(params) {
         let motionId = global.stage.connect('captured-event', (stage, event) => {
-            if (event.type() == Clutter.EventType.MOTION) {
+            if (event.type() === Clutter.EventType.MOTION) {
                 this._cursorTracker.set_pointer_visible(true);
                 global.stage.disconnect(motionId);
             }


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