🔧 Use 'unmanged' signal to adjust window clone transitions

This commit is contained in:
Simon Schneegans
2022-01-22 12:38:14 +01:00
parent 61fbdcbc49
commit 33ac6fa80c
+20 -11
View File
@@ -91,6 +91,7 @@ class Extension {
if (WindowPreview) { if (WindowPreview) {
this._origDeleteAll = WindowPreview.prototype._deleteAll; this._origDeleteAll = WindowPreview.prototype._deleteAll;
this._origRestack = WindowPreview.prototype._restack; this._origRestack = WindowPreview.prototype._restack;
this._origInit = WindowPreview.prototype._init;
// This is required, else WindowPreview's _restack() which is called by the // This is required, else WindowPreview's _restack() which is called by the
// "this.overlayEnabled = false", sometimes tries to access an already delete // "this.overlayEnabled = false", sometimes tries to access an already delete
@@ -102,24 +103,23 @@ class Extension {
} }
}; };
// The _deleteAll is called when the user clicks the X in the overview. // When a window is removed from the overview, we need adjust the transitions of the
WindowPreview.prototype._deleteAll = function() { // window clone according to the chosen effect. We do this in the 'unmanaged' signal
// Do not attempt to close windows twice. Due to the animation in the overview, // of the WindowPreview's Meta.Window. This is not ideal, as it does not work for
// the close button can be clicked twice which normally would lead to a crash. // dialogs which close themselves... Maybe there's a better way?
if (!this._closeRequested) { WindowPreview.prototype._init = function(...params) {
// Call the original method. // Call the original method.
extensionThis._origDeleteAll.apply(this); extensionThis._origInit.apply(this, params);
// Hide the window's icon, name, and close button.
this.overlayEnabled = false;
this._icon.visible = false;
// When the user clicks the X in the overview, the window is not deleted // When the user clicks the X in the overview, the window is not deleted
// immediately. However, as soon as the window is really deleted, we need to // immediately. However, as soon as the window is really deleted, we need to
// adjust the transition of its clone. // adjust the transition of its clone.
const connectionID = this.metaWindow.connect('unmanaged', () => { const connectionID = this.metaWindow.connect('unmanaged', () => {
if (this.window_container) { if (this.window_container) {
// Hide the window's icon, name, and close button.
this.overlayEnabled = false;
this._icon.visible = false;
const transitionConfig = extensionThis._effect.getCloseTransition( const transitionConfig = extensionThis._effect.getCloseTransition(
this.window_container, extensionThis._settings); this.window_container, extensionThis._settings);
extensionThis._tweakTransitions(this.window_container, transitionConfig); extensionThis._tweakTransitions(this.window_container, transitionConfig);
@@ -131,6 +131,14 @@ class Extension {
this.connect('destroy', () => { this.connect('destroy', () => {
this.metaWindow.disconnect(connectionID); this.metaWindow.disconnect(connectionID);
}); });
};
// The _deleteAll is called when the user clicks the X in the overview. We should
// not attempt to close windows twice. Due to the animation in the overview, the
// close button can be clicked twice which normally would lead to a crash.
WindowPreview.prototype._deleteAll = function() {
if (!this._closeRequested) {
extensionThis._origDeleteAll.apply(this);
} }
}; };
} }
@@ -276,6 +284,7 @@ class Extension {
if (WindowPreview) { if (WindowPreview) {
WindowPreview.prototype._deleteAll = this._origDeleteAll; WindowPreview.prototype._deleteAll = this._origDeleteAll;
WindowPreview.prototype._restack = this._origRestack; WindowPreview.prototype._restack = this._origRestack;
WindowPreview.prototype._init = this._origInit;
} }
this._settings = null; this._settings = null;