[gnome-shell/wip/carlosg/osk-gesture-feedback: 8/8] keyboard: Make OSK follow gesture progress




commit f5349e42efe17c8caf3509c9162a23a24151861c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Feb 12 00:54:55 2021 +0100

    keyboard: Make OSK follow gesture progress
    
    With all other gestures offering live feedback of progress, seems
    to make sense to update the "swipe from bottom edge to show OSK"
    gesture as well.

 js/ui/keyboard.js | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index cd51d1c7dd..474314ea72 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -1148,11 +1148,10 @@ var KeyboardManager = class KeyBoardManager {
         let mode = Shell.ActionMode.ALL & ~Shell.ActionMode.LOCK_SCREEN;
         let bottomDragAction = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM, mode);
         bottomDragAction.connect('activated', () => {
-            this.open(Main.layoutManager.bottomIndex);
+            this._keyboard.gestureActivate(Main.layoutManager.bottomIndex);
         });
-        Main.layoutManager.connect('keyboard-visible-changed', (_manager, visible) => {
-            bottomDragAction.cancel();
-            bottomDragAction.set_enabled(!visible);
+        bottomDragAction.connect('progress', (_action, progress) => {
+            this._keyboard.gestureProgress(progress);
         });
         global.stage.add_action(bottomDragAction);
         this._bottomDragAction = bottomDragAction;
@@ -1729,7 +1728,7 @@ var Keyboard = GObject.registerClass({
         this._keyboardRestingId = 0;
     }
 
-    open() {
+    open(immediate = false) {
         this._clearShowIdle();
         this._keyboardRequested = true;
 
@@ -1738,6 +1737,11 @@ var Keyboard = GObject.registerClass({
             return;
         }
 
+        if (immediate) {
+            this._open();
+            return;
+        }
+
         this._clearKeyboardRestTimer();
         this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
             KEYBOARD_REST_TIME,
@@ -1839,6 +1843,21 @@ var Keyboard = GObject.registerClass({
         Main.layoutManager.keyboardBox.hide();
     }
 
+    gestureProgress(delta) {
+        Main.layoutManager.keyboardBox.show();
+        let progress = Math.min(delta, this.height) / this.height;
+        this.translation_y = -this.height * progress;
+        this.opacity = 255 * progress;
+        if (this._focusWindow) {
+            let windowActor = this._focusWindow.get_compositor_private();
+            windowActor.translation_y = -this.height * progress;
+        }
+    }
+
+    gestureActivate() {
+        this.open(true);
+    }
+
     resetSuggestions() {
         if (this._suggestions)
             this._suggestions.clear();


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