keyboard: Allow for terminal variants in specific languages
Do not hardcode the us-terminal OSK keymap, and append '-extended' to the current group name, accounting with the existing 'us' fallback. This allows for concerned individuals to propose language-specific terminal layouts. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>
This commit is contained in:
parent
0131408c0d
commit
4a4582b76c
@ -496,18 +496,7 @@ const Key = GObject.registerClass({
|
|||||||
|
|
||||||
class KeyboardModel {
|
class KeyboardModel {
|
||||||
constructor(groupName) {
|
constructor(groupName) {
|
||||||
let names = [groupName];
|
this._model = this._loadModel(groupName);
|
||||||
if (groupName.includes('+'))
|
|
||||||
names.push(groupName.replace(/\+.*/, ''));
|
|
||||||
names.push('us');
|
|
||||||
|
|
||||||
for (let i = 0; i < names.length; i++) {
|
|
||||||
try {
|
|
||||||
this._model = this._loadModel(names[i]);
|
|
||||||
break;
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadModel(groupName) {
|
_loadModel(groupName) {
|
||||||
@ -1460,15 +1449,36 @@ export const Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateLayoutForGroup(groupName) {
|
_updateLayout(groupName, purpose) {
|
||||||
let keyboardModel = new KeyboardModel(groupName);
|
let keyboardModel = null;
|
||||||
let levels = keyboardModel.getLevels();
|
|
||||||
let layers = {};
|
let layers = {};
|
||||||
let layout = new Clutter.Actor({
|
let layout = new Clutter.Actor({
|
||||||
layout_manager: new Clutter.BinLayout(),
|
layout_manager: new Clutter.BinLayout(),
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
y_expand: true,
|
y_expand: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let groups = [groupName];
|
||||||
|
if (groupName.includes('+'))
|
||||||
|
groups.push(groupName.replace(/\+.*/, ''));
|
||||||
|
groups.push('us');
|
||||||
|
|
||||||
|
if (purpose === Clutter.InputContentPurpose.TERMINAL)
|
||||||
|
groups = groups.map(g => `${g}-extended`);
|
||||||
|
|
||||||
|
for (const group of groups) {
|
||||||
|
try {
|
||||||
|
keyboardModel = new KeyboardModel(group);
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore this error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keyboardModel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let levels = keyboardModel.getLevels();
|
||||||
|
|
||||||
for (let i = 0; i < levels.length; i++) {
|
for (let i = 0; i < levels.length; i++) {
|
||||||
let currentLevel = levels[i];
|
let currentLevel = levels[i];
|
||||||
/* There are keyboard maps which consist of 3 levels (no uppercase,
|
/* There are keyboard maps which consist of 3 levels (no uppercase,
|
||||||
@ -1495,13 +1505,8 @@ export const Keyboard = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ensureKeys() {
|
_ensureKeys() {
|
||||||
let group;
|
const group = this._keyboardController.getCurrentGroup();
|
||||||
if (this._purpose === Clutter.InputContentPurpose.TERMINAL)
|
this._updateLayout(group, this._purpose);
|
||||||
group = 'us-extended';
|
|
||||||
else
|
|
||||||
group = this._keyboardController.getCurrentGroup();
|
|
||||||
|
|
||||||
this._updateLayoutForGroup(group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_addRowKeys(keys, layout) {
|
_addRowKeys(keys, layout) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user