magnifier: Add method to enable/disable crosshairs
These do some some signals connection and monitor layout tracking that we forget to disconnect when the magnifier is disconnected. This causes warnings if enabling the magnifier, disabling it, switching to another tty, and back. (Presumably also happens for monitor hotplugs). This signal should just stay connected as long as it's needed, so add a setEnabled() method on the CrossHairs actor that we can hook on the magnifier. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1902>
This commit is contained in:
parent
a363f1343a
commit
3df4b5ec7c
@ -172,6 +172,9 @@ var Magnifier = class Magnifier {
|
|||||||
this.stopTrackingMouse();
|
this.stopTrackingMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._crossHairs)
|
||||||
|
this._crossHairs.setEnabled(activate);
|
||||||
|
|
||||||
// Make sure system mouse pointer is shown when all zoom regions are
|
// Make sure system mouse pointer is shown when all zoom regions are
|
||||||
// invisible.
|
// invisible.
|
||||||
if (!activate)
|
if (!activate)
|
||||||
@ -1677,9 +1680,7 @@ class Crosshairs extends Clutter.Actor {
|
|||||||
this._clipSize = [0, 0];
|
this._clipSize = [0, 0];
|
||||||
this._clones = [];
|
this._clones = [];
|
||||||
this.reCenter();
|
this.reCenter();
|
||||||
|
this._monitorsChangedId = 0;
|
||||||
Main.layoutManager.connect('monitors-changed',
|
|
||||||
this._monitorsChanged.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_monitorsChanged() {
|
_monitorsChanged() {
|
||||||
@ -1687,6 +1688,16 @@ class Crosshairs extends Clutter.Actor {
|
|||||||
this.reCenter();
|
this.reCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setEnabled(enabled) {
|
||||||
|
if (enabled && this._monitorsChangedId === 0) {
|
||||||
|
this._monitorsChangedId = Main.layoutManager.connect(
|
||||||
|
'monitors-changed', this._monitorsChanged.bind(this));
|
||||||
|
} else if (!enabled && this._monitorsChangedId !== 0) {
|
||||||
|
Main.layoutManager.disconnect(this._monitorsChangedId);
|
||||||
|
this._monitorsChangedId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addToZoomRegion
|
* addToZoomRegion
|
||||||
* Either add the crosshairs actor to the given ZoomRegion, or, if it is
|
* Either add the crosshairs actor to the given ZoomRegion, or, if it is
|
||||||
|
Loading…
Reference in New Issue
Block a user