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

Prevent switching layout to us-extended.json in terminal mode #36

Merged
merged 3 commits into from
Mar 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let backup_addRowKeys;
let backup_toggleModifier;
let backup_setActiveLayer;
let backup_touchMode;
let backup_getCurrentGroup;
let currentSeat;
let _indicator;
let settings;
Expand Down Expand Up @@ -198,7 +199,22 @@ function override_setActiveLayer(activeLevel) {
this._updateCurrentPageVisible();
this._aspectContainer.setRatio(...this._currentPage.getRatio());
this._emojiSelection.setRatio(...this._currentPage.getRatio());
}

function override_getCurrentGroup() {
// Special case for Korean, if Hangul mode is disabled, use the 'us' keymap
if (this._currentSource.id === 'hangul') {
const inputSourceManager = InputSourceManager.getInputSourceManager();
const currentSource = inputSourceManager.currentSource;
let prop;
for (let i = 0; (prop = currentSource.properties.get(i)) !== null; ++i) {
if (prop.get_key() === 'InputMode' &&
prop.get_prop_type() === IBus.PropType.TOGGLE &&
prop.get_state() !== IBus.PropState.CHECKED)
return 'us';
}
}
return this._currentSource.xkbId;
}

function enable_overrides() {
Expand All @@ -208,6 +224,8 @@ function enable_overrides() {
Keyboard.Keyboard.prototype["_addRowKeys"] = override_addRowKeys;
Keyboard.KeyboardManager.prototype["_lastDeviceIsTouchscreen"] =
override_lastDeviceIsTouchScreen;
Keyboard.KeyboardController.prototype["getCurrentGroup"] =
override_getCurrentGroup;

// Unregister original osk layouts resource file
getDefaultLayouts()._unregister();
Expand All @@ -223,6 +241,8 @@ function disable_overrides() {
Keyboard.Keyboard.prototype["_addRowKeys"] = backup_addRowKeys;
Keyboard.KeyboardManager.prototype["_lastDeviceIsTouchscreen"] =
backup_lastDeviceIsTouchScreen;
Keyboard.KeyboardController.prototype["getCurrentGroup"] =
backup_getCurrentGroup;

// Unregister modified osk layouts resource file
getModifiedLayouts()._unregister();
Expand Down Expand Up @@ -272,6 +292,9 @@ function init() {
backup_lastDeviceIsTouchScreen =
Keyboard.KeyboardManager._lastDeviceIsTouchscreen;

backup_getCurrentGroup =
Keyboard.KeyboardController.getCurrentGroup;

currentSeat = Clutter.get_default_backend().get_default_seat();
backup_touchMode = currentSeat.get_touch_mode;
}
Expand Down