🔧 Prevent non-fatal error message

This commit is contained in:
Simon Schneegans
2022-05-07 20:45:20 +02:00
parent 07929e1775
commit e9b82d0b78
3 changed files with 39 additions and 21 deletions
+27 -9
View File
@@ -78,6 +78,7 @@ class Extension {
this._origDoRemoveWindow = Workspace.prototype._doRemoveWindow; this._origDoRemoveWindow = Workspace.prototype._doRemoveWindow;
this._origShouldAnimateActor = WindowManager.prototype._shouldAnimateActor; this._origShouldAnimateActor = WindowManager.prototype._shouldAnimateActor;
this._origWaitForOverviewToHide = WindowManager.prototype._waitForOverviewToHide; this._origWaitForOverviewToHide = WindowManager.prototype._waitForOverviewToHide;
this._origDestroyWindowDone = WindowManager.prototype._destroyWindowDone;
// We will also override these animation times. // We will also override these animation times.
this._origWindowTime = imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME; this._origWindowTime = imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME;
@@ -199,9 +200,9 @@ class Extension {
// ----------------------------------------------- patching the window-close animation // ----------------------------------------------- patching the window-close animation
// The signal handler below is all which is required outside of the overview. All // The signal handler below and the following patch are all which is required outside
// other hacks further below are just required to defer the window-hiding in the // of the overview. All other hacks further below are just required to defer the
// overview until the effect is finished. // window-hiding in the overview until the effect is finished.
// The close animation is set up in WindowManager's _destroyWindow: // The close animation is set up in WindowManager's _destroyWindow:
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/windowManager.js#L1541 // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/windowManager.js#L1541
@@ -211,6 +212,23 @@ class Extension {
this._setupEffect(actor, false); this._setupEffect(actor, false);
}); });
// Once the window-close animation is is finished, the window manager's
// _destroyWindowDone is called. We use this to free the effect so that it can be
// re-used in future.
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/windowManager.js#L1541
WindowManager.prototype._destroyWindowDone = function(shellwm, actor) {
if (this._destroying.has(actor)) {
const shader = actor.get_effect('burn-my-windows-effect');
if (shader) {
actor.remove_effect(shader);
shader.free();
}
}
// Call the original method.
extensionThis._origDestroyWindowDone.apply(this, [shellwm, actor]);
};
// These three method overrides are mega-hacky! Usually, windows are not faded when // These three method overrides are mega-hacky! Usually, windows are not faded when
// closed from the overview (why?). With these overrides we make sure that they are // closed from the overview (why?). With these overrides we make sure that they are
// actually faded out. To do this, _windowRemoved and _doRemoveWindow now check // actually faded out. To do this, _windowRemoved and _doRemoveWindow now check
@@ -301,6 +319,7 @@ class Extension {
Workspace.prototype._doRemoveWindow = this._origDoRemoveWindow; Workspace.prototype._doRemoveWindow = this._origDoRemoveWindow;
WindowManager.prototype._shouldAnimateActor = this._origShouldAnimateActor; WindowManager.prototype._shouldAnimateActor = this._origShouldAnimateActor;
WindowManager.prototype._waitForOverviewToHide = this._origWaitForOverviewToHide; WindowManager.prototype._waitForOverviewToHide = this._origWaitForOverviewToHide;
WindowManager.prototype._destroyWindowDone = this._origDestroyWindowDone;
imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = this._origWindowTime; imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = this._origWindowTime;
imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME = this._origDialogTime; imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME = this._origDialogTime;
@@ -469,13 +488,12 @@ class Extension {
}); });
// Remove the effect if the animation finished or was interrupted. // Remove the effect if the animation finished or was interrupted.
transition.connect('stopped', () => { if (forOpening) {
if (forOpening) { transition.connect('stopped', () => {
actor.remove_effect_by_name('burn-my-windows-effect'); actor.remove_effect_by_name('burn-my-windows-effect');
} shader.free();
});
effect.returnShader(shader); }
});
} }
// Finally, ensure that all animation times are set properly so that other extensions // Finally, ensure that all animation times are set properly so that other extensions
+6 -6
View File
@@ -119,12 +119,6 @@ var Fire = class Fire {
return shader; return shader;
} }
// This will be called from extension.js once a shader which was previously acquired via
// getShader() is not used anymore.
static returnShader(shader) {
availableShaders.push(shader);
}
// The tweakTransition() is called from extension.js to tweak a window's open / close // The tweakTransition() is called from extension.js to tweak a window's open / close
// transitions - usually windows are faded in / out and scaled up / down by GNOME Shell. // transitions - usually windows are faded in / out and scaled up / down by GNOME Shell.
// The parameter 'forOpening' is set to true if this is called for a window-open // The parameter 'forOpening' is set to true if this is called for a window-open
@@ -289,6 +283,12 @@ if (utils.isInShellProcess()) {
[settings.get_double('flame-movement-speed')]); [settings.get_double('flame-movement-speed')]);
} }
// This is called by extension.js when the shader is not used anymore. We will store
// this instance of the shader so that it can be re-used in th future.
free() {
availableShaders.push(this);
}
// This is called by the constructor. This is means it's only called when the effect // This is called by the constructor. This is means it's only called when the effect
// is used for the first time. // is used for the first time.
vfunc_build_pipeline() { vfunc_build_pipeline() {
+6 -6
View File
@@ -101,12 +101,6 @@ var Hexagon = class Hexagon {
return shader; return shader;
} }
// This will be called from extension.js once a shader which was previously acquired via
// getShader() is not used anymore.
static returnShader(shader) {
availableShaders.push(shader);
}
// The tweakTransition() is called from extension.js to tweak a window's open / close // The tweakTransition() is called from extension.js to tweak a window's open / close
// transitions - usually windows are faded in / out and scaled up / down by GNOME Shell. // transitions - usually windows are faded in / out and scaled up / down by GNOME Shell.
// The parameter 'forOpening' is set to true if this is called for a window-open // The parameter 'forOpening' is set to true if this is called for a window-open
@@ -189,6 +183,12 @@ if (utils.isInShellProcess()) {
[line.red / 255, line.green / 255, line.blue / 255, line.alpha / 255]); [line.red / 255, line.green / 255, line.blue / 255, line.alpha / 255]);
} }
// This is called by extension.js when the shader is not used anymore. We will store
// this instance of the shader so that it can be re-used in th future.
free() {
availableShaders.push(this);
}
// This is called by the constructor. This is means it's only called when the effect // This is called by the constructor. This is means it's only called when the effect
// is used for the first time. // is used for the first time.
vfunc_build_pipeline() { vfunc_build_pipeline() {