From 7e4e3c19d010b8204f89703706c605a97153a60a Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Tue, 30 Mar 2021 14:56:46 +0800
Subject: [PATCH] loginDialog: Use GObject bindings over onUpdate handler

Instead of iterating over all actors each frame and sync'ing their
opacities, we can set up bindings once before the animation.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/654
---
 js/gdm/loginDialog.js | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index faecff8..29954f7 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -918,25 +918,29 @@ var LoginDialog = new Lang.Class({
         this._showPrompt();
     },
 
+    _bindOpacity() {
+	this._bindings = Main.layoutManager.uiGroup.get_children()
+	    .filter(c => c != Main.layoutManager.screenShieldGroup)
+	    .map(c => this.actor.bind_property('opacity', c, 'opacity', 0));
+    },
+
+    _unbindOpacity() {
+	this._bindings.forEach(b => b.unbind());
+    },
+
     _loginScreenSessionActivated() {
         if (this.actor.opacity == 255 && this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
             return;
 
+        this._bindOpacity();
         Tweener.addTween(this.actor,
                          { opacity: 255,
                            time: _FADE_ANIMATION_TIME,
                            transition: 'easeOutQuad',
-                           onUpdate: () => {
-                               let children = Main.layoutManager.uiGroup.get_children();
-
-                               for (let i = 0; i < children.length; i++) {
-                                   if (children[i] != Main.layoutManager.screenShieldGroup)
-                                       children[i].opacity = this.actor.opacity;
-                               }
-                           },
                            onComplete: () => {
                                if (this._authPrompt.verificationStatus != AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
                                    this._authPrompt.reset();
+                               this._unbindOpacity();
                            } });
     },
 
@@ -950,20 +954,14 @@ var LoginDialog = new Lang.Class({
     },
 
     _startSession(serviceName) {
+        this._bindOpacity();
         Tweener.addTween(this.actor,
                          { opacity: 0,
                            time: _FADE_ANIMATION_TIME,
                            transition: 'easeOutQuad',
-                           onUpdate: () => {
-                               let children = Main.layoutManager.uiGroup.get_children();
-
-                               for (let i = 0; i < children.length; i++) {
-                                   if (children[i] != Main.layoutManager.screenShieldGroup)
-                                       children[i].opacity = this.actor.opacity;
-                               }
-                           },
                            onComplete: () => {
                                this._greeter.call_start_session_when_ready_sync(serviceName, true, null);
+                               this._unbindOpacity();
                            } });
     },
 
-- 
2.23.0

