keyboard: Refactor code
Move inline anonymous function to be its own. This method will become asynchronous in following commits. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2508>
This commit is contained in:
parent
d7dc50da71
commit
766314acb2
@ -1510,31 +1510,8 @@ var Keyboard = GObject.registerClass({
|
||||
button.setWidth(key.width);
|
||||
|
||||
if (key.action !== 'modifier') {
|
||||
button.connect('commit', (actor, keyval, str) => {
|
||||
if (this._modifiers.size === 0 && str !== '' &&
|
||||
keyval && this._oskCompletionEnabled) {
|
||||
Main.inputMethod.handleVirtualKey(keyval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (str === '' || !Main.inputMethod.currentFocus ||
|
||||
(keyval && this._oskCompletionEnabled) ||
|
||||
this._modifiers.size > 0 ||
|
||||
!this._keyboardController.commitString(str, true)) {
|
||||
if (keyval !== 0) {
|
||||
this._forwardModifiers(this._modifiers, Clutter.EventType.KEY_PRESS);
|
||||
this._keyboardController.keyvalPress(keyval);
|
||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, KEY_RELEASE_TIMEOUT, () => {
|
||||
this._keyboardController.keyvalRelease(keyval);
|
||||
this._forwardModifiers(this._modifiers, Clutter.EventType.KEY_RELEASE);
|
||||
this._disableAllModifiers();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!this._latched)
|
||||
this._setActiveLayer(0);
|
||||
button.connect('commit', (_actor, keyval, str) => {
|
||||
this._commitAction(keyval, str);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1592,6 +1569,33 @@ var Keyboard = GObject.registerClass({
|
||||
}
|
||||
}
|
||||
|
||||
_commitAction(keyval, str) {
|
||||
if (this._modifiers.size === 0 && str !== '' &&
|
||||
keyval && this._oskCompletionEnabled) {
|
||||
Main.inputMethod.handleVirtualKey(keyval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (str === '' || !Main.inputMethod.currentFocus ||
|
||||
(keyval && this._oskCompletionEnabled) ||
|
||||
this._modifiers.size > 0 ||
|
||||
!this._keyboardController.commitString(str, true)) {
|
||||
if (keyval !== 0) {
|
||||
this._forwardModifiers(this._modifiers, Clutter.EventType.KEY_PRESS);
|
||||
this._keyboardController.keyvalPress(keyval);
|
||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, KEY_RELEASE_TIMEOUT, () => {
|
||||
this._keyboardController.keyvalRelease(keyval);
|
||||
this._forwardModifiers(this._modifiers, Clutter.EventType.KEY_RELEASE);
|
||||
this._disableAllModifiers();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!this._latched)
|
||||
this._setActiveLayer(0);
|
||||
}
|
||||
|
||||
_previousWordPosition(text, cursor) {
|
||||
/* Skip word prior to cursor */
|
||||
let pos = Math.max(0, text.slice(0, cursor).search(/\s+\S+\s*$/));
|
||||
|
Loading…
x
Reference in New Issue
Block a user