Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Commit c7cb598

Browse files
Prevent switching layout in terminal mode (#36)
Add new override for the getCurrentGroup() function in order to prevent the on-screen keyboard from switching to the ùs-extended.json` layout in terminal mode, as our layout is already extended now. Co-authored-by: Nick Shmyrev <dev@nick-shmyrev.dev>
1 parent a88c08c commit c7cb598

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/extension.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ let backup_addRowKeys;
1515
let backup_toggleModifier;
1616
let backup_setActiveLayer;
1717
let backup_touchMode;
18+
let backup_getCurrentGroup;
1819
let currentSeat;
1920
let _indicator;
2021
let settings;
@@ -198,7 +199,22 @@ function override_setActiveLayer(activeLevel) {
198199
this._updateCurrentPageVisible();
199200
this._aspectContainer.setRatio(...this._currentPage.getRatio());
200201
this._emojiSelection.setRatio(...this._currentPage.getRatio());
202+
}
201203

204+
function override_getCurrentGroup() {
205+
// Special case for Korean, if Hangul mode is disabled, use the 'us' keymap
206+
if (this._currentSource.id === 'hangul') {
207+
const inputSourceManager = InputSourceManager.getInputSourceManager();
208+
const currentSource = inputSourceManager.currentSource;
209+
let prop;
210+
for (let i = 0; (prop = currentSource.properties.get(i)) !== null; ++i) {
211+
if (prop.get_key() === 'InputMode' &&
212+
prop.get_prop_type() === IBus.PropType.TOGGLE &&
213+
prop.get_state() !== IBus.PropState.CHECKED)
214+
return 'us';
215+
}
216+
}
217+
return this._currentSource.xkbId;
202218
}
203219

204220
function enable_overrides() {
@@ -208,6 +224,8 @@ function enable_overrides() {
208224
Keyboard.Keyboard.prototype["_addRowKeys"] = override_addRowKeys;
209225
Keyboard.KeyboardManager.prototype["_lastDeviceIsTouchscreen"] =
210226
override_lastDeviceIsTouchScreen;
227+
Keyboard.KeyboardController.prototype["getCurrentGroup"] =
228+
override_getCurrentGroup;
211229

212230
// Unregister original osk layouts resource file
213231
getDefaultLayouts()._unregister();
@@ -223,6 +241,8 @@ function disable_overrides() {
223241
Keyboard.Keyboard.prototype["_addRowKeys"] = backup_addRowKeys;
224242
Keyboard.KeyboardManager.prototype["_lastDeviceIsTouchscreen"] =
225243
backup_lastDeviceIsTouchScreen;
244+
Keyboard.KeyboardController.prototype["getCurrentGroup"] =
245+
backup_getCurrentGroup;
226246

227247
// Unregister modified osk layouts resource file
228248
getModifiedLayouts()._unregister();
@@ -272,6 +292,9 @@ function init() {
272292
backup_lastDeviceIsTouchScreen =
273293
Keyboard.KeyboardManager._lastDeviceIsTouchscreen;
274294

295+
backup_getCurrentGroup =
296+
Keyboard.KeyboardController.getCurrentGroup;
297+
275298
currentSeat = Clutter.get_default_backend().get_default_seat();
276299
backup_touchMode = currentSeat.get_touch_mode;
277300
}

0 commit comments

Comments
 (0)