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
This commit is contained in:
Ray Strode 2020-10-08 09:36:30 -04:00
parent 6ba3ca5f95
commit 2b44fa893f

View File

@ -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);
}