[gnome-shell/wip/carlosg/osk-updates: 16/40] keyboard: Add generic handling for key actions
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/osk-updates: 16/40] keyboard: Add generic handling for key actions
- Date: Sat, 2 Jul 2022 01:40:48 +0000 (UTC)
commit 50f8e9790ee25bda1992437a3189ff07c81ee621
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 14 21:09:27 2022 +0200
keyboard: Add generic handling for key actions
These actions are defined in the JSON files themselves, allowing
us to migrate away from the sets of pre/post default keys, and fold
them into the JSON files for fuller control on layout and appearance.
As a first migration step, handle the relevant actions in the buttons
created from the JSON files, so we can port these.
js/ui/keyboard.js | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 20647c88b2..5a7f116480 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -1556,6 +1556,32 @@ var Keyboard = GObject.registerClass({
if (!this._latched)
this._setActiveLayer(0);
});
+ button.connect('pressed', () => {
+ if (key.action === 'levelSwitch') {
+ this._setActiveLayer(key.level);
+ this._setLatched (
+ key.level === 1 &&
+ key.iconName === 'keyboard-caps-lock-symbolic');
+ }
+ });
+ button.connect('released', () => {
+ if (key.action === 'hide')
+ this.close();
+ else if (key.action === 'languageMenu')
+ this._popupLanguageMenu(button);
+ else if (key.action === 'emoji')
+ this._toggleEmoji();
+ });
+
+ if (key.action === 'levelSwitch' &&
+ key.iconName === 'keyboard-shift-symbolic') {
+ layout.shiftKeys.push(button);
+ if (key.level === 1) {
+ button.connect('long-press', () => {
+ this._setLatched(true);
+ });
+ }
+ }
if (key.action || key.keyval)
button.keyButton.add_style_class_name('default-key');
@@ -1564,6 +1590,11 @@ var Keyboard = GObject.registerClass({
}
}
+ _setLatched(latched) {
+ this._latched = latched;
+ this._setCurrentLevelLatched(this._currentPage, this._latched);
+ }
+
_popupLanguageMenu(keyActor) {
if (this._languagePopup)
this._languagePopup.destroy();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]