keyboard: Separate keyval action notification
Add a distinct signal for keys defining a keyval to have it handled via event emulation. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>
This commit is contained in:
parent
4d71d9f46d
commit
f0b18c9ccc
@ -223,6 +223,7 @@ const Key = GObject.registerClass({
|
|||||||
'long-press': {},
|
'long-press': {},
|
||||||
'pressed': {},
|
'pressed': {},
|
||||||
'released': {},
|
'released': {},
|
||||||
|
'keyval': {param_types: [GObject.TYPE_UINT]},
|
||||||
'commit': {param_types: [GObject.TYPE_UINT, GObject.TYPE_STRING]},
|
'commit': {param_types: [GObject.TYPE_UINT, GObject.TYPE_STRING]},
|
||||||
},
|
},
|
||||||
}, class Key extends St.BoxLayout {
|
}, class Key extends St.BoxLayout {
|
||||||
@ -316,15 +317,16 @@ const Key = GObject.registerClass({
|
|||||||
this._pressTimeoutId = 0;
|
this._pressTimeoutId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let keyval;
|
if (this._pressed) {
|
||||||
if (button === this.keyButton)
|
if (this._keyval && button === this.keyButton)
|
||||||
keyval = this._keyval;
|
this.emit('keyval', this._keyval);
|
||||||
if (!keyval && commitString)
|
else if (commitString) {
|
||||||
keyval = this._getKeyvalFromString(commitString);
|
const keyval = this._getKeyvalFromString(commitString);
|
||||||
console.assert(keyval !== undefined, 'Need keyval or commitString');
|
this.emit('commit', keyval, commitString);
|
||||||
|
} else {
|
||||||
if (this._pressed && (commitString || keyval))
|
console.error('Need keyval or commitString');
|
||||||
this.emit('commit', keyval, commitString || '');
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.emit('released');
|
this.emit('released');
|
||||||
this._hideSubkeys();
|
this._hideSubkeys();
|
||||||
@ -1437,6 +1439,13 @@ export const Keyboard = GObject.registerClass({
|
|||||||
keyval: key.keyval,
|
keyval: key.keyval,
|
||||||
}, strings);
|
}, strings);
|
||||||
|
|
||||||
|
if (key.keyval) {
|
||||||
|
button.connect('keyval', (_actor, keyval) => {
|
||||||
|
this._keyboardController.keyvalPress(keyval);
|
||||||
|
this._keyboardController.keyvalRelease(keyval);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (key.action !== 'modifier') {
|
if (key.action !== 'modifier') {
|
||||||
button.connect('commit', (_actor, keyval, str) => {
|
button.connect('commit', (_actor, keyval, str) => {
|
||||||
this._commitAction(keyval, str).then(() => {
|
this._commitAction(keyval, str).then(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user