From 2b44fa893f990f0f611d4b9d60c171649ec5cfc8 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 8 Oct 2020 09:36:30 -0400 Subject: [PATCH] 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 b368162ce..9beece646 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); }