🎉 Add option to also destroy dialogs

This commit is contained in:
Simon Schneegans
2021-12-25 13:32:15 +01:00
parent 75b803d523
commit 9b2ef55871
5 changed files with 109 additions and 6 deletions
+24 -6
View File
@@ -13,7 +13,7 @@
'use strict'; 'use strict';
const {Clutter} = imports.gi; const {Clutter, Meta} = imports.gi;
const Workspace = imports.ui.workspace.Workspace; const Workspace = imports.ui.workspace.Workspace;
const WindowManager = imports.ui.windowManager.WindowManager; const WindowManager = imports.ui.windowManager.WindowManager;
@@ -48,14 +48,22 @@ class Extension {
this._origShouldAnimateActor = WindowManager.prototype._shouldAnimateActor; this._origShouldAnimateActor = WindowManager.prototype._shouldAnimateActor;
// We may also override these animation times. // We may also override these animation times.
this._origDestroyTime = imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME; this._origWindowTime = imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME;
this._origDialogTime = imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME;
// Update animation times if the respective settings are changed.
const loadAnimationTimes = () => { const loadAnimationTimes = () => {
imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME =
this._settings.get_int('destroy-animation-time'); this._settings.get_int('destroy-animation-time');
imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME =
this._settings.get_boolean('destroy-dialogs') ?
this._settings.get_int('destroy-animation-time') :
this._origDialogTime;
}; };
this._settings.connect('changed::destroy-animation-time', loadAnimationTimes); this._settings.connect('changed::destroy-animation-time', loadAnimationTimes);
this._settings.connect('changed::destroy-dialogs', loadAnimationTimes);
loadAnimationTimes(); loadAnimationTimes();
// We will use extensionThis to refer to the extension inside the patched methods of // We will use extensionThis to refer to the extension inside the patched methods of
@@ -67,7 +75,7 @@ class Extension {
// from the overview (why?). With these overrides we make sure that they are actually // from the overview (why?). With these overrides we make sure that they are actually
// faded out. To do this, _windowRemoved and _doRemoveWindow now check whether there // faded out. To do this, _windowRemoved and _doRemoveWindow now check whether there
// is a transition ongoing (via extensionThis._shouldDestroy). If that's the case, // is a transition ongoing (via extensionThis._shouldDestroy). If that's the case,
// they methods do nothing. Are the actors removed in the end? I hope so. The // these methods do nothing. Are the actors removed in the end? I hope so. The
// _destroyWindow of the WindowManager sets the transitions up and should take care of // _destroyWindow of the WindowManager sets the transitions up and should take care of
// removing the actors at the end of the transitions. // removing the actors at the end of the transitions.
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/workspace.js#L1299 // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/workspace.js#L1299
@@ -107,11 +115,18 @@ class Extension {
// one, set up the window close animation. This usually fades-out the window and // one, set up the window close animation. This usually fades-out the window and
// scales it a bit down. If no transition is in progress, something unexpected // scales it a bit down. If no transition is in progress, something unexpected
// happened. We rather try not to burn the window! // happened. We rather try not to burn the window!
const transition = actor.get_transition('opacity'); const transition = actor.get_transition('scale-y');
if (!transition) { if (!transition) {
return; return;
} }
// We do nothing if a dialog got closed and we should not burn them.
if (!this._settings.get_boolean('destroy-dialogs') &&
(actor.meta_window.window_type == Meta.WindowType.MODAL_DIALOG ||
actor.meta_window.window_type == Meta.WindowType.DIALOG)) {
return;
}
// If there's a transition in progress, we re-target these transitions so that the // If there's a transition in progress, we re-target these transitions so that the
// window is neither scaled nor faded. // window is neither scaled nor faded.
const tweakTransition = (property, value) => { const tweakTransition = (property, value) => {
@@ -151,13 +166,16 @@ class Extension {
Workspace.prototype._doRemoveWindow = this._origDoRemoveWindow; Workspace.prototype._doRemoveWindow = this._origDoRemoveWindow;
WindowManager.prototype._shouldAnimateActor = this._origShouldAnimateActor; WindowManager.prototype._shouldAnimateActor = this._origShouldAnimateActor;
imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = this._origDestroyTime; imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = this._origWindowTime;
imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME = this._origDialogTime;
this._settings = null; this._settings = null;
} }
// ----------------------------------------------------------------------- private stuff // ----------------------------------------------------------------------- private stuff
// This is required to enable window-close animations in the overview. See the comment
// for Workspace.prototype._windowRemoved above for an explanation.
_shouldDestroy(workspace, metaWindow) { _shouldDestroy(workspace, metaWindow) {
const index = workspace._lookupIndex(metaWindow); const index = workspace._lookupIndex(metaWindow);
if (index == -1) { if (index == -1) {
@@ -165,7 +183,7 @@ class Extension {
} }
const actor = workspace._windows[index]._windowActor; const actor = workspace._windows[index]._windowActor;
if (!actor.get_transition('opacity')) { if (!actor.get_transition('scale-y')) {
return true; return true;
} }
+1
View File
@@ -44,6 +44,7 @@ var PreferencesDialog = class PreferencesDialog {
// Bind all properties. // Bind all properties.
this._bindAdjustment('destroy-animation-time'); this._bindAdjustment('destroy-animation-time');
this._bindSwitch('destroy-dialogs');
this._bindAdjustment('flame-movement-speed'); this._bindAdjustment('flame-movement-speed');
this._bindAdjustment('flame-scale'); this._bindAdjustment('flame-scale');
this._bindColorButton('fire-color-1'); this._bindColorButton('fire-color-1');
+44
View File
@@ -106,6 +106,50 @@
</object> </object>
</child> </child>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Also Burn Dialogs</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="destroy-dialogs">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-dialogs">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
+34
View File
@@ -88,6 +88,40 @@
</object> </object>
</child> </child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Also Burn Dialogs</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="destroy-dialogs">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-dialogs">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
@@ -9,6 +9,12 @@
<description>The time it takes to burn the windows.</description> <description>The time it takes to burn the windows.</description>
</key> </key>
<key name="destroy-dialogs" type="b">
<default>true</default>
<summary>Destroy Dialogs</summary>
<description>Set to true to burn dialogs as well.</description>
</key>
<key name="flame-movement-speed" type="d"> <key name="flame-movement-speed" type="d">
<default>0.5</default> <default>0.5</default>
<summary>Flame Movement Speed</summary> <summary>Flame Movement Speed</summary>