From 3e0915521a9dfbaec306890ccff5b3c689fa0b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 27 Mar 2019 22:57:33 +0100 Subject: [PATCH] magnifier: Only connect to signals when ZoomRegion is active There's no need to listen signals when the zoom region is inactive, so let's just connect/disconnect them. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/472 --- js/ui/magnifier.js | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index a059ee98f..ba7227d67 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -754,13 +754,29 @@ var ZoomRegion = class ZoomRegion { this._pointerIdleMonitor = Meta.IdleMonitor.get_for_device(Meta.VIRTUAL_CORE_POINTER_ID); this._scrollContentsTimerId = 0; + } - Main.layoutManager.connect('monitors-changed', - this._monitorsChanged.bind(this)); - this._focusCaretTracker.connect('caret-moved', - this._updateCaret.bind(this)); - this._focusCaretTracker.connect('focus-changed', - this._updateFocus.bind(this)); + _connectSignals() { + if (this._signalConnections) + return; + + this._signalConnections = []; + let id = Main.layoutManager.connect('monitors-changed', + this._monitorsChanged.bind(this)); + this._signalConnections.push([Main.layoutManager, id]); + + id = this._focusCaretTracker.connect('caret-moved', this._updateCaret.bind(this)); + this._signalConnections.push([this._focusCaretTracker, id]); + + id = this._focusCaretTracker.connect('focus-changed', this._updateFocus.bind(this)); + this._signalConnections.push([this._focusCaretTracker, id]); + } + + _disconnectSignals() { + for (let [obj, id] of this._signalConnections) + obj.disconnect(id); + + delete this._signalConnections; } _updateScreenPosition() { @@ -824,7 +840,9 @@ var ZoomRegion = class ZoomRegion { this._updateMagViewGeometry(); this._updateCloneGeometry(); this._updateMousePosition(); + this._connectSignals(); } else { + this._disconnectSignals(); this._destroyActors(); } @@ -1574,9 +1592,6 @@ var ZoomRegion = class ZoomRegion { } _monitorsChanged() { - if (!this.isActive()) - return; - this._background.set_size(global.screen_width, global.screen_height); this._updateScreenPosition(); }