From 1ea4d72fe5316585578913ba329874a444a1d7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 29 Jul 2021 21:56:57 +0200 Subject: [PATCH] magnifier: Don't query pointer unless necessary The PointerWatcher passes the current pointer position to every watch, so we don't have to query the pointer again scrollToMousePos() is used as watch callback. While that should be the only use, be conservative and still query the pointer when called without arguments. Part-of: --- js/ui/magnifier.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index 08466b9a0..f170bbed0 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -230,8 +230,8 @@ var Magnifier = class Magnifier { * system pointer. * @returns {bool} true. */ - scrollToMousePos() { - let [xMouse, yMouse] = global.get_pointer(); + scrollToMousePos(...args) { + const [xMouse, yMouse] = args.length ? args : global.get_pointer(); if (xMouse != this.xMouse || yMouse != this.yMouse) { this.xMouse = xMouse;