magnifier: Track cursor sprite changes only when active
There's no point in keeping the cursor sprite texture around all the time, and to listen for its changes, we just need this when the magnifier is active. So, initialize the magnifier texture and monitor for the sprite changes on activation, while disconnect from the signal and nullify the texture when the magnifier is deactivated. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/443
This commit is contained in:
parent
8146e9d527
commit
9158f55360
@ -88,7 +88,7 @@ var MouseSpriteContent = GObject.registerClass({
|
|||||||
this._texture = coglTexture;
|
this._texture = coglTexture;
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
|
|
||||||
if (!oldTexture ||
|
if (!oldTexture || !coglTexture ||
|
||||||
oldTexture.get_width() != coglTexture.get_width() ||
|
oldTexture.get_width() != coglTexture.get_width() ||
|
||||||
oldTexture.get_height() != coglTexture.get_height())
|
oldTexture.get_height() != coglTexture.get_height())
|
||||||
this.invalidate_size();
|
this.invalidate_size();
|
||||||
@ -106,7 +106,6 @@ var Magnifier = class Magnifier {
|
|||||||
|
|
||||||
this._mouseSprite = new Clutter.Actor({ request_mode: Clutter.RequestMode.CONTENT_SIZE });
|
this._mouseSprite = new Clutter.Actor({ request_mode: Clutter.RequestMode.CONTENT_SIZE });
|
||||||
this._mouseSprite.content = new MouseSpriteContent();
|
this._mouseSprite.content = new MouseSpriteContent();
|
||||||
this._updateSpriteTexture();
|
|
||||||
|
|
||||||
this._cursorRoot = new Clutter.Actor();
|
this._cursorRoot = new Clutter.Actor();
|
||||||
this._cursorRoot.add_actor(this._mouseSprite);
|
this._cursorRoot.add_actor(this._mouseSprite);
|
||||||
@ -122,8 +121,6 @@ var Magnifier = class Magnifier {
|
|||||||
let showAtLaunch = this._settingsInit(aZoomRegion);
|
let showAtLaunch = this._settingsInit(aZoomRegion);
|
||||||
aZoomRegion.scrollContentsTo(this.xMouse, this.yMouse);
|
aZoomRegion.scrollContentsTo(this.xMouse, this.yMouse);
|
||||||
|
|
||||||
cursorTracker.connect('cursor-changed', this._updateMouseSprite.bind(this));
|
|
||||||
|
|
||||||
// Export to dbus.
|
// Export to dbus.
|
||||||
magDBusService = new MagnifierDBus.ShellMagnifier();
|
magDBusService = new MagnifierDBus.ShellMagnifier();
|
||||||
this.setActive(showAtLaunch);
|
this.setActive(showAtLaunch);
|
||||||
@ -159,9 +156,15 @@ var Magnifier = class Magnifier {
|
|||||||
|
|
||||||
if (isActive != activate) {
|
if (isActive != activate) {
|
||||||
if (activate) {
|
if (activate) {
|
||||||
|
this._updateMouseSprite();
|
||||||
|
this._cursorSpriteChangedId =
|
||||||
|
this._cursorTracker.connect('cursor-changed',
|
||||||
|
this._updateMouseSprite.bind(this));
|
||||||
Meta.disable_unredirect_for_display(global.display);
|
Meta.disable_unredirect_for_display(global.display);
|
||||||
this.startTrackingMouse();
|
this.startTrackingMouse();
|
||||||
} else {
|
} else {
|
||||||
|
this._cursorTracker.disconnect(this._cursorSpriteChangedId);
|
||||||
|
this._mouseSprite.content.texture = null;
|
||||||
Meta.enable_unredirect_for_display(global.display);
|
Meta.enable_unredirect_for_display(global.display);
|
||||||
this.stopTrackingMouse();
|
this.stopTrackingMouse();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user