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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1932>
This commit is contained in:
Florian Müllner 2021-07-29 21:56:57 +02:00 committed by Marge Bot
parent 3fa5e5963c
commit 1ea4d72fe5

View File

@ -230,8 +230,8 @@ var Magnifier = class Magnifier {
* system pointer. * system pointer.
* @returns {bool} true. * @returns {bool} true.
*/ */
scrollToMousePos() { scrollToMousePos(...args) {
let [xMouse, yMouse] = global.get_pointer(); const [xMouse, yMouse] = args.length ? args : global.get_pointer();
if (xMouse != this.xMouse || yMouse != this.yMouse) { if (xMouse != this.xMouse || yMouse != this.yMouse) {
this.xMouse = xMouse; this.xMouse = xMouse;