[gnome-shell/wip/carlosg/osk-gesture-feedback: 1/8] layout: Move keyboard slide animation to keyboard




commit 2bcc6cfbeff80cc8fd7baef6c9d6cae88845c1b3
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 11 13:08:47 2021 +0100

    layout: Move keyboard slide animation to keyboard
    
    The animation handling is kinda split between layout (for the
    keyboard slide), and keyboard (for the focus window slide). It
    would be nice to have more fine grained control on those, so
    move the animation handling altogether to keyboard.js as a start.
    
    This is roughly similar, except that transformations apply to
    the Keyboard actor, instead of the keyboardBox (its parent). We
    now queue a relayout after the animation in order to update the
    chrome tracking.
    
    The only layering break now is that we emit
    layoutManager::keyboard-visible-changed in keyboard.js, its
    purpose will be dropped in future commits, so leave it there for
    now.

 js/ui/keyboard.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++------
 js/ui/layout.js   | 48 --------------------------------------------
 2 files changed, 53 insertions(+), 54 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index a579495ad6..aee2989f46 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -13,7 +13,8 @@ const Main = imports.ui.main;
 const PageIndicators = imports.ui.pageIndicators;
 const PopupMenu = imports.ui.popupMenu;
 
-var KEYBOARD_REST_TIME = Layout.KEYBOARD_ANIMATION_TIME * 2;
+var KEYBOARD_ANIMATION_TIME = 150;
+var KEYBOARD_REST_TIME = KEYBOARD_ANIMATION_TIME * 2;
 var KEY_LONG_PRESS_TIME = 250;
 var PANEL_SWITCH_ANIMATION_TIME = 500;
 var PANEL_SWITCH_RELATIVE_DISTANCE = 1 / 3; /* A third of the actor width */
@@ -1168,7 +1169,6 @@ var KeyboardManager = class KeyBoardManager {
             this._keyboard.setCursorLocation(null);
             this._keyboard.destroy();
             this._keyboard = null;
-            Main.layoutManager.hideKeyboard(true);
         }
     }
 
@@ -1294,6 +1294,7 @@ class Keyboard extends St.BoxLayout {
 
         Main.layoutManager.untrackChrome(this);
         Main.layoutManager.keyboardBox.remove_actor(this);
+        Main.layoutManager.keyboardBox.hide();
 
         if (this._languagePopup) {
             this._languagePopup.destroy();
@@ -1742,7 +1743,7 @@ class Keyboard extends St.BoxLayout {
 
         Main.layoutManager.keyboardIndex = monitor;
         this._relayout();
-        Main.layoutManager.showKeyboard();
+        this.animateShow();
 
         this._setEmojiActive(false);
 
@@ -1774,10 +1775,56 @@ class Keyboard extends St.BoxLayout {
         if (this._keyboardRequested)
             return;
 
-        Main.layoutManager.hideKeyboard();
+        this.animateHide();
         this.setCursorLocation(null);
     }
 
+    animateShow() {
+        Main.layoutManager.keyboardBox.show();
+        this.ease({
+            translation_y: -this.height,
+            opacity: 255,
+            duration: KEYBOARD_ANIMATION_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            onComplete: () => {
+                this._animateShowComplete();
+            },
+        });
+        Main.layoutManager.emit('keyboard-visible-changed', true);
+    }
+
+    _animateShowComplete() {
+        let keyboardBox = Main.layoutManager.keyboardBox;
+        this._keyboardHeightNotifyId = keyboardBox.connect('notify::height', () => {
+            this.translation_y = -this.height;
+        });
+
+        // Queue a relayout so the keyboardBox can update its chrome region.
+        keyboardBox.queue_relayout();
+    }
+
+    animateHide(immediate) {
+        if (this._keyboardHeightNotifyId) {
+            Main.layoutManager.keyboardBox.disconnect(this._keyboardHeightNotifyId);
+            this._keyboardHeightNotifyId = 0;
+        }
+        this.ease({
+            translation_y: 0,
+            opacity: 0,
+            duration: immediate ? 0 : KEYBOARD_ANIMATION_TIME,
+            mode: Clutter.AnimationMode.EASE_IN_QUAD,
+            onComplete: () => {
+                this._animateHideComplete();
+            },
+        });
+
+        Main.layoutManager.emit('keyboard-visible-changed', false);
+    }
+
+    _animateHideComplete() {
+        Main.layoutManager.keyboardBox.hide();
+    }
+
     resetSuggestions() {
         if (this._suggestions)
             this._suggestions.clear();
@@ -1813,7 +1860,7 @@ class Keyboard extends St.BoxLayout {
         if (show) {
             windowActor.ease({
                 y: windowActor.y - deltaY,
-                duration: Layout.KEYBOARD_ANIMATION_TIME,
+                duration: KEYBOARD_ANIMATION_TIME,
                 mode: Clutter.AnimationMode.EASE_OUT_QUAD,
                 onComplete: () => {
                     this._windowSlideAnimationComplete(window, -deltaY);
@@ -1822,7 +1869,7 @@ class Keyboard extends St.BoxLayout {
         } else {
             windowActor.ease({
                 y: windowActor.y + deltaY,
-                duration: Layout.KEYBOARD_ANIMATION_TIME,
+                duration: KEYBOARD_ANIMATION_TIME,
                 mode: Clutter.AnimationMode.EASE_IN_QUAD,
                 onComplete: () => {
                     this._windowSlideAnimationComplete(window, deltaY);
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 1a41a34beb..0c844bc49a 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -13,7 +13,6 @@ const Params = imports.misc.params;
 const Ripples = imports.ui.ripples;
 
 var STARTUP_ANIMATION_TIME = 500;
-var KEYBOARD_ANIMATION_TIME = 150;
 var BACKGROUND_FADE_ANIMATION_TIME = 1000;
 
 var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
@@ -731,53 +730,6 @@ var LayoutManager = GObject.registerClass({
         this.emit('startup-complete');
     }
 
-    showKeyboard() {
-        this.keyboardBox.show();
-        this.keyboardBox.ease({
-            translation_y: -this.keyboardBox.height,
-            opacity: 255,
-            duration: KEYBOARD_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            onComplete: () => {
-                this._showKeyboardComplete();
-            },
-        });
-        this.emit('keyboard-visible-changed', true);
-    }
-
-    _showKeyboardComplete() {
-        // Poke Chrome to update the input shape; it doesn't notice
-        // anchor point changes
-        this._updateRegions();
-
-        this._keyboardHeightNotifyId = this.keyboardBox.connect('notify::height', () => {
-            this.keyboardBox.translation_y = -this.keyboardBox.height;
-        });
-    }
-
-    hideKeyboard(immediate) {
-        if (this._keyboardHeightNotifyId) {
-            this.keyboardBox.disconnect(this._keyboardHeightNotifyId);
-            this._keyboardHeightNotifyId = 0;
-        }
-        this.keyboardBox.ease({
-            translation_y: 0,
-            opacity: 0,
-            duration: immediate ? 0 : KEYBOARD_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_IN_QUAD,
-            onComplete: () => {
-                this._hideKeyboardComplete();
-            },
-        });
-
-        this.emit('keyboard-visible-changed', false);
-    }
-
-    _hideKeyboardComplete() {
-        this.keyboardBox.hide();
-        this._updateRegions();
-    }
-
     // setDummyCursorGeometry:
     //
     // The cursor dummy is a standard widget commonly used for popup


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