[gnome-shell/gnome-42] windowManager: Handle window dimming animation getting cancelled



commit eebcbebd2721b76be02c5249d586796a55bd21d0
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Thu Jun 30 09:40:51 2022 +0200

    windowManager: Handle window dimming animation getting cancelled
    
    When a window with a modal dialog gets minimized and at the same time
    the dialog is closed, the WindowDimmer undim animation starts and gets
    cancelled when the minimize animation is done, because that unmaps the
    window actor.
    
    In this case we want ensure the dimming effect still goes into a
    proper state instead of being stuck mid-animation, so listen to
    onStopped instead of onComplete for syncing state of the window dimmer.
    
    While at it, clean things up a little and move the check for the
    attach-modal-dialogs pref inside the _syncEnabled() function.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5581
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2349>
    (cherry picked from commit 4fd2719dc53ba77a0d85fe1ed569634f8bcd88fe)

 js/ui/windowManager.js | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index bd47e6e5d5..2050ff8ab5 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -132,18 +132,12 @@ class WindowDimmer extends Clutter.BrightnessContrastEffect {
             name: WINDOW_DIMMER_EFFECT_NAME,
             enabled: false,
         });
-        this._enabled = true;
     }
 
-    _syncEnabled() {
+    _syncEnabled(dimmed) {
         let animating = this.actor.get_transition(`@effects.${this.name}.brightness`) !== null;
-        let dimmed = this.brightness.red != 127;
-        this.enabled = this._enabled && (animating || dimmed);
-    }
 
-    setEnabled(enabled) {
-        this._enabled = enabled;
-        this._syncEnabled();
+        this.enabled = Meta.prefs_get_attach_modal_dialogs() && (animating || dimmed);
     }
 
     setDimmed(dimmed, animate) {
@@ -153,20 +147,17 @@ class WindowDimmer extends Clutter.BrightnessContrastEffect {
         this.actor.ease_property(`@effects.${this.name}.brightness`, color, {
             mode: Clutter.AnimationMode.LINEAR,
             duration: (dimmed ? DIM_TIME : UNDIM_TIME) * (animate ? 1 : 0),
-            onComplete: () => this._syncEnabled(),
+            onStopped: () => this._syncEnabled(dimmed),
         });
 
-        this._syncEnabled();
+        this._syncEnabled(dimmed);
     }
 });
 
 function getWindowDimmer(actor) {
-    let enabled = Meta.prefs_get_attach_modal_dialogs();
     let effect = actor.get_effect(WINDOW_DIMMER_EFFECT_NAME);
 
-    if (effect) {
-        effect.setEnabled(enabled);
-    } else if (enabled) {
+    if (!effect) {
         effect = new WindowDimmer();
         actor.add_effect(effect);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]