[gnome-shell/wip/carlosg/osk-updates: 2/28] keyboard: Unify OSK key commit handling in single-state signal
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/osk-updates: 2/28] keyboard: Unify OSK key commit handling in single-state signal
- Date: Mon, 25 Jul 2022 21:48:33 +0000 (UTC)
commit 7a5a87e72bc0efc138c8919274e97d941ee6f4e8
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 14 20:42:30 2022 +0200
keyboard: Unify OSK key commit handling in single-state signal
Instead of having callers handle pressed+released, emit string
commits on a distinct signal that is emitted all at once during
release.
This also unifies the behavior of keys that have an extended keys
popup and not wrt press/release behavior and key repeat.
js/ui/keyboard.js | 39 ++++++++++++++-------------------------
1 file changed, 14 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 320fe8c891..330ba17cc8 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -300,8 +300,9 @@ var Key = GObject.registerClass({
Signals: {
'activated': {},
'long-press': {},
- 'pressed': { param_types: [GObject.TYPE_UINT, GObject.TYPE_STRING] },
- 'released': { param_types: [GObject.TYPE_UINT, GObject.TYPE_STRING] },
+ 'pressed': {},
+ 'released': {},
+ 'commit': { param_types: [GObject.TYPE_UINT, GObject.TYPE_STRING] },
},
}, class Key extends St.BoxLayout {
_init(params, extendedKeys) {
@@ -360,13 +361,10 @@ var Key = GObject.registerClass({
return Clutter.unicode_to_keysym(unicode);
}
- _press(button, commitString) {
+ _press(button) {
this.emit('activated');
- let keyval;
-
if (button === this.keyButton) {
- keyval = this._keyval;
this._pressTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
KEY_LONG_PRESS_TIME,
() => {
@@ -386,11 +384,8 @@ var Key = GObject.registerClass({
});
}
- if (!keyval)
- keyval = this._getKeyval(commitString);
-
- if (this._extendedKeys.length === 0)
- this.emit('pressed', keyval, commitString);
+ this.emit('pressed');
+ this._pressed = true;
}
_release(button, commitString) {
@@ -405,11 +400,12 @@ var Key = GObject.registerClass({
if (!keyval && commitString)
keyval = this._getKeyval(commitString);
- if (this._extendedKeys.length > 0)
- this.emit('pressed', keyval, commitString);
+ if (this._pressed && (commitString || keyval))
+ this.emit('commit', keyval, commitString || '');
- this.emit('released', keyval, commitString);
+ this.emit('released');
this._hideSubkeys();
+ this._pressed = false;
}
cancel() {
@@ -932,7 +928,7 @@ var EmojiPager = GObject.registerClass({
key.connect('long-press', () => {
this._panAction.cancel();
});
- key.connect('released', (actor, keyval, str) => {
+ key.connect('commit', (actor, keyval, str) => {
if (this._currentKey != key)
return;
this._currentKey = null;
@@ -1556,20 +1552,13 @@ var Keyboard = GObject.registerClass({
if (key.width !== null)
button.setWidth(key.width);
- button.connect('pressed', (actor, keyval, str) => {
- if (!Main.inputMethod.currentFocus ||
+ button.connect('commit', (actor, keyval, str) => {
+ if (str === '' || !Main.inputMethod.currentFocus ||
!this._keyboardController.commitString(str, true)) {
if (keyval != 0) {
this._keyboardController.keyvalPress(keyval);
- button._keyvalPress = true;
- }
- }
- });
- button.connect('released', (actor, keyval, _str) => {
- if (keyval != 0) {
- if (button._keyvalPress)
this._keyboardController.keyvalRelease(keyval);
- button._keyvalPress = false;
+ }
}
if (!this._latched)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]