[gnome-shell/wip/rstrode/rhel-7.9: 79/86] screenShield: Fix pointer motion signal handler leak




commit f2604a5837f50bf3b175563dc74018432d34a72e
Author: Ray Strode <rstrode redhat com>
Date:   Mon Sep 28 22:28:08 2020 -0400

    screenShield: Fix pointer motion signal handler leak
    
    The screen shield code listens for motion events on the stage
    so that it can hide the pointer until the user moves the mouse.
    
    Unfortunately, if the user never moves the mouse, the signal
    handler connection gets leaked.
    
    This commit makes sure the connection gets disconnected when the
    shield goes away.

 js/ui/screenShield.js | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 5608ca1a1a..dfe1d3b774 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -932,6 +932,25 @@ var ScreenShield = new Lang.Class({
         }
     },
 
+    _showPointer() {
+        this._cursorTracker.set_pointer_visible(true);
+
+        if (this._motionId) {
+            global.stage.disconnect(this._motionId);
+            this._motionId = 0;
+        }
+    },
+
+    _hidePointerUntilMotion() {
+        this._motionId = global.stage.connect('captured-event', (stage, event) => {
+            if (event.type() == Clutter.EventType.MOTION)
+                this._showPointer();
+
+            return Clutter.EVENT_PROPAGATE;
+        });
+        this._cursorTracker.set_pointer_visible(false);
+    },
+
     _hideLockScreen(animate, velocity) {
         if (this._lockScreenState == MessageTray.State.HIDDEN)
             return;
@@ -962,7 +981,7 @@ var ScreenShield = new Lang.Class({
             this._hideLockScreenComplete();
         }
 
-        this._cursorTracker.set_pointer_visible(true);
+        this._showPointer();
     },
 
     _ensureUnlockDialog(onPrimary, allowCancel) {
@@ -1096,15 +1115,7 @@ var ScreenShield = new Lang.Class({
 
         this._checkArrowAnimation();
 
-        let motionId = global.stage.connect('captured-event', (stage, event) => {
-            if (event.type() == Clutter.EventType.MOTION) {
-                this._cursorTracker.set_pointer_visible(true);
-                global.stage.disconnect(motionId);
-            }
-
-            return Clutter.EVENT_PROPAGATE;
-        });
-        this._cursorTracker.set_pointer_visible(false);
+        this._hidePointerUntilMotion();
 
         this._lockScreenState = MessageTray.State.SHOWN;
         this._lockScreenGroup.fixed_position_set = false;


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