keyboard: Simplify focus window tracking
Keep the focus window in a single field, and optionally animate depending on keyboard visibility. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1668>
This commit is contained in:
parent
a6a4e0a504
commit
0a12405e01
@ -1234,9 +1234,7 @@ var Keyboard = GObject.registerClass({
|
|||||||
this._emojiActive = false;
|
this._emojiActive = false;
|
||||||
|
|
||||||
this._languagePopup = null;
|
this._languagePopup = null;
|
||||||
this._currentFocusWindow = null;
|
this._focusWindow = null;
|
||||||
this._animFocusedWindow = null;
|
|
||||||
this._delayedAnimFocusWindow = null;
|
|
||||||
|
|
||||||
this._latched = false; // current level is latched
|
this._latched = false; // current level is latched
|
||||||
|
|
||||||
@ -1247,9 +1245,7 @@ var Keyboard = GObject.registerClass({
|
|||||||
this._connectSignal(this._focusTracker, 'position-changed',
|
this._connectSignal(this._focusTracker, 'position-changed',
|
||||||
this._onFocusPositionChanged.bind(this));
|
this._onFocusPositionChanged.bind(this));
|
||||||
this._connectSignal(this._focusTracker, 'reset', () => {
|
this._connectSignal(this._focusTracker, 'reset', () => {
|
||||||
this._delayedAnimFocusWindow = null;
|
this._setFocusWindow(null);
|
||||||
this._animFocusedWindow = null;
|
|
||||||
this._oskFocusWindow = null;
|
|
||||||
});
|
});
|
||||||
// Valid only for X11
|
// Valid only for X11
|
||||||
if (!Meta.is_wayland_compositor()) {
|
if (!Meta.is_wayland_compositor()) {
|
||||||
@ -1759,11 +1755,6 @@ var Keyboard = GObject.registerClass({
|
|||||||
this.animateShow();
|
this.animateShow();
|
||||||
|
|
||||||
this._setEmojiActive(false);
|
this._setEmojiActive(false);
|
||||||
|
|
||||||
if (this._delayedAnimFocusWindow) {
|
|
||||||
this._setAnimationWindow(this._delayedAnimFocusWindow);
|
|
||||||
this._delayedAnimFocusWindow = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
@ -1793,6 +1784,9 @@ var Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
animateShow() {
|
animateShow() {
|
||||||
|
if (this._focusWindow)
|
||||||
|
this._animateWindow(this._focusWindow, true);
|
||||||
|
|
||||||
Main.layoutManager.keyboardBox.show();
|
Main.layoutManager.keyboardBox.show();
|
||||||
this.ease({
|
this.ease({
|
||||||
translation_y: -this.height,
|
translation_y: -this.height,
|
||||||
@ -1818,6 +1812,9 @@ var Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
animateHide(immediate) {
|
animateHide(immediate) {
|
||||||
|
if (this._focusWindow)
|
||||||
|
this._animateWindow(this._focusWindow, false);
|
||||||
|
|
||||||
if (this._keyboardHeightNotifyId) {
|
if (this._keyboardHeightNotifyId) {
|
||||||
Main.layoutManager.keyboardBox.disconnect(this._keyboardHeightNotifyId);
|
Main.layoutManager.keyboardBox.disconnect(this._keyboardHeightNotifyId);
|
||||||
this._keyboardHeightNotifyId = 0;
|
this._keyboardHeightNotifyId = 0;
|
||||||
@ -1893,16 +1890,18 @@ var Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_setAnimationWindow(window) {
|
_setFocusWindow(window) {
|
||||||
if (this._animFocusedWindow == window)
|
if (this._focusWindow === window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this._animFocusedWindow)
|
if (this._keyboardVisible) {
|
||||||
this._animateWindow(this._animFocusedWindow, false);
|
if (this._focusWindow)
|
||||||
if (window)
|
this._animateWindow(this._focusWindow, false);
|
||||||
this._animateWindow(window, true);
|
if (window)
|
||||||
|
this._animateWindow(window, true);
|
||||||
|
}
|
||||||
|
|
||||||
this._animFocusedWindow = window;
|
this._focusWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCursorLocation(window, x, y, w, h) {
|
setCursorLocation(window, x, y, w, h) {
|
||||||
@ -1911,20 +1910,13 @@ var Keyboard = GObject.registerClass({
|
|||||||
if (window && monitor) {
|
if (window && monitor) {
|
||||||
let keyboardHeight = Main.layoutManager.keyboardBox.height;
|
let keyboardHeight = Main.layoutManager.keyboardBox.height;
|
||||||
|
|
||||||
if (y + h >= monitor.y + monitor.height - keyboardHeight) {
|
if (y + h >= monitor.y + monitor.height - keyboardHeight)
|
||||||
if (this._keyboardVisible)
|
this._setFocusWindow(window);
|
||||||
this._setAnimationWindow(window);
|
else if (y < keyboardHeight)
|
||||||
else
|
this._setFocusWindow(null);
|
||||||
this._delayedAnimFocusWindow = window;
|
|
||||||
} else if (y < keyboardHeight) {
|
|
||||||
this._delayedAnimFocusWindow = null;
|
|
||||||
this._setAnimationWindow(null);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this._setAnimationWindow(null);
|
this._setFocusWindow(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._oskFocusWindow = window;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user