[gnome-shell/wip/carlosg/osk-gesture-feedback: 3/8] keyboard: Drop layoutManager's keyboard-visible-changed




commit 2aebc021294ddd6fb0fe884e2615a41ab5c77f99
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 11 14:10:48 2021 +0100

    keyboard: Drop layoutManager's keyboard-visible-changed
    
    Since now the signal is emitted and handled all within keyboard.js,
    use an internal signal to manage keyboard visibility and gesture
    enablement.

 js/ui/keyboard.js | 21 ++++++++++++++-------
 js/ui/layout.js   | 13 +++++++------
 2 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 00d12f26d8..f8fb322dc7 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -1156,6 +1156,7 @@ var KeyboardManager = class KeyBoardManager {
             bottomDragAction.set_enabled(!visible);
         });
         global.stage.add_action(bottomDragAction);
+        this._bottomDragAction = bottomDragAction;
 
         this._syncEnabled();
     }
@@ -1178,10 +1179,14 @@ var KeyboardManager = class KeyBoardManager {
 
         if (enabled && !this._keyboard) {
             this._keyboard = new Keyboard();
+            this._keyboard.connect('visibility-changed', () => {
+                this._bottomDragAction.enabled = !this._keyboard.visible;
+            });
         } else if (!enabled && this._keyboard) {
             this._keyboard.setCursorLocation(null);
             this._keyboard.destroy();
             this._keyboard = null;
+            this._bottomDragAction.enabled = true;
         }
     }
 
@@ -1223,8 +1228,11 @@ var KeyboardManager = class KeyBoardManager {
     }
 };
 
-var Keyboard = GObject.registerClass(
-class Keyboard extends St.BoxLayout {
+var Keyboard = GObject.registerClass({
+    Signals: {
+        'visibility-changed': {},
+    },
+}, class Keyboard extends St.BoxLayout {
     _init() {
         super._init({ name: 'keyboard', vertical: true });
         this._focusInExtendedKeys = false;
@@ -1261,9 +1269,6 @@ class Keyboard extends St.BoxLayout {
         this._showIdleId = 0;
 
         this._keyboardVisible = false;
-        this._connectSignal(Main.layoutManager, 'keyboard-visible-changed', (_lm, visible) => {
-            this._keyboardVisible = visible;
-        });
         this._keyboardRequested = false;
         this._keyboardRestingId = 0;
 
@@ -1803,7 +1808,8 @@ class Keyboard extends St.BoxLayout {
                 this._animateShowComplete();
             },
         });
-        Main.layoutManager.emit('keyboard-visible-changed', true);
+        this._keyboardVisible = true;
+        this.emit('visibility-changed');
     }
 
     _animateShowComplete() {
@@ -1831,7 +1837,8 @@ class Keyboard extends St.BoxLayout {
             },
         });
 
-        Main.layoutManager.emit('keyboard-visible-changed', false);
+        this._keyboardVisible = false;
+        this.emit('visibility-changed');
     }
 
     _animateHideComplete() {
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 0c844bc49a..eab27d4801 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -181,12 +181,13 @@ const defaultParams = {
 };
 
 var LayoutManager = GObject.registerClass({
-    Signals: { 'hot-corners-changed': {},
-               'startup-complete': {},
-               'startup-prepared': {},
-               'monitors-changed': {},
-               'system-modal-opened': {},
-               'keyboard-visible-changed': { param_types: [GObject.TYPE_BOOLEAN] } },
+    Signals: {
+        'hot-corners-changed': {},
+        'startup-complete': {},
+        'startup-prepared': {},
+        'monitors-changed': {},
+        'system-modal-opened': {}
+    },
 }, class LayoutManager extends GObject.Object {
     _init() {
         super._init();


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