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.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1668>
This commit is contained in:
Carlos Garnacho 2021-02-11 13:08:47 +01:00 committed by Marge Bot
parent 76836fe388
commit f52cafeb4a
2 changed files with 54 additions and 56 deletions

View File

@ -8,12 +8,12 @@ const Signals = imports.signals;
const InputSourceManager = imports.ui.status.keyboard; const InputSourceManager = imports.ui.status.keyboard;
const IBusManager = imports.misc.ibusManager; const IBusManager = imports.misc.ibusManager;
const BoxPointer = imports.ui.boxpointer; const BoxPointer = imports.ui.boxpointer;
const Layout = imports.ui.layout;
const Main = imports.ui.main; const Main = imports.ui.main;
const PageIndicators = imports.ui.pageIndicators; const PageIndicators = imports.ui.pageIndicators;
const PopupMenu = imports.ui.popupMenu; 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 KEY_LONG_PRESS_TIME = 250;
var PANEL_SWITCH_ANIMATION_TIME = 500; var PANEL_SWITCH_ANIMATION_TIME = 500;
var PANEL_SWITCH_RELATIVE_DISTANCE = 1 / 3; /* A third of the actor width */ var PANEL_SWITCH_RELATIVE_DISTANCE = 1 / 3; /* A third of the actor width */
@ -1168,7 +1168,6 @@ var KeyboardManager = class KeyBoardManager {
this._keyboard.setCursorLocation(null); this._keyboard.setCursorLocation(null);
this._keyboard.destroy(); this._keyboard.destroy();
this._keyboard = null; this._keyboard = null;
Main.layoutManager.hideKeyboard(true);
} }
} }
@ -1213,7 +1212,7 @@ var KeyboardManager = class KeyBoardManager {
var Keyboard = GObject.registerClass( var Keyboard = GObject.registerClass(
class Keyboard extends St.BoxLayout { class Keyboard extends St.BoxLayout {
_init() { _init() {
super._init({ name: 'keyboard', vertical: true }); super._init({ name: 'keyboard', reactive: true, vertical: true });
this._focusInExtendedKeys = false; this._focusInExtendedKeys = false;
this._emojiActive = false; this._emojiActive = false;
@ -1294,6 +1293,7 @@ class Keyboard extends St.BoxLayout {
Main.layoutManager.untrackChrome(this); Main.layoutManager.untrackChrome(this);
Main.layoutManager.keyboardBox.remove_actor(this); Main.layoutManager.keyboardBox.remove_actor(this);
Main.layoutManager.keyboardBox.hide();
if (this._languagePopup) { if (this._languagePopup) {
this._languagePopup.destroy(); this._languagePopup.destroy();
@ -1742,7 +1742,7 @@ class Keyboard extends St.BoxLayout {
Main.layoutManager.keyboardIndex = monitor; Main.layoutManager.keyboardIndex = monitor;
this._relayout(); this._relayout();
Main.layoutManager.showKeyboard(); this.animateShow();
this._setEmojiActive(false); this._setEmojiActive(false);
@ -1774,10 +1774,56 @@ class Keyboard extends St.BoxLayout {
if (this._keyboardRequested) if (this._keyboardRequested)
return; return;
Main.layoutManager.hideKeyboard(); this.animateHide();
this.setCursorLocation(null); 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() { resetSuggestions() {
if (this._suggestions) if (this._suggestions)
this._suggestions.clear(); this._suggestions.clear();
@ -1813,7 +1859,7 @@ class Keyboard extends St.BoxLayout {
if (show) { if (show) {
windowActor.ease({ windowActor.ease({
y: windowActor.y - deltaY, y: windowActor.y - deltaY,
duration: Layout.KEYBOARD_ANIMATION_TIME, duration: KEYBOARD_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD, mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => { onComplete: () => {
this._windowSlideAnimationComplete(window, -deltaY); this._windowSlideAnimationComplete(window, -deltaY);
@ -1822,7 +1868,7 @@ class Keyboard extends St.BoxLayout {
} else { } else {
windowActor.ease({ windowActor.ease({
y: windowActor.y + deltaY, y: windowActor.y + deltaY,
duration: Layout.KEYBOARD_ANIMATION_TIME, duration: KEYBOARD_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_IN_QUAD, mode: Clutter.AnimationMode.EASE_IN_QUAD,
onComplete: () => { onComplete: () => {
this._windowSlideAnimationComplete(window, deltaY); this._windowSlideAnimationComplete(window, deltaY);

View File

@ -13,7 +13,6 @@ const Params = imports.misc.params;
const Ripples = imports.ui.ripples; const Ripples = imports.ui.ripples;
var STARTUP_ANIMATION_TIME = 500; var STARTUP_ANIMATION_TIME = 500;
var KEYBOARD_ANIMATION_TIME = 150;
var BACKGROUND_FADE_ANIMATION_TIME = 1000; var BACKGROUND_FADE_ANIMATION_TIME = 1000;
var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
@ -731,53 +730,6 @@ var LayoutManager = GObject.registerClass({
this.emit('startup-complete'); 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: // setDummyCursorGeometry:
// //
// The cursor dummy is a standard widget commonly used for popup // The cursor dummy is a standard widget commonly used for popup